Home > Archive > Compilers > September 2007 > Production missing on page 9 of Compiler Construction
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Production missing on page 9 of Compiler Construction
|
|
| pupeno@pupeno.com 2007-08-31, 11:38 pm |
| Hello,
I'm reading Compiler Construction, by Niklaus Wirth, available on
http://www.oberon.ethz.ch/WirthPubl/CBEAll.pdf and on page 9 he shows
this little piece of BNF:
E = T | A "+" T.
T = F | T "*" F.
F = V | "(" E ")".
V = "a" | "b" | "c" | "d".
A is being used on the right hand side without it being defined on the
left hand side first. What am I missing?
The only thing I can think of is that it is missing a production at
first, like:
A = E
>From this BNF it writes this "programs" (on page 10):
a*b+c
a+b*c
(a+b)*(c+d)
Thanks.
| |
| Hans-Peter Diettrich 2007-09-03, 10:11 pm |
| pupeno@pupeno.com wrote:
> I'm reading Compiler Construction, by Niklaus Wirth, available on
> http://www.oberon.ethz.ch/WirthPubl/CBEAll.pdf and on page 9 he shows
> this little piece of BNF:
>
> E = T | A "+" T.
> T = F | T "*" F.
> F = V | "(" E ")".
> V = "a" | "b" | "c" | "d".
>
> A is being used on the right hand side without it being defined on the
> left hand side first. What am I missing?
IMO it's a typo, should read 'E'.
E = Expression
T = Term
F = Factor
V = Value
A is not mentioned elsewhere.
DoDi
| |
| Adrian Devries 2007-09-03, 10:11 pm |
| pupeno@pupeno.com schrieb:
> I'm reading Compiler Construction, by Niklaus Wirth, available on
> http://www.oberon.ethz.ch/WirthPubl/CBEAll.pdf and on page 9 he shows
> this little piece of BNF:
>
> E = T | A "+" T.
> T = F | T "*" F.
> F = V | "(" E ")".
> V = "a" | "b" | "c" | "d".
> A is being used on the right hand side without it being defined on the
> left hand side first. What am I missing?
Hello,
I think, it is an erratum. Solution: Within the production 'E = T | A
"+" T.' replace 'A' by 'E'.
The sentence above the cited section reads as follows:
"The symbols E, T, F, and V stand for expression, term, factor, and
variable."
Please confer the german edition of the referenced paper:
Wirth, Niklaus:
Grundlagen und Techniken des Compilerbaus / Niklaus Wirth. -
Bonn; Paris [u. a.]: Addison-Wesley, 1996
ISBN 3-89319-931-4
On page 6 you will find the following productions:
"(...) Die Symbole A, T, F und V stehen f|r Ausdruck, Term, Faktor und
Variable.
A = T | A "+" T.
T = F | T "*" F.
F = V | "(" A ")".
V = "a" | "b" | "c" | "d".
(...)"
Regards,
Adrian Devries
| |
| Torben Ęgidius Mogensen 2007-09-03, 10:11 pm |
| "pupeno@pupeno.com" <pupeno@pupeno.com> writes:
> E = T | A "+" T.
> T = F | T "*" F.
> F = V | "(" E ")".
> V = "a" | "b" | "c" | "d".
>
> A is being used on the right hand side without it being defined on the
> left hand side first. What am I missing?
>
> The only thing I can think of is that it is missing a production at
> first, like:
>
> A = E
Alternatively, you can simply replace the "A" by an "E". It has the
same effect as adding A = E, but it doesn't make the grammar larger.
In all likelyhood, Wirth originally used A for the German/Swiss word
"Ausdruck" (meaning "Expression") and changed it to E for "Expression"
but missed a spot.
Torben
[Thanks also to several other people who sent in similar messages. -John]
| |
|
|
|
|
|