R: [antlr-interest] Input String for Lexer
Bussolaro Luigi
luigi.bussolaro at telecomitalia.it
Tue Jun 1 03:59:18 PDT 2004
I used with success ur suggestion but before i used following solution, in any case ur is more clean.
InputStream is = new java.io.ByteArrayInputStream(string.getBytes());
ExprLexer lexer = new ExprLexer(is);
Tks
Luigi
-----Messaggio originale-----
Da: John B. Brodie [mailto:jbb at cfl.rr.com] Per conto di jbb at acm.org
Inviato: martedì 25 maggio 2004 16.57
A: antlr-interest at yahoogroups.com
Oggetto: Re: [antlr-interest] Input String for Lexer
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
--------------------------------------------------------------------
CONFIDENTIALITY NOTICE
This message and its attachments are addressed solely to the persons above and may contain confidential information. If you have received the message in error, be informed that any use of the content hereof is prohibited. Please return it immediately to the sender and delete the message. Should you have any questions, please contact us by replying to webmaster at telecomitalia.it.
Thank you
www.telecomitalia.it
--------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20040601/b5ef3aa7/attachment.html
More information about the antlr-interest
mailing list