23 lines
705 B
Go
23 lines
705 B
Go
package ast
|
|
|
|
import "code.jmug.me/jmug/compiler-in-go/pkg/token"
|
|
|
|
// ExpressionStatement is a simple wrapper of an expression in a statement
|
|
// This is common in scripting languages and allows you to have a source line
|
|
// that is solely an expression, think of the Python REPL and how you can
|
|
// type `1 + 1` and get a result.
|
|
type ExpressionStatement struct {
|
|
Token token.Token // The first token in the expression.
|
|
Expression Expression
|
|
}
|
|
|
|
func (es *ExpressionStatement) statementNode() {}
|
|
func (es *ExpressionStatement) TokenLiteral() string {
|
|
return es.Token.Literal
|
|
}
|
|
func (es *ExpressionStatement) String() string {
|
|
if es.Expression != nil {
|
|
return es.Expression.String()
|
|
}
|
|
return ""
|
|
}
|