[antlr-interest] Rule parameter troubles

Andrew Bradnan andrew.bradnan at gmail.com
Sat Nov 28 11:13:59 PST 2009


I was trying to use a rule parameter and can't call another rule with that
parameter when I use +.  An example will make more sense.

test [bool wtf] returns [int n]:
    {$wtf}?=>'wtf' test2[$wtf]+;    // attribute is not a token, parameter,
or return value: wtf
test [bool wtf] returns [int n]:
    {$wtf}?=>'wtf' test2[$wtf];    // works fine

test [bool wtf] returns [int n]:
    {$wtf}?=>'wtf' test2[false]+;  // works fine as well

test2 [bool wtf2]:
    {$wtf2}?=>'foobar';
If I take the gated semantic predicate out of test2, then all the above
work.
test2 [bool wtf2]:
    'foobar';    // works for all the above
What did I miss?
Thanks
-- 
/Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091128/2ea7f94f/attachment.html 


More information about the antlr-interest mailing list