home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
pascal
/
qparser.arc
/
CALC.GRM
< prev
next >
Wrap
Text File
|
1984-11-06
|
626b
|
21 lines
\ CALC -- A simple four-function calculator grammar
\ which allows variable assignments.
Goal -> Stmts QUIT #quit
Stmts -> Stmts Stmt
-> Stmt
Stmt -> Expr <eol> #prtval
-> <identifier> := Expr <eol> #assign
-> <eol> \ allow an empty line
Expr -> Expr + Term #plus
-> Expr - Term #minus
-> Term
Term -> Term * Fact #mpy
-> Term / Fact #divide
-> Fact
Fact -> Primary
-> - Primary #uminus
Primary -> ( Expr ) #parens
-> <identifier> #variable
-> <real> #realval
-> <integer> #intval