[antlr-interest] Tried of dealing with '\r' and '\n' ?

thrutchy eric_mahurin at yahoo.com
Wed Jul 28 12:11:19 PDT 2004


I got a little tired of dealing with carriage returns and
newlines/linefeeds in the lexer, so I did these two things:

1. Filter the Reader through LineNumberReader to convert things to
unix-style (simple '\n').  For example:

lexer = new myLexer(new LineNumberReader(new FileReader(name)));

2. Override consume in your lexer to automatically call newline() like
it already calls tab().  Here's what I did:

    public void consume() throws CharStreamException {
        if (inputState.guessing==0 && LA(1)=='\n') newline();
        super.consume();
    }

Eric




 
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