Add all the files from the interpreter repo
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
230fe61b12
commit
0acd1d41e8
34 changed files with 3784 additions and 0 deletions
23
pkg/ast/expression_statement.go
Normal file
23
pkg/ast/expression_statement.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package ast
|
||||
|
||||
import "code.jmug.me/jmug/interpreter-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 ""
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue