Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.6-beta-2
-
Fix Version/s: 1.6-rc-1, 1.5.8, 1.7-beta-1
-
Component/s: None
-
Labels:None
-
Environment:I've attached an example which has been tested on Xandros Linux and Windows XP. Works fine with latest build of source.
-
Testcase included:yes
-
Patch Submitted:Yes
-
Number of attachments :
Description
I've attached an example of observing the compilation process.
This came out of the discussion here: http://www.nabble.com/Groovy-as-arithmetic-expression-evaluator--to19459935.html
This example code is in /src/examples/groovyShell
The class is called ArithmeticShell. "The arithmetic shell is similar to a GroovyShell in that it can evaluate text as code and return a result. It is not a subclass of GroovyShell because it does not widen the contract of GroovyShell, instead it narrows it. Using one of these shells like a GroovyShell would result in many runtime errors." It should how to observe the compilation process and how to walk the AST.
I did not do a static import on java.lang.Math because it was a hassle to test. I did not extend CodeVisitorSupport for reasons stated in the Javadoc.
It includes a GroovyTestCase but does not include an Ant script to build it.
Perhaps this can help someone.
Thanks a lot Hamlet for this great example!
Keep contributions coming