update directory package structure
This commit is contained in:
parent
d954348e75
commit
27438eea6f
126 changed files with 178 additions and 178 deletions
|
@ -8,9 +8,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/compiler"
|
"github.com/d5/tengo/compiler"
|
||||||
|
"github.com/d5/tengo/compiler/source"
|
||||||
|
"github.com/d5/tengo/compiler/token"
|
||||||
"github.com/d5/tengo/objects"
|
"github.com/d5/tengo/objects"
|
||||||
"github.com/d5/tengo/source"
|
|
||||||
"github.com/d5/tengo/token"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func NoError(t *testing.T, err error, msg ...interface{}) bool {
|
func NoError(t *testing.T, err error, msg ...interface{}) bool {
|
||||||
|
|
|
@ -4,12 +4,12 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
|
||||||
"github.com/d5/tengo/compiler"
|
"github.com/d5/tengo/compiler"
|
||||||
|
"github.com/d5/tengo/compiler/ast"
|
||||||
|
"github.com/d5/tengo/compiler/parser"
|
||||||
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/objects"
|
"github.com/d5/tengo/objects"
|
||||||
"github.com/d5/tengo/parser"
|
"github.com/d5/tengo/runtime"
|
||||||
"github.com/d5/tengo/source"
|
|
||||||
"github.com/d5/tengo/vm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -156,11 +156,11 @@ func compileFile(file *ast.File) (time.Duration, *compiler.Bytecode, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runVM(bytecode *compiler.Bytecode) (time.Duration, objects.Object, error) {
|
func runVM(bytecode *compiler.Bytecode) (time.Duration, objects.Object, error) {
|
||||||
globals := make([]*objects.Object, vm.GlobalsSize)
|
globals := make([]*objects.Object, runtime.GlobalsSize)
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
v := vm.NewVM(bytecode, globals)
|
v := runtime.NewVM(bytecode, globals)
|
||||||
if err := v.Run(); err != nil {
|
if err := v.Run(); err != nil {
|
||||||
return time.Since(start), nil, err
|
return time.Since(start), nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
|
||||||
"github.com/d5/tengo/compiler"
|
"github.com/d5/tengo/compiler"
|
||||||
|
"github.com/d5/tengo/compiler/ast"
|
||||||
|
"github.com/d5/tengo/compiler/parser"
|
||||||
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/objects"
|
"github.com/d5/tengo/objects"
|
||||||
"github.com/d5/tengo/parser"
|
"github.com/d5/tengo/runtime"
|
||||||
"github.com/d5/tengo/source"
|
|
||||||
"github.com/d5/tengo/vm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -34,7 +34,7 @@ func startRepl(in io.Reader, out io.Writer) {
|
||||||
stdin := bufio.NewScanner(in)
|
stdin := bufio.NewScanner(in)
|
||||||
|
|
||||||
fileSet := source.NewFileSet()
|
fileSet := source.NewFileSet()
|
||||||
globals := make([]*objects.Object, vm.GlobalsSize)
|
globals := make([]*objects.Object, runtime.GlobalsSize)
|
||||||
symbolTable := compiler.NewSymbolTable()
|
symbolTable := compiler.NewSymbolTable()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
@ -61,7 +61,7 @@ func startRepl(in io.Reader, out io.Writer) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
machine := vm.NewVM(c.Bytecode(), globals)
|
machine := runtime.NewVM(c.Bytecode(), globals)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, _ = fmt.Fprintf(out, "VM error:\n %s\n", err.Error())
|
_, _ = fmt.Fprintf(out, "VM error:\n %s\n", err.Error())
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
"github.com/d5/tengo"
|
"github.com/d5/tengo"
|
||||||
"github.com/d5/tengo/compiler"
|
"github.com/d5/tengo/compiler"
|
||||||
"github.com/d5/tengo/vm"
|
"github.com/d5/tengo/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -113,7 +113,7 @@ func doRun(data []byte, _, _ string) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
machine := vm.NewVM(bytecode, nil)
|
machine := runtime.NewVM(bytecode, nil)
|
||||||
|
|
||||||
err = machine.Run()
|
err = machine.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package ast
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ArrayLit struct {
|
type ArrayLit struct {
|
|
@ -3,8 +3,8 @@ package ast
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AssignStmt struct {
|
type AssignStmt struct {
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type BadExpr struct {
|
type BadExpr struct {
|
||||||
From source.Pos
|
From source.Pos
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type BadStmt struct {
|
type BadStmt struct {
|
||||||
From source.Pos
|
From source.Pos
|
|
@ -1,8 +1,8 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BinaryExpr struct {
|
type BinaryExpr struct {
|
|
@ -3,7 +3,7 @@ package ast
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BlockStmt struct {
|
type BlockStmt struct {
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type BoolLit struct {
|
type BoolLit struct {
|
||||||
Value bool
|
Value bool
|
|
@ -1,8 +1,8 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BranchStmt struct {
|
type BranchStmt struct {
|
|
@ -3,7 +3,7 @@ package ast
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CallExpr struct {
|
type CallExpr struct {
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type CharLit struct {
|
type CharLit struct {
|
||||||
Value rune
|
Value rune
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type EmptyStmt struct {
|
type EmptyStmt struct {
|
||||||
Semicolon source.Pos
|
Semicolon source.Pos
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type ExprStmt struct {
|
type ExprStmt struct {
|
||||||
Expr Expr
|
Expr Expr
|
|
@ -3,7 +3,7 @@ package ast
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
type File struct {
|
type File struct {
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type FloatLit struct {
|
type FloatLit struct {
|
||||||
Value float64
|
Value float64
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type ForInStmt struct {
|
type ForInStmt struct {
|
||||||
ForPos source.Pos
|
ForPos source.Pos
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type ForStmt struct {
|
type ForStmt struct {
|
||||||
ForPos source.Pos
|
ForPos source.Pos
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type FuncLit struct {
|
type FuncLit struct {
|
||||||
Type *FuncType
|
Type *FuncType
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type FuncType struct {
|
type FuncType struct {
|
||||||
FuncPos source.Pos
|
FuncPos source.Pos
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type Ident struct {
|
type Ident struct {
|
||||||
Name string
|
Name string
|
|
@ -3,7 +3,7 @@ package ast
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IdentList struct {
|
type IdentList struct {
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type IfStmt struct {
|
type IfStmt struct {
|
||||||
IfPos source.Pos
|
IfPos source.Pos
|
|
@ -1,8 +1,8 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IncDecStmt struct {
|
type IncDecStmt struct {
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type IndexExpr struct {
|
type IndexExpr struct {
|
||||||
Expr Expr
|
Expr Expr
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type IntLit struct {
|
type IntLit struct {
|
||||||
Value int64
|
Value int64
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type MapElementLit struct {
|
type MapElementLit struct {
|
||||||
Key string
|
Key string
|
|
@ -3,7 +3,7 @@ package ast
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MapLit struct {
|
type MapLit struct {
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type Node interface {
|
type Node interface {
|
||||||
Pos() source.Pos
|
Pos() source.Pos
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type ParenExpr struct {
|
type ParenExpr struct {
|
||||||
Expr Expr
|
Expr Expr
|
|
@ -3,7 +3,7 @@ package ast
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ReturnStmt struct {
|
type ReturnStmt struct {
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type SelectorExpr struct {
|
type SelectorExpr struct {
|
||||||
Expr Expr
|
Expr Expr
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type SliceExpr struct {
|
type SliceExpr struct {
|
||||||
Expr Expr
|
Expr Expr
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type StringLit struct {
|
type StringLit struct {
|
||||||
Value string
|
Value string
|
|
@ -1,8 +1,8 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UnaryExpr struct {
|
type UnaryExpr struct {
|
|
@ -1,6 +1,6 @@
|
||||||
package ast
|
package ast
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type UndefinedLit struct {
|
type UndefinedLit struct {
|
||||||
TokenPos source.Pos
|
TokenPos source.Pos
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
|
"github.com/d5/tengo/compiler/token"
|
||||||
"github.com/d5/tengo/objects"
|
"github.com/d5/tengo/objects"
|
||||||
"github.com/d5/tengo/token"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Compiler struct {
|
type Compiler struct {
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Compiler) compileAssign(lhs, rhs []ast.Expr, op token.Token) error {
|
func (c *Compiler) compileAssign(lhs, rhs []ast.Expr, op token.Token) error {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package compiler
|
package compiler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Compiler) compileForStmt(stmt *ast.ForStmt) error {
|
func (c *Compiler) compileForStmt(stmt *ast.ForStmt) error {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package compiler
|
package compiler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Compiler) compileLogical(node *ast.BinaryExpr) error {
|
func (c *Compiler) compileLogical(node *ast.BinaryExpr) error {
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
|
|
||||||
"github.com/d5/tengo/assert"
|
"github.com/d5/tengo/assert"
|
||||||
"github.com/d5/tengo/compiler"
|
"github.com/d5/tengo/compiler"
|
||||||
|
"github.com/d5/tengo/compiler/parser"
|
||||||
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/objects"
|
"github.com/d5/tengo/objects"
|
||||||
"github.com/d5/tengo/parser"
|
|
||||||
"github.com/d5/tengo/source"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCompiler_Compile(t *testing.T) {
|
func TestCompiler_Compile(t *testing.T) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package parser
|
package parser
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type Error struct {
|
type Error struct {
|
||||||
Pos source.FilePos
|
Pos source.FilePos
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrorList []*Error
|
type ErrorList []*Error
|
|
@ -3,8 +3,8 @@ package parser
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ParseFile(file *source.File, src []byte, trace io.Writer) (res *ast.File, err error) {
|
func ParseFile(file *source.File, src []byte, trace io.Writer) (res *ast.File, err error) {
|
|
@ -3,8 +3,8 @@ package parser
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParseSource parses source code 'src' and builds an AST.
|
// ParseSource parses source code 'src' and builds an AST.
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/scanner"
|
"github.com/d5/tengo/compiler/scanner"
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type bailout struct{}
|
type bailout struct{}
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestArray(t *testing.T) {
|
func TestArray(t *testing.T) {
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAssignment(t *testing.T) {
|
func TestAssignment(t *testing.T) {
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBoolean(t *testing.T) {
|
func TestBoolean(t *testing.T) {
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCall(t *testing.T) {
|
func TestCall(t *testing.T) {
|
|
@ -3,7 +3,7 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestChar(t *testing.T) {
|
func TestChar(t *testing.T) {
|
|
@ -3,7 +3,7 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestForIn(t *testing.T) {
|
func TestForIn(t *testing.T) {
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFor(t *testing.T) {
|
func TestFor(t *testing.T) {
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFunction(t *testing.T) {
|
func TestFunction(t *testing.T) {
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIf(t *testing.T) {
|
func TestIf(t *testing.T) {
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIndex(t *testing.T) {
|
func TestIndex(t *testing.T) {
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLogical(t *testing.T) {
|
func TestLogical(t *testing.T) {
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMap(t *testing.T) {
|
func TestMap(t *testing.T) {
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSelector(t *testing.T) {
|
func TestSelector(t *testing.T) {
|
|
@ -3,7 +3,7 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSemicolon(t *testing.T) {
|
func TestSemicolon(t *testing.T) {
|
|
@ -3,8 +3,8 @@ package parser_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestString(t *testing.T) {
|
func TestString(t *testing.T) {
|
|
@ -7,10 +7,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d5/tengo/assert"
|
"github.com/d5/tengo/assert"
|
||||||
"github.com/d5/tengo/ast"
|
"github.com/d5/tengo/compiler/ast"
|
||||||
"github.com/d5/tengo/parser"
|
"github.com/d5/tengo/compiler/parser"
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type pfn func(int, int) source.Pos // position conversion function
|
type pfn func(int, int) source.Pos // position conversion function
|
|
@ -1,6 +1,6 @@
|
||||||
package parser
|
package parser
|
||||||
|
|
||||||
import "github.com/d5/tengo/token"
|
import "github.com/d5/tengo/compiler/token"
|
||||||
|
|
||||||
var stmtStart = map[token.Token]bool{
|
var stmtStart = map[token.Token]bool{
|
||||||
token.Break: true,
|
token.Break: true,
|
|
@ -1,5 +1,5 @@
|
||||||
package scanner
|
package scanner
|
||||||
|
|
||||||
import "github.com/d5/tengo/source"
|
import "github.com/d5/tengo/compiler/source"
|
||||||
|
|
||||||
type ErrorHandler func(pos source.FilePos, msg string)
|
type ErrorHandler func(pos source.FilePos, msg string)
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
// byte order mark
|
// byte order mark
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/d5/tengo/assert"
|
"github.com/d5/tengo/assert"
|
||||||
"github.com/d5/tengo/scanner"
|
"github.com/d5/tengo/compiler/scanner"
|
||||||
"github.com/d5/tengo/source"
|
"github.com/d5/tengo/compiler/source"
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testFileSet = source.NewFileSet()
|
var testFileSet = source.NewFileSet()
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Array struct {
|
type Array struct {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package objects
|
package objects
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Bool struct {
|
type Bool struct {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package objects
|
package objects
|
||||||
|
|
||||||
import "github.com/d5/tengo/token"
|
import "github.com/d5/tengo/compiler/token"
|
||||||
|
|
||||||
type Break struct{}
|
type Break struct{}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package objects
|
package objects
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BuiltinFunction struct {
|
type BuiltinFunction struct {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package objects
|
package objects
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Char struct {
|
type Char struct {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package objects
|
package objects
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Closure struct {
|
type Closure struct {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package objects
|
package objects
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CompiledFunction struct {
|
type CompiledFunction struct {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package objects
|
package objects
|
||||||
|
|
||||||
import "github.com/d5/tengo/token"
|
import "github.com/d5/tengo/compiler/token"
|
||||||
|
|
||||||
type Continue struct {
|
type Continue struct {
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Float struct {
|
type Float struct {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package objects
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Int struct {
|
type Int struct {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package objects
|
package objects
|
||||||
|
|
||||||
import "github.com/d5/tengo/token"
|
import "github.com/d5/tengo/compiler/token"
|
||||||
|
|
||||||
type Iterator interface {
|
type Iterator interface {
|
||||||
Object
|
Object
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Map struct {
|
type Map struct {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package objects
|
package objects
|
||||||
|
|
||||||
import "github.com/d5/tengo/token"
|
import "github.com/d5/tengo/compiler/token"
|
||||||
|
|
||||||
type Object interface {
|
type Object interface {
|
||||||
TypeName() string
|
TypeName() string
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package objects
|
package objects
|
||||||
|
|
||||||
import "github.com/d5/tengo/token"
|
import "github.com/d5/tengo/compiler/token"
|
||||||
|
|
||||||
type ReturnValue struct {
|
type ReturnValue struct {
|
||||||
Value Object
|
Value Object
|
||||||
|
|
|
@ -3,7 +3,7 @@ package objects
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/d5/tengo/token"
|
"github.com/d5/tengo/compiler/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
type String struct {
|
type String struct {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package objects
|
package objects
|
||||||
|
|
||||||
import "github.com/d5/tengo/token"
|
import "github.com/d5/tengo/compiler/token"
|
||||||
|
|
||||||
var undefined = &Undefined{}
|
var undefined = &Undefined{}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package vm
|
package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
|
@ -1,4 +1,4 @@
|
||||||
package vm
|
package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/d5/tengo/objects"
|
"github.com/d5/tengo/objects"
|
|
@ -1,11 +1,11 @@
|
||||||
package vm
|
package runtime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/d5/tengo/compiler"
|
"github.com/d5/tengo/compiler"
|
||||||
|
"github.com/d5/tengo/compiler/token"
|
||||||
"github.com/d5/tengo/objects"
|
"github.com/d5/tengo/objects"
|
||||||
"github.com/d5/tengo/token"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
|
@ -1,4 +1,4 @@
|
||||||
package vm_test
|
package runtime_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
|
@ -1,4 +1,4 @@
|
||||||
package vm_test
|
package runtime_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -193,8 +193,8 @@ out = func() {
|
||||||
`, 136)
|
`, 136)
|
||||||
|
|
||||||
// assigning different type value
|
// assigning different type value
|
||||||
expect(t, `a := 1; a = "foo"; out = a`, "foo") // global
|
expect(t, `a := 1; a = "foo"; out = a`, "foo") // global
|
||||||
expect(t, `func() { a := 1; a = "foo"; out = a }()`, "foo") // local
|
expect(t, `func() { a := 1; a = "foo"; out = a }()`, "foo") // local
|
||||||
expect(t, `
|
expect(t, `
|
||||||
out = func() {
|
out = func() {
|
||||||
a := 5
|
a := 5
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue