I think  you need to work through the examples in the book as everything that 
you need to do this is in my answer to you below. Other than writing it for 
you, there is not much more to show you!

Jim

> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of George Soom
> Sent: Friday, May 28, 2010 1:12 AM
> To: [email protected]
> Subject: Re: [antlr-interest] parsing rules
> 
> Thank You, again
> 
> Sadly this leads me to some serious misunderstandings. My main job is
> computing using
> Maxima and Fortran, so this is all a bit too new for me. A
> example-by-example is all I need.
> Let me present You a complete simple grammar and template:
> ----
> grammar TestGrammar;
> 
> options {
>   output = template;
> }
> 
> prog
>       : s+=statement+
       ->prog(stats={$s})
>       ;
> 
> statement
>       : assign { $st = $assign.st; }
>       | print { $st = $print.st; }
>       ;
> 
> assign
>       :ID ':=' INT ';' -> assign(x={$ID.text},y={$INT.text})
>       ;
> 
> print
>       : 'toScreen' '(' STRING ')' ';' -> print(string={$STRING.text})
>       ;
> 
> ID: 'a'..'z' + ;
> INT:'0'..'9' + ;
> STRING: (ID|INT)+ ;
> -----
> 
> and templates:
> 
> ----
> group TestTemplate;
> 
> assign(id,int) ::= "<id> = <int>"
> print(string) ::= "print <string>"
prog(stats) ::= <<
<stats: {<it>}; separator="\n">
>>

> ----
> 
> What do I need to add to get translated result from parser.prog() ?

Get an instance of prog, do a toString on it. It's all in the book and also 
check the downloadable examples.

Jim




List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to