diff options
| author | seyko <seyko2@gmail.com> | 2016-04-05 10:43:50 +0300 |
|---|---|---|
| committer | seyko <seyko2@gmail.com> | 2016-04-05 10:43:50 +0300 |
| commit | d3e85e80fd192d3fb19fa207bd6ce158a012b45a (patch) | |
| tree | b45515d25016bb0f836f31995472741243d18ab8 /tccpp.c | |
| parent | 21665f433890e2038626f0b3123b189a62a67dc9 (diff) | |
| download | tinycc-d3e85e80fd192d3fb19fa207bd6ce158a012b45a.tar.gz tinycc-d3e85e80fd192d3fb19fa207bd6ce158a012b45a.tar.bz2 | |
Identifiers can start and/or contain '.' in *.S
modified version of the old one which don't allow '.'
in #define Identifiers. This allow correctly preprocess
the following code in *.S
#define SRC(y...) \
9999: y; \
.section __ex_table, "a"; \
.long 9999b, 6001f ; \
// .previous
SRC(1: movw (%esi), %bx)
6001:
A test included.
Diffstat (limited to 'tccpp.c')
| -rw-r--r-- | tccpp.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -1328,6 +1328,8 @@ ST_FUNC void parse_define(void) parse_flags |= PARSE_FLAG_SPACES; next_nomacro_spc(); if (tok == '(') { + /* must be able to parse TOK_DOTS (in asm mode '.' can be part of identifier) */ + parse_flags &= ~PARSE_FLAG_ASM_FILE; next_nomacro(); ps = &first; if (tok != ')') for (;;) { @@ -1355,6 +1357,7 @@ ST_FUNC void parse_define(void) } next_nomacro_spc(); t = MACRO_FUNC; + parse_flags |= (saved_parse_flags & PARSE_FLAG_ASM_FILE); } tok_str_new(&str); spc = 2; @@ -2460,7 +2463,8 @@ maybe_newline: p1 = p; h = TOK_HASH_INIT; h = TOK_HASH_FUNC(h, c); - while (c = *++p, isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM)) + while (c = *++p, (isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM)) + || (c == '.' && (parse_flags & PARSE_FLAG_ASM_FILE))) h = TOK_HASH_FUNC(h, c); if (c != '\\') { TokenSym **pts; @@ -2492,7 +2496,9 @@ maybe_newline: p--; PEEKC(c, p); parse_ident_slow: - while (isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM)) { + while ((isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM)) + || (c == '.' && (parse_flags & PARSE_FLAG_ASM_FILE))) + { cstr_ccat(&tokcstr, c); PEEKC(c, p); } @@ -2551,7 +2557,7 @@ maybe_newline: cstr_reset(&tokcstr); cstr_ccat(&tokcstr, '.'); goto parse_num; - } else if ((isidnum_table['.' - CH_EOF] & IS_ID) != 0) { /* asm mode */ + } else if (parse_flags & PARSE_FLAG_ASM_FILE) { *--p = c = '.'; goto parse_ident_fast; } else if (c == '.') { |
