Skip to content

Commit

Permalink
ast: Add TypeDecl Node (#5102)
Browse files Browse the repository at this point in the history
ast: A TypeDecl Node

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 authored Apr 8, 2024
1 parent f1fa646 commit 1bc062d
Show file tree
Hide file tree
Showing 6 changed files with 3,061 additions and 3,022 deletions.
7 changes: 7 additions & 0 deletions compiler/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,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 @@ -76,6 +76,7 @@ var unpacker = unpack.New(
Top{},
astzed.TypeArray{},
astzed.TypeDef{},
TypeDecl{},
astzed.TypeEnum{},
astzed.TypeError{},
astzed.TypeMap{},
Expand Down
Loading

0 comments on commit 1bc062d

Please sign in to comment.