Skip to content

Commit

Permalink
wdteutil: rename from auto (#187)
Browse files Browse the repository at this point in the history
* wdteutil: Rename from `auto`.

* wdteutil: Remove accidentally included `fmt.Println()` call.

Woops. I wonder how long that's been there for... `git blame` time, I
guess.

* std: Remove some references to scope bounds from the Godoc comments.

* wdte: Update some dependencies.

* wdte: Parallelize the tests.

* multiple: Fix some golint and go vet warnings.
  • Loading branch information
DeedleFake authored Jun 27, 2019
1 parent dbbf4e0 commit 495aa7f
Show file tree
Hide file tree
Showing 22 changed files with 77 additions and 75 deletions.
3 changes: 0 additions & 3 deletions auto/doc.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/pgen/grammar.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (g Grammar) detectAmbiguities() {
}
known := make(map[lookup]struct{}, len(g))

for nterm, _ := range g {
for nterm := range g {
for term, rule := range g.First(nterm) {
if isEpsilon(term) {
continue
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
// manual implementations of Func. If more automatic behavior is
// required, possibly at the cost of some runtime performance,
// functions for automatically wrapping Go functions are provided in
// the auto package.
// the wdteutil package.
//
// One final note: WDTE is lazily-evaluated. Very, very
// lazily-evaluated. Until Go code manually calls a Func
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ require (
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/peterh/liner v1.1.0
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 // indirect
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb h1:fgwFCsaw9buMuxNd6+DQfAuSFqbNiQZpcgJQAgJsK6k=
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
2 changes: 2 additions & 0 deletions std/all/gen.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pkgs=$(cd .. && find . -type d -mindepth 1 | grep -v '\./all')

echo "package $pkgname" > $out
echo >> $out
echo '// Code generated automatically. DO NOT EDIT.' >> $out
echo >> $out
echo "import (" >> $out
for pkg in $pkgs; do
echo " _ \"github.com/DeedleFake/wdte/std/$(echo "$pkg" | cut -c3-)\""
Expand Down
2 changes: 2 additions & 0 deletions std/all/gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions std/arrays/arrays.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"sort"

"github.com/DeedleFake/wdte"
"github.com/DeedleFake/wdte/auto"
"github.com/DeedleFake/wdte/std"
"github.com/DeedleFake/wdte/wdteutil"
)

// Concat is a WDTE function with the following signatures:
Expand All @@ -25,7 +25,7 @@ func Concat(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("concat")

if len(args) < 2 {
return auto.SaveArgs(wdte.GoFunc(Concat), args...)
return wdteutil.SaveArgs(wdte.GoFunc(Concat), args...)
}

array := args[0].Call(frame).(wdte.Array)
Expand All @@ -38,7 +38,7 @@ func Concat(frame wdte.Frame, args ...wdte.Func) wdte.Func {
func sorter(sortFunc func(interface{}, func(int, int) bool)) (f wdte.GoFunc) {
return func(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) < 2 {
return auto.SaveArgs(f, args...)
return wdteutil.SaveArgs(f, args...)
}

var array wdte.Array
Expand Down
14 changes: 7 additions & 7 deletions std/io/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"os"

"github.com/DeedleFake/wdte"
"github.com/DeedleFake/wdte/auto"
"github.com/DeedleFake/wdte/std"
"github.com/DeedleFake/wdte/wdteutil"
)

// These variables are what are returned by the corresponding
Expand Down Expand Up @@ -157,7 +157,7 @@ func Seek(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("seek")

if len(args) < 3 {
return auto.SaveArgsReverse(wdte.GoFunc(Seek), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Seek), args...)
}

s := args[0].Call(frame).(io.Seeker)
Expand Down Expand Up @@ -217,7 +217,7 @@ func Combine(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("combine")

if len(args) < 2 {
return auto.SaveArgs(wdte.GoFunc(Combine), args...)
return wdteutil.SaveArgs(wdte.GoFunc(Combine), args...)
}

switch a0 := args[0].Call(frame).(type) {
Expand Down Expand Up @@ -262,7 +262,7 @@ func Copy(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("copy")

if len(args) < 2 {
return auto.SaveArgs(wdte.GoFunc(Copy), args...)
return wdteutil.SaveArgs(wdte.GoFunc(Copy), args...)
}

var w writer
Expand Down Expand Up @@ -391,7 +391,7 @@ func Scan(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("scan")

if len(args) < 2 {
return auto.SaveArgs(wdte.GoFunc(Scan), args...)
return wdteutil.SaveArgs(wdte.GoFunc(Scan), args...)
}

var r reader
Expand Down Expand Up @@ -484,7 +484,7 @@ func Runes(frame wdte.Frame, args ...wdte.Func) wdte.Func {
func write(f func(io.Writer, interface{}) error) (gf wdte.Func) {
return wdte.GoFunc(func(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) < 2 {
return auto.SaveArgsReverse(gf, args...)
return wdteutil.SaveArgsReverse(gf, args...)
}

var w writer
Expand Down Expand Up @@ -597,7 +597,7 @@ func Panic(frame wdte.Frame, args ...wdte.Func) wdte.Func {
set(args[i])
}
if e == nil {
return auto.SaveArgs(wdte.GoFunc(Panic), args...)
return wdteutil.SaveArgs(wdte.GoFunc(Panic), args...)
}

_, err := fmt.Fprintf(w, "%v%v\n", desc, e)
Expand Down
4 changes: 2 additions & 2 deletions std/rand/rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"math/rand"

"github.com/DeedleFake/wdte"
"github.com/DeedleFake/wdte/auto"
"github.com/DeedleFake/wdte/std"
"github.com/DeedleFake/wdte/std/stream"
"github.com/DeedleFake/wdte/wdteutil"
)

// A Source is a WDTE function that can create successive random
Expand Down Expand Up @@ -109,7 +109,7 @@ func Stream(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("stream")

if len(args) < 2 {
return auto.SaveArgsReverse(wdte.GoFunc(Stream), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Stream), args...)
}

r := args[0].Call(frame).(Source)
Expand Down
33 changes: 15 additions & 18 deletions std/std.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"math"

"github.com/DeedleFake/wdte"
"github.com/DeedleFake/wdte/auto"
"github.com/DeedleFake/wdte/wdteutil"
)

// Plus is a WDTE function with the following signatures:
Expand All @@ -16,7 +16,7 @@ import (
// Returns the sum of a and the rest of its arguments.
func Plus(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 1 {
return auto.SaveArgsReverse(wdte.GoFunc(Plus), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Plus), args...)
}

frame = frame.Sub("+")
Expand All @@ -40,7 +40,7 @@ func Plus(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// Returns a minus b.
func Minus(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 1 {
return auto.SaveArgsReverse(wdte.GoFunc(Minus), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Minus), args...)
}

frame = frame.Sub("-")
Expand All @@ -66,7 +66,7 @@ func Minus(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// Returns the product of a and its other arguments.
func Times(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 1 {
return auto.SaveArgsReverse(wdte.GoFunc(Times), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Times), args...)
}

frame = frame.Sub("*")
Expand All @@ -90,7 +90,7 @@ func Times(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// Returns a divided by b.
func Div(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 1 {
return auto.SaveArgsReverse(wdte.GoFunc(Div), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Div), args...)
}

frame = frame.Sub("/")
Expand All @@ -116,7 +116,7 @@ func Div(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// Returns a mod b.
func Mod(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 1 {
return auto.SaveArgsReverse(wdte.GoFunc(Mod), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Mod), args...)
}

frame = frame.Sub("%")
Expand Down Expand Up @@ -148,7 +148,7 @@ func Mod(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// equality check is used.
func Equals(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 1 {
return auto.SaveArgsReverse(wdte.GoFunc(Equals), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Equals), args...)
}

a1 := args[0].Call(frame)
Expand Down Expand Up @@ -185,7 +185,7 @@ func Equals(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// must support ordering.
func Less(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 1 {
return auto.SaveArgsReverse(wdte.GoFunc(Less), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Less), args...)
}

a1 := args[0].Call(frame)
Expand Down Expand Up @@ -229,7 +229,7 @@ func Less(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// must support ordering.
func Greater(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 1 {
return auto.SaveArgsReverse(wdte.GoFunc(Greater), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Greater), args...)
}

a1 := args[0].Call(frame)
Expand Down Expand Up @@ -273,7 +273,7 @@ func Greater(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// implementation must support ordering.
func LessEqual(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 1 {
return auto.SaveArgsReverse(wdte.GoFunc(LessEqual), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(LessEqual), args...)
}

a1 := args[0].Call(frame)
Expand Down Expand Up @@ -317,7 +317,7 @@ func LessEqual(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// implementation must support ordering.
func GreaterEqual(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 1 {
return auto.SaveArgsReverse(wdte.GoFunc(GreaterEqual), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(GreaterEqual), args...)
}

a1 := args[0].Call(frame)
Expand Down Expand Up @@ -459,7 +459,7 @@ func Len(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// Returns the ith index of a. a is assumed to implement wdte.Atter.
func At(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 1 {
return auto.SaveArgsReverse(wdte.GoFunc(At), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(At), args...)
}

frame = frame.Sub("at")
Expand All @@ -486,8 +486,6 @@ func At(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// collected from executing that compound. The argument must be a
// compound literal or the function will fail. Assigning a compound to
// an ID and then passing that ID will not work.
//
// It surrounds the returned scope with a bound called "collect".
func Collect(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) == 0 {
return wdte.GoFunc(Collect)
Expand Down Expand Up @@ -531,11 +529,10 @@ func Known(frame wdte.Frame, args ...wdte.Func) wdte.Func {
// (sub id val) scope
//
// Sub returns a subscope of scope with the value val bound to the ID
// id. It puts a "collect" lower bound on the scope but does not add
// any upper bounds.
// id.
func Sub(frame wdte.Frame, args ...wdte.Func) wdte.Func {
if len(args) <= 2 {
return auto.SaveArgsReverse(wdte.GoFunc(Sub), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Sub), args...)
}

frame = frame.Sub("sub")
Expand All @@ -558,7 +555,7 @@ func Reflect(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("reflect")

if len(args) < 2 {
return auto.SaveArgsReverse(wdte.GoFunc(Reflect), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Reflect), args...)
}

v := args[0].Call(frame)
Expand Down
12 changes: 6 additions & 6 deletions std/stream/end.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"sort"

"github.com/DeedleFake/wdte"
"github.com/DeedleFake/wdte/auto"
"github.com/DeedleFake/wdte/wdteutil"
)

// end is a special value returned by the function provided to new.
Expand Down Expand Up @@ -121,7 +121,7 @@ func Reduce(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("reduce")

if len(args) < 3 {
return auto.SaveArgsReverse(wdte.GoFunc(Reduce), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Reduce), args...)
}

s := args[0].Call(frame).(Stream)
Expand Down Expand Up @@ -150,7 +150,7 @@ func Fold(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("fold")

if len(args) < 2 {
return auto.SaveArgsReverse(wdte.GoFunc(Fold), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Fold), args...)
}

s := args[0].Call(frame).(Stream)
Expand Down Expand Up @@ -188,7 +188,7 @@ func Extent(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("extent")

if len(args) < 3 {
return auto.SaveArgsReverse(wdte.GoFunc(Extent), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Extent), args...)
}

s := args[0].Call(frame).(Stream)
Expand Down Expand Up @@ -290,7 +290,7 @@ func Any(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("any")

if len(args) < 2 {
return auto.SaveArgsReverse(wdte.GoFunc(Any), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(Any), args...)
}

s := args[0].Call(frame).(Stream)
Expand Down Expand Up @@ -320,7 +320,7 @@ func All(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("all")

if len(args) < 2 {
return auto.SaveArgsReverse(wdte.GoFunc(All), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(All), args...)
}

s := args[0].Call(frame).(Stream)
Expand Down
6 changes: 3 additions & 3 deletions std/stream/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package stream

import (
"github.com/DeedleFake/wdte"
"github.com/DeedleFake/wdte/auto"
"github.com/DeedleFake/wdte/wdteutil"
)

// New is a WDTE function with the following signature:
Expand All @@ -17,7 +17,7 @@ func New(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("new")

if len(args) < 2 {
return auto.SaveArgsReverse(wdte.GoFunc(New), args...)
return wdteutil.SaveArgsReverse(wdte.GoFunc(New), args...)
}

prev := args[0]
Expand Down Expand Up @@ -111,7 +111,7 @@ func Concat(frame wdte.Frame, args ...wdte.Func) wdte.Func {
frame = frame.Sub("concat")

if len(args) < 2 {
return auto.SaveArgs(wdte.GoFunc(Concat), args...)
return wdteutil.SaveArgs(wdte.GoFunc(Concat), args...)
}

var i int
Expand Down
Loading

0 comments on commit 495aa7f

Please sign in to comment.