Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2002-01-21 06:46:05


I think that in order to make progress with command line parsing library, Iit
would be usefull to discuss possible syntaxes and possible clashes between
them. I've written some initial implementation of the parsing proper which is
available at:
http://groups.yahoo.com/group/boost/files/Command Line Parsing/cmdline.cpp

The interface is similar to that of Bill Kempf's parser, but more syntaxes
are allowed. There is also quite a lot of tests, so that various corner cases
are covered.

I'd like to ask that we don't start "Spirit vs. hand-make parser" discussion
once again. Currently, I'm interested in syntax only; and, in general,
discussion about parsing back-end will be more appropriate when command line
parsing library interface is agreed upon.

I'll use the following terms:
"option" means what you'd expect
"parameter" is short for "parameter to an option"
"argument" is everything which is not option or its parameter.

There's the list of supported syntaxes:

1. Special tokens:
"-" is always interpreted as argument
"--" is silently eaten, and makes everything following it on the command line
to be interpreted as argument.

2. Long options:
--long_option
--long_option=parameter
--long_option parameter

In the last case if the token following the option looks like another option,
it is taken to be an option, regardless of whether the first option requires
or allows a parameter.

Long options can be abbreviated. They can be made case insensitive.

3. Short options:
-<letter>
-<letter>parameter
-<letter> parameter

The same comment as for long options apply.

4. Sticky short options

If 'x' and 'y' are two short options, and 'x' does not take a parameter, then

        -xy40

is invalid (extra parameter to x)
When sticky syntax is allowed, it is treated as if

        -x -y40

was given

5. Dos options
/<letter>
/<letter>parameter
/<letter> parameter

Work the same way as short options, except that cannot be sticky.

6. Long options in disguise.
-long_option
-long_option=parameter
-long_option parameter

"/" can also be used.

When long options disguise is allowed, dash followed by a long option name is
taken to be a long option, regardless of other possible interpretations.
Abbreviations is are used when enabled. I think that we'll need some check
"-f" can match both a short option and a long one and if the options do not
form a pair, it should be an error.

Comments?

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk