Re: Do people create parsers for command line arguments?

Kaz Kylheku <480-992-1380@kylheku.com>
Fri, 29 Jul 2022 20:52:04 -0000 (UTC)

          From comp.compilers

Related articles
Do people create parsers for command line arguments? costello@mitre.org (Roger L Costello) (2022-07-28)
Re: Do people create parsers for command line arguments? 480-992-1380@kylheku.com (Kaz Kylheku) (2022-07-29)
Re: Do people create parsers for command line arguments? gah4@u.washington.edu (gah4) (2022-07-29)
Re: Do people create parsers for command line arguments? gciofono@gmail.com (Giacinto Cifelli) (2022-08-08)
Re: Do people create parsers for command line arguments? gah4@u.washington.edu (gah4) (2022-08-08)
Re: Do people create parsers for command line arguments? gah4@u.washington.edu (gah4) (2022-08-23)
Re: Do people create parsers for command line arguments? johann@myrkraverk.invalid (Johann 'Myrkraverk' Oskarsson) (2022-09-29)
| List of all articles for this month |

From: Kaz Kylheku <480-992-1380@kylheku.com>
Newsgroups: comp.compilers
Date: Fri, 29 Jul 2022 20:52:04 -0000 (UTC)
Organization: A noiseless patient Spider
References: 22-07-054
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="51767"; mail-complaints-to="abuse@iecc.com"
Keywords: parse
Posted-Date: 29 Jul 2022 17:49:35 EDT

On 2022-07-28, Roger L Costello <costello@mitre.org> wrote:
> Hi Folks,
>
> I've seen some tools with pretty complicated arguments. The argument list is a
> language unto itself.
>
> Do people create parsers for command line arguments? Or is a parser overkill?


It happens.


You probably know these examples.


The find utility has an expression syntax whose tokens are command line
arguments. Parentheses are used for overriding precedence; they must be
escaped in common shell languages, so they are passed through to find
verbatim:


    find /etc \( -name '*.conf' -o -name '*.xml \) -exec command {} \:


The [ command also parses expressions that are individual arguments:


    if [ $foo = $bar -o $n1 -gt $n2 ] ; then ...


The tcpdump utility uses command line arguments as the tokens for
pcap filter expressions. (Sort of). Example from man page:


              To print traffic between helios and either hot or ace:


                            tcpdump host helios and \( hot or ace \)


However, tcpdump can do its own splitting; the expression can be
quoted as one argument.


All of these programs must be parsing. They have phrase structures
and operator precedence with parentheses right the command line.


--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.