From: | Hans-Peter Diettrich <DrDiettrich1@aol.com> |
Newsgroups: | comp.compilers |
Date: | Sat, 28 Jun 2008 22:53:42 +0200 |
Organization: | Compilers Central |
References: | 08-06-053 08-06-055 08-06-061 08-06-071 08-06-074 |
Keywords: | parse, design |
Posted-Date: | 28 Jun 2008 17:54:13 EDT |
Max Hailperin schrieb:
> Consider for example the following situation:
>
> A -> B c
> A -> D e
[...]
> In fact, given that there is some lookahead, the LR parser can do even
> more. Suppose we complete the grammar with
>
> B -> f f f f f
> D -> f f f f f
IMO this is an example of a bad language design, which I encounterd
already in many languages. The fact, that a parser generator can handle
such a grammar, is not an excuse for a thoughtless language design. No
offense on you, your example is a very practical one <sigh>.
When we have an look at any application, using the above grammar for
e.g. serializing data, a possibly huge amount of input must be kept in
the stack, before any action can be taken. And more memory is wasted for
the automaton tables. When the language, and consequently also the
grammar is converted into LL(1), by swapping the terms in A, no special
amount of time or memory has to be wasted in the analysis of the input.
DoDi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.