Skip to content

Commit

Permalink
Add support for anonymous blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcauberer committed Nov 5, 2022
1 parent fb862d7 commit 2fa89ac
Show file tree
Hide file tree
Showing 18 changed files with 1,982 additions and 122 deletions.
2 changes: 1 addition & 1 deletion src-bootstrap/symbol/SymbolTable.spice
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public type ScopeType enum {
SCOPE_STRUCT,
SCOPE_INTERFACE,
SCOPE_ENUM,
SCOPE_IF_BODY,
SCOPE_IF_ELSE_BODY,
SCOPE_WHILE_BODY,
SCOPE_FOR_BODY,
SCOPE_FOREACH_BODY,
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ set(SOURCES
# Type checker
typechecker/TypeChecker.cpp
typechecker/TypeChecker.h
typechecker/TypeCheckerFirst.cpp
typechecker/TypeCheckerSecond.cpp
typechecker/TypeCheckerLookup.cpp
typechecker/TypeCheckerAnalyze.cpp
typechecker/OpRuleManager.cpp
typechecker/OpRuleManager.h
# Borrow checker
Expand Down
24 changes: 12 additions & 12 deletions src/Spice.g4
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ grammar Spice;

// Control structures
entry: (mainFunctionDef | functionDef | procedureDef | structDef | interfaceDef | enumDef | genericTypeDef | globalVarDef | importStmt | extDecl)*;
mainFunctionDef: F LESS TYPE_INT GREATER MAIN LPAREN paramLst? RPAREN blockStmt;
functionDef: specifierLst? F LESS dataType GREATER (IDENTIFIER DOT)? IDENTIFIER (LESS typeLst GREATER)? LPAREN paramLst? RPAREN blockStmt;
procedureDef: specifierLst? P (IDENTIFIER DOT)? IDENTIFIER (LESS typeLst GREATER)? LPAREN paramLst? RPAREN blockStmt;
mainFunctionDef: F LESS TYPE_INT GREATER MAIN LPAREN paramLst? RPAREN LBRACE stmtLst RBRACE;
functionDef: specifierLst? F LESS dataType GREATER (IDENTIFIER DOT)? IDENTIFIER (LESS typeLst GREATER)? LPAREN paramLst? RPAREN LBRACE stmtLst RBRACE;
procedureDef: specifierLst? P (IDENTIFIER DOT)? IDENTIFIER (LESS typeLst GREATER)? LPAREN paramLst? RPAREN LBRACE stmtLst RBRACE;
structDef: specifierLst? TYPE IDENTIFIER (LESS typeLst GREATER)? STRUCT (COLON typeLst)? LBRACE field* RBRACE;
interfaceDef: specifierLst? TYPE IDENTIFIER INTERFACE LBRACE signature+ RBRACE;
enumDef: specifierLst? TYPE IDENTIFIER ENUM LBRACE enumItemLst RBRACE;
genericTypeDef: specifierLst? TYPE IDENTIFIER typeAltsLst SEMICOLON;
globalVarDef: specifierLst? dataType IDENTIFIER (ASSIGN value)? SEMICOLON;
extDecl: EXT (LESS dataType GREATER)? IDENTIFIER LPAREN (typeLst ELLIPSIS?)? RPAREN DLL? SEMICOLON;
threadDef: THREAD blockStmt;
unsafeBlockDef: UNSAFE blockStmt;
forLoop: FOR (forHead | LPAREN forHead RPAREN) blockStmt;
threadDef: THREAD LBRACE stmtLst RBRACE;
unsafeBlockDef: UNSAFE LBRACE stmtLst RBRACE;
forLoop: FOR (forHead | LPAREN forHead RPAREN) LBRACE stmtLst RBRACE;
forHead: declStmt SEMICOLON assignExpr SEMICOLON assignExpr;
foreachLoop: FOREACH (foreachHead | LPAREN foreachHead RPAREN) blockStmt;
foreachLoop: FOREACH (foreachHead | LPAREN foreachHead RPAREN) LBRACE stmtLst RBRACE;
foreachHead: (declStmt COMMA)? declStmt COLON assignExpr;
whileLoop: WHILE assignExpr blockStmt;
ifStmt: IF assignExpr blockStmt elseStmt?;
elseStmt: ELSE ifStmt | ELSE blockStmt;
whileLoop: WHILE assignExpr LBRACE stmtLst RBRACE;
ifStmt: IF assignExpr LBRACE stmtLst RBRACE elseStmt?;
elseStmt: ELSE ifStmt | ELSE LBRACE stmtLst RBRACE;
assertStmt: ASSERT assignExpr SEMICOLON;
blockStmt: LBRACE stmtLst RBRACE;
anonymousBlockStmt: LBRACE stmtLst RBRACE;

// Statements, declarations, definitions and lists
stmtLst: (stmt | forLoop | foreachLoop | whileLoop | ifStmt | assertStmt | threadDef | unsafeBlockDef | blockStmt)*;
stmtLst: (stmt | forLoop | foreachLoop | whileLoop | ifStmt | assertStmt | threadDef | unsafeBlockDef | anonymousBlockStmt)*;
typeLst: dataType (COMMA dataType)*;
typeAltsLst: dataType (BITWISE_OR dataType)*;
paramLst: declStmt (COMMA declStmt)*;
Expand Down
48 changes: 24 additions & 24 deletions src/ast/ASTBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ std::any ASTBuilder::visitMainFunctionDef(SpiceParser::MainFunctionDefContext *c
if (rule = dynamic_cast<SpiceParser::ParamLstContext *>(subTree); rule != nullptr) { // ArgLstDef
currentNode = mainFctDefNode->createChild<ParamLstNode>(CodeLoc(rule->start, filePath));
mainFctDefNode->hasArgs = true;
} else if (rule = dynamic_cast<SpiceParser::BlockStmtContext *>(subTree); rule != nullptr) // BlockStmt
currentNode = mainFctDefNode->createChild<BlockStmtNode>(CodeLoc(rule->start, filePath));
} else if (rule = dynamic_cast<SpiceParser::StmtLstContext *>(subTree); rule != nullptr) // StmtLst
currentNode = mainFctDefNode->createChild<StmtLstNode>(CodeLoc(rule->start, filePath));
else
assert(dynamic_cast<antlr4::tree::TerminalNode *>(subTree)); // Fail if we did not get a terminal

Expand Down Expand Up @@ -90,8 +90,8 @@ std::any ASTBuilder::visitFunctionDef(SpiceParser::FunctionDefContext *ctx) {
} else if (rule = dynamic_cast<SpiceParser::ParamLstContext *>(subTree); rule != nullptr) { // ParamLst
currentNode = fctDefNode->createChild<ParamLstNode>(CodeLoc(rule->start, filePath));
fctDefNode->hasParams = true;
} else if (rule = dynamic_cast<SpiceParser::BlockStmtContext *>(subTree); rule != nullptr) // BlockStmt
currentNode = fctDefNode->createChild<BlockStmtNode>(CodeLoc(rule->start, filePath));
} else if (rule = dynamic_cast<SpiceParser::StmtLstContext *>(subTree); rule != nullptr) // StmtLst
currentNode = fctDefNode->createChild<StmtLstNode>(CodeLoc(rule->start, filePath));
else
assert(dynamic_cast<antlr4::tree::TerminalNode *>(subTree)); // Fail if we did not get a terminal

Expand Down Expand Up @@ -125,8 +125,8 @@ std::any ASTBuilder::visitProcedureDef(SpiceParser::ProcedureDefContext *ctx) {
} else if (rule = dynamic_cast<SpiceParser::ParamLstContext *>(subTree); rule != nullptr) { // ParamLst
currentNode = procDefNode->createChild<ParamLstNode>(CodeLoc(rule->start, filePath));
procDefNode->hasParams = true;
} else if (rule = dynamic_cast<SpiceParser::BlockStmtContext *>(subTree); rule != nullptr) // BlockStmt
currentNode = procDefNode->createChild<BlockStmtNode>(CodeLoc(rule->start, filePath));
} else if (rule = dynamic_cast<SpiceParser::StmtLstContext *>(subTree); rule != nullptr) // StmtLst
currentNode = procDefNode->createChild<StmtLstNode>(CodeLoc(rule->start, filePath));
else
assert(dynamic_cast<antlr4::tree::TerminalNode *>(subTree)); // Fail if we did not get a terminal

