mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-21 02:22:34 +01:00
31 lines
681 B
Go
31 lines
681 B
Go
|
package ast
|
||
|
|
||
|
import (
|
||
|
"github.com/d5/tengo/compiler/source"
|
||
|
)
|
||
|
|
||
|
// CondExpr represents a ternary conditional expression.
|
||
|
type CondExpr struct {
|
||
|
Cond Expr
|
||
|
True Expr
|
||
|
False Expr
|
||
|
QuestionPos source.Pos
|
||
|
ColonPos source.Pos
|
||
|
}
|
||
|
|
||
|
func (e *CondExpr) exprNode() {}
|
||
|
|
||
|
// Pos returns the position of first character belonging to the node.
|
||
|
func (e *CondExpr) Pos() source.Pos {
|
||
|
return e.Cond.Pos()
|
||
|
}
|
||
|
|
||
|
// End returns the position of first character immediately after the node.
|
||
|
func (e *CondExpr) End() source.Pos {
|
||
|
return e.False.End()
|
||
|
}
|
||
|
|
||
|
func (e *CondExpr) String() string {
|
||
|
return "(" + e.Cond.String() + " ? " + e.True.String() + " : " + e.False.String() + ")"
|
||
|
}
|