github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/ast/gotostat.go (about)

     1  package ast
     2  
     3  import (
     4  	"github.com/arnodel/golua/token"
     5  )
     6  
     7  // GotoStat is a statement node representing a goto statement.
     8  type GotoStat struct {
     9  	Location
    10  	Label Name
    11  }
    12  
    13  var _ Stat = GotoStat{}
    14  
    15  // NewGotoStat returns a GotoStat instance with the given label.
    16  func NewGotoStat(gotoTok *token.Token, lbl Name) GotoStat {
    17  	return GotoStat{
    18  		Location: MergeLocations(LocFromToken(gotoTok), lbl),
    19  		Label:    lbl,
    20  	}
    21  }
    22  
    23  // ProcessStat uses the given StatProcessor to process the receiver.
    24  func (s GotoStat) ProcessStat(p StatProcessor) {
    25  	p.ProcessGotoStat(s)
    26  }
    27  
    28  // HWrite prints a tree representation of the node.
    29  func (s GotoStat) HWrite(w HWriter) {
    30  	w.Writef("goto %s", s.Label)
    31  }