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

     1  package ast
     2  
     3  import (
     4  	"github.com/arnodel/golua/token"
     5  )
     6  
     7  // Bool is an expression node representing a boolean literal.
     8  type Bool struct {
     9  	Location
    10  	Val bool
    11  }
    12  
    13  var _ ExpNode = Bool{}
    14  
    15  // HWrite prints a tree representation of the node.
    16  func (b Bool) HWrite(w HWriter) {
    17  	w.Writef("%t", b.Val)
    18  }
    19  
    20  // ProcessExp uses the given ExpProcessor to process the receiver.
    21  func (b Bool) ProcessExp(p ExpProcessor) {
    22  	p.ProcesBoolExp(b)
    23  }
    24  
    25  // True is a true boolean literal.
    26  func True(tok *token.Token) Bool {
    27  	return Bool{Location: LocFromToken(tok), Val: true}
    28  }
    29  
    30  // False is a false boolean literal.
    31  func False(tok *token.Token) Bool {
    32  	return Bool{Location: LocFromToken(tok), Val: false}
    33  }