[antlr-interest] Parsing a command line?

Johannes Luber jaluber at gmx.de
Thu Feb 19 22:45:18 PST 2009


kedar mhaswade schrieb:
> I am writing a command line interface program in Java. The syntax of the
> command line is sort of defined, but is not really formally defined in
> terms of an EBNF or railroad diagram. My questions are:
> 
> - Is ANTLR (and ANTLRWorks) the right tool to define the grammar and
> write the parser to parse the command line?

If you can define a grammar then you can create a grammar for ANTLR.
ANTLR possibly may be overkill here though.
> 
> - An implementation of the command line parsing works, but there are
> rather too many hacks and although I haven't done any parsing course in
> school, it occurs to me that that is not the right way of doing things. 
> Should I be investing into ANTLR for this problem?
> 
> - Has anyone done this kind of thing?

You should google for command line parsing to look at others'
implementations. GNU's getopt, NDesk.Options package, at least two
projects on CodeProject.com, and many more.

Johannes
> 
> Thanks,
> Kedar
> 
> 
> ------------------------------------------------------------------------
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list