Expand Down Expand Up @@ -307,8 +307,8 @@ std::any ASTBuilder::visitThreadDef(SpiceParser::ThreadDefContext *ctx) {

for (const auto &subTree : ctx->children) {
antlr4::ParserRuleContext *rule;
if (rule = dynamic_cast<SpiceParser::BlockStmtContext *>(subTree); rule != nullptr) // BlockStmt
currentNode = threadDefNode->createChild<BlockStmtNode>(CodeLoc(rule->start, filePath));
if (rule = dynamic_cast<SpiceParser::StmtLstContext *>(subTree); rule != nullptr) // StmtLst
currentNode = threadDefNode->createChild<StmtLstNode>(CodeLoc(rule->start, filePath));
else
assert(dynamic_cast<antlr4::tree::TerminalNode *>(subTree)); // Fail if we did not get a terminal

Expand All @@ -326,8 +326,8 @@ std::any ASTBuilder::visitUnsafeBlockDef(SpiceParser::UnsafeBlockDefContext *ctx

for (const auto &subTree : ctx->children) {
antlr4::ParserRuleContext *rule;
if (rule = dynamic_cast<SpiceParser::BlockStmtContext *>(subTree); rule != nullptr) // BlockStmt
currentNode = unsafeBlockDefNode->createChild<BlockStmtNode>(CodeLoc(rule->start, filePath));
if (rule = dynamic_cast<SpiceParser::StmtLstContext *>(subTree); rule != nullptr) // StmtLst
currentNode = unsafeBlockDefNode->createChild<StmtLstNode>(CodeLoc(rule->start, filePath));
else
assert(dynamic_cast<antlr4::tree::TerminalNode *>(subTree)); // Fail if we did not get a terminal

Expand All @@ -347,8 +347,8 @@ std::any ASTBuilder::visitForLoop(SpiceParser::ForLoopContext *ctx) {
antlr4::ParserRuleContext *rule;
if (rule = dynamic_cast<SpiceParser::ForHeadContext *>(subTree); rule != nullptr) // ForHead
visit(rule);
else if (rule = dynamic_cast<SpiceParser::BlockStmtContext *>(subTree); rule != nullptr) // BlockStmt
currentNode = forLoopNode->createChild<BlockStmtNode>(CodeLoc(rule->start, filePath));
else if (rule = dynamic_cast<SpiceParser::StmtLstContext *>(subTree); rule != nullptr) // StmtLst
currentNode = forLoopNode->createChild<StmtLstNode>(CodeLoc(rule->start, filePath));
else
assert(dynamic_cast<antlr4::tree::TerminalNode *>(subTree)); // Fail if we did not get a terminal

Expand Down Expand Up @@ -389,8 +389,8 @@ std::any ASTBuilder::visitForeachLoop(SpiceParser::ForeachLoopContext *ctx) {
antlr4::ParserRuleContext *rule;
if (rule = dynamic_cast<SpiceParser::ForeachHeadContext *>(subTree); rule != nullptr) // ForeachHead
visit(rule);
else if (rule = dynamic_cast<SpiceParser::BlockStmtContext *>(subTree); rule != nullptr) // BlockStmt
currentNode = foreachLoopNode->createChild<BlockStmtNode>(CodeLoc(rule->start, filePath));
else if (rule = dynamic_cast<SpiceParser::StmtLstContext *>(subTree); rule != nullptr) // StmtLst
currentNode = foreachLoopNode->createChild<StmtLstNode>(CodeLoc(rule->start, filePath));
else
assert(dynamic_cast<antlr4::tree::TerminalNode *>(subTree)); // Fail if we did not get a terminal

Expand Down Expand Up @@ -431,8 +431,8 @@ std::any ASTBuilder::visitWhileLoop(SpiceParser::WhileLoopContext *ctx) {
antlr4::ParserRuleContext *rule;
if (rule = dynamic_cast<SpiceParser::AssignExprContext *>(subTree); rule != nullptr) // AssignExpr
currentNode = whileLoopNode->createChild<AssignExprNode>(CodeLoc(rule->start, filePath));
else if (rule = dynamic_cast<SpiceParser::BlockStmtContext *>(subTree); rule != nullptr) // BlockStmt
currentNode = whileLoopNode->createChild<BlockStmtNode>(CodeLoc(rule->start, filePath));
else if (rule = dynamic_cast<SpiceParser::StmtLstContext *>(subTree); rule != nullptr) // StmtLst
currentNode = whileLoopNode->createChild<StmtLstNode>(CodeLoc(rule->start, filePath));
else
assert(dynamic_cast<antlr4::tree::TerminalNode *>(subTree)); // Fail if we did not get a terminal

Expand All @@ -452,8 +452,8 @@ std::any ASTBuilder::visitIfStmt(SpiceParser::IfStmtContext *ctx) {
antlr4::ParserRuleContext *rule;
if (rule = dynamic_cast<SpiceParser::AssignExprContext *>(subTree); rule != nullptr) // AssignExpr
currentNode = ifStmtNode->createChild<AssignExprNode>(CodeLoc(rule->start, filePath));
else if (rule = dynamic_cast<SpiceParser::BlockStmtContext *>(subTree); rule != nullptr) // BlockStmt
currentNode = ifStmtNode->createChild<BlockStmtNode>(CodeLoc(rule->start, filePath));
else if (rule = dynamic_cast<SpiceParser::StmtLstContext *>(subTree); rule != nullptr) // StmtLst
currentNode = ifStmtNode->createChild<StmtLstNode>(CodeLoc(rule->start, filePath));
else if (rule = dynamic_cast<SpiceParser::ElseStmtContext *>(subTree); rule != nullptr) // ElseStmt
currentNode = ifStmtNode->createChild<ElseStmtNode>(CodeLoc(rule->start, filePath));
else
Expand All @@ -476,8 +476,8 @@ std::any ASTBuilder::visitElseStmt(SpiceParser::ElseStmtContext *ctx) {
if (rule = dynamic_cast<SpiceParser::IfStmtContext *>(subTree); rule != nullptr) { // IfStmt
currentNode = elseStmtNode->createChild<IfStmtNode>(CodeLoc(rule->start, filePath));
elseStmtNode->isElseIf = true;
} else if (rule = dynamic_cast<SpiceParser::BlockStmtContext *>(subTree); rule != nullptr) // BlockStmt
currentNode = elseStmtNode->createChild<BlockStmtNode>(CodeLoc(rule->start, filePath));
} else if (rule = dynamic_cast<SpiceParser::StmtLstContext *>(subTree); rule != nullptr) // StmtLst
currentNode = elseStmtNode->createChild<StmtLstNode>(CodeLoc(rule->start, filePath));
else
assert(dynamic_cast<antlr4::tree::TerminalNode *>(subTree)); // Fail if we did not get a terminal

Expand Down Expand Up @@ -509,8 +509,8 @@ std::any ASTBuilder::visitAssertStmt(SpiceParser::AssertStmtContext *ctx) {
return nullptr;
}

std::any ASTBuilder::visitBlockStmt(SpiceParser::BlockStmtContext *ctx) {
auto blockStmtNode = dynamic_cast<BlockStmtNode *>(currentNode);
std::any ASTBuilder::visitAnonymousBlockStmt(SpiceParser::AnonymousBlockStmtContext *ctx) {
auto blockStmtNode = dynamic_cast<AnonymousBlockStmtNode *>(currentNode);
saveErrorMessage(blockStmtNode, ctx);

for (const auto &subTree : ctx->children) {
Expand Down Expand Up @@ -550,8 +550,8 @@ std::any ASTBuilder::visitStmtLst(SpiceParser::StmtLstContext *ctx) {
currentNode = stmtLstNode->createChild<ThreadDefNode>(CodeLoc(rule->start, filePath));
else if (rule = dynamic_cast<SpiceParser::UnsafeBlockDefContext *>(subTree); rule != nullptr) // UnsafeBlockDef
currentNode = stmtLstNode->createChild<UnsafeBlockDefNode>(CodeLoc(rule->start, filePath));
else if (rule = dynamic_cast<SpiceParser::BlockStmtContext *>(subTree); rule != nullptr) // BlockStmt
currentNode = stmtLstNode->createChild<BlockStmtNode>(CodeLoc(rule->start, filePath));
else if (rule = dynamic_cast<SpiceParser::AnonymousBlockStmtContext *>(subTree); rule != nullptr) // AnonymousBlockStmt
currentNode = stmtLstNode->createChild<AnonymousBlockStmtNode>(CodeLoc(rule->start, filePath));
else
assert(dynamic_cast<antlr4::tree::TerminalNode *>(subTree)); // Fail if we did not get a terminal

Expand Down
2 changes: 1 addition & 1 deletion src/ast/ASTBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ASTBuilder : private CompilerPass, public SpiceVisitor {
std::any visitIfStmt(SpiceParser::IfStmtContext *ctx) override;
std::any visitElseStmt(SpiceParser::ElseStmtContext *ctx) override;
std::any visitAssertStmt(SpiceParser::AssertStmtContext *ctx) override;
std::any visitBlockStmt(SpiceParser::BlockStmtContext *ctx) override;
std::any visitAnonymousBlockStmt(SpiceParser::AnonymousBlockStmtContext *ctx) override;
std::any visitStmtLst(SpiceParser::StmtLstContext *ctx) override;
std::any visitTypeLst(SpiceParser::TypeLstContext *ctx) override;
std::any visitTypeAltsLst(SpiceParser::TypeAltsLstContext *ctx) override;
Expand Down
30 changes: 18 additions & 12 deletions src/ast/ASTNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ class MainFctDefNode : public ASTNode {

// Public get methods
[[nodiscard]] ParamLstNode *paramLst() const { return getChild<ParamLstNode>(); }
[[nodiscard]] BlockStmtNode *blockStmt() const { return getChild<BlockStmtNode>(); }
[[nodiscard]] StmtLstNode *stmtLst() const { return getChild<StmtLstNode>(); }

// Other methods
[[nodiscard]] std::string getScopeId() const { return "fct:main"; }

// Public members
Scope *fctScope = nullptr;
Expand All @@ -178,7 +181,7 @@ class FctDefNode : public ASTNode {
[[nodiscard]] DataTypeNode *returnType() const { return getChild<DataTypeNode>(); }
[[nodiscard]] TypeLstNode *templateTypeLst() const { return getChild<TypeLstNode>(); }
[[nodiscard]] ParamLstNode *paramLst() const { return getChild<ParamLstNode>(); }
[[nodiscard]] BlockStmtNode *blockStmt() const { return getChild<BlockStmtNode>(); }
[[nodiscard]] StmtLstNode *stmtLst() const { return getChild<StmtLstNode>(); }

// Other methods
[[nodiscard]] std::string getScopeId() const { return "fct:" + codeLoc.toString(); }
Expand Down Expand Up @@ -209,7 +212,7 @@ class ProcDefNode : public ASTNode {
[[nodiscard]] SpecifierLstNode *specifierLst() const { return getChild<SpecifierLstNode>(); }
[[nodiscard]] TypeLstNode *templateTypeLst() const { return getChild<TypeLstNode>(); }
[[nodiscard]] ParamLstNode *paramLst() const { return getChild<ParamLstNode>(); }
[[nodiscard]] BlockStmtNode *blockStmt() const { return getChild<BlockStmtNode>(); }
[[nodiscard]] StmtLstNode *stmtLst() const { return getChild<StmtLstNode>(); }

// Other methods
[[nodiscard]] std::string getScopeId() const { return "proc:" + codeLoc.toString(); }
Expand Down Expand Up @@ -356,7 +359,7 @@ class ThreadDefNode : public ASTNode {
std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitThreadDef(this); }

// Public get methods
[[nodiscard]] BlockStmtNode *blockStmt() const { return getChild<BlockStmtNode>(); }
[[nodiscard]] StmtLstNode *stmtLst() const { return getChild<StmtLstNode>(); }

// Other methods
[[nodiscard]] std::string getScopeId() const { return "thread:" + codeLoc.toString(); }
Expand All @@ -373,7 +376,7 @@ class UnsafeBlockDefNode : public ASTNode {
std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitUnsafeBlockDef(this); }

// Public get methods
[[nodiscard]] BlockStmtNode *blockStmt() const { return getChild<BlockStmtNode>(); }
[[nodiscard]] StmtLstNode *stmtLst() const { return getChild<StmtLstNode>(); }

// Other methods
[[nodiscard]] std::string getScopeId() const { return "unsafe:" + codeLoc.toString(); }
Expand All @@ -393,7 +396,7 @@ class ForLoopNode : public ASTNode {
[[nodiscard]] DeclStmtNode *initDecl() const { return getChild<DeclStmtNode>(); }
[[nodiscard]] AssignExprNode *condAssign() const { return getChild<AssignExprNode>(0); }
[[nodiscard]] AssignExprNode *incAssign() const { return getChild<AssignExprNode>(1); }
[[nodiscard]] BlockStmtNode *blockStmt() const { return getChild<BlockStmtNode>(); }
[[nodiscard]] StmtLstNode *stmtLst() const { return getChild<StmtLstNode>(); }

// Other methods
[[nodiscard]] std::string getScopeId() const { return "for:" + codeLoc.toString(); }
Expand All @@ -416,7 +419,7 @@ class ForeachLoopNode : public ASTNode {
}
[[nodiscard]] DeclStmtNode *itemDecl() const { return getChildren<DeclStmtNode>().back(); }
[[nodiscard]] AssignExprNode *arrayAssign() const { return getChild<AssignExprNode>(); }
[[nodiscard]] BlockStmtNode *blockStmt() const { return getChild<BlockStmtNode>(); }
[[nodiscard]] StmtLstNode *stmtLst() const { return getChild<StmtLstNode>(); }

// Other methods
[[nodiscard]] std::string getScopeId() const { return "foreach:" + codeLoc.toString(); }
Expand All @@ -434,7 +437,7 @@ class WhileLoopNode : public ASTNode {

// Public get methods
[[nodiscard]] AssignExprNode *condition() const { return getChild<AssignExprNode>(); }
[[nodiscard]] BlockStmtNode *blockStmt() const { return getChild<BlockStmtNode>(); }
[[nodiscard]] StmtLstNode *stmtLst() const { return getChild<StmtLstNode>(); }

// Other methods
[[nodiscard]] std::string getScopeId() const { return "while:" + codeLoc.toString(); }
Expand All @@ -452,7 +455,7 @@ class IfStmtNode : public ASTNode {

// Public get methods
[[nodiscard]] AssignExprNode *condition() const { return getChild<AssignExprNode>(); }
[[nodiscard]] BlockStmtNode *blockStmt() const { return getChild<BlockStmtNode>(); }
[[nodiscard]] StmtLstNode *stmtLst() const { return getChild<StmtLstNode>(); }
[[nodiscard]] ElseStmtNode *elseStmt() const { return getChild<ElseStmtNode>(); }

// Other methods
Expand All @@ -471,7 +474,7 @@ class ElseStmtNode : public ASTNode {

// Public get methods
[[nodiscard]] IfStmtNode *ifStmt() const { return getChild<IfStmtNode>(); }
[[nodiscard]] BlockStmtNode *blockStmt() const { return getChild<BlockStmtNode>(); }
[[nodiscard]] StmtLstNode *stmtLst() const { return getChild<StmtLstNode>(); }

// Other methods
[[nodiscard]] std::string getScopeId() const { return "if:" + codeLoc.toString(); }
Expand Down Expand Up @@ -499,16 +502,19 @@ class AssertStmtNode : public ASTNode {

// ========================================================== ScopeNode ==========================================================

class BlockStmtNode : public ASTNode {
class AnonymousBlockStmtNode : public ASTNode {
public:
// Constructors
using ASTNode::ASTNode;

// Visitor methods
std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitBlockStmt(this); }
std::any accept(AbstractASTVisitor *visitor) override { return visitor->visitAnonymousBlockStmt(this); }

// Public get methods
[[nodiscard]] StmtLstNode *stmtLst() const { return getChild<StmtLstNode>(); }

// Other methods
[[nodiscard]] std::string getScopeId() const { return "anon:" + codeLoc.toString(); }
};

// ========================================================= StmtLstNode =========================================================
Expand Down
2 changes: 1 addition & 1 deletion src/ast/ASTVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ std::any ASTVisitor::visitElseStmt(ElseStmtNode *node) { return visitChildren(no

std::any ASTVisitor::visitAssertStmt(AssertStmtNode *node) { return visitChildren(node); }

std::any ASTVisitor::visitBlockStmt(BlockStmtNode *node) { return visitChildren(node); }
std::any ASTVisitor::visitAnonymousBlockStmt(AnonymousBlockStmtNode *node) { return visitChildren(node); }

std::any ASTVisitor::visitStmtLst(StmtLstNode *node) { return visitChildren(node); }

Expand Down

0 comments on commit 2fa89ac

Please sign in to comment.