Skip to content

Commit

Permalink
init work for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
ziflex committed Jun 5, 2023
1 parent 38ebb2a commit 9f35ee0
Show file tree
Hide file tree
Showing 14 changed files with 258 additions and 119 deletions.
1 change: 1 addition & 0 deletions pkg/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package compiler

import (
"errors"

"github.com/MontFerret/ferret/pkg/runtime"

"github.com/MontFerret/ferret/pkg/parser"
Expand Down
3 changes: 2 additions & 1 deletion pkg/compiler/compiler_eq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package compiler_test

import (
"context"
runtime2 "github.com/MontFerret/ferret/pkg/runtime"
"testing"

runtime2 "github.com/MontFerret/ferret/pkg/runtime"

. "github.com/smartystreets/goconvey/convey"

"github.com/MontFerret/ferret/pkg/compiler"
Expand Down
19 changes: 19 additions & 0 deletions pkg/compiler/compiler_for_while_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package compiler_test

import (
"testing"

. "github.com/smartystreets/goconvey/convey"

"github.com/MontFerret/ferret/pkg/compiler"
)

func TestForWhile(t *testing.T) {
RunUseCases(t, compiler.New(), []UseCase{
{
"FOR i WHILE false RETURN i",
[]any{},
ShouldEqualJSON,
},
})
}
3 changes: 2 additions & 1 deletion pkg/compiler/compiler_func_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package compiler_test

import (
"github.com/MontFerret/ferret/pkg/compiler"
"testing"

"github.com/MontFerret/ferret/pkg/compiler"
)

func TestFunctionCall(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/compiler/compiler_math_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package compiler_test
import (
"context"
j "encoding/json"
runtime2 "github.com/MontFerret/ferret/pkg/runtime"
"testing"

runtime2 "github.com/MontFerret/ferret/pkg/runtime"

. "github.com/smartystreets/goconvey/convey"

"github.com/MontFerret/ferret/pkg/compiler"
Expand Down
3 changes: 2 additions & 1 deletion pkg/compiler/compiler_member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package compiler_test

import (
"fmt"
"github.com/MontFerret/ferret/pkg/runtime"
"regexp"
"strconv"
"strings"
"testing"

"github.com/MontFerret/ferret/pkg/runtime"

. "github.com/smartystreets/goconvey/convey"

"github.com/MontFerret/ferret/pkg/compiler"
Expand Down
10 changes: 5 additions & 5 deletions pkg/compiler/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const emptyNS = ""
const separator = "::"

type NamespaceContainer struct {
funcs *core.Functions
funcs core.Functions
name string
}

Expand All @@ -26,7 +26,7 @@ func NewRootNamespace() *NamespaceContainer {
return ns
}

func NewNamespace(funcs *core.Functions, name string) *NamespaceContainer {
func NewNamespace(funcs core.Functions, name string) *NamespaceContainer {
return &NamespaceContainer{funcs, strings.ToUpper(name)}
}

Expand Down Expand Up @@ -67,13 +67,13 @@ func (nc *NamespaceContainer) RemoveFunction(name string) {
nc.funcs.Unset(nc.makeFullName(name))
}

func (nc *NamespaceContainer) MustRegisterFunctions(funcs *core.Functions) {
func (nc *NamespaceContainer) MustRegisterFunctions(funcs core.Functions) {
if err := nc.RegisterFunctions(funcs); err != nil {
panic(err)
}
}

func (nc *NamespaceContainer) RegisterFunctions(funcs *core.Functions) error {
func (nc *NamespaceContainer) RegisterFunctions(funcs core.Functions) error {
for _, name := range funcs.Names() {
fun, _ := funcs.Get(name)

Expand Down Expand Up @@ -104,7 +104,7 @@ func (nc *NamespaceContainer) RegisteredFunctions() []string {
return res
}

func (nc *NamespaceContainer) Functions() *core.Functions {
func (nc *NamespaceContainer) Functions() core.Functions {
return nc.funcs
}

Expand Down
Loading

0 comments on commit 9f35ee0

Please sign in to comment.