diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-08-19 00:43:05 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-08-19 00:43:05 +0900 |
| commit | 58560c1c803551ba3a715f5d8ebdff982ad1e500 (patch) | |
| tree | 568fdd0863b1ea3976f52c74fef91e3e95fb17a7 /preprocess.c | |
| parent | 2fe3448b4547f60333b23a6cd2e5fbafacbfe2dd (diff) | |
| download | ducc-58560c1c803551ba3a715f5d8ebdff982ad1e500.tar.gz ducc-58560c1c803551ba3a715f5d8ebdff982ad1e500.tar.zst ducc-58560c1c803551ba3a715f5d8ebdff982ad1e500.zip | |
feat: update keyword list for C23
Diffstat (limited to 'preprocess.c')
| -rw-r--r-- | preprocess.c | 227 |
1 files changed, 140 insertions, 87 deletions
diff --git a/preprocess.c b/preprocess.c index 0cf7c27..c2c373f 100644 --- a/preprocess.c +++ b/preprocess.c @@ -22,40 +22,16 @@ enum TokenKind { TokenKind_pp_directive_pragma, TokenKind_pp_directive_undef, - TokenKind_and, - TokenKind_andand, - TokenKind_arrow, - TokenKind_assign, - TokenKind_assign_add, - TokenKind_assign_and, - TokenKind_assign_div, - TokenKind_assign_lshift, - TokenKind_assign_mod, - TokenKind_assign_mul, - TokenKind_assign_or, - TokenKind_assign_rshift, - TokenKind_assign_sub, - TokenKind_assign_xor, - TokenKind_brace_l, - TokenKind_brace_r, - TokenKind_bracket_l, - TokenKind_bracket_r, - TokenKind_colon, - TokenKind_comma, - TokenKind_dot, - TokenKind_ellipsis, - TokenKind_eq, - TokenKind_ge, - TokenKind_gt, - TokenKind_ident, - TokenKind_keyword__Bool, - TokenKind_keyword__Complex, - TokenKind_keyword__Imaginary, + // C23: 6.4.1 + TokenKind_keyword_alignas, + TokenKind_keyword_alignof, TokenKind_keyword_auto, + TokenKind_keyword_bool, TokenKind_keyword_break, TokenKind_keyword_case, TokenKind_keyword_char, TokenKind_keyword_const, + TokenKind_keyword_constexpr, TokenKind_keyword_continue, TokenKind_keyword_default, TokenKind_keyword_do, @@ -63,6 +39,7 @@ enum TokenKind { TokenKind_keyword_else, TokenKind_keyword_enum, TokenKind_keyword_extern, + TokenKind_keyword_false, TokenKind_keyword_float, TokenKind_keyword_for, TokenKind_keyword_goto, @@ -70,6 +47,7 @@ enum TokenKind { TokenKind_keyword_inline, TokenKind_keyword_int, TokenKind_keyword_long, + TokenKind_keyword_nullptr, TokenKind_keyword_register, TokenKind_keyword_restrict, TokenKind_keyword_return, @@ -77,14 +55,55 @@ enum TokenKind { TokenKind_keyword_signed, TokenKind_keyword_sizeof, TokenKind_keyword_static, + TokenKind_keyword_static_assert, TokenKind_keyword_struct, TokenKind_keyword_switch, + TokenKind_keyword_thread_local, + TokenKind_keyword_true, TokenKind_keyword_typedef, + TokenKind_keyword_typeof, + TokenKind_keyword_typeof_unqual, TokenKind_keyword_union, TokenKind_keyword_unsigned, TokenKind_keyword_void, TokenKind_keyword_volatile, TokenKind_keyword_while, + TokenKind_keyword__Atomic, + TokenKind_keyword__BitInt, + TokenKind_keyword__Complex, + TokenKind_keyword__Decimal128, + TokenKind_keyword__Decimal32, + TokenKind_keyword__Decimal64, + TokenKind_keyword__Generic, + TokenKind_keyword__Imaginary, + TokenKind_keyword__Noreturn, + + TokenKind_and, + TokenKind_andand, + TokenKind_arrow, + TokenKind_assign, + TokenKind_assign_add, + TokenKind_assign_and, + TokenKind_assign_div, + TokenKind_assign_lshift, + TokenKind_assign_mod, + TokenKind_assign_mul, + TokenKind_assign_or, + TokenKind_assign_rshift, + TokenKind_assign_sub, + TokenKind_assign_xor, + TokenKind_brace_l, + TokenKind_brace_r, + TokenKind_bracket_l, + TokenKind_bracket_r, + TokenKind_colon, + TokenKind_comma, + TokenKind_dot, + TokenKind_ellipsis, + TokenKind_eq, + TokenKind_ge, + TokenKind_gt, + TokenKind_ident, TokenKind_le, TokenKind_literal_int, TokenKind_literal_str, @@ -152,66 +171,14 @@ const char* token_kind_stringify(TokenKind k) { return "#pragma"; else if (k == TokenKind_pp_directive_undef) return "#undef"; - else if (k == TokenKind_and) - return "&"; - else if (k == TokenKind_andand) - return "&&"; - else if (k == TokenKind_arrow) - return "->"; - else if (k == TokenKind_assign) - return "="; - else if (k == TokenKind_assign_add) - return "+="; - else if (k == TokenKind_assign_and) - return "&="; - else if (k == TokenKind_assign_div) - return "/="; - else if (k == TokenKind_assign_lshift) - return "<<="; - else if (k == TokenKind_assign_mod) - return "%="; - else if (k == TokenKind_assign_mul) - return "*="; - else if (k == TokenKind_assign_or) - return "|="; - else if (k == TokenKind_assign_rshift) - return ">>="; - else if (k == TokenKind_assign_sub) - return "-="; - else if (k == TokenKind_assign_xor) - return "^="; - else if (k == TokenKind_brace_l) - return "{"; - else if (k == TokenKind_brace_r) - return "}"; - else if (k == TokenKind_bracket_l) - return "["; - else if (k == TokenKind_bracket_r) - return "]"; - else if (k == TokenKind_colon) - return ":"; - else if (k == TokenKind_comma) - return ","; - else if (k == TokenKind_dot) - return "."; - else if (k == TokenKind_ellipsis) - return "..."; - else if (k == TokenKind_eq) - return "=="; - else if (k == TokenKind_ge) - return ">="; - else if (k == TokenKind_gt) - return ">"; - else if (k == TokenKind_ident) - return "<identifier>"; - else if (k == TokenKind_keyword__Bool) - return "_Bool"; - else if (k == TokenKind_keyword__Complex) - return "_Complex"; - else if (k == TokenKind_keyword__Imaginary) - return "_Imaginary"; + else if (k == TokenKind_keyword_alignas) + return "alignas"; + else if (k == TokenKind_keyword_alignof) + return "alignof"; else if (k == TokenKind_keyword_auto) return "auto"; + else if (k == TokenKind_keyword_bool) + return "bool"; else if (k == TokenKind_keyword_break) return "break"; else if (k == TokenKind_keyword_case) @@ -220,6 +187,8 @@ const char* token_kind_stringify(TokenKind k) { return "char"; else if (k == TokenKind_keyword_const) return "const"; + else if (k == TokenKind_keyword_constexpr) + return "constexpr"; else if (k == TokenKind_keyword_continue) return "continue"; else if (k == TokenKind_keyword_default) @@ -234,6 +203,8 @@ const char* token_kind_stringify(TokenKind k) { return "enum"; else if (k == TokenKind_keyword_extern) return "extern"; + else if (k == TokenKind_keyword_false) + return "false"; else if (k == TokenKind_keyword_float) return "float"; else if (k == TokenKind_keyword_for) @@ -248,6 +219,8 @@ const char* token_kind_stringify(TokenKind k) { return "int"; else if (k == TokenKind_keyword_long) return "long"; + else if (k == TokenKind_keyword_nullptr) + return "nullptr"; else if (k == TokenKind_keyword_register) return "register"; else if (k == TokenKind_keyword_restrict) @@ -262,12 +235,22 @@ const char* token_kind_stringify(TokenKind k) { return "sizeof"; else if (k == TokenKind_keyword_static) return "static"; + else if (k == TokenKind_keyword_static_assert) + return "static_assert"; else if (k == TokenKind_keyword_struct) return "struct"; else if (k == TokenKind_keyword_switch) return "switch"; + else if (k == TokenKind_keyword_thread_local) + return "thread_local"; + else if (k == TokenKind_keyword_true) + return "true"; else if (k == TokenKind_keyword_typedef) return "typedef"; + else if (k == TokenKind_keyword_typeof) + return "typeof"; + else if (k == TokenKind_keyword_typeof_unqual) + return "typeof_unqual"; else if (k == TokenKind_keyword_union) return "union"; else if (k == TokenKind_keyword_unsigned) @@ -278,6 +261,76 @@ const char* token_kind_stringify(TokenKind k) { return "volatile"; else if (k == TokenKind_keyword_while) return "while"; + else if (k == TokenKind_keyword__Atomic) + return "_Atomic"; + else if (k == TokenKind_keyword__BitInt) + return "_BitInt"; + else if (k == TokenKind_keyword__Complex) + return "_Complex"; + else if (k == TokenKind_keyword__Decimal128) + return "_Decimal128"; + else if (k == TokenKind_keyword__Decimal32) + return "_Decimal32"; + else if (k == TokenKind_keyword__Decimal64) + return "_Decimal64"; + else if (k == TokenKind_keyword__Generic) + return "_Generic"; + else if (k == TokenKind_keyword__Imaginary) + return "_Imaginary"; + else if (k == TokenKind_keyword__Noreturn) + return "_Noreturn"; + else if (k == TokenKind_and) + return "&"; + else if (k == TokenKind_andand) + return "&&"; + else if (k == TokenKind_arrow) + return "->"; + else if (k == TokenKind_assign) + return "="; + else if (k == TokenKind_assign_add) + return "+="; + else if (k == TokenKind_assign_and) + return "&="; + else if (k == TokenKind_assign_div) + return "/="; + else if (k == TokenKind_assign_lshift) + return "<<="; + else if (k == TokenKind_assign_mod) + return "%="; + else if (k == TokenKind_assign_mul) + return "*="; + else if (k == TokenKind_assign_or) + return "|="; + else if (k == TokenKind_assign_rshift) + return ">>="; + else if (k == TokenKind_assign_sub) + return "-="; + else if (k == TokenKind_assign_xor) + return "^="; + else if (k == TokenKind_brace_l) + return "{"; + else if (k == TokenKind_brace_r) + return "}"; + else if (k == TokenKind_bracket_l) + return "["; + else if (k == TokenKind_bracket_r) + return "]"; + else if (k == TokenKind_colon) + return ":"; + else if (k == TokenKind_comma) + return ","; + else if (k == TokenKind_dot) + return "."; + else if (k == TokenKind_ellipsis) + return "..."; + else if (k == TokenKind_eq) + return "=="; + else if (k == TokenKind_ge) + return ">="; + else if (k == TokenKind_gt) + return ">"; + else if (k == TokenKind_ident) + return "<identifier>"; else if (k == TokenKind_le) return "le"; else if (k == TokenKind_literal_int) |
