jastrachan | 26 Jan 20:08 2005
Picon

Re: [groovy-dev] Quick heads up - hello world just worked with the new Antlr parser

On 26 Jan 2005, at 19:06, Scott Stirling wrote:
> Awesome!
>
> Way to go!

Thanks Scott!

BTW notice the nice Velocity style GString expressions

println "hello $foo how are you"

which are pretty cute. So ${foo} can be replaced with just $foo if the 
expression is a simple name - just like in Velocity.

>
> Scott Stirling
> Framingham, MA
>
> On Jan 26, 2005, at 2:02 PM, jastrachan@... wrote:
>
>>
>> On 26 Jan 2005, at 14:07, jastrachan@... wrote:
>>> There's still heaps to do, but I just managed to run the Groovy 
>>> command line (GroovyMain) to parse a hello world script using the 
>>> new Antlr grammar...
>>>
>>> class HelloWorld extends GroovyTestCase {
>>>   void testCase() {
>>>     println "Hello"
>>>   }
>>> }
>>>
>>> Not the most impressive of programs, but its a start at least :). To 
>>> try it out, you just need the new Antlr parser on the classpath when 
>>> running your Groovy stuff.
>>
>> I've managed to spend nearly a whole afternoon on this, so most of 
>> the basic expressions are wired in now. e.g. the following works..
>>
>> class HelloWorld extends GroovyTestCase {
>>
>>     String foo = "John"
>>     String bar = "Jez"
>>
>>     void testCase() {
>>         println "Hello"
>>         println 123
>>         println 123.456
>>
>>         println "Hello $foo!"
>>         println "Hello ${bar}!"
>>
>>         def x = 123
>>
>>         println "value is $x"
>>
>>         x = x + 1
>>         println "value is now ${x}"
>>
>>         def f = this
>>         def answer = f.foo("hello ", "James")
>>
>>         println "Received answer $answer"
>>
>>         assert answer == "hello James"
>>
>>         answer = foo2("hello ", "Guillaume")
>>         assert answer == "hello Guillaume"
>>
>>         println "Now the answer is $answer"
>>     }
>>
>>     String foo(a, b) {
>>         return a + b
>>     }
>>
>>
>>     def foo2(a, b) {
>>         def answer = a + b
>>         return answer
>>     }
>>
>> }
>>
>>
>> Still more work is required to complete the entire Antlr AST -> 
>> Groovy AST, but at least the basics are in there now. We also need 
>> much more semantic error reporting. (I've not yet figured out how to 
>> wire in the new AntlrParserPlugin with the existing 'control' message 
>> reporting stuff).
>>
>> Its still quite some way from being usable - but at least we can now 
>> start to tinker with New Groovy, rather than just look at its 
>> EBNF/Antlr file...
>>
>> James
>> -------
>> http://radio.weblogs.com/0112098/
>>
>
>

James
-------
http://radio.weblogs.com/0112098/


Gmane