[antlr-interest] Re: CLI with ANTLR - best practice

idontwantanidwith2000init idontwantanidwith2000init at yahoo.com
Fri Apr 9 12:49:22 PDT 2004


about unput, taken from jguru faq:

Question  Can I push back the most recently read token into the 
input stream?  
Topics  Tools:ANTLR:Recognition:Lookahead, 
Tools:ANTLR:Recognition:Syntactic predicates  
Author  Terence Parr PREMIUM  
Created  Oct 27, 2001  

Answer 
You are thinking in terms of the old one-token-of-lookahead type 
parser generators without backtracking capabilities. ANTLR 
specifically provides a mechanism to lookahead ahead a fixed amount, 
k, or infinitely via syntactic predicates (a selective programmer-
controlled form of backtracking). You can tell ANTLR to try out an 
alternative and back up to retry the next potentially viable 
alternative if that one fails. It's like specifying the infinite 
lookahead language that predicts an alternative. 



--- In antlr-interest at yahoogroups.com, "thierryj8" <thierryj8 at y...> 
wrote:
> Best practice for CLI in Lex&Yacc, O'Reilly:
> 
> ".. In order to scan the command line rather than a file, we must
> rewrite input() and unput()..." (p38), 
> 
> "...The input routine handles calls from the lexer to obtain
> characters" (p41),
> 
> "...The unput() routine handles calls from the lexer to "push back"
> characters into the input stream." (p41)
> 
> Input() treats the CLI end of line as the end of file. Is there an
> equivalent in ANTLR?



 
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