Hi
I have a stripped down grammer where I want to have a keyword, followed by
an ID, then ':' and then a block demarcated by '{' and '}'. The grammer is:
grammar ParserTest;
options {
output=AST;
}
tokens {
PLUS = '+' ;
MINUS = '-' ;
MULT = '*' ;
DIV = '/' ;
FULLSTOP = '.' ;
}
@header {
package test;
}
@lexer::header {
package test;
}
recurDef: 'recur'^ labelName ':'! blockDef ;
labelName: ID ;
blockDef: '{'! '}'! ;
ID : ('a'..'z'|'A'..'Z'|'_')('a'..'z'|'A'..'Z'|'0'..'9'|'_')* ;
URL : (ID|':'|'?'|'/')+ ;
NUMBER : (DIGIT)+ ;
WHITESPACE : ( '\t' | ' ' | '\r' | '\n'| '\u000C' )+ { $channel =
HIDDEN; } ;
fragment DIGIT : '0'..'9' ;
When I used the generated parser against the following:
recur Transaction: {
}
I get the following error:
line 1:6 mismatched input 'Transaction:' expecting ID
Shouldn't the lexical analyser recognize the 'Transaction' part as an ID,
and then the colon as a separate character. If the ':'! is removed from the
rule, and the content changes to
recur Transaction{
}
it correctly detects the ID as being distinct from the following '{'
character. So why is the ':' being treated as a special case?
Any guidance would be appreciated.
Regards
Gary
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
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.