IR GRAMMAR program := body body := decls code decls := { vars | procs } vars := VARS NL {var} var := VAR SP IDENT NL code procs := PROCS NL {proc} proc := PROC SP IDENT SP formals NL body formals := '(' SP {IDENT SP} ')' code := CODE NL {codeline} ENDCODE NL codeline := labeldec NL | TB inst NL labeldec := label ':' inst := nop | load | store | return | callinst | branch | cmpinst | movinst | neginst | arith | incinst | decinst load := ld SP '[' addr ']' ',' register store := st SP operand ',' '[' addr ']' callinst := call SP IDENT branch := branchop SP label branchop := ba | bg | bl | be | bge | ble | bne compinst := cmp SP operand ',' operand movinst := mov SP operand ',' register neginst := neg SP operand ',' register arith := arithop SP operand ',' operand ',' register arithop := add | sub | umul | udiv incinst := inc SP register decinst := dec SP register label := L INTEGER register := %t INTEGER | %o0 | %i0 addr := register | IDENT | $a INTEGER | STRING operand := addr | INTEGER The following are the various classes of terminals: Keywords: VARS VAR PROCS PROC CODE ENDCODE Instruction operators: ld st return call inc dec br bg bl be bge ble bne cmp mov neg add sub umul udiv Operands and operand prefixes: %t %o0 %i0 $a Punctuation: '(' ')' ':' '[' ']' ',' IDENT: an alpha followed by any number of alphas, digits,'$' or '_' characters. INTEGER: sequence of digits optionally preceded by a '-' representing a signed 32-bit integer. STRING: a "-delimited sequence of printable characters (not allowing ") Separators: space (SP), newline (NL), and tab (TB). Separators are grammatically significant, and must appear EXACTLY as shown in the grammar.