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