[antlr-interest] Trying to convert a file-oriented lexer to a line-oriented one
siva.kumar at loglogic.com
siva.kumar at loglogic.com
Wed Jun 25 14:49:44 PDT 2008
Hi everyone,
I've looked for examples of using a lexer in a
line-oriented fashion but can't seem to find one.
Most grammar examples, use this:
grammar test;
public static void main(String[] args) throws Exception {
testLexer lex = new testLexer(new ANTLRFileStream(args[0]));
CommonTokenStream tokens = new CommonTokenStream(lex);
testParser parser = new testParser(tokens);
try {
parser.line();
} catch (RecognitionException e) {
e.printStackTrace();
}
}
I looked at the Java API classes at:
http://www.antlr.org/api/Java/annotated.html
But I'm having some trouble figuring out how to call the lexer on each
line that I've read from the file.
What I am essentially trying to do is:
Open a file
While lines exist
Get a line
Call the Parser
Any help is appreciated.
Thanks,
-Siva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080625/1bf4fb47/attachment.html
More information about the antlr-interest
mailing list