[antlr-interest] Passings strings to the parser

Anakreon anakreonmejdi at yahoo.gr
Thu May 6 08:17:15 PDT 2004


Bharath S wrote:
> Hi all,
> 
> I saw several examples of tests written for grammar. In most examples, the
> parser is tested by passing strings to either the parser in this form:
> 
> Parser p = new Parser("2 + 2");
> 
> Or with the "USE" statement in this form:
> 
> use("3 * 12 - 7");
> assertTrue(parser.expression());
> 
> However, I find that when the parser gets automatically generated, it does
> not have a constructor that accepts strings. It accepts data input streams,
> buffered reader, console input (system.in) etc but not strings. Does this
> mean I have to write my own constructor which would consider strings just
> like command line input? 
No.Use the constructor whic accepts a Reader and pass a StringReader instance.


 
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