diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-09-10 00:20:09 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-09-10 00:20:09 -0400 |
| commit | b5d9584e6fc9e113435e0d555c2df62379cdcb8b (patch) | |
| tree | 24714d2331b009607a7acd83c5c4dde031c70891 /src/c_tokenizer.cpp | |
| parent | 9dfbdeace6fd6fbeaea38bd48757f0ca0aee09a9 (diff) | |
| download | zig-b5d9584e6fc9e113435e0d555c2df62379cdcb8b.tar.gz zig-b5d9584e6fc9e113435e0d555c2df62379cdcb8b.zip | |
support parens in C macros
closes #454
Diffstat (limited to 'src/c_tokenizer.cpp')
| -rw-r--r-- | src/c_tokenizer.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/c_tokenizer.cpp b/src/c_tokenizer.cpp index 920bcacf90..0988c659b8 100644 --- a/src/c_tokenizer.cpp +++ b/src/c_tokenizer.cpp @@ -114,6 +114,9 @@ static void begin_token(CTokenize *ctok, CTokId id) { case CTokIdCharLit: case CTokIdNumLitFloat: case CTokIdMinus: + case CTokIdLParen: + case CTokIdRParen: + case CTokIdEOF: break; } } @@ -214,6 +217,18 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) { ctok->state = CTokStateFloat; buf_init_from_str(&ctok->buf, "0."); break; + case '(': + begin_token(ctok, CTokIdLParen); + end_token(ctok); + break; + case ')': + begin_token(ctok, CTokIdRParen); + end_token(ctok); + break; + case '-': + begin_token(ctok, CTokIdMinus); + end_token(ctok); + break; default: return mark_error(ctok); } @@ -738,4 +753,7 @@ found_end_of_macro: } assert(ctok->cur_tok == nullptr); + + begin_token(ctok, CTokIdEOF); + end_token(ctok); } |
