Skip to content

Commit

Permalink
ast: A TypeDecl Node
Browse files Browse the repository at this point in the history
This commit adds a separate AST decl type for type declarations as
opposed to using const deleclartions for this case. This is part of a
series of changes preparing the AST code base to support position
information for AST nodes.
  • Loading branch information
mattnibs committed Apr 5, 2024
1 parent 3be401c commit 3f56ba3
Show file tree
Hide file tree
Showing 6 changed files with 3,066 additions and 3,029 deletions.
7 changes: 7 additions & 0 deletions compiler/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ type ConstDecl struct {
Expr Expr `json:"expr"`
}

type TypeDecl struct {
Kind string `json:"kind" unpack:""`
Name string `json:"name"`
Type astzed.Type `json:"type"`
}

type FuncDecl struct {
Kind string `json:"kind" unpack:""`
Name string `json:"name"`
Expand All @@ -227,6 +233,7 @@ type OpDecl struct {
func (*ConstDecl) DeclAST() {}
func (*FuncDecl) DeclAST() {}
func (*OpDecl) DeclAST() {}
func (*TypeDecl) DeclAST() {}

// ----------------------------------------------------------------------------
// Operators
Expand Down
1 change: 1 addition & 0 deletions compiler/ast/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var unpacker = unpack.New(
Top{},
astzed.TypeArray{},
astzed.TypeDef{},
TypeDecl{},
astzed.TypeEnum{},
astzed.TypeError{},
astzed.TypeMap{},
Expand Down
Loading

0 comments on commit 3f56ba3

Please sign in to comment.