Compare commits

...

2 Commits

  1. 4
      cmd/eval/main.go
  2. 14
      gg/decoder.go
  3. 4
      gg/decoder_test.go
  4. 2
      gg/gg.go
  5. 5
      gg/grammar/location.go
  6. 2
      go.mod
  7. 4
      vm/function.go
  8. 2
      vm/scope_global.go
  9. 4
      vm/vm.go
  10. 2
      vm/vm_test.go

@ -5,8 +5,8 @@ import (
"fmt"
"os"
"github.com/mediocregopher/ginger/gg"
"github.com/mediocregopher/ginger/vm"
"code.betamike.com/mediocregopher/ginger/gg"
"code.betamike.com/mediocregopher/ginger/vm"
)
func main() {

@ -7,8 +7,8 @@ import (
"strconv"
"unicode"
. "github.com/mediocregopher/ginger/gg/grammar"
"github.com/mediocregopher/ginger/graph"
. "code.betamike.com/mediocregopher/ginger/gg/grammar"
"code.betamike.com/mediocregopher/ginger/graph"
"golang.org/x/exp/slices"
)
@ -53,9 +53,7 @@ var (
Rune('-'),
positiveNumber,
func(neg Located[rune], posNum Located[string]) Located[string] {
return Located[string]{
neg.Location, string(neg.Value) + posNum.Value,
}
return Locate(neg.Location, string(neg.Value)+posNum.Value)
},
)
@ -68,7 +66,7 @@ var (
panic(fmt.Errorf("parsing %q as int: %w", str, err))
}
return Located[Value]{str.Location, Number(i)}
return Locate(str.Location, Number(i))
},
)
)
@ -93,7 +91,7 @@ var (
for _, r := range tail {
name = append(name, r.Value)
}
return Located[Value]{head.Location, Name(string(name))}
return Locate(head.Location, Name(string(name)))
},
)
)
@ -228,7 +226,7 @@ var graphSym, value = func() (
gs.g = new(Graph)
}
return Located[Value]{r.Location, Value{Graph: gs.g}}
return Locate(r.Location, Value{Graph: gs.g})
},
)

@ -5,8 +5,8 @@ import (
"strconv"
"testing"
. "github.com/mediocregopher/ginger/gg/grammar"
"github.com/mediocregopher/ginger/graph"
. "code.betamike.com/mediocregopher/ginger/gg/grammar"
"code.betamike.com/mediocregopher/ginger/graph"
"github.com/stretchr/testify/assert"
)

@ -4,7 +4,7 @@ package gg
import (
"fmt"
"github.com/mediocregopher/ginger/graph"
"code.betamike.com/mediocregopher/ginger/graph"
)
// Type aliases for convenience

@ -18,6 +18,11 @@ type Located[T any] struct {
Value T
}
// Locate returns a Located instance combining the given values.
func Locate[T any](l Location, v T) Located[T] {
return Located[T]{l, v}
}
// LocatedError is an error related to a specific point within a stream of
// runes.
type LocatedError Located[error]

@ -1,4 +1,4 @@
module github.com/mediocregopher/ginger
module code.betamike.com/mediocregopher/ginger
go 1.18

@ -3,8 +3,8 @@ package vm
import (
"fmt"
"github.com/mediocregopher/ginger/gg"
"github.com/mediocregopher/ginger/graph"
"code.betamike.com/mediocregopher/ginger/gg"
"code.betamike.com/mediocregopher/ginger/graph"
)
// Function is an entity which accepts an argument Value and performs some

@ -3,7 +3,7 @@ package vm
import (
"fmt"
"github.com/mediocregopher/ginger/gg"
"code.betamike.com/mediocregopher/ginger/gg"
)
func globalFn(fn func(Value) (Value, error)) Value {

@ -7,8 +7,8 @@ import (
"io"
"strings"
"github.com/mediocregopher/ginger/gg"
"github.com/mediocregopher/ginger/graph"
"code.betamike.com/mediocregopher/ginger/gg"
"code.betamike.com/mediocregopher/ginger/graph"
)
// ZeroValue is a Value with no fields set. It is equivalent to the 0-tuple.

@ -4,7 +4,7 @@ import (
"bytes"
"testing"
"github.com/mediocregopher/ginger/gg"
"code.betamike.com/mediocregopher/ginger/gg"
"github.com/stretchr/testify/assert"
)

Loading…
Cancel
Save