diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-07-20 10:20:53 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-07-28 13:18:30 +0200 |
commit | b738f3adbe76fb4bd446f1de1f0ece71cf6b78e8 (patch) | |
tree | 8fda8bc675beb1ff5537f752991589c27a44d191 | |
parent | 03c8e4b465c8cffd2596d2741b29ad2ba4ec1765 (diff) |
lexer: recognize module related keywords
Add support for the `import`, `export`, `from` and `as` keywords used in
module import and export statements.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | include/ucode/lexer.h | 4 | ||||
-rw-r--r-- | lexer.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/include/ucode/lexer.h b/include/ucode/lexer.h index dbec129..e3aba8e 100644 --- a/include/ucode/lexer.h +++ b/include/ucode/lexer.h @@ -117,6 +117,10 @@ typedef enum { TK_NULLISH, TK_PLACEH, TK_TEMPLATE, + TK_IMPORT, + TK_EXPORT, + TK_FROM, + TK_AS, TK_EOF, TK_ERROR @@ -54,6 +54,8 @@ static const struct keyword reserved_words[] = { { TK_RETURN, "return", 6 }, { TK_ENDFOR, "endfor", 6 }, { TK_SWITCH, "switch", 6 }, + { TK_IMPORT, "import", 6 }, + { TK_EXPORT, "export", 6 }, { TK_ENDIF, "endif", 5 }, { TK_WHILE, "while", 5 }, { TK_BREAK, "break", 5 }, @@ -66,11 +68,13 @@ static const struct keyword reserved_words[] = { { TK_THIS, "this", 4 }, { TK_NULL, "null", 4 }, { TK_CASE, "case", 4 }, + { TK_FROM, "from", 4 }, { TK_TRY, "try", 3 }, { TK_FOR, "for", 3 }, { TK_LOCAL, "let", 3 }, { TK_IF, "if", 2 }, { TK_IN, "in", 2 }, + { TK_AS, "as", 2 }, }; |