From 974e2d208583aaa3529734d45099001bae85f715 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 14 Feb 2021 10:34:24 -0500 Subject: [PATCH] README.md neatens --- go/README.md | 14 +++++++++----- go/build-dsl | 22 +++++++++++++++------- go/go.mod | 3 ++- go/go.sum | 2 ++ go/parser-experiments/one/build | 12 ++++++++---- go/parser-experiments/one/main.go | 4 ++-- go/src/README-old.mv | 6 ------ go/todo.txt | 1 - go/u/tester | 3 +-- 9 files changed, 39 insertions(+), 28 deletions(-) delete mode 100644 go/src/README-old.mv diff --git a/go/README.md b/go/README.md index c9e847d48..0a981febb 100644 --- a/go/README.md +++ b/go/README.md @@ -113,12 +113,16 @@ So, in broad overview, the key packages are: ### Dependencies -* Miller dependencies are all in the Go standard library, except a local one: - * `src/github.com/goccmack` - * GOCC lexer/parser code-generator from [github.com/goccmack/gocc](https://github.com/goccmack/gocc): +* Miller dependencies are all in the Go standard library, except two: + * GOCC lexer/parser code-generator from [github.com/goccmack/gocc](https://github.com/goccmack/gocc): * This package defines the grammar for Miller's domain-specific language (DSL) for the Miller `put` and `filter` verbs. And, GOCC is a joy to use. :) - * Note on the path: `go get github.com/goccmack/gocc` uses this directory path, and is nice enough to also create `bin/gocc` for me -- so I thought I would just let it continue to do that by using that local path. :) -* I kept this locally so I could source-control it along with Miller and guarantee its stability. It is used on the terms of its open-source license. + * It is used on the terms of its open-source license. + * [golang.org/x/term](https://pkg.go.dev/golang.org/x/term): + * Just a one-line Miller callsite for is-a-terminal checking for the [Miller REPL](https://github.com/johnkerl/miller/blob/go-mod/go/src/auxents/repl/README.md). + * It is used on the terms of its open-source license. +* See also [./go.mod](go.mod). Setup: + * `go get github.com/goccmack/gocc` + * `go get golang.org/x/term` ### Miller per se diff --git a/go/build-dsl b/go/build-dsl index 06d1fac18..c6c95641c 100755 --- a/go/build-dsl +++ b/go/build-dsl @@ -2,6 +2,13 @@ # ================================================================ # Reads the Miller DSL grammar file and generates Go code. +# +# This is not run on every build / commit / etc. +# +# It's intended to be run manually by the developer, as needed when mlr.bnf +# changes for example. +# +# Resulting auto-generated .go files should then be checked into source control. # ================================================================ set -euo pipefail @@ -14,18 +21,19 @@ if [ $# -eq 1 ]; then fi # Build the bin/gocc executable: -###### go get github.com/goccmack/gocc -mkdir -p ./bin -#go build github.com/goccmack/gocc -go build github.com/johnkerl/gocc -mv gocc ./bin/ +#go get github.com/goccmack/gocc +go get github.com/johnkerl/gocc +bingocc="$GOPATH/bin/gocc" +if [ ! -x "$bingocc" ]; then + exit 1 +fi rm -f src/parsing/*.txt if [ "$verbose" = "true" ]; then lr1="src/parsing/LR1_conflicts.txt" - ./bin/gocc -v -o ./src/parsing -p miller/src/parsing src/parsing/mlr.bnf || expand -2 $lr1 + $bingocc -v -o ./src/parsing -p miller/src/parsing src/parsing/mlr.bnf || expand -2 $lr1 else - ./bin/gocc -o ./src/parsing -p miller/src/parsing src/parsing/mlr.bnf + $bingocc -o ./src/parsing -p miller/src/parsing src/parsing/mlr.bnf fi # Code-gen directories: diff --git a/go/go.mod b/go/go.mod index 19e80e5a9..9a48e00c9 100644 --- a/go/go.mod +++ b/go/go.mod @@ -3,6 +3,7 @@ module miller go 1.15 require ( - github.com/johnkerl/gocc v0.0.0-20210214145925-018e125fd1ee + github.com/goccmack/gocc v0.0.0-20210201103733-1bd198f09019 // indirect + github.com/johnkerl/gocc v0.0.0-20210214145925-018e125fd1ee // indirect golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf ) diff --git a/go/go.sum b/go/go.sum index 16827bb00..459846a62 100644 --- a/go/go.sum +++ b/go/go.sum @@ -1,3 +1,5 @@ +github.com/goccmack/gocc v0.0.0-20210201103733-1bd198f09019 h1:frVuW4LszXD/AjX9dC1y4I+GwTjZMl6153O2mk/lmHo= +github.com/goccmack/gocc v0.0.0-20210201103733-1bd198f09019/go.mod h1:ZjwYs2UwOh6NiluQ1XCoKNLVECdeFf33rrGEZ+IpNq4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/johnkerl/gocc v0.0.0-20210214145651-3650cede3074 h1:8+mZMwac/qKah1hHAuw1U5I7mqN+uRF+oVZ4ismxcJU= github.com/johnkerl/gocc v0.0.0-20210214145651-3650cede3074/go.mod h1:6oAcMpl/qp57NgiufLc2bISrDa4q12XciKeOCUqdeoU= diff --git a/go/parser-experiments/one/build b/go/parser-experiments/one/build index 57ee44644..706e4bf23 100755 --- a/go/parser-experiments/one/build +++ b/go/parser-experiments/one/build @@ -27,18 +27,22 @@ mkdir -p $dir # ---------------------------------------------------------------- # Run the parser-generator -export GOPATH=$(pwd) # Build the bin/gocc executable: -go get github.com/goccmack/gocc +#go get github.com/goccmack/gocc +go get github.com/johnkerl/gocc +bingocc="$GOPATH/bin/gocc" +if [ ! -x "$bingocc" ]; then + exit 1 +fi rm -f $dir/*.txt if [ "$verbose" = "true" ]; then lr1="$dir/LR1_conflicts.txt" # The -o specifies the package name within the autogen - bin/gocc -v -o $dir $bnf || expand -2 $lr1 + $bingocc -v -o $dir $bnf || expand -2 $lr1 else - bin/gocc -o $dir $bnf + $bingocc -o $dir $bnf fi echo "Parser-autogen OK" diff --git a/go/parser-experiments/one/main.go b/go/parser-experiments/one/main.go index 9842760d0..ded35cba5 100644 --- a/go/parser-experiments/one/main.go +++ b/go/parser-experiments/one/main.go @@ -4,8 +4,8 @@ import ( "fmt" "os" - "experimental/lexer" - "experimental/parser" + "src/experimental/lexer" + "src/experimental/parser" ) func parseOne(input string) { diff --git a/go/src/README-old.mv b/go/src/README-old.mv deleted file mode 100644 index c34e65beb..000000000 --- a/go/src/README-old.mv +++ /dev/null @@ -1,6 +0,0 @@ -* Miller dependencies are all in the Go standard library, except a local one: - * `src/github.com/goccmack` - * GOCC lexer/parser code-generator from [github.com/goccmack/gocc](https://github.com/goccmack/gocc): - * This package defines the grammar for Miller's domain-specific language (DSL) for the Miller `put` and `filter` verbs. And, GOCC is a joy to use. :) - * Note on the path: `go get github.com/goccmack/gocc` uses this directory path, and is nice enough to also create `bin/gocc` for me -- so I thought I would just let it continue to do that by using that local path. :) -* I kept this locally so I could source-control it along with Miller and guarantee its stability. It is used on the terms of its open-source license. diff --git a/go/todo.txt b/go/todo.txt index 7b2bee1ce..799931fd4 100644 --- a/go/todo.txt +++ b/go/todo.txt @@ -7,7 +7,6 @@ TOP OF LIST: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! do go.mod correctly w/ regard to gocc and golang.org/x/term/ - o u/tester neaten? o parser-experiments neaten i go get github.com/johnkerl/gocc@gocc2x.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/go/u/tester b/go/u/tester index 03e7b113b..b6f2ec8c2 100755 --- a/go/u/tester +++ b/go/u/tester @@ -5,8 +5,7 @@ # Note reg-test/run has FAR more test cases # ================================================================ -# go test -v ./... doesn't work since it triggers unready things in -# src/github.com/goccmack +# go test -v ./... doesn't work since it triggers unready things in ./parser-experiments/. go test miller/src/types go test src/dsl/ast_test.go