[antlr-interest] ANTLR for command line interface

Ric Klaren klaren at cs.utwente.nl
Wed Apr 21 02:18:22 PDT 2004


On Fri, Apr 09, 2004 at 03:50:31PM -0000, thierryj8 wrote:
> - What is the effect of the "interactive" mode (Supposed to be for CLI)?

AFAIK it does nothing. It's probably some artifact of an older version of
an intended feature. Terence might be able to shed some light on it.

> - Should look ahead entries be cancelled after a NEWLINE & HOW?

That is particularly nasty to do at hand I have no idea how. I'd probably
start looking at generated code and see if I can get somewhere by
overriding LA/LT methods of the parser/lexer.

Another option is to use a parser in two modes one mode that sees wether
the input is complete and keep retrying untill it is. How to implement
these modes is another question... you might get somewhere with some
semantic predicates ( ()=> () construct I'm always confusing
syntactic/semantic) or faking the evaluation of them.

> - Are there examples of CLIs with ANTLR?

I recall someone doing something with syntax highlighting with antlr
(Bogdan Mitu might be the name but not sure...) He patched some things to
let antlr deal with incomplete input. This might be interesting for you. It
might be listed in the showcase or files section of antlr.org. Try
searching the archives.

> Because there is a parser, a lexer, and the usage of code in Java,
> there are several ways of soving problems. Is there a best practice
> standard?

In general this depends on the problem.

Cheers,

Ric

On Fri, Apr 09, 2004 at 04:29:44PM -0000, thierryj8 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?

The LA() method would be the closest thing. (And the underlying inputbuffer
mechanism) ANTLR does not have an unput.

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
     Human beings, who are almost unique in having the ability to learn
   from the experience of others, are also remarkable for their apparent
         disinclination to do so. --- Douglas Adams, Last Chance to See



 
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