From 27438eea6f9778bde7f1a11b6cbbca106ce3cbeb Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Fri, 11 Jan 2019 02:27:28 -0800 Subject: [PATCH] update directory package structure --- assert/assert.go | 4 ++-- cmd/bench/main.go | 12 +++++------ cmd/repl/main.go | 12 +++++------ cmd/tengo/main.go | 4 ++-- {ast => compiler/ast}/array_lit.go | 2 +- {ast => compiler/ast}/assign_stmt.go | 4 ++-- {ast => compiler/ast}/ast.go | 0 {ast => compiler/ast}/bad_expr.go | 2 +- {ast => compiler/ast}/bad_stmt.go | 2 +- {ast => compiler/ast}/binary_expr.go | 4 ++-- {ast => compiler/ast}/block_stmt.go | 2 +- {ast => compiler/ast}/bool_lit.go | 2 +- {ast => compiler/ast}/branch_stmt.go | 4 ++-- {ast => compiler/ast}/call_expr.go | 2 +- {ast => compiler/ast}/char_lit.go | 2 +- {ast => compiler/ast}/empty_stmt.go | 2 +- {ast => compiler/ast}/expr.go | 0 {ast => compiler/ast}/expr_stmt.go | 2 +- {ast => compiler/ast}/file.go | 2 +- {ast => compiler/ast}/float_lit.go | 2 +- {ast => compiler/ast}/for_in_stmt.go | 2 +- {ast => compiler/ast}/for_stmt.go | 2 +- {ast => compiler/ast}/func_lit.go | 2 +- {ast => compiler/ast}/func_type.go | 2 +- {ast => compiler/ast}/ident.go | 2 +- {ast => compiler/ast}/ident_list.go | 2 +- {ast => compiler/ast}/if_stmt.go | 2 +- {ast => compiler/ast}/inc_dec_stmt.go | 4 ++-- {ast => compiler/ast}/index_expr.go | 2 +- {ast => compiler/ast}/int_lit.go | 2 +- {ast => compiler/ast}/map_element_lit.go | 2 +- {ast => compiler/ast}/map_lit.go | 2 +- {ast => compiler/ast}/node.go | 2 +- {ast => compiler/ast}/paren_expr.go | 2 +- {ast => compiler/ast}/return_stmt.go | 2 +- {ast => compiler/ast}/selector_expr.go | 2 +- {ast => compiler/ast}/slice_expr.go | 2 +- {ast => compiler/ast}/stmt.go | 0 {ast => compiler/ast}/string_lit.go | 2 +- {ast => compiler/ast}/unary_expr.go | 4 ++-- {ast => compiler/ast}/undefined_lit.go | 2 +- compiler/compiler.go | 4 ++-- compiler/compiler_assign.go | 4 ++-- compiler/compiler_for.go | 2 +- compiler/compiler_logical.go | 4 ++-- compiler/compiler_test.go | 4 ++-- {parser => compiler/parser}/error.go | 2 +- {parser => compiler/parser}/error_list.go | 2 +- {parser => compiler/parser}/parse_file.go | 4 ++-- {parser => compiler/parser}/parse_source.go | 4 ++-- {parser => compiler/parser}/parser.go | 8 ++++---- .../parser}/parser_array_test.go | 4 ++-- .../parser}/parser_assignment_test.go | 4 ++-- .../parser}/parser_boolean_test.go | 4 ++-- .../parser}/parser_call_test.go | 4 ++-- .../parser}/parser_char_test.go | 2 +- .../parser}/parser_for_in_test.go | 2 +- .../parser}/parser_for_test.go | 4 ++-- .../parser}/parser_function_test.go | 4 ++-- {parser => compiler/parser}/parser_if_test.go | 4 ++-- .../parser}/parser_index_test.go | 4 ++-- .../parser}/parser_logical_test.go | 4 ++-- .../parser}/parser_map_test.go | 4 ++-- .../parser}/parser_precendence_test.go | 0 .../parser}/parser_selector_test.go | 4 ++-- .../parser}/parser_semicolon_test.go | 2 +- .../parser}/parser_string_test.go | 4 ++-- {parser => compiler/parser}/parser_test.go | 8 ++++---- {parser => compiler/parser}/sync.go | 2 +- .../scanner}/error_handler.go | 2 +- {scanner => compiler/scanner}/mode.go | 0 {scanner => compiler/scanner}/scanner.go | 4 ++-- {scanner => compiler/scanner}/scanner_test.go | 6 +++--- {source => compiler/source}/file.go | 0 {source => compiler/source}/file_pos.go | 0 {source => compiler/source}/file_set.go | 0 {source => compiler/source}/pos.go | 0 {token => compiler/token}/keywords.go | 0 {token => compiler/token}/tokens.go | 0 objects/array.go | 2 +- objects/bool.go | 2 +- objects/break.go | 2 +- objects/builtin_function.go | 2 +- objects/char.go | 2 +- objects/closure.go | 2 +- objects/compiled_function.go | 2 +- objects/continue.go | 2 +- objects/float.go | 2 +- objects/int.go | 2 +- objects/iterator.go | 2 +- objects/map.go | 2 +- objects/object.go | 2 +- objects/return_value.go | 2 +- objects/string.go | 2 +- objects/undefined.go | 2 +- {vm => runtime}/errors.go | 2 +- {vm => runtime}/frame.go | 2 +- {vm => runtime}/vm.go | 4 ++-- {vm => runtime}/vm_array_test.go | 2 +- {vm => runtime}/vm_assignment_test.go | 6 +++--- {vm => runtime}/vm_bitwise_test.go | 2 +- {vm => runtime}/vm_boolean_test.go | 2 +- {vm => runtime}/vm_builtin_test.go | 2 +- {vm => runtime}/vm_call_test.go | 2 +- {vm => runtime}/vm_char_test.go | 2 +- {vm => runtime}/vm_equality_test.go | 2 +- {vm => runtime}/vm_error_test.go | 2 +- {vm => runtime}/vm_float_test.go | 2 +- {vm => runtime}/vm_for_in_test.go | 2 +- {vm => runtime}/vm_for_test.go | 2 +- {vm => runtime}/vm_function_test.go | 2 +- {vm => runtime}/vm_if_test.go | 2 +- {vm => runtime}/vm_inc_dec_test.go | 2 +- {vm => runtime}/vm_integer_test.go | 2 +- {vm => runtime}/vm_logic_test.go | 2 +- {vm => runtime}/vm_map_test.go | 2 +- {vm => runtime}/vm_not_operator_test.go | 2 +- {vm => runtime}/vm_return_test.go | 2 +- {vm => runtime}/vm_selector_test.go | 2 +- {vm => runtime}/vm_string_test.go | 2 +- {vm => runtime}/vm_tail_call_test.go | 2 +- {vm => runtime}/vm_test.go | 20 +++++++++---------- {vm => runtime}/vm_undefined_test.go | 2 +- script/compiled.go | 4 ++-- script/script.go | 8 ++++---- tengo.go | 8 ++++---- 126 files changed, 178 insertions(+), 178 deletions(-) rename {ast => compiler/ast}/array_lit.go (92%) rename {ast => compiler/ast}/assign_stmt.go (88%) rename {ast => compiler/ast}/ast.go (100%) rename {ast => compiler/ast}/bad_expr.go (86%) rename {ast => compiler/ast}/bad_stmt.go (86%) rename {ast => compiler/ast}/binary_expr.go (84%) rename {ast => compiler/ast}/block_stmt.go (91%) rename {ast => compiler/ast}/bool_lit.go (88%) rename {ast => compiler/ast}/branch_stmt.go (86%) rename {ast => compiler/ast}/call_expr.go (92%) rename {ast => compiler/ast}/char_lit.go (88%) rename {ast => compiler/ast}/empty_stmt.go (88%) rename {ast => compiler/ast}/expr.go (100%) rename {ast => compiler/ast}/expr_stmt.go (85%) rename {ast => compiler/ast}/file.go (91%) rename {ast => compiler/ast}/float_lit.go (88%) rename {ast => compiler/ast}/for_in_stmt.go (92%) rename {ast => compiler/ast}/for_stmt.go (93%) rename {ast => compiler/ast}/func_lit.go (87%) rename {ast => compiler/ast}/func_type.go (87%) rename {ast => compiler/ast}/ident.go (88%) rename {ast => compiler/ast}/ident_list.go (94%) rename {ast => compiler/ast}/if_stmt.go (92%) rename {ast => compiler/ast}/inc_dec_stmt.go (83%) rename {ast => compiler/ast}/index_expr.go (90%) rename {ast => compiler/ast}/int_lit.go (87%) rename {ast => compiler/ast}/map_element_lit.go (89%) rename {ast => compiler/ast}/map_lit.go (92%) rename {ast => compiler/ast}/node.go (66%) rename {ast => compiler/ast}/paren_expr.go (87%) rename {ast => compiler/ast}/return_stmt.go (93%) rename {ast => compiler/ast}/selector_expr.go (87%) rename {ast => compiler/ast}/slice_expr.go (91%) rename {ast => compiler/ast}/stmt.go (100%) rename {ast => compiler/ast}/string_lit.go (88%) rename {ast => compiler/ast}/unary_expr.go (82%) rename {ast => compiler/ast}/undefined_lit.go (87%) rename {parser => compiler/parser}/error.go (82%) rename {parser => compiler/parser}/error_list.go (96%) rename {parser => compiler/parser}/parse_file.go (82%) rename {parser => compiler/parser}/parse_source.go (79%) rename {parser => compiler/parser}/parser.go (99%) rename {parser => compiler/parser}/parser_array_test.go (96%) rename {parser => compiler/parser}/parser_assignment_test.go (97%) rename {parser => compiler/parser}/parser_boolean_test.go (89%) rename {parser => compiler/parser}/parser_call_test.go (97%) rename {parser => compiler/parser}/parser_char_test.go (90%) rename {parser => compiler/parser}/parser_for_in_test.go (97%) rename {parser => compiler/parser}/parser_for_test.go (96%) rename {parser => compiler/parser}/parser_function_test.go (93%) rename {parser => compiler/parser}/parser_if_test.go (98%) rename {parser => compiler/parser}/parser_index_test.go (96%) rename {parser => compiler/parser}/parser_logical_test.go (92%) rename {parser => compiler/parser}/parser_map_test.go (96%) rename {parser => compiler/parser}/parser_precendence_test.go (100%) rename {parser => compiler/parser}/parser_selector_test.go (98%) rename {parser => compiler/parser}/parser_semicolon_test.go (95%) rename {parser => compiler/parser}/parser_string_test.go (86%) rename {parser => compiler/parser}/parser_test.go (99%) rename {parser => compiler/parser}/sync.go (83%) rename {scanner => compiler/scanner}/error_handler.go (61%) rename {scanner => compiler/scanner}/mode.go (100%) rename {scanner => compiler/scanner}/scanner.go (99%) rename {scanner => compiler/scanner}/scanner_test.go (98%) rename {source => compiler/source}/file.go (100%) rename {source => compiler/source}/file_pos.go (100%) rename {source => compiler/source}/file_set.go (100%) rename {source => compiler/source}/pos.go (100%) rename {token => compiler/token}/keywords.go (100%) rename {token => compiler/token}/tokens.go (100%) rename {vm => runtime}/errors.go (82%) rename {vm => runtime}/frame.go (91%) rename {vm => runtime}/vm.go (99%) rename {vm => runtime}/vm_array_test.go (98%) rename {vm => runtime}/vm_assignment_test.go (95%) rename {vm => runtime}/vm_bitwise_test.go (97%) rename {vm => runtime}/vm_boolean_test.go (97%) rename {vm => runtime}/vm_builtin_test.go (99%) rename {vm => runtime}/vm_call_test.go (95%) rename {vm => runtime}/vm_char_test.go (88%) rename {vm => runtime}/vm_equality_test.go (98%) rename {vm => runtime}/vm_error_test.go (96%) rename {vm => runtime}/vm_float_test.go (93%) rename {vm => runtime}/vm_for_in_test.go (96%) rename {vm => runtime}/vm_for_test.go (97%) rename {vm => runtime}/vm_function_test.go (99%) rename {vm => runtime}/vm_if_test.go (98%) rename {vm => runtime}/vm_inc_dec_test.go (95%) rename {vm => runtime}/vm_integer_test.go (97%) rename {vm => runtime}/vm_logic_test.go (98%) rename {vm => runtime}/vm_map_test.go (97%) rename {vm => runtime}/vm_not_operator_test.go (93%) rename {vm => runtime}/vm_return_test.go (95%) rename {vm => runtime}/vm_selector_test.go (99%) rename {vm => runtime}/vm_string_test.go (97%) rename {vm => runtime}/vm_tail_call_test.go (98%) rename {vm => runtime}/vm_test.go (94%) rename {vm => runtime}/vm_undefined_test.go (94%) diff --git a/assert/assert.go b/assert/assert.go index 43f8289..58374ad 100644 --- a/assert/assert.go +++ b/assert/assert.go @@ -8,9 +8,9 @@ import ( "testing" "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/source" - "github.com/d5/tengo/token" ) func NoError(t *testing.T, err error, msg ...interface{}) bool { diff --git a/cmd/bench/main.go b/cmd/bench/main.go index 9683895..16d98ca 100644 --- a/cmd/bench/main.go +++ b/cmd/bench/main.go @@ -4,12 +4,12 @@ import ( "fmt" "time" - "github.com/d5/tengo/ast" "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/parser" - "github.com/d5/tengo/source" - "github.com/d5/tengo/vm" + "github.com/d5/tengo/runtime" ) 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) { - globals := make([]*objects.Object, vm.GlobalsSize) + globals := make([]*objects.Object, runtime.GlobalsSize) start := time.Now() - v := vm.NewVM(bytecode, globals) + v := runtime.NewVM(bytecode, globals) if err := v.Run(); err != nil { return time.Since(start), nil, err } diff --git a/cmd/repl/main.go b/cmd/repl/main.go index aa47eb6..2bce704 100644 --- a/cmd/repl/main.go +++ b/cmd/repl/main.go @@ -7,12 +7,12 @@ import ( "os" "os/user" - "github.com/d5/tengo/ast" "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/parser" - "github.com/d5/tengo/source" - "github.com/d5/tengo/vm" + "github.com/d5/tengo/runtime" ) const ( @@ -34,7 +34,7 @@ func startRepl(in io.Reader, out io.Writer) { stdin := bufio.NewScanner(in) fileSet := source.NewFileSet() - globals := make([]*objects.Object, vm.GlobalsSize) + globals := make([]*objects.Object, runtime.GlobalsSize) symbolTable := compiler.NewSymbolTable() for { @@ -61,7 +61,7 @@ func startRepl(in io.Reader, out io.Writer) { continue } - machine := vm.NewVM(c.Bytecode(), globals) + machine := runtime.NewVM(c.Bytecode(), globals) if err != nil { _, _ = fmt.Fprintf(out, "VM error:\n %s\n", err.Error()) continue diff --git a/cmd/tengo/main.go b/cmd/tengo/main.go index da6a35e..c956782 100644 --- a/cmd/tengo/main.go +++ b/cmd/tengo/main.go @@ -11,7 +11,7 @@ import ( "github.com/d5/tengo" "github.com/d5/tengo/compiler" - "github.com/d5/tengo/vm" + "github.com/d5/tengo/runtime" ) var ( @@ -113,7 +113,7 @@ func doRun(data []byte, _, _ string) (err error) { return } - machine := vm.NewVM(bytecode, nil) + machine := runtime.NewVM(bytecode, nil) err = machine.Run() if err != nil { diff --git a/ast/array_lit.go b/compiler/ast/array_lit.go similarity index 92% rename from ast/array_lit.go rename to compiler/ast/array_lit.go index dae7852..9dcb1d7 100644 --- a/ast/array_lit.go +++ b/compiler/ast/array_lit.go @@ -3,7 +3,7 @@ package ast import ( "strings" - "github.com/d5/tengo/source" + "github.com/d5/tengo/compiler/source" ) type ArrayLit struct { diff --git a/ast/assign_stmt.go b/compiler/ast/assign_stmt.go similarity index 88% rename from ast/assign_stmt.go rename to compiler/ast/assign_stmt.go index 56afddd..4d9719d 100644 --- a/ast/assign_stmt.go +++ b/compiler/ast/assign_stmt.go @@ -3,8 +3,8 @@ package ast import ( "strings" - "github.com/d5/tengo/source" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/source" + "github.com/d5/tengo/compiler/token" ) type AssignStmt struct { diff --git a/ast/ast.go b/compiler/ast/ast.go similarity index 100% rename from ast/ast.go rename to compiler/ast/ast.go diff --git a/ast/bad_expr.go b/compiler/ast/bad_expr.go similarity index 86% rename from ast/bad_expr.go rename to compiler/ast/bad_expr.go index 3be1de8..121eac8 100644 --- a/ast/bad_expr.go +++ b/compiler/ast/bad_expr.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type BadExpr struct { From source.Pos diff --git a/ast/bad_stmt.go b/compiler/ast/bad_stmt.go similarity index 86% rename from ast/bad_stmt.go rename to compiler/ast/bad_stmt.go index 19a5536..b02d812 100644 --- a/ast/bad_stmt.go +++ b/compiler/ast/bad_stmt.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type BadStmt struct { From source.Pos diff --git a/ast/binary_expr.go b/compiler/ast/binary_expr.go similarity index 84% rename from ast/binary_expr.go rename to compiler/ast/binary_expr.go index e75efc7..c073400 100644 --- a/ast/binary_expr.go +++ b/compiler/ast/binary_expr.go @@ -1,8 +1,8 @@ package ast import ( - "github.com/d5/tengo/source" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/source" + "github.com/d5/tengo/compiler/token" ) type BinaryExpr struct { diff --git a/ast/block_stmt.go b/compiler/ast/block_stmt.go similarity index 91% rename from ast/block_stmt.go rename to compiler/ast/block_stmt.go index 61fa6e8..d8db888 100644 --- a/ast/block_stmt.go +++ b/compiler/ast/block_stmt.go @@ -3,7 +3,7 @@ package ast import ( "strings" - "github.com/d5/tengo/source" + "github.com/d5/tengo/compiler/source" ) type BlockStmt struct { diff --git a/ast/bool_lit.go b/compiler/ast/bool_lit.go similarity index 88% rename from ast/bool_lit.go rename to compiler/ast/bool_lit.go index 3e8b7e6..3d7781f 100644 --- a/ast/bool_lit.go +++ b/compiler/ast/bool_lit.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type BoolLit struct { Value bool diff --git a/ast/branch_stmt.go b/compiler/ast/branch_stmt.go similarity index 86% rename from ast/branch_stmt.go rename to compiler/ast/branch_stmt.go index 5fc67e3..1875f57 100644 --- a/ast/branch_stmt.go +++ b/compiler/ast/branch_stmt.go @@ -1,8 +1,8 @@ package ast import ( - "github.com/d5/tengo/source" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/source" + "github.com/d5/tengo/compiler/token" ) type BranchStmt struct { diff --git a/ast/call_expr.go b/compiler/ast/call_expr.go similarity index 92% rename from ast/call_expr.go rename to compiler/ast/call_expr.go index a009df2..c9adb24 100644 --- a/ast/call_expr.go +++ b/compiler/ast/call_expr.go @@ -3,7 +3,7 @@ package ast import ( "strings" - "github.com/d5/tengo/source" + "github.com/d5/tengo/compiler/source" ) type CallExpr struct { diff --git a/ast/char_lit.go b/compiler/ast/char_lit.go similarity index 88% rename from ast/char_lit.go rename to compiler/ast/char_lit.go index 823137c..ae4bb29 100644 --- a/ast/char_lit.go +++ b/compiler/ast/char_lit.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type CharLit struct { Value rune diff --git a/ast/empty_stmt.go b/compiler/ast/empty_stmt.go similarity index 88% rename from ast/empty_stmt.go rename to compiler/ast/empty_stmt.go index 162b8c6..569d905 100644 --- a/ast/empty_stmt.go +++ b/compiler/ast/empty_stmt.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type EmptyStmt struct { Semicolon source.Pos diff --git a/ast/expr.go b/compiler/ast/expr.go similarity index 100% rename from ast/expr.go rename to compiler/ast/expr.go diff --git a/ast/expr_stmt.go b/compiler/ast/expr_stmt.go similarity index 85% rename from ast/expr_stmt.go rename to compiler/ast/expr_stmt.go index 70ae961..9a3bb05 100644 --- a/ast/expr_stmt.go +++ b/compiler/ast/expr_stmt.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type ExprStmt struct { Expr Expr diff --git a/ast/file.go b/compiler/ast/file.go similarity index 91% rename from ast/file.go rename to compiler/ast/file.go index a0af179..38daa06 100644 --- a/ast/file.go +++ b/compiler/ast/file.go @@ -3,7 +3,7 @@ package ast import ( "strings" - "github.com/d5/tengo/source" + "github.com/d5/tengo/compiler/source" ) type File struct { diff --git a/ast/float_lit.go b/compiler/ast/float_lit.go similarity index 88% rename from ast/float_lit.go rename to compiler/ast/float_lit.go index ababff6..ca219c7 100644 --- a/ast/float_lit.go +++ b/compiler/ast/float_lit.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type FloatLit struct { Value float64 diff --git a/ast/for_in_stmt.go b/compiler/ast/for_in_stmt.go similarity index 92% rename from ast/for_in_stmt.go rename to compiler/ast/for_in_stmt.go index 485cc5b..3bed403 100644 --- a/ast/for_in_stmt.go +++ b/compiler/ast/for_in_stmt.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type ForInStmt struct { ForPos source.Pos diff --git a/ast/for_stmt.go b/compiler/ast/for_stmt.go similarity index 93% rename from ast/for_stmt.go rename to compiler/ast/for_stmt.go index 6ea0de7..1d2e11d 100644 --- a/ast/for_stmt.go +++ b/compiler/ast/for_stmt.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type ForStmt struct { ForPos source.Pos diff --git a/ast/func_lit.go b/compiler/ast/func_lit.go similarity index 87% rename from ast/func_lit.go rename to compiler/ast/func_lit.go index 591eec5..b61cb91 100644 --- a/ast/func_lit.go +++ b/compiler/ast/func_lit.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type FuncLit struct { Type *FuncType diff --git a/ast/func_type.go b/compiler/ast/func_type.go similarity index 87% rename from ast/func_type.go rename to compiler/ast/func_type.go index fe818cb..fac46ef 100644 --- a/ast/func_type.go +++ b/compiler/ast/func_type.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type FuncType struct { FuncPos source.Pos diff --git a/ast/ident.go b/compiler/ast/ident.go similarity index 88% rename from ast/ident.go rename to compiler/ast/ident.go index baa8838..ad0dc3e 100644 --- a/ast/ident.go +++ b/compiler/ast/ident.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type Ident struct { Name string diff --git a/ast/ident_list.go b/compiler/ast/ident_list.go similarity index 94% rename from ast/ident_list.go rename to compiler/ast/ident_list.go index 18b7cf6..e93100b 100644 --- a/ast/ident_list.go +++ b/compiler/ast/ident_list.go @@ -3,7 +3,7 @@ package ast import ( "strings" - "github.com/d5/tengo/source" + "github.com/d5/tengo/compiler/source" ) type IdentList struct { diff --git a/ast/if_stmt.go b/compiler/ast/if_stmt.go similarity index 92% rename from ast/if_stmt.go rename to compiler/ast/if_stmt.go index d255a27..6f071d3 100644 --- a/ast/if_stmt.go +++ b/compiler/ast/if_stmt.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type IfStmt struct { IfPos source.Pos diff --git a/ast/inc_dec_stmt.go b/compiler/ast/inc_dec_stmt.go similarity index 83% rename from ast/inc_dec_stmt.go rename to compiler/ast/inc_dec_stmt.go index d4500b2..46f9165 100644 --- a/ast/inc_dec_stmt.go +++ b/compiler/ast/inc_dec_stmt.go @@ -1,8 +1,8 @@ package ast import ( - "github.com/d5/tengo/source" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/source" + "github.com/d5/tengo/compiler/token" ) type IncDecStmt struct { diff --git a/ast/index_expr.go b/compiler/ast/index_expr.go similarity index 90% rename from ast/index_expr.go rename to compiler/ast/index_expr.go index 2512ba4..bca7ce2 100644 --- a/ast/index_expr.go +++ b/compiler/ast/index_expr.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type IndexExpr struct { Expr Expr diff --git a/ast/int_lit.go b/compiler/ast/int_lit.go similarity index 87% rename from ast/int_lit.go rename to compiler/ast/int_lit.go index 50ac36a..39314a5 100644 --- a/ast/int_lit.go +++ b/compiler/ast/int_lit.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type IntLit struct { Value int64 diff --git a/ast/map_element_lit.go b/compiler/ast/map_element_lit.go similarity index 89% rename from ast/map_element_lit.go rename to compiler/ast/map_element_lit.go index 2b3ae26..8d4b001 100644 --- a/ast/map_element_lit.go +++ b/compiler/ast/map_element_lit.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type MapElementLit struct { Key string diff --git a/ast/map_lit.go b/compiler/ast/map_lit.go similarity index 92% rename from ast/map_lit.go rename to compiler/ast/map_lit.go index 01bf8e4..f74fb8e 100644 --- a/ast/map_lit.go +++ b/compiler/ast/map_lit.go @@ -3,7 +3,7 @@ package ast import ( "strings" - "github.com/d5/tengo/source" + "github.com/d5/tengo/compiler/source" ) type MapLit struct { diff --git a/ast/node.go b/compiler/ast/node.go similarity index 66% rename from ast/node.go rename to compiler/ast/node.go index c6af154..6777442 100644 --- a/ast/node.go +++ b/compiler/ast/node.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type Node interface { Pos() source.Pos diff --git a/ast/paren_expr.go b/compiler/ast/paren_expr.go similarity index 87% rename from ast/paren_expr.go rename to compiler/ast/paren_expr.go index c617fcc..abc35a0 100644 --- a/ast/paren_expr.go +++ b/compiler/ast/paren_expr.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type ParenExpr struct { Expr Expr diff --git a/ast/return_stmt.go b/compiler/ast/return_stmt.go similarity index 93% rename from ast/return_stmt.go rename to compiler/ast/return_stmt.go index d60825a..88d2a24 100644 --- a/ast/return_stmt.go +++ b/compiler/ast/return_stmt.go @@ -3,7 +3,7 @@ package ast import ( "strings" - "github.com/d5/tengo/source" + "github.com/d5/tengo/compiler/source" ) type ReturnStmt struct { diff --git a/ast/selector_expr.go b/compiler/ast/selector_expr.go similarity index 87% rename from ast/selector_expr.go rename to compiler/ast/selector_expr.go index e5cbce5..02e320a 100644 --- a/ast/selector_expr.go +++ b/compiler/ast/selector_expr.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type SelectorExpr struct { Expr Expr diff --git a/ast/slice_expr.go b/compiler/ast/slice_expr.go similarity index 91% rename from ast/slice_expr.go rename to compiler/ast/slice_expr.go index f9bbe39..ba6faf6 100644 --- a/ast/slice_expr.go +++ b/compiler/ast/slice_expr.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type SliceExpr struct { Expr Expr diff --git a/ast/stmt.go b/compiler/ast/stmt.go similarity index 100% rename from ast/stmt.go rename to compiler/ast/stmt.go diff --git a/ast/string_lit.go b/compiler/ast/string_lit.go similarity index 88% rename from ast/string_lit.go rename to compiler/ast/string_lit.go index 8219d9e..057a69a 100644 --- a/ast/string_lit.go +++ b/compiler/ast/string_lit.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type StringLit struct { Value string diff --git a/ast/unary_expr.go b/compiler/ast/unary_expr.go similarity index 82% rename from ast/unary_expr.go rename to compiler/ast/unary_expr.go index c221dc0..525bb8e 100644 --- a/ast/unary_expr.go +++ b/compiler/ast/unary_expr.go @@ -1,8 +1,8 @@ package ast import ( - "github.com/d5/tengo/source" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/source" + "github.com/d5/tengo/compiler/token" ) type UnaryExpr struct { diff --git a/ast/undefined_lit.go b/compiler/ast/undefined_lit.go similarity index 87% rename from ast/undefined_lit.go rename to compiler/ast/undefined_lit.go index 4bf8d00..d4f536b 100644 --- a/ast/undefined_lit.go +++ b/compiler/ast/undefined_lit.go @@ -1,6 +1,6 @@ package ast -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type UndefinedLit struct { TokenPos source.Pos diff --git a/compiler/compiler.go b/compiler/compiler.go index 55dc00b..69e7fe0 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -5,9 +5,9 @@ import ( "io" "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/token" ) type Compiler struct { diff --git a/compiler/compiler_assign.go b/compiler/compiler_assign.go index 1c211f5..30b912e 100644 --- a/compiler/compiler_assign.go +++ b/compiler/compiler_assign.go @@ -4,8 +4,8 @@ import ( "errors" "fmt" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func (c *Compiler) compileAssign(lhs, rhs []ast.Expr, op token.Token) error { diff --git a/compiler/compiler_for.go b/compiler/compiler_for.go index da04799..a2d4278 100644 --- a/compiler/compiler_for.go +++ b/compiler/compiler_for.go @@ -1,7 +1,7 @@ package compiler import ( - "github.com/d5/tengo/ast" + "github.com/d5/tengo/compiler/ast" ) func (c *Compiler) compileForStmt(stmt *ast.ForStmt) error { diff --git a/compiler/compiler_logical.go b/compiler/compiler_logical.go index 9d5b625..5dfff28 100644 --- a/compiler/compiler_logical.go +++ b/compiler/compiler_logical.go @@ -1,8 +1,8 @@ package compiler import ( - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func (c *Compiler) compileLogical(node *ast.BinaryExpr) error { diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go index 1d0a0f4..f05b977 100644 --- a/compiler/compiler_test.go +++ b/compiler/compiler_test.go @@ -8,9 +8,9 @@ import ( "github.com/d5/tengo/assert" "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/parser" - "github.com/d5/tengo/source" ) func TestCompiler_Compile(t *testing.T) { diff --git a/parser/error.go b/compiler/parser/error.go similarity index 82% rename from parser/error.go rename to compiler/parser/error.go index 2e08acb..f2db31f 100644 --- a/parser/error.go +++ b/compiler/parser/error.go @@ -1,6 +1,6 @@ package parser -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type Error struct { Pos source.FilePos diff --git a/parser/error_list.go b/compiler/parser/error_list.go similarity index 96% rename from parser/error_list.go rename to compiler/parser/error_list.go index 1677908..6ff3f19 100644 --- a/parser/error_list.go +++ b/compiler/parser/error_list.go @@ -4,7 +4,7 @@ import ( "fmt" "sort" - "github.com/d5/tengo/source" + "github.com/d5/tengo/compiler/source" ) type ErrorList []*Error diff --git a/parser/parse_file.go b/compiler/parser/parse_file.go similarity index 82% rename from parser/parse_file.go rename to compiler/parser/parse_file.go index 2c4bf26..0ff9731 100644 --- a/parser/parse_file.go +++ b/compiler/parser/parse_file.go @@ -3,8 +3,8 @@ package parser import ( "io" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/source" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/source" ) func ParseFile(file *source.File, src []byte, trace io.Writer) (res *ast.File, err error) { diff --git a/parser/parse_source.go b/compiler/parser/parse_source.go similarity index 79% rename from parser/parse_source.go rename to compiler/parser/parse_source.go index 64aff92..3a62e15 100644 --- a/parser/parse_source.go +++ b/compiler/parser/parse_source.go @@ -3,8 +3,8 @@ package parser import ( "io" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/source" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/source" ) // ParseSource parses source code 'src' and builds an AST. diff --git a/parser/parser.go b/compiler/parser/parser.go similarity index 99% rename from parser/parser.go rename to compiler/parser/parser.go index c420152..2bc77e5 100644 --- a/parser/parser.go +++ b/compiler/parser/parser.go @@ -5,10 +5,10 @@ import ( "io" "strconv" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/scanner" - "github.com/d5/tengo/source" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/scanner" + "github.com/d5/tengo/compiler/source" + "github.com/d5/tengo/compiler/token" ) type bailout struct{} diff --git a/parser/parser_array_test.go b/compiler/parser/parser_array_test.go similarity index 96% rename from parser/parser_array_test.go rename to compiler/parser/parser_array_test.go index af176c9..720c705 100644 --- a/parser/parser_array_test.go +++ b/compiler/parser/parser_array_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestArray(t *testing.T) { diff --git a/parser/parser_assignment_test.go b/compiler/parser/parser_assignment_test.go similarity index 97% rename from parser/parser_assignment_test.go rename to compiler/parser/parser_assignment_test.go index 36bfacf..0abf122 100644 --- a/parser/parser_assignment_test.go +++ b/compiler/parser/parser_assignment_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestAssignment(t *testing.T) { diff --git a/parser/parser_boolean_test.go b/compiler/parser/parser_boolean_test.go similarity index 89% rename from parser/parser_boolean_test.go rename to compiler/parser/parser_boolean_test.go index 5534493..5624236 100644 --- a/parser/parser_boolean_test.go +++ b/compiler/parser/parser_boolean_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestBoolean(t *testing.T) { diff --git a/parser/parser_call_test.go b/compiler/parser/parser_call_test.go similarity index 97% rename from parser/parser_call_test.go rename to compiler/parser/parser_call_test.go index 806804f..fd6bfe2 100644 --- a/parser/parser_call_test.go +++ b/compiler/parser/parser_call_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestCall(t *testing.T) { diff --git a/parser/parser_char_test.go b/compiler/parser/parser_char_test.go similarity index 90% rename from parser/parser_char_test.go rename to compiler/parser/parser_char_test.go index 0627342..a36c8ba 100644 --- a/parser/parser_char_test.go +++ b/compiler/parser/parser_char_test.go @@ -3,7 +3,7 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" + "github.com/d5/tengo/compiler/ast" ) func TestChar(t *testing.T) { diff --git a/parser/parser_for_in_test.go b/compiler/parser/parser_for_in_test.go similarity index 97% rename from parser/parser_for_in_test.go rename to compiler/parser/parser_for_in_test.go index 9893b3c..9f40cb8 100644 --- a/parser/parser_for_in_test.go +++ b/compiler/parser/parser_for_in_test.go @@ -3,7 +3,7 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" + "github.com/d5/tengo/compiler/ast" ) func TestForIn(t *testing.T) { diff --git a/parser/parser_for_test.go b/compiler/parser/parser_for_test.go similarity index 96% rename from parser/parser_for_test.go rename to compiler/parser/parser_for_test.go index 641680e..52cffd4 100644 --- a/parser/parser_for_test.go +++ b/compiler/parser/parser_for_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestFor(t *testing.T) { diff --git a/parser/parser_function_test.go b/compiler/parser/parser_function_test.go similarity index 93% rename from parser/parser_function_test.go rename to compiler/parser/parser_function_test.go index 569c9af..dd6f74e 100644 --- a/parser/parser_function_test.go +++ b/compiler/parser/parser_function_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestFunction(t *testing.T) { diff --git a/parser/parser_if_test.go b/compiler/parser/parser_if_test.go similarity index 98% rename from parser/parser_if_test.go rename to compiler/parser/parser_if_test.go index 1407167..db4fe85 100644 --- a/parser/parser_if_test.go +++ b/compiler/parser/parser_if_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestIf(t *testing.T) { diff --git a/parser/parser_index_test.go b/compiler/parser/parser_index_test.go similarity index 96% rename from parser/parser_index_test.go rename to compiler/parser/parser_index_test.go index badb9d8..176c023 100644 --- a/parser/parser_index_test.go +++ b/compiler/parser/parser_index_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestIndex(t *testing.T) { diff --git a/parser/parser_logical_test.go b/compiler/parser/parser_logical_test.go similarity index 92% rename from parser/parser_logical_test.go rename to compiler/parser/parser_logical_test.go index 511593a..2a2bdd4 100644 --- a/parser/parser_logical_test.go +++ b/compiler/parser/parser_logical_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestLogical(t *testing.T) { diff --git a/parser/parser_map_test.go b/compiler/parser/parser_map_test.go similarity index 96% rename from parser/parser_map_test.go rename to compiler/parser/parser_map_test.go index 25d7bb5..f39ba17 100644 --- a/parser/parser_map_test.go +++ b/compiler/parser/parser_map_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestMap(t *testing.T) { diff --git a/parser/parser_precendence_test.go b/compiler/parser/parser_precendence_test.go similarity index 100% rename from parser/parser_precendence_test.go rename to compiler/parser/parser_precendence_test.go diff --git a/parser/parser_selector_test.go b/compiler/parser/parser_selector_test.go similarity index 98% rename from parser/parser_selector_test.go rename to compiler/parser/parser_selector_test.go index 7fd2fc4..be6f62f 100644 --- a/parser/parser_selector_test.go +++ b/compiler/parser/parser_selector_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestSelector(t *testing.T) { diff --git a/parser/parser_semicolon_test.go b/compiler/parser/parser_semicolon_test.go similarity index 95% rename from parser/parser_semicolon_test.go rename to compiler/parser/parser_semicolon_test.go index 88742e1..b69e5a1 100644 --- a/parser/parser_semicolon_test.go +++ b/compiler/parser/parser_semicolon_test.go @@ -3,7 +3,7 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" + "github.com/d5/tengo/compiler/ast" ) func TestSemicolon(t *testing.T) { diff --git a/parser/parser_string_test.go b/compiler/parser/parser_string_test.go similarity index 86% rename from parser/parser_string_test.go rename to compiler/parser/parser_string_test.go index 8b6bafd..712a946 100644 --- a/parser/parser_string_test.go +++ b/compiler/parser/parser_string_test.go @@ -3,8 +3,8 @@ package parser_test import ( "testing" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/token" ) func TestString(t *testing.T) { diff --git a/parser/parser_test.go b/compiler/parser/parser_test.go similarity index 99% rename from parser/parser_test.go rename to compiler/parser/parser_test.go index 301091b..42c1d21 100644 --- a/parser/parser_test.go +++ b/compiler/parser/parser_test.go @@ -7,10 +7,10 @@ import ( "testing" "github.com/d5/tengo/assert" - "github.com/d5/tengo/ast" - "github.com/d5/tengo/parser" - "github.com/d5/tengo/source" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/ast" + "github.com/d5/tengo/compiler/parser" + "github.com/d5/tengo/compiler/source" + "github.com/d5/tengo/compiler/token" ) type pfn func(int, int) source.Pos // position conversion function diff --git a/parser/sync.go b/compiler/parser/sync.go similarity index 83% rename from parser/sync.go rename to compiler/parser/sync.go index 9c43618..4d08826 100644 --- a/parser/sync.go +++ b/compiler/parser/sync.go @@ -1,6 +1,6 @@ package parser -import "github.com/d5/tengo/token" +import "github.com/d5/tengo/compiler/token" var stmtStart = map[token.Token]bool{ token.Break: true, diff --git a/scanner/error_handler.go b/compiler/scanner/error_handler.go similarity index 61% rename from scanner/error_handler.go rename to compiler/scanner/error_handler.go index 1cd1f47..baae0ac 100644 --- a/scanner/error_handler.go +++ b/compiler/scanner/error_handler.go @@ -1,5 +1,5 @@ package scanner -import "github.com/d5/tengo/source" +import "github.com/d5/tengo/compiler/source" type ErrorHandler func(pos source.FilePos, msg string) diff --git a/scanner/mode.go b/compiler/scanner/mode.go similarity index 100% rename from scanner/mode.go rename to compiler/scanner/mode.go diff --git a/scanner/scanner.go b/compiler/scanner/scanner.go similarity index 99% rename from scanner/scanner.go rename to compiler/scanner/scanner.go index 5f22fba..5ed9faa 100644 --- a/scanner/scanner.go +++ b/compiler/scanner/scanner.go @@ -5,8 +5,8 @@ import ( "unicode" "unicode/utf8" - "github.com/d5/tengo/source" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/source" + "github.com/d5/tengo/compiler/token" ) // byte order mark diff --git a/scanner/scanner_test.go b/compiler/scanner/scanner_test.go similarity index 98% rename from scanner/scanner_test.go rename to compiler/scanner/scanner_test.go index cce3694..f602819 100644 --- a/scanner/scanner_test.go +++ b/compiler/scanner/scanner_test.go @@ -8,9 +8,9 @@ import ( "time" "github.com/d5/tengo/assert" - "github.com/d5/tengo/scanner" - "github.com/d5/tengo/source" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/scanner" + "github.com/d5/tengo/compiler/source" + "github.com/d5/tengo/compiler/token" ) var testFileSet = source.NewFileSet() diff --git a/source/file.go b/compiler/source/file.go similarity index 100% rename from source/file.go rename to compiler/source/file.go diff --git a/source/file_pos.go b/compiler/source/file_pos.go similarity index 100% rename from source/file_pos.go rename to compiler/source/file_pos.go diff --git a/source/file_set.go b/compiler/source/file_set.go similarity index 100% rename from source/file_set.go rename to compiler/source/file_set.go diff --git a/source/pos.go b/compiler/source/pos.go similarity index 100% rename from source/pos.go rename to compiler/source/pos.go diff --git a/token/keywords.go b/compiler/token/keywords.go similarity index 100% rename from token/keywords.go rename to compiler/token/keywords.go diff --git a/token/tokens.go b/compiler/token/tokens.go similarity index 100% rename from token/tokens.go rename to compiler/token/tokens.go diff --git a/objects/array.go b/objects/array.go index 4b6f55d..27663ce 100644 --- a/objects/array.go +++ b/objects/array.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/token" ) type Array struct { diff --git a/objects/bool.go b/objects/bool.go index 88ff024..ef0b025 100644 --- a/objects/bool.go +++ b/objects/bool.go @@ -1,7 +1,7 @@ package objects import ( - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/token" ) type Bool struct { diff --git a/objects/break.go b/objects/break.go index 2af3907..deedfb7 100644 --- a/objects/break.go +++ b/objects/break.go @@ -1,6 +1,6 @@ package objects -import "github.com/d5/tengo/token" +import "github.com/d5/tengo/compiler/token" type Break struct{} diff --git a/objects/builtin_function.go b/objects/builtin_function.go index fb83454..847c885 100644 --- a/objects/builtin_function.go +++ b/objects/builtin_function.go @@ -1,7 +1,7 @@ package objects import ( - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/token" ) type BuiltinFunction struct { diff --git a/objects/char.go b/objects/char.go index 340e3c5..183d543 100644 --- a/objects/char.go +++ b/objects/char.go @@ -1,7 +1,7 @@ package objects import ( - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/token" ) type Char struct { diff --git a/objects/closure.go b/objects/closure.go index b288a5a..15eaffe 100644 --- a/objects/closure.go +++ b/objects/closure.go @@ -1,7 +1,7 @@ package objects import ( - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/token" ) type Closure struct { diff --git a/objects/compiled_function.go b/objects/compiled_function.go index 940226c..92e9185 100644 --- a/objects/compiled_function.go +++ b/objects/compiled_function.go @@ -1,7 +1,7 @@ package objects import ( - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/token" ) type CompiledFunction struct { diff --git a/objects/continue.go b/objects/continue.go index 60ac895..2337d76 100644 --- a/objects/continue.go +++ b/objects/continue.go @@ -1,6 +1,6 @@ package objects -import "github.com/d5/tengo/token" +import "github.com/d5/tengo/compiler/token" type Continue struct { } diff --git a/objects/float.go b/objects/float.go index ecbe8a4..1558e29 100644 --- a/objects/float.go +++ b/objects/float.go @@ -4,7 +4,7 @@ import ( "math" "strconv" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/token" ) type Float struct { diff --git a/objects/int.go b/objects/int.go index 3421455..fb583c6 100644 --- a/objects/int.go +++ b/objects/int.go @@ -3,7 +3,7 @@ package objects import ( "strconv" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/token" ) type Int struct { diff --git a/objects/iterator.go b/objects/iterator.go index 3d61ecf..425555b 100644 --- a/objects/iterator.go +++ b/objects/iterator.go @@ -1,6 +1,6 @@ package objects -import "github.com/d5/tengo/token" +import "github.com/d5/tengo/compiler/token" type Iterator interface { Object diff --git a/objects/map.go b/objects/map.go index a0eab33..fc95ca9 100644 --- a/objects/map.go +++ b/objects/map.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/token" ) type Map struct { diff --git a/objects/object.go b/objects/object.go index 8ddd2ca..5837e6a 100644 --- a/objects/object.go +++ b/objects/object.go @@ -1,6 +1,6 @@ package objects -import "github.com/d5/tengo/token" +import "github.com/d5/tengo/compiler/token" type Object interface { TypeName() string diff --git a/objects/return_value.go b/objects/return_value.go index 3f59e57..d936370 100644 --- a/objects/return_value.go +++ b/objects/return_value.go @@ -1,6 +1,6 @@ package objects -import "github.com/d5/tengo/token" +import "github.com/d5/tengo/compiler/token" type ReturnValue struct { Value Object diff --git a/objects/string.go b/objects/string.go index 0cba8e3..672bdbb 100644 --- a/objects/string.go +++ b/objects/string.go @@ -3,7 +3,7 @@ package objects import ( "fmt" - "github.com/d5/tengo/token" + "github.com/d5/tengo/compiler/token" ) type String struct { diff --git a/objects/undefined.go b/objects/undefined.go index d77054b..4d69d07 100644 --- a/objects/undefined.go +++ b/objects/undefined.go @@ -1,6 +1,6 @@ package objects -import "github.com/d5/tengo/token" +import "github.com/d5/tengo/compiler/token" var undefined = &Undefined{} diff --git a/vm/errors.go b/runtime/errors.go similarity index 82% rename from vm/errors.go rename to runtime/errors.go index 1ff2780..d29a194 100644 --- a/vm/errors.go +++ b/runtime/errors.go @@ -1,4 +1,4 @@ -package vm +package runtime import ( "errors" diff --git a/vm/frame.go b/runtime/frame.go similarity index 91% rename from vm/frame.go rename to runtime/frame.go index 8e427e8..f7c3017 100644 --- a/vm/frame.go +++ b/runtime/frame.go @@ -1,4 +1,4 @@ -package vm +package runtime import ( "github.com/d5/tengo/objects" diff --git a/vm/vm.go b/runtime/vm.go similarity index 99% rename from vm/vm.go rename to runtime/vm.go index a087e6e..9f0d311 100644 --- a/vm/vm.go +++ b/runtime/vm.go @@ -1,11 +1,11 @@ -package vm +package runtime import ( "fmt" "github.com/d5/tengo/compiler" + "github.com/d5/tengo/compiler/token" "github.com/d5/tengo/objects" - "github.com/d5/tengo/token" ) const ( diff --git a/vm/vm_array_test.go b/runtime/vm_array_test.go similarity index 98% rename from vm/vm_array_test.go rename to runtime/vm_array_test.go index 3163560..d8ba8d0 100644 --- a/vm/vm_array_test.go +++ b/runtime/vm_array_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_assignment_test.go b/runtime/vm_assignment_test.go similarity index 95% rename from vm/vm_assignment_test.go rename to runtime/vm_assignment_test.go index a2e0bbd..cb475cc 100644 --- a/vm/vm_assignment_test.go +++ b/runtime/vm_assignment_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" @@ -193,8 +193,8 @@ out = func() { `, 136) // assigning different type value - expect(t, `a := 1; a = "foo"; out = a`, "foo") // global - expect(t, `func() { a := 1; a = "foo"; out = a }()`, "foo") // local + expect(t, `a := 1; a = "foo"; out = a`, "foo") // global + expect(t, `func() { a := 1; a = "foo"; out = a }()`, "foo") // local expect(t, ` out = func() { a := 5 diff --git a/vm/vm_bitwise_test.go b/runtime/vm_bitwise_test.go similarity index 97% rename from vm/vm_bitwise_test.go rename to runtime/vm_bitwise_test.go index 71801dd..ab87b37 100644 --- a/vm/vm_bitwise_test.go +++ b/runtime/vm_bitwise_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import "testing" diff --git a/vm/vm_boolean_test.go b/runtime/vm_boolean_test.go similarity index 97% rename from vm/vm_boolean_test.go rename to runtime/vm_boolean_test.go index 8c33e31..7fb2fa6 100644 --- a/vm/vm_boolean_test.go +++ b/runtime/vm_boolean_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_builtin_test.go b/runtime/vm_builtin_test.go similarity index 99% rename from vm/vm_builtin_test.go rename to runtime/vm_builtin_test.go index aa2f028..4d75a81 100644 --- a/vm/vm_builtin_test.go +++ b/runtime/vm_builtin_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_call_test.go b/runtime/vm_call_test.go similarity index 95% rename from vm/vm_call_test.go rename to runtime/vm_call_test.go index ca00199..2e3c318 100644 --- a/vm/vm_call_test.go +++ b/runtime/vm_call_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import "testing" diff --git a/vm/vm_char_test.go b/runtime/vm_char_test.go similarity index 88% rename from vm/vm_char_test.go rename to runtime/vm_char_test.go index a14f327..b815a60 100644 --- a/vm/vm_char_test.go +++ b/runtime/vm_char_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import "testing" diff --git a/vm/vm_equality_test.go b/runtime/vm_equality_test.go similarity index 98% rename from vm/vm_equality_test.go rename to runtime/vm_equality_test.go index 4bb2cf5..e61fab2 100644 --- a/vm/vm_equality_test.go +++ b/runtime/vm_equality_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "fmt" diff --git a/vm/vm_error_test.go b/runtime/vm_error_test.go similarity index 96% rename from vm/vm_error_test.go rename to runtime/vm_error_test.go index 77b0868..dd80aca 100644 --- a/vm/vm_error_test.go +++ b/runtime/vm_error_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_float_test.go b/runtime/vm_float_test.go similarity index 93% rename from vm/vm_float_test.go rename to runtime/vm_float_test.go index 111e578..fa5abb5 100644 --- a/vm/vm_float_test.go +++ b/runtime/vm_float_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_for_in_test.go b/runtime/vm_for_in_test.go similarity index 96% rename from vm/vm_for_in_test.go rename to runtime/vm_for_in_test.go index dd86f05..4bca8b2 100644 --- a/vm/vm_for_in_test.go +++ b/runtime/vm_for_in_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_for_test.go b/runtime/vm_for_test.go similarity index 97% rename from vm/vm_for_test.go rename to runtime/vm_for_test.go index 3bcaf9b..7883a56 100644 --- a/vm/vm_for_test.go +++ b/runtime/vm_for_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_function_test.go b/runtime/vm_function_test.go similarity index 99% rename from vm/vm_function_test.go rename to runtime/vm_function_test.go index 3f3ee5f..e541700 100644 --- a/vm/vm_function_test.go +++ b/runtime/vm_function_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_if_test.go b/runtime/vm_if_test.go similarity index 98% rename from vm/vm_if_test.go rename to runtime/vm_if_test.go index 288bcb8..34ab117 100644 --- a/vm/vm_if_test.go +++ b/runtime/vm_if_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_inc_dec_test.go b/runtime/vm_inc_dec_test.go similarity index 95% rename from vm/vm_inc_dec_test.go rename to runtime/vm_inc_dec_test.go index 389c388..5bf8702 100644 --- a/vm/vm_inc_dec_test.go +++ b/runtime/vm_inc_dec_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_integer_test.go b/runtime/vm_integer_test.go similarity index 97% rename from vm/vm_integer_test.go rename to runtime/vm_integer_test.go index 4f90d0e..51afdc3 100644 --- a/vm/vm_integer_test.go +++ b/runtime/vm_integer_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_logic_test.go b/runtime/vm_logic_test.go similarity index 98% rename from vm/vm_logic_test.go rename to runtime/vm_logic_test.go index c80af98..8bd053a 100644 --- a/vm/vm_logic_test.go +++ b/runtime/vm_logic_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import "testing" diff --git a/vm/vm_map_test.go b/runtime/vm_map_test.go similarity index 97% rename from vm/vm_map_test.go rename to runtime/vm_map_test.go index e76e394..740d559 100644 --- a/vm/vm_map_test.go +++ b/runtime/vm_map_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_not_operator_test.go b/runtime/vm_not_operator_test.go similarity index 93% rename from vm/vm_not_operator_test.go rename to runtime/vm_not_operator_test.go index 2bca70b..b7028c9 100644 --- a/vm/vm_not_operator_test.go +++ b/runtime/vm_not_operator_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_return_test.go b/runtime/vm_return_test.go similarity index 95% rename from vm/vm_return_test.go rename to runtime/vm_return_test.go index 133e33e..9e6d686 100644 --- a/vm/vm_return_test.go +++ b/runtime/vm_return_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_selector_test.go b/runtime/vm_selector_test.go similarity index 99% rename from vm/vm_selector_test.go rename to runtime/vm_selector_test.go index c87a206..9410773 100644 --- a/vm/vm_selector_test.go +++ b/runtime/vm_selector_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_string_test.go b/runtime/vm_string_test.go similarity index 97% rename from vm/vm_string_test.go rename to runtime/vm_string_test.go index 6e2e9cd..11d6f44 100644 --- a/vm/vm_string_test.go +++ b/runtime/vm_string_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import ( "testing" diff --git a/vm/vm_tail_call_test.go b/runtime/vm_tail_call_test.go similarity index 98% rename from vm/vm_tail_call_test.go rename to runtime/vm_tail_call_test.go index 12fe470..9a767b5 100644 --- a/vm/vm_tail_call_test.go +++ b/runtime/vm_tail_call_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import "testing" diff --git a/vm/vm_test.go b/runtime/vm_test.go similarity index 94% rename from vm/vm_test.go rename to runtime/vm_test.go index 43c4cc6..0870beb 100644 --- a/vm/vm_test.go +++ b/runtime/vm_test.go @@ -1,20 +1,20 @@ -package vm_test +package runtime_test import ( "errors" "fmt" "reflect" - "runtime" + _runtime "runtime" "strings" "testing" "github.com/d5/tengo/assert" - "github.com/d5/tengo/ast" "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/parser" - "github.com/d5/tengo/source" - "github.com/d5/tengo/vm" + "github.com/d5/tengo/runtime" ) const ( @@ -130,7 +130,7 @@ func (o *tracer) Write(p []byte) (n int, err error) { } func traceCompileRun(file *ast.File, symbols map[string]objects.Object) (res map[string]objects.Object, trace []string, err error) { - var v *vm.VM + var v *runtime.VM defer func() { if e := recover(); e != nil { @@ -139,7 +139,7 @@ func traceCompileRun(file *ast.File, symbols map[string]objects.Object) (res map // stack trace var stackTrace []string for i := 2; ; i += 1 { - _, file, line, ok := runtime.Caller(i) + _, file, line, ok := _runtime.Caller(i) if !ok { break } @@ -156,7 +156,7 @@ func traceCompileRun(file *ast.File, symbols map[string]objects.Object) (res map } }() - globals := make([]*objects.Object, vm.GlobalsSize) + globals := make([]*objects.Object, runtime.GlobalsSize) symTable := compiler.NewSymbolTable() for name, value := range symbols { @@ -187,7 +187,7 @@ func traceCompileRun(file *ast.File, symbols map[string]objects.Object) (res map trace = append(trace, fmt.Sprintf("\n[Compiled Constants]\n\n%s", strings.Join(constStr, "\n"))) trace = append(trace, fmt.Sprintf("\n[Compiled Instructions]\n\n%s\n", strings.Join(compiler.FormatInstructions(bytecode.Instructions, 0), "\n"))) - v = vm.NewVM(bytecode, globals) + v = runtime.NewVM(bytecode, globals) err = v.Run() { diff --git a/vm/vm_undefined_test.go b/runtime/vm_undefined_test.go similarity index 94% rename from vm/vm_undefined_test.go rename to runtime/vm_undefined_test.go index 49b796d..4e445b0 100644 --- a/vm/vm_undefined_test.go +++ b/runtime/vm_undefined_test.go @@ -1,4 +1,4 @@ -package vm_test +package runtime_test import "testing" diff --git a/script/compiled.go b/script/compiled.go index d568905..f5d508d 100644 --- a/script/compiled.go +++ b/script/compiled.go @@ -3,7 +3,7 @@ package script import ( "github.com/d5/tengo/compiler" "github.com/d5/tengo/objects" - "github.com/d5/tengo/vm" + "github.com/d5/tengo/runtime" ) var undefined objects.Object = &objects.Undefined{} @@ -12,7 +12,7 @@ var undefined objects.Object = &objects.Undefined{} // Use Script.Compile() to create Compiled object. type Compiled struct { symbolTable *compiler.SymbolTable - machine *vm.VM + machine *runtime.VM } // Run executes the compiled script in the virtual machine. diff --git a/script/script.go b/script/script.go index ad8fc85..5756035 100644 --- a/script/script.go +++ b/script/script.go @@ -4,10 +4,10 @@ import ( "fmt" "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/parser" - "github.com/d5/tengo/source" - "github.com/d5/tengo/vm" + "github.com/d5/tengo/runtime" ) // Script can simplify compilation and execution of embedded scripts. @@ -70,7 +70,7 @@ func (s *Script) Compile() (*Compiled, error) { return &Compiled{ symbolTable: symbolTable, - machine: vm.NewVM(c.Bytecode(), globals), + machine: runtime.NewVM(c.Bytecode(), globals), }, nil } diff --git a/tengo.go b/tengo.go index 24f5e69..58846e5 100644 --- a/tengo.go +++ b/tengo.go @@ -2,9 +2,9 @@ package tengo import ( "github.com/d5/tengo/compiler" - "github.com/d5/tengo/parser" - "github.com/d5/tengo/source" - "github.com/d5/tengo/vm" + "github.com/d5/tengo/compiler/parser" + "github.com/d5/tengo/compiler/source" + "github.com/d5/tengo/runtime" ) func Compile(input []byte, filename string) (*compiler.Bytecode, error) { @@ -25,7 +25,7 @@ func Compile(input []byte, filename string) (*compiler.Bytecode, error) { } func Run(b *compiler.Bytecode) error { - v := vm.NewVM(b, nil) + v := runtime.NewVM(b, nil) return v.Run() }