|Good practical language and OS agnostic text? firstname.lastname@example.org (2012-04-17)|
|Re: Good practical language and OS agnostic text? email@example.com (Uli Kusterer) (2012-04-21)|
|Re: Good practical language and OS agnostic text? firstname.lastname@example.org (BGB) (2012-04-21)|
|Re: Recursive descent parsing and optimization, was Good practical lan email@example.com (BartC) (2012-04-22)|
|Re: Recursive descent parsing and optimization, was Good practical lan firstname.lastname@example.org (Dmitry A. Kazakov) (2012-04-22)|
|Re: Recursive descent parsing and optimization, was Good practical lan email@example.com (BGB) (2012-04-22)|
|Re: Recursive descent parsing and optimization, was Good practical lan firstname.lastname@example.org (Bartc) (2012-04-23)|
|From:||"Dmitry A. Kazakov" <email@example.com>|
|Date:||Sun, 22 Apr 2012 18:18:30 +0200|
|Organization:||cbb software GmbH|
|References:||12-04-019 12-04-056 12-04-060 12-04-066|
|Posted-Date:||22 Apr 2012 15:43:49 EDT|
On Sun, 22 Apr 2012 12:51:44 +0100, BartC wrote:
> "BGB" <firstname.lastname@example.org> wrote in message
>> On 4/21/2012 2:22 AM, Uli Kusterer wrote:
>> although I use recursive descent, the above sounds different from what I
>> usually do.
>> checks for and handles vaious statement types
>> calls ReadExpression
>> (actually, this is a tower of functions, one for each precedence
>> level, working from lowest to highest precedence)
> Sounds like it's influenced by the C grammar, which defines expressions
> using something like 13 or 17 layers of precedence.
Rather by an attempt to describe precedence using grammar means.
> Beyond about 3-4 levels, I found that unmanageable. For expression syntax, I
> don't use any precedence in the grammar at all; I have precedence as an
> attribute of an operator, and an expression can be parsed with a single
Yes, there is a very simple technique using two stacks, one for operands
another for operations.
> Or rather two: readfactor(priority), and readterm(). Readfactor() deals with
> the binary operators linking successive terms, while readterm() does all
> the real work (since my syntax doesn't distinguish between expressions and
> statements, that's quite a big workload).
Actually operations have two priorities; left and right. When left < right
you have left to right association. When right > left, it becomes right to
Some operators may have these priorities sufficiently different. For
example the assignment operator. If your unlucky languages allows it, then
A+B = C+D better be A+(B=(C+D)). That would require the following order of
LP("=") << LP( "+") < RP("+") << RP("=")
> Instead I read them as I go along, but with provision for a one-symbol
Same here. Except that I have one token look-ahead.
Dmitry A. Kazakov
Return to the
Search the comp.compilers archives again.