Skip to content

Commit e3cb48a

Browse files
Merge pull request #64 from MarcellPerger1/add-typechecking
refactor: Rename VarType to VarDeclType
2 parents 47621cf + 01a5fb5 commit e3cb48a

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

parser/astgen/ast_node.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ..common import HasRegion, StrRegion
88

99
__all__ = [
10-
"AstNode", "AstProgramNode", "VarDeclScope", "VarType", "AstDeclNode",
10+
"AstNode", "AstProgramNode", "VarDeclScope", "VarDeclType", "AstDeclNode",
1111
"AstRepeat", "AstIf", "AstWhile", "AstAssign", "AstAugAssign", "AstDefine",
1212
"AstNumber", "AstString", "AstAnyName", "AstIdent", "AstAttrName",
1313
"AstListLiteral", "AstAttribute", "AstItem", "AstCall", "AstOp", "AstBinOp",
@@ -90,7 +90,7 @@ class VarDeclScope(Enum):
9090
GLOBAL = 'global'
9191

9292

93-
class VarType(Enum):
93+
class VarDeclType(Enum):
9494
VARIABLE = 'variable'
9595
LIST = 'list'
9696

@@ -99,7 +99,7 @@ class VarType(Enum):
9999
class AstDeclNode(AstNode):
100100
name = 'var_decl'
101101
scope: VarDeclScope
102-
type: VarType
102+
type: VarDeclType
103103
ident: AstIdent
104104
value: AstNode | None
105105

parser/astgen/astgen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ def _walk_smt(self, smt: AnyNode) -> list[AstNode]:
136136
def _walk_var_decl(self, smt: DeclNode):
137137
scope = (VarDeclScope.LET if isinstance(smt.decl_scope, DeclScope_Let)
138138
else VarDeclScope.GLOBAL)
139-
tp = (VarType.LIST if isinstance(smt.decl_type, DeclType_List)
140-
else VarType.VARIABLE)
139+
tp = (VarDeclType.LIST if isinstance(smt.decl_type, DeclType_List)
140+
else VarDeclType.VARIABLE)
141141
# Add the region from the keywords to first decl (to make single-var
142142
# decls a more sensible .region that includes the `let` keyword as well)
143143
extra_region_first = region_union(smt.decl_scope, smt.decl_type)
@@ -146,7 +146,7 @@ def _walk_var_decl(self, smt: DeclNode):
146146
for i, d in enumerate(smt.decl_list.decls)]
147147

148148
def _walk_single_decl(self, d: DeclItemNode, scope: VarDeclScope,
149-
tp: VarType, extra_region: StrRegion | None):
149+
tp: VarDeclType, extra_region: StrRegion | None):
150150
return AstDeclNode(
151151
region_union(d.ident, d.value, extra_region),
152152
scope, tp, self._walk_ident(d.ident),

test/test_astgen/.snapshots/test_astgen.txt

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/test_e2e/.snapshots/test_main_examples.txt

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)