Reserved keyword foreach for future use and updates AST with previously added reserved keywords

This commit is contained in:
nocturn9x 2021-08-24 15:44:40 +02:00
parent 3a25803346
commit 6c6d8236c4
4 changed files with 7 additions and 4 deletions

View File

@ -80,7 +80,7 @@ const reserved = to_table({
"assert": TokenType.Assert, "or": TokenType.LogicalOr,
"and": TokenType.LogicalAnd, "del": TokenType.Del,
"async": TokenType.Async, "await": TokenType.Await,
"dynamyc": TokenType.Dynamic
"dynamyc": TokenType.Dynamic, "foreach": TokenType.Foreach
})
type

View File

@ -30,9 +30,11 @@ type
# Declarations
classDecl = 0u8,
funDecl,
asyncFunDecl,
varDecl,
# Statements
forStmt,
foreachStmt,
ifStmt,
returnStmt,
breakStmt,
@ -44,6 +46,7 @@ type
delStmt,
fromStmt,
importStmt,
awaitStmt,
# An expression followed by a semicolon
exprStmt,
# Expressions

View File

@ -36,7 +36,7 @@ type
Continue, Var, Let, Const, Is,
Return, Async, Class, Import, From,
IsNot, Raise, Assert, Del, Await,
Dynamic
Dynamic, Foreach
# Basic types

View File

@ -463,8 +463,8 @@ proc statement(self: Parser): ASTNode =
of TokenType.Import:
discard self.step()
result = self.importStmt()
of TokenType.Async, TokenType.Await, TokenType.Dynamic:
discard # TODO: Reserved for future use
of TokenType.Async, TokenType.Await, TokenType.Dynamic, TokenType.Foreach:
discard self.step() # TODO: Reserved for future use
of TokenType.LeftBrace:
discard self.step()
result = self.blockStmt()