use enum for defining tokens

This commit is contained in:
Yashas 2018-12-24 11:39:57 +05:30
parent 453bf60cab
commit 1c0992cd03

View File

@ -188,7 +188,7 @@ typedef struct s_symbol {
/* Possible entries for "usage" /* Possible entries for "usage"
* *
* This byte is used as a serie of bits, the syntax is different for * This byte is used as a series of bits, the syntax is different for
* functions and other symbols: * functions and other symbols:
* *
* VARIABLE * VARIABLE
@ -317,108 +317,116 @@ typedef struct s_valuepair {
/* Tokens recognized by lex() /* Tokens recognized by lex()
* Some of these constants are assigned as well to the variable "lastst" (see SC1.C) * Some of these constants are assigned as well to the variable "lastst" (see SC1.C)
*/ */
#define tFIRST 256 /* value of first multi-character operator */ enum {
#define tMIDDLE 280 /* value of last multi-character operator */ /* multi-character operators */
#define tLAST 331 /* value of last multi-character match-able token */ tFIRST = 256, /* value of first multi-character operator */
/* multi-character operators */
#define taMULT 256 /* *= */ taMULT = tFIRST, /* *= */
#define taDIV 257 /* /= */ taDIV, /* /= */
#define taMOD 258 /* %= */ taMOD, /* %= */
#define taADD 259 /* += */ taADD, /* += */
#define taSUB 260 /* -= */ taSUB, /* -= */
#define taSHL 261 /* <<= */ taSHL, /* <<= */
#define taSHRU 262 /* >>>= */ taSHRU, /* >>>= */
#define taSHR 263 /* >>= */ taSHR, /* >>= */
#define taAND 264 /* &= */ taAND, /* &= */
#define taXOR 265 /* ^= */ taXOR, /* ^= */
#define taOR 266 /* |= */ taOR, /* |= */
#define tlOR 267 /* || */ tlOR, /* || */
#define tlAND 268 /* && */ tlAND, /* && */
#define tlEQ 269 /* == */ tlEQ, /* == */
#define tlNE 270 /* != */ tlNE, /* != */
#define tlLE 271 /* <= */ tlLE, /* <= */
#define tlGE 272 /* >= */ tlGE, /* >= */
#define tSHL 273 /* << */ tSHL, /* << */
#define tSHRU 274 /* >>> */ tSHRU, /* >>> */
#define tSHR 275 /* >> */ tSHR, /* >> */
#define tINC 276 /* ++ */ tINC, /* ++ */
#define tDEC 277 /* -- */ tDEC, /* -- */
#define tELLIPS 278 /* ... */ tELLIPS, /* ... */
#define tDBLDOT 279 /* .. */ tDBLDOT, /* .. */
#define tDBLCOLON 280 /* :: */ tDBLCOLON, /* :: */
/* reserved words (statements) */
#define tASSERT 281 tMIDDLE = tDBLCOLON, /* value of last multi-character operator */
#define tBEGIN 282
#define tBREAK 283 /* reserved words (statements) */
#define tCASE 284 tASSERT,
#define tCHAR 285 tBEGIN,
#define tCONST 286 tBREAK,
#define tCONTINUE 287 tCASE,
#define tDEFAULT 288 tCHAR,
#define tDEFINED 289 tCONST,
#define tDO 290 tCONTINUE,
#define tELSE 291 tDEFAULT,
#define tEMIT 292 tDEFINED,
#define t__EMIT 293 tDO,
#define tEND 294 tELSE,
#define tENUM 295 tEMIT,
#define tEXIT 296 t__EMIT,
#define tFOR 297 tEND,
#define tFORWARD 298 tENUM,
#define tGOTO 299 tEXIT,
#define tIF 300 tFOR,
#define tNATIVE 301 tFORWARD,
#define tNEW 302 tGOTO,
#define tOPERATOR 303 tIF,
#define tPUBLIC 304 tNATIVE,
#define tRETURN 305 tNEW,
#define tSIZEOF 306 tOPERATOR,
#define tSLEEP 307 tPUBLIC,
#define tSTATE 308 tRETURN,
#define tSTATIC 309 tSIZEOF,
#define tSTOCK 310 tSLEEP,
#define tSWITCH 311 tSTATE,
#define tTAGOF 312 tSTATIC,
#define tTHEN 313 tSTOCK,
#define tWHILE 314 tSWITCH,
/* compiler directives */ tTAGOF,
#define tpASSERT 315 /* #assert */ tTHEN,
#define tpDEFINE 316 tWHILE,
#define tpELSE 317 /* #else */
#define tpELSEIF 318 /* #elseif */ /* compiler directives */
#define tpEMIT 319 tpASSERT, /* #assert */
#define tpENDIF 320 tpDEFINE,
#define tpENDINPUT 321 tpELSE, /* #else */
#define tpENDSCRPT 322 tpELSEIF, /* #elseif */
#define tpERROR 323 tpEMIT,
#define tpFILE 324 tpENDIF,
#define tpIF 325 /* #if */ tpENDINPUT,
#define tINCLUDE 326 tpENDSCRPT,
#define tpLINE 327 tpERROR,
#define tpPRAGMA 328 tpFILE,
#define tpTRYINCLUDE 329 tpIF,/* #if */
#define tpUNDEF 330 tINCLUDE,
#define tpWARNING 331 tpLINE,
/* semicolon is a special case, because it can be optional */ tpPRAGMA,
#define tTERM 332 /* semicolon or newline */ tpTRYINCLUDE,
#define tENDEXPR 333 /* forced end of expression */ tpUNDEF,
/* other recognized tokens */ tpWARNING,
#define tNUMBER 334 /* integer number */
#define tRATIONAL 335 /* rational number */ tLAST = tpWARNING, /* value of last multi-character match-able token */
#define tSYMBOL 336
#define tLABEL 337 /* semicolon is a special case, because it can be optional */
#define tSTRING 338 tTERM,/* semicolon or newline */
/* argument types for emit/__emit */ tENDEXPR, /* forced end of expression */
#define teANY 339 /* any value */ /* other recognized tokens */
#define teNUMERIC 340 /* integer/rational number */ tNUMBER,/* integer number */
#define teDATA 341 /* data (variable name or address) */ tRATIONAL, /* rational number */
#define teLOCAL 342 /* local variable (name or offset) */ tSYMBOL,
#define teFUNCTN 343 /* Pawn function */ tLABEL,
#define teNATIVE 344 /* native function */ tSTRING,
#define teNONNEG 345 /* nonnegative integer */ /* argument types for emit/__emit */
/* for assigment to "lastst" only (see SC1.C) */ teANY , /* any value */
#define tEXPR 346 teNUMERIC, /* integer/rational number */
#define tENDLESS 347 /* endless loop */ teDATA , /* data (variable name or address) */
teLOCAL, /* local variable (name or offset) */
teFUNCTN, /* Pawn function */
teNATIVE, /* native function */
teNONNEG , /* nonnegative integer */
/* for assigment to "lastst" only (see SC1.C) */
tEXPR,
tENDLESS, /* endless loop */
};
/* (reversed) evaluation of staging buffer */ /* (reversed) evaluation of staging buffer */
#define sSTARTREORDER 0x01 #define sSTARTREORDER 0x01