[antlr-interest] lexer and parser implementation in ANTLRv3

Luke Silver LukeSilver at web.de
Wed Dec 20 14:12:18 PST 2006


Hi,

I?ve generated an ANTLRv3 lexer and parser for my grammar and now I would like to integrate this files (myLexer.java, myParser.java) in my project. My problem is that the input string for a test grammar is not of the type "CharStream" it?s of the Type "StringReader" (Java5).
There is a good description in the ANTLR reference manual (Java Runtime Model, lexer and parser implementation) of how to implement more constructors for the lexer and the parser but this is for ANTLRv2.7. How can I implement a constructor of the type "StringReader" in ANTLRv3? Or is a constructor a false attempt?

Here is a part of my project:


//grammar of type StringReader

public static Class classmethod(Reader grammar) {

try {

MyLexer lexer = new MyLexer(grammar);

CommonTokenStream tokens = new CommonTokenStream(lexer);

MyParser parser = new MyParser(tokens);


// parse grammar

parser.firstrule();

}

catch ...



Best wishes,

Luke
______________________________________________________________________________
"Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de
Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht!



More information about the antlr-interest mailing list