Re: Simple Expression Recursion vs Expression/Term/Factor

"luca" <lucadesantis@infinito.it>
6 Aug 2001 04:04:57 -0400

          From comp.compilers

Related articles
Simple Expression Recursion vs Expression/Term/Factor stoggers@uniquest.demon.co.uk (Mike Stogden) (2001-08-02)
Re: Simple Expression Recursion vs Expression/Term/Factor Mark.van.den.Brand@cwi.nl (M.G.J. van den Brand) (2001-08-06)
Re: Simple Expression Recursion vs Expression/Term/Factor lucadesantis@infinito.it (luca) (2001-08-06)
Re: Simple Expression Recursion vs Expression/Term/Factor gregod@cs.rpi.edu (Douglas Gregor) (2001-08-06)
Re: Simple Expression Recursion vs Expression/Term/Factor joachim_d@gmx.de (Joachim Durchholz) (2001-08-08)
Re: Simple Expression Recursion vs Expression/Term/Factor lucads@xoommail.xoom.it (Luca) (2001-08-08)
Re: Simple Expression Recursion vs Expression/Term/Factor andi@diagonal.ch (Andreas Gieriet) (2001-08-15)
| List of all articles for this month |
From: "luca" <lucadesantis@infinito.it>
Newsgroups: comp.compilers
Date: 6 Aug 2001 04:04:57 -0400
Organization: Micron Technology, Inc.
References: 01-08-016
Keywords: parse
Posted-Date: 06 Aug 2001 04:04:56 EDT

Mike Stogden wrote in message 01-08-016...
>I have seen expressions for the same language described as...
>
>expr -> expr + expr
>expr -> expr * expr
>etc...
>
>alternatively...
>
>expr -> expr + term
>term -> factor | term * factor
>factor -> number | identifier
>etc...
>


I think the second approach allows to manage priority of operations is a
simpler way.
Using the form Espression/Term/Factor , the syntax tree obtained has
implicit informations about priority of multiplication respect to addition.
In other words: precedence of multiplication is reflected in the structure
of syntax tree obtained after parsing. In the first approach you must add
code to the compiler to check priority, you need to process syntax tree to
compute expressions.


bye
Luca De Santis
http://members.xoom.it/lucads


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.