History

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")

seyko committed 10 years ago

Commit 78e4ee51 parent 78ee3751 file · +34 −9Browse files

Unified · Split

tccpp.c+34−9
@@ -2558,6 +2558,7 @@ static inline void next_nomacro1(void) · 2557 unmodified lines
25582558 TokenSym *ts;
25592559 uint8_t *p, *p1;
25602560 unsigned int h;
2561+ int is_dec;
25612562
25622563 p = file->buf_ptr;
25632564 redo_no_start:
@@ -2752,23 +2753,45 @@ maybe_newline: · 188 unmodified lines
27522753 }
27532754 break;
27542755
2755− case '0': case '1': case '2': case '3':
2756+ case '0':
2757+ t = c;
2758+ cstr_reset(&tokcstr);
2759+ cstr_ccat(&tokcstr, c);
2760+ PEEKC(c, p);
2761+ is_dec = 1;
2762+ if ((c == 'x') || (c == 'o') || (c == 'b'))
2763+ is_dec = 0;
2764+ goto parse_num;
2765+
2766+ case '1': case '2': case '3':
27562767 case '4': case '5': case '6': case '7':
27572768 case '8': case '9':
2769+ is_dec = 1;
2770+ t = c;
27582771 cstr_reset(&tokcstr);
2759− /* after the first digit, accept digits, alpha, '.' or sign if
2760− prefixed by 'eEpP' */
2772+ cstr_ccat(&tokcstr, c);
2773+ PEEKC(c, p);
27612774 parse_num:
27622775 for(;;) {
2776+ if (parse_flags & PARSE_FLAG_ASM_FILE) {
2777+ if (!((isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
2778+ || (c == '.')
2779+ || ((c == '+' || c == '-')
2780+ && (((t == 'e' || t == 'E') && is_dec) ||
2781+ ((t == 'p' || t == 'P') && !is_dec)))
2782+ ))
2783+ break;
2784+ } else
2785+ if (!((isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
2786+ || c == '.'
2787+ || ((c == '+' || c == '-')
2788+ && (t == 'e' || t == 'E' || t == 'p' || t == 'P')
2789+ )))
2790+ break;
2791+
27632792 t = c;
27642793 cstr_ccat(&tokcstr, c);
27652794 PEEKC(c, p);
2766− if (!((isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
2767− || c == '.'
2768− || ((c == '+' || c == '-')
2769− && (t == 'e' || t == 'E' || t == 'p' || t == 'P')
2770− )))
2771− break;
27722795 }
27732796 /* We add a trailing '\0' to ease parsing */
27742797 cstr_ccat(&tokcstr, '\0');
@@ -2782,6 +2805,8 @@ maybe_newline: · 7 unmodified lines
27822805 /* special dot handling because it can also start a number */
27832806 PEEKC(c, p);
27842807 if (isnum(c)) {
2808+ t = '.';
2809+ is_dec = 1;
27852810 cstr_reset(&tokcstr);
27862811 cstr_ccat(&tokcstr, '.');
27872812 goto parse_num;

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