The scanner generated by lex separates the user input program into tokens based on our definition of the language tokens in simple.lex
The parser generated by yacc performs the syntax-directed translation obeying our statement of the language grammer in simple.lr
(astdef.h)
Prog
| Prog.main | Stmtlist | list of statements |
| Prog.vars | Varlist | alpha-list of variable names |
| Prog.const_listptr | list of string constants | |
| info | ^ character string | |
| offset | integer field to hold label index | |
| next | ^ next in list of global strings |
(symtab.h)
Root (points to SYMTABREC) (our symbol table)
(symboltb.h)
| attrs | ^attrec | |
| left | ^ left child in symtab | |
| right | ^ right child in symtab | |
| id: | user variable name | |
| level: | procedure level | |
| offset | address offset | |
| cur: | ^ attrptr | |
| next: | ^ next in list of vars | |
| type: | STMTTYPE | AssignStmt StdProcCall IfThenStmt | |
| ifthen | se.bexpr | boolean ExprTree | |
| se.slist | list of statements comprising the "then-block" | ||
| assign | se.lhs | ^Address Tree | |
| se.rhs | ^Expression Tree | ||
| procoll | se.type | ReadProc ReadlnProc WriteProc WriteLnProc | |
| se.params | List of Parameters |
| height: | height of exprTree | |
| OP: | + - * / - fetch | |
| ee. | ee.addr | ^Address Tree [fetch] |
| ee.child | ^Expression Tree [Usubop] | |
| ee.left | ^Expression Tree
(AddOp SubOp MpyOp DivOp) |
|
| ee.right | ^Expression Tree
(AddOp SubOp MpyOp DivOp) |
|
| ee.btree | ^ Boolean Expression Tree |
| Type: | ADDRKIND (Memory, Immediate) |
| ae.attrs | Memory |
| ae.i | Integer Immediate |
| Type: | PARAMDESC (Reference Value String) |
| pe.loc | ^Address Tree |
| pe.val | ^Expression Tree |
| pe.where | ^location of string in constlist |
| pe.next | ^next entry in list of parameters of I/O statement |
(semstack.h)
| type | SEMSTACKTAG | type of entry |
| se.addr | ^address entry | |
| se.expr | ^expression entry | |
| se.id | identifier entry | |
| se.oper | OPERATION entry "typedef enum AddOp,SubOp,MpyOp,DivOp,UsubOp,Fetch,EqOp" in semform.h | |
| se.stmt | statement entry | |
| se.slist | first | statement list entry |
| last | ||
| se.plist | first | parameter list (I/O) entry |
| last |