Re: Supporting multiple input syntaxes

Hans-Peter Diettrich <DrDiettrich1@netscape.net>
Thu, 13 Aug 2020 10:27:45 +0200

          From comp.compilers

Related articles
Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-12)
Re: Supporting multiple input syntaxes 793-849-0957@kylheku.com (Kaz Kylheku) (2020-08-13)
Re: Supporting multiple input syntaxes DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2020-08-13)
Re: Supporting multiple input syntaxes minforth@arcor.de (2020-08-13)
Re: Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-13)
Re: Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-13)
Supporting multiple input syntaxes davidlovemore@gmail.com (David Lovemore) (2020-08-15)
Re: Supporting multiple input syntaxes mijoryx@yahoo.com.dmarc.email (luser droog) (2020-08-15)
Re: Supporting multiple input syntaxes davidlovemore@gmail.com (David Lovemore) (2020-08-16)
[9 later articles]
| List of all articles for this month |

From: Hans-Peter Diettrich <DrDiettrich1@netscape.net>
Newsgroups: comp.compilers
Date: Thu, 13 Aug 2020 10:27:45 +0200
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="68932"; mail-complaints-to="abuse@iecc.com"
Keywords: C, parse
Posted-Date: 13 Aug 2020 18:22:50 EDT

Am 13.08.2020 um 00:20 schrieb luser droog:
> 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?


IMO this depends widely on the usage of the parser output (diagnostics,
backend...). C90 is much stricter than K&R, requires more checks. Do you
need extensive error diagnostics, or do you assume that all source code
is free of errors?




> https://github.com/luser-dr00g/pcomb/blob/master/pc9syn.c


You seem to implement an LL(1) parser? My C98 Parser is LL(2), i.e. an
LL(1) parser with one or two locations where more lookahead is required.
Also identifiers are classified as typenames and others prior to their
usage.


For real-world testing (recommended!) a preprocessor is required and a
copy of the standard libraries of existing compiler(s).


Your test_syntax() source misses "=" from the variable declarations
(initializers). What about pointer syntax/semantics? If you add these
(and other) syntax differences conditionally (version specific) to your
code, which way would look better to you? Which way will be safer to
maintain?




Nice code BTW :-)


DoDi


Post a followup to this message

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