[antlr-interest] Input String for Lexer

jbb at acm.org jbb at acm.org
Tue May 25 07:57:13 PDT 2004


Luigi Bussolaro asked:
>Does anybody know the way to give a String in input to my Lexer instead
>an InputStream?
>It's really necessary to rewrite the whole Lexer?

No need to rewrite the Lexer.

One of the Lexer's constructors takes a java.io.Reader as its parameter.
java.io.StringReader is derived from Reader and thus may be passed to
this constructor. So you can just do:

    Your_Lexer lexer = new Your_Lexer(new StringReader("your string here"));

Hope this helps...
	-jbb


 
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