Related articles |
---|
Can Pascal be parsed by LR(1) parsing algorithm? amb@apple.com (A. Michael Burbidge) (1990-10-09) |
Re: Can Pascal be parsed by LR(1) parsing algorithm? mauney@eos.ncsu.edu (1990-10-10) |
Re: Can Pascal be parsed by LR(1) parsing algorithm? hankd@dynamo.ecn.purdue.edu (1990-10-10) |
Re: Can Pascal be parsed by LR(1) parsing algorithm? joel@decwrl.dec.com (1990-10-15) |
Can Pascal be parsed by LR(1) parsing algorithm? meissner@osf.org (1990-10-10) |
Re: Can Pascal be parsed by LR(1) parsing algorithm? KARSTEN@tfl.dk (Karsten Nyblad, TFL, Denmark) (1990-10-10) |
Re: Can Pascal be parsed by LR(1) parsing algorithm? bliss@sp64.csrd.uiuc.edu (1990-10-10) |
Re: Can Pascal be parsed by LR(1) parsing algorithm? lindsay@comp.vuw.ac.nz (1990-10-16) |
[10 later articles] |
Newsgroups: | comp.compilers |
From: | mauney@eos.ncsu.edu (Jon Mauney) |
Keywords: | pascal, parse |
Organization: | North Carolina State University |
References: | <9010091533.AA02386@apple.com> |
Date: | Wed, 10 Oct 90 13:37:52 GMT |
In article <9010091533.AA02386@apple.com>, amb@apple.com (A. Michael
Burbidge) writes:
> After struggling for some time to write a yacc description for the
> Pascal language and after reading the description of the modifier yacc
> contained in the UCB Pascal source directory I am beginning to wonder
> if an LR(1) parsing algorithm can parse Pascal. ...
Pascal is not terribly hard to do with LL(1), except of course the
dangling else. Therefore it is also LALR(1). An LALR(1) grammar for
Pascal is included with the parser generator distributed in conjunction
with the Fischer&LeBlanc book "Crafting a Compiler".
Handling the optional semicolon is not particularly difficult.
Contortions are often added to grammars for specific purposes unrelated to
the general problem of parsing the language, such as achieving a
particular error recovery, or working around a deficiency in the parser
generator. Berkeley Pascal was, for some time, unable to accept a null
statement in the "then" clause:
if i<0 then else foo(i);
Rumor has it that this was due to a failing in yacc. The Berkeley
Pascal/yacc grammar is probably a poor role model.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.