mirror of
https://github.com/mirror/tinycc.git
synced 2025-04-05 12:50:08 +08:00
PP_NUM in ASM mode
oxe+1 is parsed as 0xe +1 if (parse_flags & PARSE_FLAG_ASM_FILE) Helps to compile a code: __asm__("mov $0xe" "+1", "%eax\n")
This commit is contained in:
parent
78ee3759b8
commit
78e4ee55b7
41
tccpp.c
41
tccpp.c
@ -2558,6 +2558,7 @@ static inline void next_nomacro1(void)
|
|||||||
TokenSym *ts;
|
TokenSym *ts;
|
||||||
uint8_t *p, *p1;
|
uint8_t *p, *p1;
|
||||||
unsigned int h;
|
unsigned int h;
|
||||||
|
int is_dec;
|
||||||
|
|
||||||
p = file->buf_ptr;
|
p = file->buf_ptr;
|
||||||
redo_no_start:
|
redo_no_start:
|
||||||
@ -2752,23 +2753,45 @@ maybe_newline:
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '0': case '1': case '2': case '3':
|
case '0':
|
||||||
case '4': case '5': case '6': case '7':
|
|
||||||
case '8': case '9':
|
|
||||||
cstr_reset(&tokcstr);
|
|
||||||
/* after the first digit, accept digits, alpha, '.' or sign if
|
|
||||||
prefixed by 'eEpP' */
|
|
||||||
parse_num:
|
|
||||||
for(;;) {
|
|
||||||
t = c;
|
t = c;
|
||||||
|
cstr_reset(&tokcstr);
|
||||||
cstr_ccat(&tokcstr, c);
|
cstr_ccat(&tokcstr, c);
|
||||||
PEEKC(c, p);
|
PEEKC(c, p);
|
||||||
|
is_dec = 1;
|
||||||
|
if ((c == 'x') || (c == 'o') || (c == 'b'))
|
||||||
|
is_dec = 0;
|
||||||
|
goto parse_num;
|
||||||
|
|
||||||
|
case '1': case '2': case '3':
|
||||||
|
case '4': case '5': case '6': case '7':
|
||||||
|
case '8': case '9':
|
||||||
|
is_dec = 1;
|
||||||
|
t = c;
|
||||||
|
cstr_reset(&tokcstr);
|
||||||
|
cstr_ccat(&tokcstr, c);
|
||||||
|
PEEKC(c, p);
|
||||||
|
parse_num:
|
||||||
|
for(;;) {
|
||||||
|
if (parse_flags & PARSE_FLAG_ASM_FILE) {
|
||||||
|
if (!((isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
|
||||||
|
|| (c == '.')
|
||||||
|
|| ((c == '+' || c == '-')
|
||||||
|
&& (((t == 'e' || t == 'E') && is_dec) ||
|
||||||
|
((t == 'p' || t == 'P') && !is_dec)))
|
||||||
|
))
|
||||||
|
break;
|
||||||
|
} else
|
||||||
if (!((isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
|
if (!((isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
|
||||||
|| c == '.'
|
|| c == '.'
|
||||||
|| ((c == '+' || c == '-')
|
|| ((c == '+' || c == '-')
|
||||||
&& (t == 'e' || t == 'E' || t == 'p' || t == 'P')
|
&& (t == 'e' || t == 'E' || t == 'p' || t == 'P')
|
||||||
)))
|
)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
t = c;
|
||||||
|
cstr_ccat(&tokcstr, c);
|
||||||
|
PEEKC(c, p);
|
||||||
}
|
}
|
||||||
/* We add a trailing '\0' to ease parsing */
|
/* We add a trailing '\0' to ease parsing */
|
||||||
cstr_ccat(&tokcstr, '\0');
|
cstr_ccat(&tokcstr, '\0');
|
||||||
@ -2782,6 +2805,8 @@ maybe_newline:
|
|||||||
/* special dot handling because it can also start a number */
|
/* special dot handling because it can also start a number */
|
||||||
PEEKC(c, p);
|
PEEKC(c, p);
|
||||||
if (isnum(c)) {
|
if (isnum(c)) {
|
||||||
|
t = '.';
|
||||||
|
is_dec = 1;
|
||||||
cstr_reset(&tokcstr);
|
cstr_reset(&tokcstr);
|
||||||
cstr_ccat(&tokcstr, '.');
|
cstr_ccat(&tokcstr, '.');
|
||||||
goto parse_num;
|
goto parse_num;
|
||||||
|
Loading…
Reference in New Issue
Block a user