Please feel free to check out my personal blog and all of my websites at: http://renfrewgroup.freehostia.com or specifically the calculator development resource:
http://casiodev.hostcell.net
(now called Calculator-Centre)
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Please feel free to check out my personal blog and all of my websites at: http://renfrewgroup.freehostia.com or specifically the calculator development resource:
http://casiodev.hostcell.net
(now called Calculator-Centre)
Fred Hamilton wrote:Cool. I usually devote a good deal of effort to parsing different kinds of strings, so I'm interested in the subject.
I had a look at that eval() method in ScriptEngine, this is not an area of java I am familiar with, so It's not at all clear to me how this helps you. Given that the API doc for this method doesn't say anything about mathematical expressions, I assume you still have a significant amount of coding to do?
Henry Wong wrote:
Fred Hamilton wrote:Cool. I usually devote a good deal of effort to parsing different kinds of strings, so I'm interested in the subject.
I had a look at that eval() method in ScriptEngine, this is not an area of java I am familiar with, so It's not at all clear to me how this helps you. Given that the API doc for this method doesn't say anything about mathematical expressions, I assume you still have a significant amount of coding to do?
The scripting engine is for scripting languages. I don't believe mathematical expressions is one of those languages, but it doesn't matter. Most languages support some form of mathematical expressions -- so you just need to slightly modify the expression into something that can be parsed.
For example, if you choose Javascript as your language, you probably don't have to do any modification, as the mathematical expression example in this topic look like Javascript.
Henry
Fred Hamilton wrote:Thanks for that, your explanation of scripts makes sense, but I don't see how you, or Rob, was able to conclude that any kind of script was involved, based on the original question. Unless you are saying that 5 * 5 +2 looks like javascript?
Fred Hamilton wrote:Unless you are saying that 5 * 5 +2 looks like javascript?
Bear Bibeault wrote:
Fred Hamilton wrote:Unless you are saying that 5 * 5 +2 looks like javascript?
It's a perfectly legal JavaScript expression. Why do you think that it is not?
Fred Hamilton wrote:... that there is something inherent in JavaScript that makes the job of parsing mathematical expressions easier.
Fred Hamilton wrote:It's not that I thought it wasn't a legal javascript expression, but it seems to be a perfectly legal expression in java also.
Fred Hamilton wrote:So at first I could not understand how Rob was able to deduce that scripts were involved. Pete's answer seems to suggest something I did not know, that there is something inherent in JavaScript that makes the job of parsing mathematical expressions easier. Otherwise, Rob would not have suggested a method in ScriptEngine. I guess.
Bear Bibeault wrote:
Fred Hamilton wrote:... that there is something inherent in JavaScript that makes the job of parsing mathematical expressions easier.
Yes. As Rob pointed out, the eval() method.
Fred Hamilton wrote:
ok, if you are saying that eval() is in fact a javascript method, then I didn't pick up that that fact either.
Anyways, thanks to Henry for the last explanation, and to all for taking the time. It's sort of coming together. I'm sure if I sleep on it and review the materials tomorrow, I'll understand it better.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:Exactly.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:Well, it can be confusing that both the ScriptEngine and the target language have an eval() method / function.
The issue is not that is easier to parse an expression using javascript, which is what I thought you guys were talking about, but rather that we are treating the expression as if it were javascript, and the script parsing functionality of eval() lends itself to parsing mathematical expressions also.
Don't get me started about those stupid light bulbs. |