[comp.lang.perl] expression evaluation

jhh@sprite.Berkeley.EDU (John H. Hartman) (11/24/90)

I'd like to write a Perl program that evaluates expressions with the
following grammar:

expr -> expr op expr
expr -> ( expr )
expr -> 1
expr -> 0
op -> ||
op -> &&


Does anyone have a program that does something similar?  

John

-----------------------------------------------------------------------
John H. Hartman
Graduate Student, UCB Sprite project
jhh@sprite.berkeley.edu

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (11/25/90)

In article <9171@pasteur.Berkeley.EDU> jhh@sprite.Berkeley.EDU (John H. Hartman) writes:
: 
: I'd like to write a Perl program that evaluates expressions with the
: following grammar:
: 
: expr -> expr op expr
: expr -> ( expr )
: expr -> 1
: expr -> 0
: op -> ||
: op -> &&
: 
: 
: Does anyone have a program that does something similar?  

My brother-in-law Mark Biggar (who did the big* packages) is about to
release a parser generator that takes an ll(1) grammar and turns it
into a recursive descent tokener/parser.  The above grammar isn't ll(1)
but could be turned into one.

Larry