[antlr-interest] Re: Bug in ANTLR C# implementation
Maassen, H.A.M.
H.A.M.Maassen at student.tue.nl
Wed Dec 1 04:05:51 PST 2004
> Interesting. But the tree parsers must be initialized in the same way
> off a parser right?.
> On second thought, perhaps you are suggesting that the method should
> be removed from C# tree parsers too?.
>>From the online manual:
CalcLexer lexer =
new CalcLexer(new DataInputStream(System.in));
CalcParser parser = new CalcParser(lexer);
parser.expr();
CommonAST t = (CommonAST)parser.getAST();
CalcTreeWalker walker = new CalcTreeWalker();
walker.expr(t);
To get this to work in C# (assuming that the CalcTreeWalker does tree-reformatting) I'd have to change it to:
CalcLexer lexer =
new CalcLexer(new DataInputStream(System.in));
CalcParser parser = new CalcParser(lexer);
parser.expr();
CommonAST t = (CommonAST)parser.getAST();
CalcTreeWalker walker = new CalcTreeWalker();
CalcTreeWalker.initializeASTFactory(walker.getASTFactory());
walker.expr(t);
That extra line feels kind of random to me :) Seems like it should just be done automatically in the constructor. Without a manual call, the procedure is never run.
static public void initializeASTFactory( ASTFactory factory )
{
factory.setMaxNodeType(163); // 163 is generated by ANTLR
}
Regards, Harald Maassen
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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 5574 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20041201/42e47129/attachment.bin
More information about the antlr-interest
mailing list