Hmmm... that's evil, ya know that ;)  Good to catch that now, though...

Probably LITERAL_1, LITERAL_2, etc. To make it easier for
debugging/printing/reporting you could add a pattern property (hmmm...
the more I think about it the more I like it... if there's a
description it could be printed w/ the error message, otherwise the
pattern. both could be useful for other purposes)

  public enum FooParserTokens implements TokenType {
    IDENT("('a'..'z')('a'..'z'|'A'..'Z')*", "an identifier ..."),
    LITERAL_1(";", null),
    LITERAL_2("+", null);
    private String pattern;
    private String description;
    private FooParserTokens(String pattern, String description) {
      this.pattern = pattern;
      this.description = description;
    }
  }

-- Scott

----------------------------------------
Scott Stanchfield
http://javadude.com



On Wed, May 19, 2010 at 2:42 PM, Terence Parr <pa...@cs.usfca.edu> wrote:
>
> On May 19, 2010, at 11:39 AM, Scott Stanchfield wrote:
>
>> You can still define the match in the superclass -- just use an
>> interface like Edgar mentioned and I demonstrated in the
>> "clarification" note I sent.
>
> oh right.
>
>> I think the big value here would be that it forces every place that
>> uses the token types to use the enum names (as there are no integer
>> values). I think that would help debugging enormously (rather than
>> seeing '4' as the value in the variables window, you'd see 'IDENT').
>
> what about ';' token?  What's it's label?
> T
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

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 il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to