Compare commits
No commits in common. "1a13c79ee4ef843a3f2a5ea3660b34972661cef7" and "c2adfa3b4669477eb3c51a7236dc9600783f8c3e" have entirely different histories.
1a13c79ee4
...
c2adfa3b46
@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"code.betamike.com/mediocregopher/ginger/gg"
|
"github.com/mediocregopher/ginger/gg"
|
||||||
"code.betamike.com/mediocregopher/ginger/vm"
|
"github.com/mediocregopher/ginger/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
. "code.betamike.com/mediocregopher/ginger/gg/grammar"
|
. "github.com/mediocregopher/ginger/gg/grammar"
|
||||||
"code.betamike.com/mediocregopher/ginger/graph"
|
"github.com/mediocregopher/ginger/graph"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -53,7 +53,9 @@ var (
|
|||||||
Rune('-'),
|
Rune('-'),
|
||||||
positiveNumber,
|
positiveNumber,
|
||||||
func(neg Located[rune], posNum Located[string]) Located[string] {
|
func(neg Located[rune], posNum Located[string]) Located[string] {
|
||||||
return Locate(neg.Location, string(neg.Value)+posNum.Value)
|
return Located[string]{
|
||||||
|
neg.Location, string(neg.Value) + posNum.Value,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,7 +68,7 @@ var (
|
|||||||
panic(fmt.Errorf("parsing %q as int: %w", str, err))
|
panic(fmt.Errorf("parsing %q as int: %w", str, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return Locate(str.Location, Number(i))
|
return Located[Value]{str.Location, Number(i)}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -91,7 +93,7 @@ var (
|
|||||||
for _, r := range tail {
|
for _, r := range tail {
|
||||||
name = append(name, r.Value)
|
name = append(name, r.Value)
|
||||||
}
|
}
|
||||||
return Locate(head.Location, Name(string(name)))
|
return Located[Value]{head.Location, Name(string(name))}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -226,7 +228,7 @@ var graphSym, value = func() (
|
|||||||
gs.g = new(Graph)
|
gs.g = new(Graph)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Locate(r.Location, Value{Graph: gs.g})
|
return Located[Value]{r.Location, Value{Graph: gs.g}}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "code.betamike.com/mediocregopher/ginger/gg/grammar"
|
. "github.com/mediocregopher/ginger/gg/grammar"
|
||||||
"code.betamike.com/mediocregopher/ginger/graph"
|
"github.com/mediocregopher/ginger/graph"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
2
gg/gg.go
2
gg/gg.go
@ -4,7 +4,7 @@ package gg
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"code.betamike.com/mediocregopher/ginger/graph"
|
"github.com/mediocregopher/ginger/graph"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Type aliases for convenience
|
// Type aliases for convenience
|
||||||
|
@ -18,11 +18,6 @@ type Located[T any] struct {
|
|||||||
Value T
|
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
|
// LocatedError is an error related to a specific point within a stream of
|
||||||
// runes.
|
// runes.
|
||||||
type LocatedError Located[error]
|
type LocatedError Located[error]
|
||||||
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
|||||||
module code.betamike.com/mediocregopher/ginger
|
module github.com/mediocregopher/ginger
|
||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ package vm
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"code.betamike.com/mediocregopher/ginger/gg"
|
"github.com/mediocregopher/ginger/gg"
|
||||||
"code.betamike.com/mediocregopher/ginger/graph"
|
"github.com/mediocregopher/ginger/graph"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Function is an entity which accepts an argument Value and performs some
|
// Function is an entity which accepts an argument Value and performs some
|
||||||
|
@ -3,7 +3,7 @@ package vm
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"code.betamike.com/mediocregopher/ginger/gg"
|
"github.com/mediocregopher/ginger/gg"
|
||||||
)
|
)
|
||||||
|
|
||||||
func globalFn(fn func(Value) (Value, error)) Value {
|
func globalFn(fn func(Value) (Value, error)) Value {
|
||||||
|
4
vm/vm.go
4
vm/vm.go
@ -7,8 +7,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.betamike.com/mediocregopher/ginger/gg"
|
"github.com/mediocregopher/ginger/gg"
|
||||||
"code.betamike.com/mediocregopher/ginger/graph"
|
"github.com/mediocregopher/ginger/graph"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ZeroValue is a Value with no fields set. It is equivalent to the 0-tuple.
|
// ZeroValue is a Value with no fields set. It is equivalent to the 0-tuple.
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.betamike.com/mediocregopher/ginger/gg"
|
"github.com/mediocregopher/ginger/gg"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user