On Wed, Sep 3, 2008 at 7:13 PM, Bill Mayfield <[EMAIL PROTECTED]> wrote: > Hi, > > Suppose I want to recognize each pattern 'okko' in a random string of > characters. Some examples: > > aaaaaoookoooookkooooaaa -> should yield one match of 'okko' > aaaokkookko -> should yield two matches of 'okko' > > > > Here is a grammar that won't work ;o) > > grammar test; > > start : .* pattern .*; > > pattern : T1 T2 T2 T1; > > > T1 : 'o'; > T2 : 'k'; > Wildcards in parser rules match any token, not any character. As your lexer only matches 'o'|'k' anything else will cause a lexer error. Try adding a lexer rule to match any other input after your other lexer rules, like: OTHER: .; Or you may want to look at filtering lexers as they may be better suited to your task.
Tom. > > No matter what grammar I try. I can't get it to work... how hard can it be? > > > Thanks for any input you may provide, > Bill > > List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address > > List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org:8080/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 -~----------~----~----~----~------~----~------~--~---
