[antlr-interest] Proper way to run the parser and lexer as a shell with Antlr 3

Bruce Trask bruce.trask at mdesystems.com
Sun May 6 19:43:47 PDT 2007


Hi Terence,
   
  That worked. Thanks.
   
  Regards,
Bruce

Terence Parr <parrt at cs.usfca.edu> wrote:
  
On May 5, 2007, at 10:35 PM, Bruce Trask wrote:

> Hello,
>
> What is the proper way to run the lexer and parser in a loop so it 
> can behave as "shell", taking input from System.in? I have tried 
> some different attempts but am having some trouble with the input 
> streams getting closed ?

Hi. By default, ANTLR consumes all input to fill buffer. Therefore, 
you need to parse line-by-line. I.e.,

while not EOF
fetch a line
create token stream from line
parse

Ter

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070506/cb8e5ae4/attachment.html 


More information about the antlr-interest mailing list