Assignment 3, due June 23Includes Machine Problem 2, due June 25
Part of
the homework for 22C:50, Summer 2003
|
Ground rules: See Machine Problem 1!
Part 1 of the assignment: The EAL assembler distributed to the class lacks many features! One of these is the ability to test expressions to see if they are already defined. Consider using the following notation to set x to one if the expression a+b has a defined value and to zero otherwise (for more discussion, see Figure 6.2 of the text):
x = DEF( a + b )
Clearly, this is a modification to the expression syntax, handled by parse_operand in our assembler. To handle this, we begin by modifying the BNF grammar for operands:
:= ... | ( )
This opens the door to a host of built-in functions in EAL, but we are only interested in one of them, the specific identifier DEF. Implement this extension to the assembler's expression evaluator! While you're at it, fix the comments at the head of parse_operand to reflect the grammar it actually handles -- there is a significant error there!
Part 2 of the assignment: Add support for conditional assembly to the EAL assembler, using the conditional notation illustrated in Figure 6.3.
; The following code just illustrates some features of EAL A = . . = B W A . = A W B B = .
IF UND(A) . = 1 ENDIF W A A: W A
Propose an experiment you could do, as a programmer, to find out whether << is a distinct lexeme or whether it is two lexemes that are collapsed into one operator at the syntactic level. Do this experiment for some C or C++ compiler and report the result.