CPW Pt. 8: Representing Assignment Expressions
Quiz 21
Extend the interface and implementation for expression nodes so that assignments and identifiers are supported:
-
Provide a constructor newIdentifierExpr() for creating a dynamically allocated expression node for an identifier specified as parameter. The identifier is a unique string.
-
Provide a method isLValueExpr() that returns true if an expression node represents an identifier.
-
Provide a enum constant EKASSIGN_ for an expression kind that represents a binary node for an assignment.
-
Change the implementations of all methods so that the new kinds of expression nodes are supported. In the implementation of evalExp you can assume that for the identifier a symbol exists. If this is not the case your code should trigger an assertion.
Write a test program xtest_expr.c.
1 | submit hpc quiz21 expr.h expr.c sym.h sym.c ustr.h ustr.c xtest_expr.c lexer.h lexer.c tokenkind.h tokenkind.c
|