home *** CD-ROM | disk | FTP | other *** search
/ The Education Master 1994 (4th Edition) / EDUCATIONS_MASTER_4TH_EDITION.bin / files / progmisc / qparser2 / cskels / calc.grm next >
Encoding:
Text File  |  1993-09-16  |  636 b   |  21 lines

  1.    \  CALC -- A simple four-function calculator grammar
  2.    \          which allows variable assignments.
  3. Goal    -> Stmts QUIT <eol> #QUIT
  4. Stmts   -> Stmts Stmt
  5.         -> <empty>
  6. Stmt    -> Expr <eol> #PRTVAL
  7.         -> <identifier> := Expr <eol> #ASSIGN1
  8.         -> <eol>    \ allow an empty line
  9. Expr    -> Expr + Term #PLUS
  10.         -> Expr - Term #MINUS
  11.         -> Term
  12. Term    -> Term * Fact #MPY
  13.         -> Term / Fact #DIVIDE
  14.         -> Fact
  15. Fact    -> Primary
  16.         -> - Primary #UMINUS
  17. Primary -> ( Expr ) #PARENS
  18.         -> <identifier> #VARIABLE
  19.         -> <real> #REALVAL
  20.         -> <integer> #INTVAL
  21.