Re: Supporting multiple input syntaxes

Rock Brentwood <rockbrentwood@gmail.com>
Sun, 14 Mar 2021 17:36:01 -0700 (PDT)

          From comp.compilers

Related articles
[11 earlier articles]
Re: Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-23)
Re: Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-23)
Re: Supporting multiple input syntaxes antispam@math.uni.wroc.pl (2021-02-11)
Re: Supporting multiple input syntaxes elronnd@elronnd.net (Elijah Stone) (2021-02-17)
Re: Supporting multiple input syntaxes antispam@math.uni.wroc.pl (2021-02-23)
Re: Supporting multiple input syntaxes ltcmelo@gmail.com (ltc...@gmail.com) (2021-03-14)
Re: Supporting multiple input syntaxes rockbrentwood@gmail.com (Rock Brentwood) (2021-03-14)
| List of all articles for this month |

From: Rock Brentwood <rockbrentwood@gmail.com>
Newsgroups: comp.compilers
Date: Sun, 14 Mar 2021 17:36:01 -0700 (PDT)
Organization: Compilers Central
References: 20-08-002
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="45952"; mail-complaints-to="abuse@iecc.com"
Keywords: parse, syntax, C
Posted-Date: 14 Mar 2021 21:09:45 EDT
In-Reply-To: 20-08-002

On Wednesday, August 12, 2020 at 5:32:56 PM UTC-5, luser droog wrote:
> I've got my project successfully parsing the circa-1975 C syntax
> from that old manual. I'd like to add parsers for K&R1 and c90
> syntaxes.
>
> How separate should these be? Should they be complete
> separate grammars, or more piecewise selection?


I'm in a similar situation with a utility that I want to grandfather in the
old syntax for, but write with a new and better syntax. My recommendation is
this: stick to C99, since that's already in POSIX. Write a separate utility to
convert legacy syntax to C99 (and to call out any
irregularities/inconsistencies in the program being converted). That's, like,
"lint" on steroids.


The other syntaxes would be used in the other utilities, only - one per
utility. It can also be hybridized with "indent" and a driver routine can
control the conversion, so that all the conversion utilities can be combined
to one. So, on input, the source syntax is selected, and on output the format
is driven in much the same way that it is with indent. It's an excellent
exercise in Text-To-AST-To-Text programming.


Each program, upon upward conversion to C99, would replace the original, once
it passes the consistency checks provided by the utility; so there isn't a
question of cueing error messages to the format of the older program, because
the older program would be replaced. Doing all of this is an example of
"refactoring" used to pay off "code debt". And there's a lot of code debt out
there that needs to be paid up.


Technical Debt (Wikipedia): https://en.wikipedia.org/wiki/Technical_debt
Code Refactoring (Wikipedia): https://en.wikipedia.org/wiki/Code_refactoring


Post a followup to this message

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