diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-09-22 14:14:21 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-09-22 14:14:21 +0200 |
commit | d36709f63e4bae54d5c9c3defd35eb3e23e64260 (patch) | |
tree | f567a64081e7650b9f85f290cda41592e6a9a929 /lexer.c | |
parent | fa947fd0d8ca3888c18f6106570f9831f72ae128 (diff) |
syntax: introduce case statement support
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lexer.c')
-rw-r--r-- | lexer.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -126,8 +126,10 @@ static const struct token reserved_words[] = { { T_CONTINUE, "continue", 8 }, { T_ENDWHILE, "endwhile", 8 }, { T_FUNC, "function", 8 }, + { T_DEFAULT, "default", 7 }, { T_RETURN, "return", 6 }, { T_ENDFOR, "endfor", 6 }, + { T_SWITCH, "switch", 6 }, { T_LOCAL, "local", 5 }, { T_ENDIF, "endif", 5 }, { T_WHILE, "while", 5 }, @@ -138,6 +140,7 @@ static const struct token reserved_words[] = { { T_ELSE, "else", 4 }, { T_THIS, "this", 4 }, { T_NULL, "null", 4 }, + { T_CASE, "case", 4 }, { T_NUMBER, "NaN", 3, parse_number }, { T_TRY, "try", 3 }, { T_FOR, "for", 3 }, @@ -146,12 +149,12 @@ static const struct token reserved_words[] = { const char *tokennames[__T_MAX] = { [0] = "End of file", - [T_FUNC] = "'function'", + [T_FUNC] = "'function'", [T_LOCAL] = "'local'", - [T_WHILE] = "'while", + [T_WHILE] = "'while", [T_ELSE] = "'else'", [T_FOR] = "'for'", - [T_IF] = "'if'", + [T_IF] = "'if'", [T_IN] = "'in'", [T_ASLEFT] = "'x<<=y'", [T_ASRIGHT] = "'x>>=y'", @@ -210,14 +213,17 @@ const char *tokennames[__T_MAX] = { [T_ENDIF] = "'endif'", [T_ENDFOR] = "'endfor'", [T_ENDWHILE] = "'endwhile'", - [T_ENDFUNC] = "'endfuncton'", - [T_RETURN] = "'return'", - [T_BREAK] = "'break'", - [T_CONTINUE] = "'continue'", + [T_ENDFUNC] = "'endfuncton'", + [T_RETURN] = "'return'", + [T_BREAK] = "'break'", + [T_CONTINUE] = "'continue'", [T_NULL] = "'null'", - [T_THIS] = "'this'", - [T_TRY] = "'try'", - [T_CATCH] = "'catch'", + [T_THIS] = "'this'", + [T_TRY] = "'try'", + [T_CATCH] = "'catch'", + [T_SWITCH] = "'switch'", + [T_CASE] = "'case'", + [T_DEFAULT] = "'default'", //[T_LSTM] = "'{%'", //[T_RSTM] = "'%}'" }; |