[antlr-interest] "everything else" clause

Mike Lischke lists at lischke-online.de
Sun Apr 25 08:30:34 PDT 2004


Hi again,

Does anybody know how I can specify a rule, which matches a few things and collects everything else into an own series of tokens. ANTLR creates a switch statement from my grammar, which contains the few allowed cases. But instead using the default branch for everything else it lists all tokens it knows for that single parser for the "rest" of the input. This does not work well however because due to the lexer there can be tokens, which are not known to the parser.

What I used was:

  program:
    (
      a
      | b
      | rest
    )*
  ;

  rest:
    (options {greedy = false;}:
      ~(
        "a"
        | "b"
      )
    )+
  ;

Using the DOT symbol like:

rest:
  (options {greedy = false;}: .)+
;

produces a nondeterminism warning for each alternative in the program rule. I would be very thankful for any good solution.

Mike
--
www.soft-gems.net



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list