Re: Deep expression chain performance

anton@mips.complang.tuwien.ac.at (Anton Ertl)
Thu, 27 Apr 2023 06:17:51 GMT

          From comp.compilers

Related articles
Deep expression chain performance borucki.andrzej@gmail.com (Andy) (2023-04-25)
Re: Deep expression chain performance anton@mips.complang.tuwien.ac.at (2023-04-26)
Re: Deep expression chain performance gah4@u.washington.edu (gah4) (2023-04-26)
Re: Deep expression chain performance 864-117-4973@kylheku.com (Kaz Kylheku) (2023-04-27)
Re: Deep expression chain performance anton@mips.complang.tuwien.ac.at (2023-04-27)
| List of all articles for this month |
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.compilers
Date: Thu, 27 Apr 2023 06:17:51 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 23-04-012 23-04-015
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="11079"; mail-complaints-to="abuse@iecc.com"
Keywords: parse, performance
Posted-Date: 27 Apr 2023 21:56:22 EDT

Kaz Kylheku <864-117-4973@kylheku.com> writes:
>ISO C specifies its grammar in an obtusely verbose way, similar to the
>above. The reason is that it makes the grammar unambiguous, meaning
>that it does not require any annotation or external remarks about
>ambiguities having to be resolved by a certain associativity or
>precedence.


They were not that keen on eliminating ambiguity. The classical
ambiguous grammar rule is there:


|selection-statement:
| if ( expression ) statement
| if ( expression ) statement else statement
| switch ( expression ) statement


They resolve that ambiguity in prose:


|An else is associated with the lexically nearest preceding if that is
|allowed by the syntax.


C is not alone in this approach.


As for why they chose to deal with expressions through BNF, my guess
is that it allowed them to split the expression syntax into different
sections, each with their own piece of the grammar, rather than having
a section on the syntax that presents an ambuguous BNF and resolves
the ambiguity in prose (and by necessity has to cover the whole
expression syntax), and then having sections on the semantics of the
various expression sub-syntaxes.


- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/


Post a followup to this message

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