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

     1  package ast
     2  
     3  import (
     4  	"github.com/arnodel/golua/token"
     5  )
     6  
     7  // Nil is an expression node representing "nil".
     8  type Nil struct {
     9  	Location
    10  }
    11  
    12  var _ ExpNode = Nil{}
    13  
    14  // HWrite prints a tree representation of the node.
    15  func (n Nil) HWrite(w HWriter) {
    16  	w.Writef("nil")
    17  }
    18  
    19  // ProcessExp uses the given ExpProcessor to process the receiver.
    20  func (n Nil) ProcessExp(p ExpProcessor) {
    21  	p.ProcessNilExp(n)
    22  }
    23  
    24  // NewNil returns a Nil instance located where the given token is.
    25  func NewNil(tok *token.Token) Nil {
    26  	return Nil{Location: LocFromToken(tok)}
    27  }