DIRECTORY
  SymbolTableDefs USING [SymbolType];
  
TreesDefs: DEFINITIONS = {
  
  -- nodes for parse trees of C statments and declarations
  TreeNode: TYPE = RECORD [
    left, right: LONG POINTER TO TreeNode,
      -- this is used to insert at end of various types of lists
    lastInList: LONG POINTER TO TreeNode,
    string: LONG STRING,
      -- these are some booleans for data type
      -- TRUE if this word appears in the data declaration
    char, short, int, long, unsigned, float, double: BOOLEAN,
    class: Class,
    structure, union, enumeration: BOOLEAN,
    declaratorType: DeclaratorType, -- defined below
    operationType: OperationType, -- defined below
    nodeType: NodeType,		-- defined below
    dataType: SymbolTableDefs.SymbolType,
    baseDataType: SymbolTableDefs.SymbolType,
    typeString: LONG STRING,
    pointerCount: CARDINAL
    ];
  
  -- the nesting shows subtree types
  NodeType: TYPE = {
  		-- declaration node types --
    dclList,		    -- (declaration,next dclList)
      declaration,	    -- (attributes, dclItemList)
        attributes,	    -- (-,dclList) if a structure definition
			    -- or (-.-) string = NAME
        dclItemList,	    -- (itemHead,next dclItemList)
          itemHead,	    -- (declarator,initList)
            declarator,     -- (-,next declarator)
	    initList,	    -- (initializer,next initList)
	      initializer,  -- (-,initList) or (expression.-)
		
  		-- statement node types --
    castType,		-- (type,nullDeclaration)
    eList,		-- (operation,next eList)
    operation,		-- (left operand,right operand)
    ifStmt,		-- (condition expression, thenElse)
        thenElse,	-- (then stmt,else stmt)
    whileStmt,		-- (expression,stmt)
    doWhileStmt,	-- (expression,stmt)
    forStmt1,		-- (stmt,forStmt2)
        forStmt2,	-- (e3,forStmt3)
            forStmt3,	-- (e1,e2)
    switchStmt,		-- (expression, stmt)
    breakStmt,		-- (-,-)
    loopStmt,		-- (-,-)
    returnStmt,		-- (-,-)	string = return value =NIL => none
    gotoStmt,		-- (-,-),	string = NAME
    emptyStmt,		-- (-,-)
    compoundStmt,	-- (declaration list,stmtList)
    expressionStmt,	-- (expression,-)
    defaultLabel,	-- (-,-)
    caseLabel,		-- (expression,-)
    labelLabel,		-- (-,-),	string = NAME
    stmtList		-- (stmt,stmtList) stmtList=NIL => end of stmtList; stmt can be NIL
    			--	stmt could be a Label also
    };
    
  DeclaratorType: TYPE = {unknown, simpleName, arrayOf, functionOf, pointerTo};
    
  OperationType: TYPE = {
        unknown, assignOp, multiplyAssign, divideAssign, modulusAssign,
	plusAssign, minusAssign, shiftLeftAssign, shiftRightAssign,
	bitAndAssign, bitOrAssign, bitXorAssign, logicalOr, logicalAnd, bitOr,
  	bitAnd, bitXor, equals, notEquals, lessThan, greaterThan,
  	lessThanOrEqual, greaterThanOrEqual, shiftLeft, shiftRight,
  	plusOp, minusOp, multiplyOp, divideOp, modulusOp, postIncrement,
  	postDecrement, preIncrement, preDecrement, dereference, addressOf,
  	unaryMinus, logicalNot, bitNot, sizeOf, castOp, arrayReference,
  	procedureCall, structReference, nameValue, iconValue, fconValue,
	stringValue, ifExpression, thenElseExpression, eList};
    
  Class: TYPE = {noClass, auto, static, extern, register, typedef};
  
  MakeNode: PROCEDURE [left, right: LONG POINTER TO TreeNode, string: LONG STRING,
  	nodeType: NodeType] RETURNS [newNode: LONG POINTER TO TreeNode];
	
  -- Frees a tree of nodes (recurses on node.left and node.right)
  FreeTree: PROCEDURE [node: LONG POINTER TO TreeNode];
  
  }.