-
Notifications
You must be signed in to change notification settings - Fork 1
/
node.go
53 lines (41 loc) · 1.06 KB
/
node.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
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Copied from Go's text/template/parse package and modified for yacc.
// Parse nodes.
package yacc
// Pos represents a byte position in the original input text from which
// this template was parsed.
type Pos int
// Nodes.
// ProductionNode holds is a named production of multiple expressions.
type ProductionNode struct {
Pos
Name string
Expressions []*ExpressionNode
}
func newProduction(pos Pos, name string) *ProductionNode {
return &ProductionNode{Pos: pos, Name: name}
}
// ExpressionNode hold a single expression.
type ExpressionNode struct {
Pos
Items []Item
Command string
}
func newExpression(pos Pos) *ExpressionNode {
return &ExpressionNode{Pos: pos}
}
// Item hold an item.
type Item struct {
Value string
Typ ItemTyp
}
// ItemTyp is the item type.
type ItemTyp int
const (
// TypToken is the token type.
TypToken ItemTyp = iota
// TypLiteral is the literal type.
TypLiteral
)