diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-05-09 12:48:38 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-05-09 12:48:38 -0400 |
| commit | eb65410b624d3aa8c56e7f2d2e68502030f8e981 (patch) | |
| tree | 10ca4c149ed0918531b9e73cf7045fe224707e99 /src/c_tokenizer.cpp | |
| parent | 62065a9aea1c3c93cfea617403b7d5dc8344e36a (diff) | |
| download | zig-eb65410b624d3aa8c56e7f2d2e68502030f8e981.tar.gz zig-eb65410b624d3aa8c56e7f2d2e68502030f8e981.zip | |
translate-c: enough C tokenization/parsing to handle shifting in macros
See #2451
Diffstat (limited to 'src/c_tokenizer.cpp')
| -rw-r--r-- | src/c_tokenizer.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/c_tokenizer.cpp b/src/c_tokenizer.cpp index 40ae8ceafe..0c17a67c9a 100644 --- a/src/c_tokenizer.cpp +++ b/src/c_tokenizer.cpp @@ -124,6 +124,8 @@ static void begin_token(CTokenize *ctok, CTokId id) { case CTokIdAsterisk: case CTokIdBang: case CTokIdTilde: + case CTokIdShl: + case CTokIdLt: break; } } @@ -223,6 +225,10 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) { begin_token(ctok, CTokIdDot); end_token(ctok); break; + case '<': + begin_token(ctok, CTokIdLt); + ctok->state = CTokStateGotLt; + break; case '(': begin_token(ctok, CTokIdLParen); end_token(ctok); @@ -251,6 +257,18 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) { return mark_error(ctok); } break; + case CTokStateGotLt: + switch (*c) { + case '<': + ctok->cur_tok->id = CTokIdShl; + end_token(ctok); + ctok->state = CTokStateStart; + break; + default: + ctok->state = CTokStateStart; + continue; + } + break; case CTokStateFloat: switch (*c) { case '.': @@ -791,6 +809,7 @@ found_end_of_macro: case CTokStateNumLitIntSuffixL: case CTokStateNumLitIntSuffixUL: case CTokStateNumLitIntSuffixLL: + case CTokStateGotLt: end_token(ctok); break; case CTokStateFloat: |
