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
|
package parser
import "fmt"
// kind defines the AST node kind. Its name is the concatenation
// of a category (Block, Decl, Expr, Op, Stmt) and an instance name.
type Kind int
const (
Undefined = Kind(iota)
BlockParen
BlockStmt
Comment
DeclFunc
ExprCall
Ident
LiteralNumber
LiteralString
OpAdd
OpAssign
OpDefine
OpDot
OpInferior
OpMultiply
OpSubtract
StmtIf
StmtReturn
)
var kindString = [...]string{
Undefined: "Undefined",
BlockParen: "BlockParen",
BlockStmt: "BlockStmt",
Comment: "Comment",
DeclFunc: "DeclFunc",
ExprCall: "ExprCall",
Ident: "Ident",
LiteralString: "LiteralString",
LiteralNumber: "LiteralNumber",
OpAdd: "OpAdd",
OpAssign: "OpAssign",
OpDefine: "OpDefine",
OpDot: "OpDot",
OpInferior: "OpInferior",
OpMultiply: "OpMultiply",
OpSubtract: "OpSubtract",
StmtIf: "StmtIf",
StmtReturn: "StmtReturn",
}
func (k Kind) String() string {
if int(k) < 0 || int(k) > len(kindString) {
return fmt.Sprintf("unknown kind %d", k)
}
return kindString[k]
}
|