[antlr-interest] [3.1 C] Mulivalue Attribute is NULL in action after matching rule

Gavin Lambert antlr at mirality.co.nz
Sat Apr 12 06:17:48 PDT 2008


At 22:23 12/04/2008, Christian Schladetsch wrote:
>The assertion fires on input "42" using antlr-2008-04-09.10:
>
>grammar Fail;
>options { language=C; }
>@preincludes { #include <assert.h> }
>sequence  : num += (NUMBER+) { assert($num != 0); } ;
>NUMBER  :  ('0'..'9')+ ;
>
>Is this correct behavior?

"Correct" is a little debatable, but you've used a syntax that's 
known to be invalid in the current version.  Try this instead:

sequence : (num += NUMBER)+ ...

(Basically, you can't assign a label to a block, only to a single 
token.)



More information about the antlr-interest mailing list