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, "assert": TokenType.Assert, "or": TokenType.LogicalOr,
"and": TokenType.LogicalAnd, "del": TokenType.Del, "and": TokenType.LogicalAnd, "del": TokenType.Del,
"async": TokenType.Async, "await": TokenType.Await, "async": TokenType.Async, "await": TokenType.Await,
"dynamyc": TokenType.Dynamic "dynamyc": TokenType.Dynamic, "foreach": TokenType.Foreach
}) })
type type

View File

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

View File

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

View File

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