home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!uwm.edu!ogicse!decwrl!world!iecc!compilers-sender
- From: tchannon@black.demon.co.uk (Tim Channon)
- Newsgroups: comp.compilers
- Subject: Re: Recursive descent parsing is better than LL(1)
- Keywords: LL(1), parse
- Message-ID: <93-01-172@comp.compilers>
- Date: 23 Jan 93 22:43:00 GMT
- Article-I.D.: comp.93-01-172
- References: <93-01-122@comp.compilers> <93-01-160@comp.compilers>
- Sender: compilers-sender@iecc.cambridge.ma.us
- Reply-To: tchannon@black.demon.co.uk (Tim Channon)
- Organization: Compilers Central
- Lines: 61
- Approved: compilers@iecc.cambridge.ma.us
-
- > 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
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-