Doesn’t a simple approach like the one shown below work?
r : ASSIGNMENTOP | KEYWORDMARKER
;
ASSIGNMENTOP : ':=' ;
KEYWORDMARKER : ':' ;
I assume you want a different token for ‘:=’ and ‘:’. If I understood the
problem wrong, let me know.
Cheers, Indhu
From: [email protected]
[mailto:[email protected]] On Behalf Of Loïc Quéran
Sent: Wednesday, October 14, 2009 2:57 PM
To: [email protected]
Subject: [antlr-interest] Syntactic predicates in lexer
Hi,
This is probably a very simple question, but I can't get syntactic
predicates to work in lexer rules:
AssignmentOperatorOrKeywordMarker
: ':=' => AssignmentOperator
| ':' => KeywordMarker
;
KeywordMarker
: ':'
;
AssignmentOperator
: ':='
;
What I want to achieve is to have the lexer produce an assignment operator
':=' token instead of a keyword marker ':' whenever possible.
The error is "unexpected token: ':='" at AssignmentOperatorOrKeywordMarker
rule definition.
Any help would be welcomed.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address