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 6, 2024
1 parent 16ceb99 commit 8e97d69
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 @@ -224,9 +224,16 @@ type OpDecl struct {
Body Seq `json:"body"`
}

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

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 8e97d69

Please sign in to comment.