[antlr-interest] Changes don't affect AST but require code regenration of tree parser?
Raphael Reitzig
r_reitzi at cs.uni-kl.de
Sat Aug 2 04:35:05 PDT 2008
Hi Gavin, Hi Kevin!
I heeded advice coming on over the list and did not use literals in
parser rules. ;)
I checked out the last version before my changes and checked. What I
did change was this
***
property
: NOT^ property
| prefixed^
| OP! property ( ( UNTIL | IMPL )^ property | ((AND | OR)^ property)+ ) CP!
| VAR EQ QUOT VAR QUOT -> ^(EQ ^(VARIABLE VAR) ^(VALUE VAR))
| term (EQ | NEQ | LES | GRT | LEQ | GEQ)^ term;
prefixed
: ( ALL | GLOB | SOME | FIN | NEXT)^ ( prefixed | property );
***
to this
***
property
: ( ALL | GLOB | SOME | FIN | NEXT | NOT)^ property
| OP! property ( ( UNTIL | IMPL )^ property | ((AND | OR)^ property)+ ) CP!
| ((VAR EQ QUOT VAR QUOT) | (QUOT VAR QUOT EQ VAR)) -> ^(EQ
^(VARIABLE VAR) ^(VALUE VAR))
| term (EQ | NEQ | LES | GRT | LEQ | GEQ)^ term;
***
I attach the hole files so can have a look yourself.
I just checked the token file against its old version; it did not change.
Regards
Raphael
"Gavin Lambert" <antlr at mirality.co.nz> wrote (Sat Aug 2 02:02:00 2008):
> At 07:35 2/08/2008, Raphael Reitzig wrote:
>> However, after I generated parser code, even the simplest
>> examples won't be accepted anymore. Tree gramar won't read a
>> token it always had, stating "No rule viable". I swore and
>> searched and swore and despaired - until I reminded myself of
>> the "Clean and rebuild all if anything is strange" mantra. I
>> generated all code again, including the tree walker. Note
>> that tree gramar never changed! Though, now everything works
>> perfectly again.
>>
>> What happened there? Why did an internal change in parser rules
>> (even lexer rules should not have been affected) render the
>> genereated tree walker code useless?
>
> Are you sure you didn't change any of the lexer rules? (And
> remember that if you're using a combined grammar, using a string
> literal in the parser counts as changing the lexer rules!)
> Reordering the rules without actually changing them will have a
> similar effect (and again, if you've used quoted literals then that
> includes parser rules).
>
> In any event, it sounds like the token definitions changed, so the
> tree parser was working on outdated values. You need to inform your
> build environment that the YourGrammar.tokens file is an input
> dependency of YourTreeGrammar.g in order to make it realise it needs
> to rebuild the tree grammar in such cases. (Exactly how you do that
> depends on your platform, language, and build tools of choice.)
>
>
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: files.zip
Type: application/zip
Size: 3101 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080802/c0eb7b00/attachment.zip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: PGP Digital Signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080802/c0eb7b00/attachment.bin
More information about the antlr-interest
mailing list