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
26
pkg/ast/return.go
Normal file
26
pkg/ast/return.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package ast
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"code.jmug.me/jmug/interpreter-in-go/pkg/token"
|
||||
)
|
||||
|
||||
type ReturnStatement struct {
|
||||
Token token.Token // TODO: This is a little redundant, figure out if I can get rid of it.
|
||||
ReturnValue Expression
|
||||
}
|
||||
|
||||
func (rs *ReturnStatement) statementNode() {}
|
||||
func (rs *ReturnStatement) TokenLiteral() string {
|
||||
return rs.Token.Literal
|
||||
}
|
||||
func (rs *ReturnStatement) String() string {
|
||||
var out bytes.Buffer
|
||||
out.WriteString(rs.TokenLiteral())
|
||||
if rs.ReturnValue != nil {
|
||||
out.WriteString(" " + rs.ReturnValue.String())
|
||||
}
|
||||
out.WriteString(";")
|
||||
return out.String()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue