1 /* scan.h - scanner for bcc */ 2 3 /* Copyright (C) 1992 Bruce Evans */ 4 5 #define NAMESIZE 64 /* limit on identifier lengths */ 6 #define SYMOFCHAR(ch) (symofchar[(unsigned char) (ch)]) 7 8 /* scanner codes */ 9 10 enum scan_states 11 { 12 /* The first group of entries consists of all the values that occur in the 13 switch for cppscan(). 14 */ 15 IDENT, 16 INTCONST, 17 #define MAXIDSYM INTCONST /* IDENT and INTCONST must be the only 18 * symofchar[] entries below this */ 19 FLOATCONST, 20 #define MAXPPNUMSYM FLOATCONST /* IDENT, INTCONST and FLOATCONST must be the 21 * only symofchar[] entries below this */ 22 CHARCONST, 23 CONTROL, 24 SLASH, 25 SPECIALCHAR, 26 STRINGCONST, 27 28 /* The next group of entries are all the rest of the values that occur in 29 symofchar[] and so in the switch for nextsym(). 30 */ 31 AMPERSAND, /* ADDRESSOP or ANDOP */ 32 BADCHAR, 33 COLON, /* also COLONOP */ 34 COMMA, /* also COMMAOP */ 35 DECSYM, /* PREDECOP or POSTDECOP */ 36 EOFSYM, 37 HYPHEN, /* NEGOP or SUBOP */ 38 INCSYM, /* PREINCOP or POSTINCOP */ 39 LBRACE, 40 LBRACKET, 41 LPAREN, 42 RBRACE, 43 RBRACKET, 44 RPAREN, 45 SEMICOLON, 46 STAR, /* INDIRECTOP or MULOP */ 47 WHITESPACE, 48 49 /* The next group of entries consists of all operator codes. These codes must 50 be contiguous so they can be used as (offsetted) array indexes. The group 51 is ordered by operator-precedence (this is not necessary). The first part 52 of it overlaps the previous group. 53 */ 54 55 /* Assign-abops (level 1) belong here but are at end to improve switch. */ 56 57 #define FIRSTOP CONDOP 58 CONDOP, /* level 2 */ 59 60 OROP, /* level 5 */ 61 62 EOROP, /* level 6 */ 63 64 ANDOP, /* level 7 */ 65 66 GTOP, /* level 9 */ 67 LTOP, 68 69 ADDOP, /* level 11 */ 70 71 DIVOP, /* level 12 */ 72 MODOP, 73 74 LOGNOTOP, /* level 13 */ 75 NOTOP, 76 77 STRUCELTOP, /* level 14 */ 78 STRUCPTROP, 79 80 /* End of symbols that appear in symofchar[]. */ 81 82 ASSIGNOP, /* level 1 - assign ops must be contiguous */ 83 ADDABOP, 84 ANDABOP, 85 DIVABOP, 86 EORABOP, 87 MODABOP, 88 MULABOP, 89 ORABOP, 90 SLABOP, 91 SRABOP, 92 SUBABOP, 93 94 COMMAOP, /* level 0 */ 95 96 COLONOP, /* level 2 */ 97 98 LOGOROP, /* level 3 */ 99 100 LOGANDOP, /* level 4 */ 101 102 EQOP, /* level 8 */ 103 NEOP, 104 105 GEOP, /* level 9 */ 106 LEOP, 107 108 SLOP, /* level 10 */ 109 SROP, 110 111 SUBOP, /* level 11 */ 112 113 MULOP, /* level 12 */ 114 115 ADDRESSOP, /* level 13 */ 116 CASTOP, 117 INDIRECTOP, 118 NEGOP, 119 PREDECOP, 120 PREINCOP, 121 POSTDECOP, 122 POSTINCOP, 123 124 FUNCOP, /* level 14 */ 125 LISTOP, 126 ROOTLISTOP, 127 128 LEAF, /* special */ 129 PTRADDABOP, 130 PTRADDOP, 131 PTRSUBOP, 132 133 /* end of operator codes (they must stay contiguous) */ 134 135 #define LASTOP PTRSUBOP 136 137 ENUMDECL, 138 NULLDECL, 139 SIGNDECL, 140 STRUCTDECL, 141 TYPEDECL, 142 TYPEDEFNAME, 143 UNIONDECL, 144 UNSIGNDECL, 145 146 AUTODECL, 147 EXTERNDECL, 148 REGDECL, 149 STATICDECL, 150 TYPEDEFDECL, 151 152 ASMSYM, 153 BREAKSYM, 154 CASESYM, 155 CONTSYM, 156 DEFAULTSYM, 157 DEFINEDSYM, 158 DOSYM, 159 ELSESYM, 160 FORSYM, 161 GOTOSYM, 162 IFSYM, 163 RETURNSYM, 164 SIZEOFSYM, 165 SWITCHSYM, 166 WHILESYM, 167 168 ASMCNTL, 169 DEFINECNTL, 170 ENDASMCNTL, 171 INCLUDECNTL, 172 LINECNTL, 173 UNDEFCNTL, 174 WARNINGCNTL, 175 ERRORCNTL, 176 177 ELIFCNTL, /* "IF" controls must be contiguous */ 178 ELSECNTL, 179 ENDIFCNTL, 180 IFCNTL, 181 IFDEFCNTL, 182 IFNDEFCNTL 183 }; 184 185 EXTERN op_pt arg1op; /* LISTOP, or ROOTLISTOP if arg1inreg */ 186 EXTERN struct 187 { 188 union 189 { 190 char *s; 191 value_t v; 192 double d; 193 } 194 value; 195 struct typestruct *type; 196 } 197 constant; /* value of last constant scanned */ 198 /* sym tells type */ 199 EXTERN char funcname[NAMESIZE]; /* name of current function for unique labels */ 200 EXTERN char gs2name[2 + NAMESIZE]; /* 2 reserved for namespace keys */ 201 #define gsname (gs2name + 2) /* before last identifier */ 202 EXTERN struct symstruct *gsymptr; /* symbol ptr for last identifier */ 203 EXTERN bool_t incppexpr; /* nonzero while scanning cpp expression */ 204 EXTERN sym_t sym; /* current symbol */ 205 extern sym_t symofchar[]; /* table to convert chars to their symbols */ 206 EXTERN bool_t expect_statement; /* If set #asm needs to clear the recursive 207 * pending operations. ie: if stmts. */ 208 209