History

tccpp: reorder some tokens

... and make future reordering possibly easier related to 9a6ee577f6165dccfde424732bfc6f16f1e2811b

grischka committed 12 years ago

Commit 0ac8aaa1 parent 10750872 files · +56 −21Browse files

Unified · Split

2 files
  1. tcc.h +18 −15
  2. tccpp.c +38 −6
tcc.h+18−15
@@ -783,35 +783,38 @@ struct TCCState { · 782 unmodified lines
783 783
784#define TOK_LAND 0xa0784#define TOK_LAND 0xa0
785#define TOK_LOR 0xa1785#define TOK_LOR 0xa1
786
787#define TOK_DEC 0xa2786#define TOK_DEC 0xa2
788#define TOK_MID 0xa3 /* inc/dec, to void constant */787#define TOK_MID 0xa3 /* inc/dec, to void constant */
789#define TOK_INC 0xa4788#define TOK_INC 0xa4
790#define TOK_UDIV 0xb0 /* unsigned division */789#define TOK_UDIV 0xb0 /* unsigned division */
791#define TOK_UMOD 0xb1 /* unsigned modulo */790#define TOK_UMOD 0xb1 /* unsigned modulo */
792#define TOK_PDIV 0xb2 /* fast division with undefined rounding for pointers */791#define TOK_PDIV 0xb2 /* fast division with undefined rounding for pointers */
793#define TOK_CINT 0xb3 /* number in tokc */792
794#define TOK_CCHAR 0xb4 /* char constant in tokc */793/* tokens that carry values (in additional token string space / tokc) --> */
795#define TOK_STR 0xb5 /* pointer to string in tokc */794#define TOK_CCHAR 0xb3 /* char constant in tokc */
796#define TOK_TWOSHARPS 0xb6 /* ## preprocessing token */795#define TOK_LCHAR 0xb4
797#define TOK_LCHAR 0xb7796#define TOK_CINT 0xb5 /* number in tokc */
798#define TOK_LSTR 0xb8797#define TOK_CUINT 0xb6 /* unsigned int constant */
799#define TOK_CFLOAT 0xb9 /* float constant */798#define TOK_CLLONG 0xb7 /* long long constant */
800#define TOK_LINENUM 0xba /* line number info */799#define TOK_CULLONG 0xb8 /* unsigned long long constant */
801#define TOK_CDOUBLE 0xc0 /* double constant */800#define TOK_STR 0xb9 /* pointer to string in tokc */
802#define TOK_CLDOUBLE 0xc1 /* long double constant */801#define TOK_LSTR 0xba
802#define TOK_CFLOAT 0xbb /* float constant */
803#define TOK_CDOUBLE 0xbc /* double constant */
804#define TOK_CLDOUBLE 0xbd /* long double constant */
805#define TOK_PPNUM 0xbe /* preprocessor number */
806#define TOK_LINENUM 0xbf /* line number info */
807/* <-- */
808
809#define TOK_TWOSHARPS 0xc0 /* ## preprocessing token */
803#define TOK_UMULL 0xc2 /* unsigned 32x32 -> 64 mul */810#define TOK_UMULL 0xc2 /* unsigned 32x32 -> 64 mul */
804#define TOK_ADDC1 0xc3 /* add with carry generation */811#define TOK_ADDC1 0xc3 /* add with carry generation */
805#define TOK_ADDC2 0xc4 /* add with carry use */812#define TOK_ADDC2 0xc4 /* add with carry use */
806#define TOK_SUBC1 0xc5 /* add with carry generation */813#define TOK_SUBC1 0xc5 /* add with carry generation */
807#define TOK_SUBC2 0xc6 /* add with carry use */814#define TOK_SUBC2 0xc6 /* add with carry use */
808#define TOK_CUINT 0xc8 /* unsigned int constant */
809#define TOK_CLLONG 0xc9 /* long long constant */
810#define TOK_CULLONG 0xca /* unsigned long long constant */
811#define TOK_ARROW 0xcb815#define TOK_ARROW 0xcb
812#define TOK_DOTS 0xcc /* three dots */816#define TOK_DOTS 0xcc /* three dots */
813#define TOK_SHR 0xcd /* unsigned shift right */817#define TOK_SHR 0xcd /* unsigned shift right */
814#define TOK_PPNUM 0xce /* preprocessor number */
815#define TOK_NOSUBST 0xcf /* means following token has already been pp'd */818#define TOK_NOSUBST 0xcf /* means following token has already been pp'd */
816 819
817#define TOK_SHL 0x01 /* shift left */820#define TOK_SHL 0x01 /* shift left */
tccpp.c+38−6
@@ -70,8 +70,33 @@ static const char tcc_keywords[] = · 69 unmodified lines
70 70
71/* WARNING: the content of this string encodes token numbers */71/* WARNING: the content of this string encodes token numbers */
72static const unsigned char tok_two_chars[] =72static const unsigned char tok_two_chars[] =
73/* outdated -- gr
73 "<=\236>=\235!=\225&&\240||\241++\244--\242==\224<<\1>>\2+=\253"74 "<=\236>=\235!=\225&&\240||\241++\244--\242==\224<<\1>>\2+=\253"
74 "-=\255*=\252/=\257%=\245&=\246^=\336|=\374->\313..\250##\266";75 "-=\255*=\252/=\257%=\245&=\246^=\336|=\374->\313..\250##\266";
76*/{
77 '<','=', TOK_LE,
78 '>','=', TOK_GE,
79 '!','=', TOK_NE,
80 '&','&', TOK_LAND,
81 '|','|', TOK_LOR,
82 '+','+', TOK_INC,
83 '-','-', TOK_DEC,
84 '=','=', TOK_EQ,
85 '<','<', TOK_SHL,
86 '>','>', TOK_SHR,
87 '+','=', TOK_A_ADD,
88 '-','=', TOK_A_SUB,
89 '*','=', TOK_A_MUL,
90 '/','=', TOK_A_DIV,
91 '%','=', TOK_A_MOD,
92 '&','=', TOK_A_AND,
93 '^','=', TOK_A_XOR,
94 '|','=', TOK_A_OR,
95 '-','>', TOK_ARROW,
96 '.','.', 0xa8, // C++ token ?
97 '#','#', TOK_TWOSHARPS,
98 0
99};
75 100
76struct macro_level {101struct macro_level {
77 struct macro_level *prev;102 struct macro_level *prev;
@@ -255,21 +280,19 @@ ST_FUNC char *get_tok_str(int v, CValue *cv) · 177 unmodified lines
255 static char buf[STRING_MAX_SIZE + 1];280 static char buf[STRING_MAX_SIZE + 1];
256 static CString cstr_buf;281 static CString cstr_buf;
257 CString *cstr;282 CString *cstr;
258 CValue cval;
259 char *p;283 char *p;
260 int i, len;284 int i, len;
261 285
262 if (!cv) {
263 cval.ull = 0;
264 cv = &cval;
265 }
266
267 /* NOTE: to go faster, we give a fixed buffer for small strings */286 /* NOTE: to go faster, we give a fixed buffer for small strings */
268 cstr_reset(&cstr_buf);287 cstr_reset(&cstr_buf);
269 cstr_buf.data = buf;288 cstr_buf.data = buf;
270 cstr_buf.size_allocated = sizeof(buf);289 cstr_buf.size_allocated = sizeof(buf);
271 p = buf;290 p = buf;
272 291
292/* just an explanation, should never happen:
293 if (v <= TOK_LINENUM && v >= TOK_CINT && cv == NULL)
294 tcc_error("internal error: get_tok_str"); */
295
273 switch(v) {296 switch(v) {
274 case TOK_CINT:297 case TOK_CINT:
275 case TOK_CUINT:298 case TOK_CUINT:
@@ -317,6 +340,15 @@ ST_FUNC char *get_tok_str(int v, CValue *cv) · 41 unmodified lines
317 cstr_ccat(&cstr_buf, '\"');340 cstr_ccat(&cstr_buf, '\"');
318 cstr_ccat(&cstr_buf, '\0');341 cstr_ccat(&cstr_buf, '\0');
319 break;342 break;
343
344 case TOK_CFLOAT:
345 case TOK_CDOUBLE:
346 case TOK_CLDOUBLE:
347 case TOK_LINENUM:
348 return NULL; /* should not happen */
349
350 /* above tokens have value, the ones below don't */
351
320 case TOK_LT:352 case TOK_LT:
321 v = '<';353 v = '<';
322 goto addv;354 goto addv;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t