github.com/cloudflare/circl@v1.5.0/abe/cpabe/tkn20/internal/dsl/interpreter.go (about)

     1  package dsl
     2  
     3  type Interpreter struct {
     4  	Literal
     5  }
     6  
     7  func (i *Interpreter) Evaluate(expr Expr) Literal {
     8  	expr.Accept(i)
     9  	return i.Literal
    10  }
    11  
    12  func (i *Interpreter) visitBinary(b Binary) {
    13  	i.Literal.Key = b.Output
    14  }
    15  
    16  func (i *Interpreter) visitUnary(u Unary) {
    17  	i.Evaluate(u.Right)
    18  }
    19  
    20  func (i *Interpreter) visitGrouping(g Grouping) {
    21  	g.Expr.Accept(i)
    22  }
    23  
    24  func (i *Interpreter) visitLiteral(at Literal) {
    25  	i.Literal = at
    26  }