-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathast.go
66 lines (53 loc) · 793 Bytes
/
ast.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package ast
import "github.com/lemon-mint/vstruct/lexer"
func NewFile(filename string) *File {
return &File{
Name: filename,
Nodes: nil,
Globals: make(map[string]*Node),
}
}
type File struct {
Name string
Nodes []*Node
Globals map[string]*Node
}
type Node struct {
Type NodeType
Name string
File string
Line int
Col int
Token lexer.Token
// Struct
Struct *Struct
// Enum
Enum *Enum
// Alias
Alias *Alias
// RawType
RawType *RawType
}
type Field struct {
Name string
StrType string
Type *Node
}
type Struct struct {
Fields []*Field
}
type Enum struct {
Enums []string
}
type Alias struct {
StrType string
Type *Node
}
type RawType struct {
Type string
}
func NewNode(nodeType NodeType) *Node {
return &Node{
Type: nodeType,
}
}