github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/ast/interfaces.go (about) 1 package ast 2 3 // Locator can provide a location in code. All AST nodes are locators. 4 type Locator interface { 5 Locate() Location 6 } 7 8 // Node is a node in the AST 9 type Node interface { 10 Locator 11 HWrite(w HWriter) 12 } 13 14 // HWriter is an interface for printing nodes 15 type HWriter interface { 16 Writef(string, ...interface{}) 17 Indent() 18 Dedent() 19 Next() 20 } 21 22 // Stat is a statement 23 type Stat interface { 24 Node 25 ProcessStat(StatProcessor) 26 } 27 28 // ExpNode is an expression 29 type ExpNode interface { 30 Node 31 ProcessExp(ExpProcessor) 32 } 33 34 // TailExpNode is an expression which can be the tail of an exp list 35 type TailExpNode interface { 36 Node 37 ProcessTailExp(TailExpProcessor) 38 } 39 40 // Var is an l-value, i.e. it can be assigned to. 41 type Var interface { 42 ExpNode 43 FunctionName() string 44 ProcessVar(VarProcessor) 45 } 46 47 // A StatProcessor can process all implementations of Stat (i.e. statements). 48 type StatProcessor interface { 49 ProcessAssignStat(AssignStat) 50 ProcessBlockStat(BlockStat) 51 ProcessBreakStat(BreakStat) 52 ProcessEmptyStat(EmptyStat) 53 ProcessForInStat(ForInStat) 54 ProcessForStat(ForStat) 55 ProcessFunctionCallStat(FunctionCall) 56 ProcessGotoStat(GotoStat) 57 ProcessIfStat(IfStat) 58 ProcessLabelStat(LabelStat) 59 ProcessLocalFunctionStat(LocalFunctionStat) 60 ProcessLocalStat(LocalStat) 61 ProcessRepeatStat(RepeatStat) 62 ProcessWhileStat(WhileStat) 63 } 64 65 // An ExpProcessor can process all implementations of ExpNode (i.e. expressions) 66 type ExpProcessor interface { 67 ProcessBFunctionCallExp(BFunctionCall) 68 ProcessBinOpExp(BinOp) 69 ProcesBoolExp(Bool) 70 ProcessEtcExp(Etc) 71 ProcessFunctionExp(Function) 72 ProcessFunctionCallExp(FunctionCall) 73 ProcessIndexExp(IndexExp) 74 ProcessNameExp(Name) 75 ProcessNilExp(Nil) 76 ProcessIntExp(Int) 77 ProcessFloatExp(Float) 78 ProcessStringExp(String) 79 ProcessTableConstructorExp(TableConstructor) 80 ProcessUnOpExp(UnOp) 81 } 82 83 // A TailExpProcessor can process all implementations fo TailExpNode. 84 type TailExpProcessor interface { 85 ProcessEtcTailExp(Etc) 86 ProcessFunctionCallTailExp(FunctionCall) 87 } 88 89 // A VarProcessor can process all types of l-values. 90 type VarProcessor interface { 91 ProcessIndexExpVar(IndexExp) 92 ProcessNameVar(Name) 93 }