[antlr-interest] predicate, uh?
Lloyd Dupont
lloyd at nova-mind.com
Thu May 26 17:19:04 PDT 2005
I have a simple grammar rule like that (inheriting from cgram)
objcMethodDefinition returns [String selName]
{
selName = "";
}
: ( PLUS | MINUS ) (castExpr)?
(
( ID COLON )=>
id0:ID COLON (castExpr)? ID { selName = id0.getText() + ":"; }
(
(id1:ID { selName += id1.getText(); })? (COLON) (castExpr)? ID { selName += ":"; }
) *
| id2:ID { selName = id2.getText(); }
)
note: there is no explicit end to this rule, because I reuse it for both declaration (ending by a ';') and definition (ending by '{').
when I test it I get this parsing error (while evaluating the (ID COLON)=> !!!) (on something as simple as "- foo { ...."
ANTLR Parsing Error: # 1 "":line 22:1896: unexpected token: { token name:LCURLY
line 22:1896: unexpected token: {
at ObjectiveCParser.postfixExpr(ObjectiveCParser.java:5876)
at ObjectiveCParser.unaryExpr(ObjectiveCParser.java:5293)
at ObjectiveCParser.castExpr(ObjectiveCParser.java:1548)
at ObjectiveCParser.objcMethodDefinition(ObjectiveCParser.java:1129)
at ObjectiveCParser.objcClassImplementation(ObjectiveCParser.java:1056)
at ObjectiveCParser.externalDef(ObjectiveCParser.java:213)
at ObjectiveCParser.externalList(ObjectiveCParser.java:1649)
at ObjectiveCParser.translationUnit(ObjectiveCParser.java:1610)
at Test.main(Test.java:40)
?!!!
how come?
what did I do wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050527/a71d32c3/attachment.html
More information about the antlr-interest
mailing list