[antlr-interest] [3.1 C] Mulivalue Attribute is NULL in action after matching rule
Jim Idle
jimi at temporal-wave.com
Sun Apr 13 08:44:16 PDT 2008
You will need the output=AST option if you are wanting to use the += operator on something like NUMBER. This is why you are being told that vectors does not exist as it is created by code generation for AST creating parsers.
Jim
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Christian Schladetsch
Sent: Saturday, April 12, 2008 6:25 PM
To: Gavin Lambert
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] [3.1 C] Mulivalue Attribute is NULL in action after matching rule
I tried the more likely (num += NUMBER)+ syntax the first time. Then I got:
error C2039: 'vectors' : is not a member of 'FailParser_Ctx_struct'
When trying to compile the parser. I guess I'll just do something else.... like revert to my hand-written C++ parser :P
On Sun, Apr 13, 2008 at 1:17 AM, Gavin Lambert <antlr at mirality.co.nz> wrote:
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.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080413/9a8a85e0/attachment.html
More information about the antlr-interest
mailing list