Implement strings and partial implementation of arrays (missing index expr eval)
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
a76f47a7a3
commit
59acf6b1a1
13 changed files with 388 additions and 20 deletions
21
pkg/ast/index.go
Normal file
21
pkg/ast/index.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package ast
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.jmug.me/jmug/interpreter-in-go/pkg/token"
|
||||
)
|
||||
|
||||
type IndexExpression struct {
|
||||
Token token.Token // The "[" token
|
||||
Left Expression
|
||||
Index Expression
|
||||
}
|
||||
|
||||
func (ie *IndexExpression) expressionNode() {}
|
||||
func (ie *IndexExpression) TokenLiteral() string {
|
||||
return ie.Token.Literal
|
||||
}
|
||||
func (ie *IndexExpression) String() string {
|
||||
return fmt.Sprintf("(%s[%s])", ie.Left.String(), ie.Index.String())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue