Related articles |
---|
Top-Down Parser Construction Conjectures bart@cs.uoregon.edu (1993-01-18) |
Recursive descent parsing is better than LL(1) jan@klikspaan.si.hhs.nl (1993-01-22) |
Re: Recursive descent parsing is better than LL(1) tchannon@black.demon.co.uk (1993-01-23) |
Re: Recursive descent parsing is better than LL(1) pjj@cs.man.ac.uk (Pete Jinks) (1993-01-27) |
Newsgroups: | comp.compilers |
From: | tchannon@black.demon.co.uk (Tim Channon) |
Organization: | Compilers Central |
Date: | Sat, 23 Jan 1993 22:43:00 GMT |
References: | 93-01-122 93-01-160 |
Keywords: | LL(1), parse |
> I present a simple contra-example:
>
> Consider the language defined by the next CFG:
>
> S -> A
> S -> B
> A -> `x' A `y'
> A -> `a'
> B -> `x' B `z'
> B -> `b'
>
> SID uses elimination of left recursion, factorisation and substitution to
> search for a better grammar.
I assume it is a matter of what you ask SID and by the time you are at S
it is too late to branch or is it.
Is this a valid LL(1) solution? (diagnostics are too large to post but all
is well)
S = 'x' { 'x'
| 'a'
| 'b'
}
('y' | 'z')
| 'a'
| 'b'.
producing this exact output
IF (sym = XSym) THEN
Get;
WHILE (sym = XSym) OR
(sym = ASym) OR
(sym = BSym) DO
IF (sym = XSym) THEN
Get;
ELSIF (sym = ASym) THEN
Get;
ELSE
Get;
END;
END;
IF (sym = YSym) THEN
Get;
ELSIF (sym = ZSym) THEN
Get;
ELSE Error(11);
END;
ELSIF (sym = ASym) THEN
Get;
ELSIF (sym = BSym) THEN
Get;
ELSE Error(12);
END;
TC.
E-mail: tchannon@black.demon.co.uk or tchannon@cix.compulink.co.uk
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.