help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parsing/defining getopt style strings


From: Akim Demaille
Subject: Re: Parsing/defining getopt style strings
Date: Wed, 19 Aug 2015 10:17:00 +0200

> Le 17 août 2015 à 11:40, Michael Treibton <address@hidden> a écrit :
> 
> Hello all,
> 
> I have an existing application which uses a lot of YACC for its
> configuration file.  In trying to stream-line a lot of options, and
> for wider changes surrounding the application itself, I'm looking at
> trying to define something in YACC which would allow to the inclusion
> of getopt style strings.
> 
> Is this possible?
> 
> By getopt, I mean BSD-style getopt where there's only a single-letter
> option.  Hence, in terms of what this might look like in the
> configuration file itself, I was thinking:
> 
>        some_command -ab -c option some_other_option
> 
> Where you can see "-ab" in this case are just options, with "-c"
> taking an "option", and then "some_other_option" being separate.
> 
> Is this even possible, I wonder?

hi Michael,

Yes, it's possible.  Yet, I don't know of any program that do it this way,
because usually the syntax of the options is really simple, and does not
require a parser to handle, for instance, balanced parens.

Even tools that have a complex language for options seem to prefer a
parser written by hand.  For instance GNU Find:

http://git.savannah.gnu.org/cgit/findutils.git/tree/find/parser.c

It sounds like a heavyweight tool for what is, in most cases, a simple job.
But perfectly possible.  yylex would return the content of argv, tokenized.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]