tcc-stupidos/libtcc/cc/token.h

98 lines
3.4 KiB
C
Raw Normal View History

#ifndef TCC_TOKEN_H
# define TCC_TOKEN_H 1
/* conditional ops */
# define TOK_LAND 0x90
# define TOK_LOR 0x91
/* warning: the following compare tokens depend on i386 asm code */
# define TOK_ULT 0x92
# define TOK_UGE 0x93
# define TOK_EQ 0x94
# define TOK_NE 0x95
# define TOK_ULE 0x96
# define TOK_UGT 0x97
# define TOK_Nset 0x98
# define TOK_Nclear 0x99
# define TOK_LT 0x9c
# define TOK_GE 0x9d
# define TOK_LE 0x9e
# define TOK_GT 0x9f
# define TOK_ISCOND(t) (t >= TOK_LAND && t <= TOK_GT)
# define TOK_DEC 0x80 /* -- */
# define TOK_MID 0x81 /* inc/dec, to void constant */
# define TOK_INC 0x82 /* ++ */
# define TOK_UDIV 0x83 /* unsigned division */
# define TOK_UMOD 0x84 /* unsigned modulo */
# define TOK_PDIV 0x85 /* fast division with undefined rounding for pointers */
# define TOK_UMULL 0x86 /* unsigned 32x32 -> 64 mul */
# define TOK_ADDC1 0x87 /* add with carry generation */
# define TOK_ADDC2 0x88 /* add with carry use */
# define TOK_SUBC1 0x89 /* add with carry generation */
# define TOK_SUBC2 0x8a /* add with carry use */
# define TOK_SHL '<' /* shift left */
# define TOK_SAR '>' /* signed shift right */
# define TOK_SHR 0x8b /* unsigned shift right */
# define TOK_NEG TOK_MID /* unary minus operation (for floats) */
# define TOK_ARROW 0xa0 /* -> */
# define TOK_DOTS 0xa1 /* three dots */
# define TOK_TWODOTS 0xa2 /* C++ token ? */
# define TOK_TWOSHARPS 0xa3 /* ## preprocessing token */
# define TOK_PLCHLDR 0xa4 /* placeholder token as defined in C99 */
# define TOK_PPJOIN (TOK_TWOSHARPS | SYM_FIELD) /* A '##' in a macro to mean pasting */
# define TOK_SOTYPE 0xa7 /* alias of '(' for parsing sizeof (type) */
/* assignment operators */
# define TOK_A_ADD 0xb0
# define TOK_A_SUB 0xb1
# define TOK_A_MUL 0xb2
# define TOK_A_DIV 0xb3
# define TOK_A_MOD 0xb4
# define TOK_A_AND 0xb5
# define TOK_A_OR 0xb6
# define TOK_A_XOR 0xb7
# define TOK_A_SHL 0xb8
# define TOK_A_SAR 0xb9
# define TOK_ASSIGN(t) (t >= TOK_A_ADD && t <= TOK_A_SAR)
# define TOK_ASSIGN_OP(t) ("+-*/%&|^<>"[t - TOK_A_ADD])
/* tokens that carry values (in additional token string space / tokc) --> */
# define TOK_CCHAR 0xc0 /* char constant in tokc */
# define TOK_LCHAR 0xc1
# define TOK_CINT 0xc2 /* number in tokc */
# define TOK_CUINT 0xc3 /* unsigned int constant */
# define TOK_CLLONG 0xc4 /* long long constant */
# define TOK_CULLONG 0xc5 /* unsigned long long constant */
# define TOK_CLONG 0xc6 /* long constant */
# define TOK_CULONG 0xc7 /* unsigned long constant */
# define TOK_STR 0xc8 /* pointer to string in tokc */
# define TOK_LSTR 0xc9
# define TOK_CFLOAT 0xca /* float constant */
# define TOK_CDOUBLE 0xcb /* double constant */
# define TOK_CLDOUBLE 0xcc /* long double constant */
# define TOK_PPNUM 0xcd /* preprocessor number */
# define TOK_PPSTR 0xce /* preprocessor string */
# define TOK_LINENUM 0xcf /* line number info */
# define TOK_HAS_VALUE(t) (t >= TOK_CCHAR && t <= TOK_LINENUM)
# define TOK_EOF (-1) /* end of file */
# define TOK_LINEFEED 10 /* line feed */
/* all identifiers and strings have token above that */
# define TOK_IDENT 256
enum tcc_token {
TOK_LAST = TOK_IDENT - 1
# define DEF(id, str) ,id
# include "token.inc"
# undef DEF
};
/* keywords: tok >= TOK_IDENT && tok < TOK_UIDENT */
# define TOK_UIDENT TOK_DEFINE
#endif /* !TCC_TOKEN_H */