-
Notifications
You must be signed in to change notification settings - Fork 10
/
interfaces.go
93 lines (82 loc) · 2.08 KB
/
interfaces.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package ast
// Locator can provide a location in code. All AST nodes are locators.
type Locator interface {
Locate() Location
}
// Node is a node in the AST
type Node interface {
Locator
HWrite(w HWriter)
}
// HWriter is an interface for printing nodes
type HWriter interface {
Writef(string, ...interface{})
Indent()
Dedent()
Next()
}
// Stat is a statement
type Stat interface {
Node
ProcessStat(StatProcessor)
}
// ExpNode is an expression
type ExpNode interface {
Node
ProcessExp(ExpProcessor)
}
// TailExpNode is an expression which can be the tail of an exp list
type TailExpNode interface {
Node
ProcessTailExp(TailExpProcessor)
}
// Var is an l-value, i.e. it can be assigned to.
type Var interface {
ExpNode
FunctionName() string
ProcessVar(VarProcessor)
}
// A StatProcessor can process all implementations of Stat (i.e. statements).
type StatProcessor interface {
ProcessAssignStat(AssignStat)
ProcessBlockStat(BlockStat)
ProcessBreakStat(BreakStat)
ProcessEmptyStat(EmptyStat)
ProcessForInStat(ForInStat)
ProcessForStat(ForStat)
ProcessFunctionCallStat(FunctionCall)
ProcessGotoStat(GotoStat)
ProcessIfStat(IfStat)
ProcessLabelStat(LabelStat)
ProcessLocalFunctionStat(LocalFunctionStat)
ProcessLocalStat(LocalStat)
ProcessRepeatStat(RepeatStat)
ProcessWhileStat(WhileStat)
}
// An ExpProcessor can process all implementations of ExpNode (i.e. expressions)
type ExpProcessor interface {
ProcessBFunctionCallExp(BFunctionCall)
ProcessBinOpExp(BinOp)
ProcesBoolExp(Bool)
ProcessEtcExp(Etc)
ProcessFunctionExp(Function)
ProcessFunctionCallExp(FunctionCall)
ProcessIndexExp(IndexExp)
ProcessNameExp(Name)
ProcessNilExp(Nil)
ProcessIntExp(Int)
ProcessFloatExp(Float)
ProcessStringExp(String)
ProcessTableConstructorExp(TableConstructor)
ProcessUnOpExp(UnOp)
}
// A TailExpProcessor can process all implementations fo TailExpNode.
type TailExpProcessor interface {
ProcessEtcTailExp(Etc)
ProcessFunctionCallTailExp(FunctionCall)
}
// A VarProcessor can process all types of l-values.
type VarProcessor interface {
ProcessIndexExpVar(IndexExp)
ProcessNameVar(Name)
}