Description
Add the following grammar rules to your parser.
StatList -> Statement ; StatList|
e
Statement -> AssignStat |
IOStat
AssignStat -> idt = Expr
IOStat -> e
Expr -> Realtion
Realtion -> SimpleExpr
SimpleExpr -> SignOp Term MoreTerm
MoreTerm -> Addop Term MoreTerm
e
Term -> Factor MoreFactor
MoreFactor -> Mulop Factor MoreFactor
e
Factor -> id |
num |
( Expr )
Addop -> + | – | ‘||’
Mulop -> * | / | &&
SignOp -> ! | – | e
Add the appropriate actions to your parser to check for undeclared variables used in an assignment statement.