expression.go 682 B

123456789101112131415161718192021222324252627
  1. package ast
  2. import "code.osinet.fr/fgm/waiig15/token"
  3. // ExpressionStatement fulfills the Node and Statement interfaces.
  4. // It represents a statement made of a bare expression like:
  5. // x + 10;
  6. type ExpressionStatement struct {
  7. Token token.Token // the first token of the expression
  8. Expression Expression
  9. }
  10. // String satisfies the Node and fmt.Stringer interfaces.
  11. func (es *ExpressionStatement) String() string {
  12. if es.Expression != nil {
  13. return es.Expression.String()
  14. }
  15. return "";
  16. }
  17. func (es *ExpressionStatement) statementNode() {}
  18. // TokenLiteral satisfies the Node interface.
  19. func (es *ExpressionStatement) TokenLiteral() string {
  20. return es.Token.Literal
  21. }