github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/ast/repeatstat.go (about) 1 package ast 2 3 import ( 4 "github.com/arnodel/golua/token" 5 ) 6 7 // RepeatStat ia a statement expression that represents a repeat / until statement. 8 type RepeatStat struct { 9 Location 10 CondStat 11 } 12 13 var _ Stat = RepeatStat{} 14 15 // NewRepeatStat returns a RepeatStat instance representing the statement 16 // "repeat <body> until <cond>". 17 func NewRepeatStat(repTok *token.Token, body BlockStat, cond ExpNode) RepeatStat { 18 return RepeatStat{ 19 Location: MergeLocations(LocFromToken(repTok), cond), 20 CondStat: CondStat{Body: body, Cond: cond}, 21 } 22 } 23 24 // ProcessStat uses the given StatProcessor to process the receiver. 25 func (s RepeatStat) ProcessStat(p StatProcessor) { 26 p.ProcessRepeatStat(s) 27 } 28 29 // HWrite prints a tree representation of the node. 30 func (s RepeatStat) HWrite(w HWriter) { 31 w.Writef("repeat if: ") 32 s.CondStat.HWrite(w) 33 }