[antlr-interest] How to use String Attributes in ANTLR3
Foolish Ewe
foolishewe at hotmail.com
Tue Dec 12 13:01:05 PST 2006
Hello All:
I'm trying to add backend support to my grammar and for my convenience, I
would like to have
Java Strings "synthetic attributes" passed from the bottom up in the grammar
(so that I can
access them in non terminal productions). I tried following the approach
that appears to
be suggested in the expression evaluator in the wiki, at:
http://www.antlr.org/wiki/display/ANTLR3/Expression+evaluator
However, something like:
testCommandSuffix returns [String text]
:
ACTION {$text = $ACTION.text;}
;
generates errors reported in the console reading:
[15:55:48] error(151): C:\temp\TestGrammar.g:111:10: cannot write to read
only attribute: $text.
[15:55:49] error(10): internal error:
org.antlr.tool.Message.toString(Message.java:124): Assertion failed! Message
ID 151 created but is not present in errorMsgIDs or warningMsgIDs.
Have I made an error here, if so, how can I fix it? Otherwise, how does one
specify a
synthetic attribute in ANTLR?
I have also noticed that in ANTLRworks 1.0b8, when trying to generate
grammars, sometimes if I get
an error, I will get a popup window reading:
"Grammar Check failed:
null
Check Console for more Information"
and if I try to edit the grammar or regenerate it, the console window does
not get any new
diagnostic messages routed to it. Does anyone else get this?
Thanks:
Bill M.
_________________________________________________________________
Visit MSN Holiday Challenge for your chance to win up to $50,000 in Holiday
cash from MSN today!
http://www.msnholidaychallenge.com/index.aspx?ocid=tagline&locale=en-us
More information about the antlr-interest
mailing list