/* seman.h * included in seman.c to manipulate the symbol table and conduct static * semantic checking. Mainly from the provided module proj3.c. * also included in traverse.c and tree.c */ #define false 0 #define true 1 #define FALSE 0 #define TRUE 1 #define bool char #define STACK_SIZE 100 #define ST_SIZE 500 #define ATTR_SIZE 2000 #define STRING_SIZE 256 /******************************************************* * error type for error reporting routine * *******************************************************/ #define STACK_OVERFLOW 100 #define REDECLARATION 101 #define ST_OVERFLOW 102 #define UNDECLARATION 103 #define ATTR_OVERFLOW 104 #define NOT_USED 105 #define NOT_INT_CONSTANT 106 #define NOT_TYPE 107 #define DIM_MISMATCH 108 #define ASSIGN_ERR 109 #define PARA_MISMATCH 110 #define REF_ARG_MISMATCH 111 #define PROC_AS_VAR 112 #define TYPE_AS_VAR 113 #define NOT_ARRAY 114 #define NOT_RECORD 115 #define ROUTINE_CALL_ERR 116 #define NOT_FIELD 117 #define FORWD_MISMATCH 118 #define LOOP_VAR 119 /******************************************************* * processing instruction for error reporting routine * *******************************************************/ #define CONTINUE 0 /* print error and return to the caller */ #define ABORT 1 /* print the fatal error and abort execution */ /***************************************************************** * these definitions correspond to the fields of a stack element * *****************************************************************/ #define MARKER 1 #define NAME 2 #define ST_PTR 3 #define DUMMY 4 #define USED 5 /**************************************************************************** * the possible attributes for symbol table. the comment to the right * * describe the attribute's value. Notice the small constants are given to * * the attributes which are common to all the ids, so that we can do some * * sorting in the link list * ****************************************************************************/ #define NAME_ATTR 1 /* value: id lexeme pointer, set by InsertEntry */ #define NEST_ATTR 2 /* value: nesting level, set by InsertEntry */ #define TREE_ATTR 3 /* value: point back to the subtree */ #define PREDE_ATTR 4 /* value: is this id predefined? */ #define TYPE_ATTR 6 /* value: pointer to the type tree for a variable, constant id or function */ #define VALUE_ATTR 7 /* value: the value of a constant id (integer, character or string pointer) */ /* added */ #define DIM_ATTR 8 /* # of dimensions wherever appropriate */ #define FORWD_ATTR 9 /* true if a routine declaration is a forward one */ /* not used in project 3 */ #define OFFSET_ATTR 10 #define SIZE_ATTR 12 #define KIND_ATTR 5 /* value: see below */ /************************************************* * the possible values of attribute kind_attr * *************************************************/ #define CONSTANT 1 #define VARIABLE 2 #define PROCE 3 #define FUNC 4 #define REF_ARG 5 #define VALUE_ARG 6 #define FIELD 7 #define TYPE 8