[antlr-interest] tree parser syntax

Safiye Celik safisce at gmail.com
Wed Aug 19 08:07:52 PDT 2009


Thanks for the answer. Now I wonder what is the way of putting that INTEGER
: ('0'..'9')+ to the tokens {} part of my tree grammar. I want this, because
I get no error for the tokens defined in tokens {} block in my tree grammar.
But I cannot do this directly as
tokens {
...
INTEGER = '0'..'9'+
...
}
I get an error of "Expecting SEMI, found '..'".
How can get rid of this error and put INTEGER token to tokens block?
Thanks in advance..

2009/8/19 Gavin Lambert <antlr at mirality.co.nz>

> At 00:59 20/08/2009, Safiye Celik wrote:
>
>> I get an error saying "lexer rule INTEGER not allowed in parser". How
>> would I handle this issue? If I first write "grammar MyGrammar;" to my .g
>> file and after listing rules and tokens write "tree grammar MyGrammar;" in
>> order to parsing the tree, I get a syntax error. In ANTLR v2, we were able
>> to declare lexer, parser, and then tree walker in the same .g file. What is
>> the way of it in v3? Or how would I declare tokens such as INTEGER above to
>> the tree grammar?
>>
>
> In v3, each grammar must be in its own separate file.  (Though as a special
> case, a "combined" grammar can have both lexer and parser rules [not tree
> parser rules, though].)
>
> The options section is used to tell the tree grammar where it will be
> getting its token definitions from.
>
> Probably your best bet is to have a look at the examples (in the separate
> examples zipfile).
>



-- 
-safiye
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090819/4ea95089/attachment.html 


More information about the antlr-interest mailing list