[antlr-interest] TokenStreamRewriteEngine class and samples of its usage
Terence Parr
parrt at cs.usfca.edu
Thu May 27 07:51:37 PDT 2004
On May 26, 2004, at 7:04 PM, kumarsriram wrote:
> Hi,
>
> I'm a novice to ANTLR. I'm trying to write an expression parser
> (extension to the one that is provided in the ANTLR examples). I
> have a case where I need to replace some input characters
> ("$input.xyz" should be replaced with "getXYZ()"). I figured out
> that I could use TokenStreamRewriteEngine to do that. But when I use
> it in my program, I end up with ClassCastExceptions whenever I
> invoke nextToken() method on the engine instance. Has anyone used
> TokenStreamRewriteEngine before? BTW, am I taking the correct
> approach?
>
> I have tested my Lexer and Parser and they seem to be work fine.
>
> Have enclosed my test code.
>
> MyLexer lexer = new MyLexer(new StringBufferInputStream(inputStr));
> System.out.println("Input string is " + inputStr);
> TokenStreamRewriteEngine writer = new TokenStreamRewriteEngine
> (lexer);
> Token t = writer.nextToken; //here's the problematic code
Hi. You need to set the token object to be TokenWithIndex as well :)
Terence
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