18 lines
412 B
Go
18 lines
412 B
Go
|
|
package ast
|
||
|
|
|
||
|
|
import "code.jmug.me/jmug/interpreter-in-go/pkg/token"
|
||
|
|
|
||
|
|
type PrefixExpression struct {
|
||
|
|
Token token.Token // The operator token
|
||
|
|
Operator string
|
||
|
|
Right Expression
|
||
|
|
}
|
||
|
|
|
||
|
|
func (pe *PrefixExpression) expressionNode() {}
|
||
|
|
func (pe *PrefixExpression) TokenLiteral() string {
|
||
|
|
return pe.Token.Literal
|
||
|
|
}
|
||
|
|
func (pe *PrefixExpression) String() string {
|
||
|
|
return "(" + pe.Operator + pe.Right.String() + ")"
|
||
|
|
}
|