Path: csiph.com!1.us.feeder.erje.net!feeder.erje.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Johann 'Myrkraverk' Oskarsson Newsgroups: comp.compilers Subject: Re: Do people create parsers for command line arguments? Date: Thu, 29 Sep 2022 13:16:13 -0400 (EDT) Organization: Easynews - www.easynews.com Lines: 33 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-09-017@comp.compilers> References: <22-07-054@comp.compilers> <22-07-057@comp.compilers> <22-07-059@comp.compilers> <22-08-001@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="63092"; mail-complaints-to="abuse@iecc.com" Keywords: parse Posted-Date: 29 Sep 2022 13:16:13 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Content-Language: en-US In-Reply-To: <22-08-001@comp.compilers> Xref: csiph.com comp.compilers:3169 On 8/8/2022 4:25 PM, Giacinto Cifelli wrote: > in general the linux command line arguments are parsed through getopt(3) > https://www.man7.org/linux/man-pages/man3/getopt.3.html > > and it is better not to implement special things on the command line, > because it could be pre-parsed or expanded by the shell itself. > > then if you want to pass a string on the command line, that is > different, but then again, it is better to take it from stdin. A much [?] younger me wrote about how to do this with reflex & byacc. http://www.myrkraverk.com/blog/2017/10/parsing-command-line-parameters-with-yacc-flex/ I know these tools even better now, thanks in parts to reading more books on the subject, but I have not updated my blog. Note that before I wrote this, the "common knowledge" I could find online at the time, being a decade ago and older, was the need to first concatenate the strings, but that's simply wrong. Of course, using these tools easily requires prior knowledge, but for the people who do, it's trivial. I do not know who, if any, have actually used my template in production. I believe it's mostly students who are curious about this. [snip] Enjoy, -- Johann | email: invalid -> com | www.myrkraverk.com/blog/ I'm not from the Internet, I just work there. | twitter: @myrkraverk