diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-05-18 14:18:04 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-05-18 16:09:36 +0200 |
commit | 5714705aee31a0d561b4cf1b8096bbe19e17a825 (patch) | |
tree | 1c249365983089fb249b1f109f13ed3a590863d0 /lexer.c | |
parent | 2c2e603204be7ec96cab7504e3ee6951412ad4bc (diff) |
syntax: introduce `const` support
Introduce support for declaring constant variables through the `const`
keyword. Variables declared with `const` follow the same scoping rules
as `let` declared ones.
In contrast to normal variables, `const` ones may not be assigned to
after their declaration. Any attempt to do so will result in a syntax
error during compilation.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lexer.c')
-rw-r--r-- | lexer.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -152,6 +152,7 @@ static const struct keyword reserved_words[] = { { TK_WHILE, "while", 5, { 0 } }, { TK_BREAK, "break", 5, { 0 } }, { TK_CATCH, "catch", 5, { 0 } }, + { TK_CONST, "const", 5, { 0 } }, { TK_BOOL, "false", 5, { .b = false } }, { TK_BOOL, "true", 4, { .b = true } }, { TK_ELIF, "elif", 4, { 0 } }, |