The Main Structures Comprising the Compiler Project Code
Spring 08

Return to Class Page

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

The Compiler Structures outlined below are:


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


Root (points to SYMTABREC) (our symbol table)

Symbol Table Structure
attrs    ^attrec
left    ^ left child in symtab
right    ^ right child in symtab

Symbol Table Atribute Record with all info concerning the "id"
id:   user variable name
level:   procedure level
offset   address offset

Alpha-list of all variables
cur:     ^ attrptr
next:    ^ next in list of vars


statement description
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

Expression Tree Node Description
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

Address Node
Type:  ADDRKIND (Memory, Immediate)
ae.attrs  Memory
ae.i Integer Immediate

description of actual (I/O) parameter
Type: PARAMDESC (Reference Value String)
pe.loc ^Address Tree
pe.val ^Expression Tree
pe.where ^location of string in constlist ^next entry in list of parameters of I/O statement


type   SEMSTACKTAG   type of entry
se.addr     ^address entry
se.expr     ^expression entry     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
se.plist first parameter list (I/O) entry