Thanks a lot - that was the problem. I knew it was going to be something simple :(
Regards Gary On Sun, Aug 1, 2010 at 9:19 PM, John B. Brodie <[email protected]> wrote: > Greetings! > > On Sun, 2010-08-01 at 20:57 +0100, Gary Brown wrote: > > 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? > > the input string `Transaction:` is a URL under your rules. > > try `Transaction :` > > it is probably just this stripped down example example, but since URL is > not used, just remove that rule... > > > > > Any guidance would be appreciated. > > > > Hope this helps... > -jbb > > > 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.
