Hello Simon,

Nothing is missing, it's just a bit too much. I am not entirely sure
but I think you cannot use TOKEN+ in another token. Maybe someone else
can explain this better? For example this will work:

statement
        :        DIGIT (PLUS DIGIT)*;

DIGIT   : '0'..'9'+;

PLUS    : '+';

Yeah you're free to choose what to do (to use inline actions) or do
your stuff separately (e.g. using a treewalker). StringTemplate might
be useful if you need code generation for example.

Martijn


On Fri, Sep 25, 2009 at 9:50 PM, Simon Gubler <[email protected]> wrote:
> Hi all
>
> The following grammar compiles with ANTLRWorks 1.2.3 but when I debug it
> with "1+2+3" it generates a Parse Tree with the following elements:
> root->statement->MissingTokenException.
>
> In the file SimplePlusGrammar.g:
> grammar SimplePlusGrammar;
> statement : INTEGER (PLUS INTEGER)*;
> PLUS    : '+';
> DIGIT   : ('0'..'9');
> INTEGER : DIGIT+;
>
> Can you explain what is missing in the grammar to generate a valid Parse
> Tree out of "1+2+3"
> In many examples so far I have seen Java Code inside the *.g file. Is it
> possible to have only the grammar definition in the *.g file so that it can
> be used by different programming languages
>
> I'm posting my questions here because I haven't found a forum or something
> similar where I can put them.
>
> Kind regards
>
> Simon Gubler
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>

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