Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.6-beta-2
-
None
-
None
-
I've attached an example which has been tested on Xandros Linux and Windows XP. Works fine with latest build of source.
-
Patch
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.