|Precedence based parsing Jeffrey.Kenton@comcast.net (Jeff Kenton) (2003-12-03)|
|Re: Precedence based parsing firstname.lastname@example.org (2003-12-08)|
|Re: Precedence based parsing email@example.com (John McEnerney) (2003-12-08)|
|Re: Precedence based parsing firstname.lastname@example.org (2003-12-08)|
|Re: Precedence based parsing email@example.com (Andi Kleen) (2003-12-08)|
|Re: Precedence based parsing firstname.lastname@example.org (2003-12-13)|
|Re: Precedence based parsing email@example.com (Rob Thorpe) (2003-12-13)|
|Re: Precedence based parsing firstname.lastname@example.org (Clint Olsen) (2003-12-20)|
|Re: Precedence based parsing email@example.com (Steve Meyer) (2003-12-23)|
|Re: Precedence based parsing firstname.lastname@example.org (Joachim Durchholz) (2003-12-27)|
|Re: Precedence based parsing email@example.com (2003-12-27)|
|[1 later articles]|
|From:||Andi Kleen <firstname.lastname@example.org>|
|Date:||8 Dec 2003 00:26:13 -0500|
|Posted-Date:||08 Dec 2003 00:26:13 EST|
Jeff Kenton <Jeffrey.Kenton@comcast.net> writes:
> I have been writing parsers and compilers for over 30 years, and one
> technique I have used for parsing expressions seems to have
> disappeared from recent books. It involves comparing the precedence
> of the newest operator with that of the previous operator, in order
> to decide whether to shift or reduce. ...
For hand written parsers top down is much easier to write than
bottom-up (of which operator precedence is a variant). Bottom up is
normally used by parser generators and for those operator precedence
is just not powerful enough.
In the popular bison parser generator you can specify the precedence
of operations with %prec (and that seems to actually get used). The
underlying algorithm is still LALR(1) (or Tomita in newer versions),
it is just used as a short hand for shorter grammars.
Return to the
Search the comp.compilers archives again.