From ab4f6898c66bee988fb439d9ada7579ec8a30f3e Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 14 Feb 2021 09:41:03 -0500 Subject: [PATCH 1/9] bugfix for default package name when using go-modules mode --- internal/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/config/config.go b/internal/config/config.go index a515d5b7..e712f54f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -212,7 +212,7 @@ func getOutDir(outDirSpec, wd string) string { func defaultPackage(wd string) (string, error) { pkg, parent, err := currentModule() - if err != nil { + if err == nil { pkg = pkg + strings.TrimPrefix(wd, parent) return pkg, nil } From 3650cede3074e582ee8a154f3b6995a600f9a7c5 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 14 Feb 2021 09:56:51 -0500 Subject: [PATCH 2/9] fix up go.mod to point to fork --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index dc54c19a..0eef2c99 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/goccmack/gocc +module github.com/johnkerl/gocc go 1.12 From 018e125fd1ee42481de599d98397ca85f16efb88 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 14 Feb 2021 09:59:25 -0500 Subject: [PATCH 3/9] fix up imports to point to fork --- .github/workflows/build.yaml | 4 +- README.md | 8 +- doc/gocc_user_guide.tex | 104 +++++++++--------- example/astx/ast.bnf | 2 +- example/astx/ast/ast.go | 2 +- example/astx/ast_test.go | 6 +- example/astx/errors/errors.go | 2 +- example/astx/lexer/acttab.go | 2 +- example/astx/lexer/lexer.go | 2 +- example/astx/parser/parser.go | 4 +- example/astx/parser/productionstable.go | 2 +- example/bools/ast/ast.go | 4 +- example/bools/errors/errors.go | 2 +- example/bools/example.bnf | 2 +- example/bools/example_test.go | 6 +- example/bools/lexer/acttab.go | 2 +- example/bools/lexer/lexer.go | 2 +- example/bools/parser/parser.go | 4 +- example/bools/parser/productionstable.go | 2 +- example/calc/calc.bnf | 4 +- example/calc/calc_test.go | 4 +- example/calc/errors/errors.go | 2 +- example/calc/lexer/acttab.go | 2 +- example/calc/lexer/lexer.go | 2 +- example/calc/parser/parser.go | 4 +- example/calc/parser/productionstable.go | 4 +- example/errorrecovery/ast/ast.go | 2 +- example/errorrecovery/er.bnf | 2 +- example/errorrecovery/er_test.go | 8 +- example/errorrecovery/errors/errors.go | 2 +- example/errorrecovery/lexer/acttab.go | 2 +- example/errorrecovery/lexer/lexer.go | 2 +- example/errorrecovery/parser/parser.go | 4 +- .../errorrecovery/parser/productionstable.go | 2 +- example/mail/lexer/acttab.go | 2 +- example/mail/lexer/lexer.go | 2 +- example/mail/parser_test.go | 4 +- example/nolexer/errors/errors.go | 2 +- example/nolexer/nolexer.bnf | 2 +- example/nolexer/nolexer_test.go | 4 +- example/nolexer/parser/parser.go | 4 +- example/nolexer/parser/productionstable.go | 2 +- example/nolexer/scanner/scanner.go | 2 +- example/rr/errors/errors.go | 2 +- example/rr/lexer/acttab.go | 2 +- example/rr/lexer/lexer.go | 2 +- example/rr/parser/parser.go | 4 +- example/rr/rr_test.go | 4 +- example/sr/ast/ast.go | 2 +- example/sr/errors/errors.go | 2 +- example/sr/lexer/acttab.go | 2 +- example/sr/lexer/lexer.go | 2 +- example/sr/parser/parser.go | 4 +- example/sr/parser/productionstable.go | 2 +- example/sr/sr.bnf | 2 +- example/sr/sr_test.go | 6 +- gen.sh | 2 +- go.sum | 4 +- internal/ast/fileheader.go | 2 +- internal/ast/lexcharlit.go | 4 +- internal/ast/lexignoredtokdef.go | 2 +- internal/ast/leximport.go | 2 +- internal/ast/lexregdef.go | 2 +- internal/ast/lexregdefid.go | 2 +- internal/ast/lextokdef.go | 2 +- internal/ast/syntaxbody.go | 2 +- internal/ast/syntaxprod.go | 2 +- internal/ast/syntaxprodid.go | 2 +- internal/ast/syntaxstringlit.go | 2 +- internal/ast/syntaxtokid.go | 2 +- internal/frontend/errors/errors.go | 2 +- internal/frontend/parser/parser.go | 4 +- internal/frontend/parser/parser_ut.go | 4 +- internal/frontend/parser/tables.go | 2 +- .../frontend/parser/tables_uncompressed.go | 2 +- internal/frontend/scanner/scanner.go | 2 +- internal/frontend/scanner/scanner_test.go | 2 +- internal/lexer/gen/golang/acttab.go | 6 +- internal/lexer/gen/golang/asciitable.go | 4 +- internal/lexer/gen/golang/chrranges.go | 2 +- internal/lexer/gen/golang/gen.go | 6 +- internal/lexer/gen/golang/imports.go | 2 +- internal/lexer/gen/golang/lexer.go | 6 +- internal/lexer/gen/golang/transtab.go | 4 +- internal/lexer/items/charrange.go | 2 +- internal/lexer/items/disjunctrangeset.go | 2 +- internal/lexer/items/disjunctrangeset_test.go | 2 +- internal/lexer/items/item.go | 6 +- internal/lexer/items/item_test.go | 2 +- internal/lexer/items/itemlist.go | 4 +- internal/lexer/items/itempos.go | 2 +- internal/lexer/items/itempos_test.go | 2 +- internal/lexer/items/itemset.go | 4 +- internal/lexer/items/itemsets.go | 4 +- internal/lexer/items/testutils_test.go | 8 +- internal/lexer/symbols/charlitsymbols.go | 2 +- internal/lexer/symbols/charrangesymbols.go | 2 +- internal/lexer/symbols/symbols.go | 2 +- internal/parser/first/first.go | 4 +- internal/parser/gen/gen.go | 12 +- internal/parser/gen/golang/action.go | 2 +- internal/parser/gen/golang/actiontable.go | 10 +- internal/parser/gen/golang/errors.go | 2 +- internal/parser/gen/golang/gototable.go | 6 +- internal/parser/gen/golang/parser.go | 10 +- .../parser/gen/golang/productionstable.go | 10 +- internal/parser/lr1/items/item.go | 4 +- internal/parser/lr1/items/itemset.go | 8 +- internal/parser/lr1/items/itemsets.go | 6 +- internal/parser/lr1/items/rowconflicts.go | 2 +- internal/parser/lr1/items/testdata_test.go | 8 +- internal/parser/symbols/symbols.go | 2 +- internal/test/t1/errors/errors.go | 2 +- internal/test/t1/lexer/acttab.go | 2 +- internal/test/t1/lexer/lexer.go | 2 +- internal/test/t1/parser/parser.go | 4 +- internal/test/t1/t1_test.go | 6 +- internal/token/gen/gen.go | 4 +- internal/token/gen/golang/token.go | 4 +- internal/util/gen/gen.go | 2 +- internal/util/gen/golang/litconv.go | 2 +- internal/util/gen/golang/rune.go | 2 +- main.go | 36 +++--- main.go.orig | 38 +++---- spec/gocc2.ebnf | 2 +- 125 files changed, 292 insertions(+), 292 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 672ed27f..616a5934 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,7 +8,7 @@ on: defaults: run: - working-directory: go/src/github.com/goccmack/gocc + working-directory: go/src/github.com/johnkerl/gocc jobs: build: @@ -33,7 +33,7 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 with: - path: go/src/github.com/goccmack/gocc + path: go/src/github.com/johnkerl/gocc - name: Install linter run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.36.0" diff --git a/README.md b/README.md index 6c598a34..eaafa315 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Have a look at [https://github.com/goccmack/gogll](https://github.com/goccmack/gogll) for scannerless GLL parser generation. # Gocc -[![Build Status](https://travis-ci.org/goccmack/gocc.svg?branch=master)](https://travis-ci.org/goccmack/gocc) +[![Build Status](https://travis-ci.org/johnkerl/gocc.svg?branch=master)](https://travis-ci.org/johnkerl/gocc) ## Introduction @@ -20,14 +20,14 @@ For complex applications the user typically uses an abstract syntax tree (AST) t See the [README](example/bools/README) for an included example. -[User Guide (PDF): Learn You a gocc for Great Good](https://raw.githubusercontent.com/goccmack/gocc/master/doc/gocc_user_guide.pdf) (gocc3 user guide will be published shortly) +[User Guide (PDF): Learn You a gocc for Great Good](https://raw.githubusercontent.com/johnkerl/gocc/master/doc/gocc_user_guide.pdf) (gocc3 user guide will be published shortly) ## Installation * First download and Install Go From http://golang.org/ * Setup your GOPATH environment variable. -* Next in your command line run: go get github.com/goccmack/gocc (go get will git clone gocc into GOPATH/src/github.com/goccmack/gocc and run go install) -* Alternatively clone the source: https://github.com/goccmack/gocc . Followed by go install github.com/goccmack/gocc +* Next in your command line run: go get github.com/johnkerl/gocc (go get will git clone gocc into GOPATH/src/github.com/johnkerl/gocc and run go install) +* Alternatively clone the source: https://github.com/johnkerl/gocc . Followed by go install github.com/johnkerl/gocc * Finally make sure that the bin folder where the gocc binary is located is in your PATH environment variable. ## Getting Started diff --git a/doc/gocc_user_guide.tex b/doc/gocc_user_guide.tex index 6ff5c2a1..6d691cba 100644 --- a/doc/gocc_user_guide.tex +++ b/doc/gocc_user_guide.tex @@ -117,17 +117,17 @@ \section{Getting started} \item Install \gocc: \begin{enumerate} - \item In your command line run: \Code{go get github.com/goccmack/gocc/} (go get will git clone gocc into GOPATH/src/github.com/goccmack/gocc and run go install) + \item In your command line run: \Code{go get github.com/johnkerl/gocc/} (go get will git clone gocc into GOPATH/src/github.com/johnkerl/gocc and run go install) or - \item Alternatively clone the repository: \url{https://github.com/goccmack/gocc/archive/master.zip}. Followed by: - \verb|go install github.com/goccmack/gocc|. + \item Alternatively clone the repository: \url{https://github.com/johnkerl/gocc/archive/master.zip}. Followed by: + \verb|go install github.com/johnkerl/gocc|. \end{enumerate} \end{enumerate} - Test your installation by running \verb|make test| from \verb|$GOPATH/src/github.com/goccmack/gocc|. + Test your installation by running \verb|make test| from \verb|$GOPATH/src/github.com/johnkerl/gocc|. \section{How to create and use a parser with gocc} Figure~\ref{fig:hl design} shows the high-level design of a user application, which uses a parser generated with gocc. @@ -174,7 +174,7 @@ \section{First example}\label{sec:first example} The source code of the following example can be found at - \verb|$GOPATH/src/github.com/goccmack/gocc/example/calc| + \verb|$GOPATH/src/github.com/johnkerl/gocc/example/calc| The grammar implements the simple desktop calculator described in~\cite{Dragon Book}. The generated code is both a parser and an interpreter for the calculator. @@ -256,8 +256,8 @@ \section{First example}\label{sec:first example} << import( - "github.com/goccmack/gocc/example/calc/token" - "github.com/goccmack/gocc/example/calc/util" + "github.com/johnkerl/gocc/example/calc/token" + "github.com/johnkerl/gocc/example/calc/util" ) >> @@ -282,7 +282,7 @@ \section{First example}\label{sec:first example} The BNF has two parts: a lexical and a syntax part. Both parts are optional -- gocc can be used to generate only a lexer or only a parser -- but every BNF must have at least a lexical part or a syntax part. This example has both and gocc will generate a lexer, a parser and all the support they require to function. - It declares the imported package \verb|github.com/goccmack/gocc/example/calc/token| (generated by gocc), which will be used in the action expressions of some productions of the grammar. + It declares the imported package \verb|github.com/johnkerl/gocc/example/calc/token| (generated by gocc), which will be used in the action expressions of some productions of the grammar. The lexical part consists of: @@ -350,8 +350,8 @@ \section{First example}\label{sec:first example} package calc import ( - "github.com/goccmack/gocc/example/calc/lexer" - "github.com/goccmack/gocc/example/calc/parser" + "github.com/johnkerl/gocc/example/calc/lexer" + "github.com/johnkerl/gocc/example/calc/parser" "fmt" "testing" ) @@ -400,16 +400,16 @@ \section{First example}\label{sec:first example} \begin{verbatim} > go test -v warning: building out-of-date packages: - github.com/goccmack/gocc/example/calc/token - github.com/goccmack/gocc/example/calc/lexer - github.com/goccmack/gocc/example/calc/errors - github.com/goccmack/gocc/example/calc/parser + github.com/johnkerl/gocc/example/calc/token + github.com/johnkerl/gocc/example/calc/lexer + github.com/johnkerl/gocc/example/calc/errors + github.com/johnkerl/gocc/example/calc/parser installing these packages with 'go test -i' will speed future tests. === RUN Test1 --- PASS: Test1 (0.00 seconds) PASS - ok github.com/goccmack/gocc/example/calc 0.017s + ok github.com/johnkerl/gocc/example/calc 0.017s \end{verbatim} {\em Congratulations!} You have executed your first gocc-generated code. @@ -426,8 +426,8 @@ \section{Commandline syntax}\label{sec:commandline} -debug_parser=false: enable debug logging in parser -h=false: help -no_lexer=false: do not generate a lexer - -o="/Users/marius/goprj/src/github.com/goccmack/gocc": output dir. - -p="github.com/goccmack/gocc": package + -o="/Users/marius/goprj/src/github.com/johnkerl/gocc": output dir. + -p="github.com/johnkerl/gocc": package -u=false: allow unreachable productions -v=false: verbose \end{verbatim} @@ -435,7 +435,7 @@ \section{Commandline syntax}\label{sec:commandline} \section{Example: parsing simple mail addresses} \label{sec:example mail} This example shows how gocc can be used to generate a stand-alone FSA to parse a regular language. The goal is to parse simple mail address specifications like: \verb|mailbox@gmail.com| or \verb|"mail box"@gmail.com|. The source code of the sample can be found at - \verb|$GOPATH/src/github.com/goccmack/gocc/example/mail| + \verb|$GOPATH/src/github.com/johnkerl/gocc/example/mail| \verb|mail.bnf| contains: @@ -493,8 +493,8 @@ \section{Example: parsing simple mail addresses} \label{sec:example mail} package mail import ( - "github.com/goccmack/gocc/example/mail/lexer" - "github.com/goccmack/gocc/example/mail/token" + "github.com/johnkerl/gocc/example/mail/lexer" + "github.com/johnkerl/gocc/example/mail/token" "testing" ) @@ -578,7 +578,7 @@ \section{Handling LR(1) conflicts} \label{sec:lr conflicts} \section{Example: reduce/reduce conflict handling} \label{sec:example rr} The source code of the following example can be found at - \verb|$GOPATH/src/github.com/goccmack/gocc/example/rr| + \verb|$GOPATH/src/github.com/johnkerl/gocc/example/rr| \begin{verbatim} RR : A | B ; @@ -589,7 +589,7 @@ \section{Example: reduce/reduce conflict handling} \label{sec:example rr} \end{verbatim} - When we run \gocc on \verb|$GOPATH/src/github.com/goccmack/gocc/example/rr/rr.bnf| we discover a reduce/reduce conflict: + When we run \gocc on \verb|$GOPATH/src/github.com/johnkerl/gocc/example/rr/rr.bnf| we discover a reduce/reduce conflict: \begin{verbatim} > gocc -v rr.bnf @@ -598,8 +598,8 @@ \section{Example: reduce/reduce conflict handling} \label{sec:example rr} -debug_parser = false -h = false -no_lexer = false --o = /home/src/github.com/goccmack/gocc/example/rr --p = github.com/goccmack/gocc/example/rr +-o = /home/src/github.com/johnkerl/gocc/example/rr +-p = github.com/johnkerl/gocc/example/rr -u = false -v = true Error: 1 LR-1 conflicts @@ -652,7 +652,7 @@ \section{Example: reduce/reduce conflict handling} \label{sec:example rr} \section{Example: Shift/reduce conflict handling} \label{sec:example sr} The source code of the following example can be found at - \verb|$GOPATH/src/github.com/goccmack/gocc/example/sr| + \verb|$GOPATH/src/github.com/johnkerl/gocc/example/sr| It is the classic example of the dangling else in the \Clang: @@ -663,7 +663,7 @@ \section{Example: Shift/reduce conflict handling} \label{sec:example sr} ; \end{verbatim} - When we run \gocc on \verb|$GOPATH/src/github.com/goccmack/gocc/example/sr/sr.bnf| we discover a shift/reduce conflict: + When we run \gocc on \verb|$GOPATH/src/github.com/johnkerl/gocc/example/sr/sr.bnf| we discover a shift/reduce conflict: \begin{verbatim} > gocc -v sr.bnf @@ -702,12 +702,12 @@ \section{Example: Using an AST} \label{sec:example ast} The code for the example can be found at - \verb|$GOPATH/src/github.com/goccmack/gocc/example/astx| + \verb|$GOPATH/src/github.com/johnkerl/gocc/example/astx| The grammar is in \verb|ast.bnf|: \begin{verbatim} - << import "github.com/goccmack/gocc/example/astx/ast" >> + << import "github.com/johnkerl/gocc/example/astx/ast" >> StmtList : Stmt << ast.NewStmtList($0) >> @@ -720,20 +720,20 @@ \section{Example: Using an AST} \label{sec:example ast} \end{verbatim} At the top of the grammar is a file header section containing an import statement for the user-provided package, - \verb|github.com/goccmack/gocc/example/astx/ast|. + \verb|github.com/johnkerl/gocc/example/astx/ast|. The production action expressions will use functions from the package, \verb|ast|. The start production, \verb"StmtList" returns a tuple: \verb|(ast.StmtList, error)|, as we can see from the code of functions \verb|NewStmtList| and \verb|AppendStmt| in - \verb|$GOPATH/src/github.com/goccmack/gocc/example/astx/ast.go|: + \verb|$GOPATH/src/github.com/johnkerl/gocc/example/astx/ast.go|: \begin{verbatim} package ast import( - "github.com/goccmack/gocc/example/astx/token" + "github.com/johnkerl/gocc/example/astx/token" ) type ( @@ -770,7 +770,7 @@ \section{Example: Using an AST} \label{sec:example ast} from the directory - \verb|$GOPATH/src/github.com/goccmack/gocc/example/astx/| + \verb|$GOPATH/src/github.com/johnkerl/gocc/example/astx/| we get the following output: @@ -787,7 +787,7 @@ \section{Example: Using an AST} \label{sec:example ast} expected one of: $ id --- PASS: TestFail (0.00s) PASS - ok github.com/goccmack/gocc/example/astx 0.006s \end{verbatim} + ok github.com/johnkerl/gocc/example/astx 0.006s \end{verbatim} The first test, \verb"TestPass", has a valid input string, \verb|"a b c d e f"|; and parses successfully; and returns the expected StmtList, \verb|[a b c d e f]|. @@ -800,10 +800,10 @@ \section{Example: Parser error recovery} \label{sec:error recovery} We modify the AST example to illustrate error recovery. See: - \verb|$GOPATH/src/github.com/goccmack/gocc/examples/errorrecovery/er.bnf|: + \verb|$GOPATH/src/github.com/johnkerl/gocc/examples/errorrecovery/er.bnf|: \begin{verbatim} - << import "github.com/goccmack/gocc/example/errorrecovery/ast" >> + << import "github.com/johnkerl/gocc/example/errorrecovery/ast" >> StmtList : Stmt << ast.NewStmtList($0) >> @@ -822,18 +822,18 @@ \section{Example: Parser error recovery} \label{sec:error recovery} From the directory, - \verb|$GOPATH/src/github.com/goccmack/gocc/examples/errorrecovery/|, + \verb|$GOPATH/src/github.com/johnkerl/gocc/examples/errorrecovery/|, run \verb|go test| as follows: \begin{verbatim} > go test -v . warning: building out-of-date packages: - github.com/goccmack/gocc/example/errorrecovery/token - github.com/goccmack/gocc/example/errorrecovery/ast - github.com/goccmack/gocc/example/errorrecovery/errors - github.com/goccmack/gocc/example/errorrecovery/parser - github.com/goccmack/gocc/example/errorrecovery/lexer + github.com/johnkerl/gocc/example/errorrecovery/token + github.com/johnkerl/gocc/example/errorrecovery/ast + github.com/johnkerl/gocc/example/errorrecovery/errors + github.com/johnkerl/gocc/example/errorrecovery/parser + github.com/johnkerl/gocc/example/errorrecovery/lexer installing these packages with 'go test -i .' will speed future tests. === RUN TestFail @@ -853,11 +853,11 @@ \section{Example: Parser error recovery} \label{sec:error recovery} f ] --- PASS: TestFail (0.00 seconds) - PASS ok github.com/goccmack/gocc/example/errorrecovery 0.015s + PASS ok github.com/johnkerl/gocc/example/errorrecovery 0.015s \end{verbatim} The test case can be found in \\ - \verb|$GOPATH/src/github.com/goccmack/gocc/examples/errorrecovery/er_test.go|. \\ + \verb|$GOPATH/src/github.com/johnkerl/gocc/examples/errorrecovery/er_test.go|. \\ It calls the parser with input string, \verb|"a b ; d e f"|, which contains an invalid token, \verb|;|. From the \verb|go test| output we see that the parser successfully recovered from the input error and returned a \verb|StmtList| containing an error symbol between \verb|[a| and \verb|d, e, f]|. The \verb|id|, \verb|b|, was lost in the error recovery. \TBDx{Explain exactly why the 'b' was lost.} The errored token was \verb|;| (invalid token) when the parser expected one of \verb|error, $| (end of input) or \verb|id|. @@ -871,19 +871,19 @@ \section{Example: Parser error recovery} \label{sec:error recovery} \item The parser will still return a non-\verb|nil| error value if it encounters an irrecoverable error. \end{enumerate} - See \verb|$GOPATH/src/github.com/goccmack/gocc/examples/errorrecovery/errors/error.go| for the definition of errors.Error. + See \verb|$GOPATH/src/github.com/johnkerl/gocc/examples/errorrecovery/errors/error.go| for the definition of errors.Error. \section{Example: Using another lexer} \label{sec:no lexer} The generation of lexer code can be suppressed with the \verb|no_lexer| option (see section~\ref{sec:commandline}). An example, which uses a hand-written lexer, can be found at: - \verb|$GOPATH/src/github.com/goccmack/gocc/examples/nolexer/nolexer.bnf|: + \verb|$GOPATH/src/github.com/johnkerl/gocc/examples/nolexer/nolexer.bnf|: \begin{verbatim} << import ( "fmt" - "github.com/goccmack/gocc/example/nolexer/token" + "github.com/johnkerl/gocc/example/nolexer/token" ) >> @@ -903,7 +903,7 @@ \section{Example: Using another lexer} \label{sec:no lexer} This grammar contains no lexical productions. We generate code for it using - \verb|$GOPATH/src/github.com/goccmack/gocc/examples/nolexer/gen.sh|: + \verb|$GOPATH/src/github.com/johnkerl/gocc/examples/nolexer/gen.sh|: \verb|gocc -no_lexer nolexer.bnf| @@ -931,7 +931,7 @@ \section{Example: Using another lexer} \label{sec:no lexer} Note the absence of a \verb|lexer| directory. Instead there is a hand-written scanner in - \verb|$GOPATH/src/github.com/goccmack/gocc/examples/nolexer/scanner/scanner.go| + \verb|$GOPATH/src/github.com/johnkerl/gocc/examples/nolexer/scanner/scanner.go| The scanner implements the interface: @@ -939,11 +939,11 @@ \section{Example: Using another lexer} \label{sec:no lexer} which is declared in the generated parser: - \verb|$GOPATH/src/github.com/goccmack/gocc/examples/nolexer/parser/parser.go|. + \verb|$GOPATH/src/github.com/johnkerl/gocc/examples/nolexer/parser/parser.go|. The scanner must recognise the tokens required by the parser generated from the BNF. They are declared in a \verb|TokenMap| in - \verb|$GOPATH/src/github.com/goccmack/gocc/examples/nolexer/token/token.go|: + \verb|$GOPATH/src/github.com/johnkerl/gocc/examples/nolexer/token/token.go|: \lstinputlisting[numbers=left,linerange=59-75,firstnumber=59]{../example/nolexer/token/token.go} @@ -955,13 +955,13 @@ \section{Example: Using another lexer} \label{sec:no lexer} Any lexeme not matching a valid terminal symbol of the grammar must be returned as \verb|INVALID|. - \verb|$GOPATH/src/github.com/goccmack/gocc/examples/nolexer/scanner/scanner.go| implements a lexical analyser for this grammar as follows: + \verb|$GOPATH/src/github.com/johnkerl/gocc/examples/nolexer/scanner/scanner.go| implements a lexical analyser for this grammar as follows: \lstinputlisting[numbers=left]{../example/nolexer/scanner/scanner.go} Examples of using the generated parser with the hand-written scanner are given in - \verb|$GOPATH/src/github.com/goccmack/gocc/examples/nolexer/nolexer_test.go| + \verb|$GOPATH/src/github.com/johnkerl/gocc/examples/nolexer/nolexer_test.go| \section{gocc syntax}\label{sec:gocc syntax} A gocc source file contains UTF-8 encoded Unicode text. diff --git a/example/astx/ast.bnf b/example/astx/ast.bnf index d5d77fb1..7b39e185 100644 --- a/example/astx/ast.bnf +++ b/example/astx/ast.bnf @@ -12,7 +12,7 @@ id : (_letter | '_') {_idchar} ; /* Syntax elements */ -<< import "github.com/goccmack/gocc/example/astx/ast" >> +<< import "github.com/johnkerl/gocc/example/astx/ast" >> StmtList : Stmt << ast.NewStmtList($0) >> diff --git a/example/astx/ast/ast.go b/example/astx/ast/ast.go index de638d91..cb24ab8d 100644 --- a/example/astx/ast/ast.go +++ b/example/astx/ast/ast.go @@ -1,7 +1,7 @@ package ast import ( - "github.com/goccmack/gocc/example/astx/token" + "github.com/johnkerl/gocc/example/astx/token" ) type ( diff --git a/example/astx/ast_test.go b/example/astx/ast_test.go index 7f13766b..1ef90852 100644 --- a/example/astx/ast_test.go +++ b/example/astx/ast_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "github.com/goccmack/gocc/example/astx/ast" - "github.com/goccmack/gocc/example/astx/lexer" - "github.com/goccmack/gocc/example/astx/parser" + "github.com/johnkerl/gocc/example/astx/ast" + "github.com/johnkerl/gocc/example/astx/lexer" + "github.com/johnkerl/gocc/example/astx/parser" ) func TestPass(t *testing.T) { diff --git a/example/astx/errors/errors.go b/example/astx/errors/errors.go index 640214b0..882f96a4 100755 --- a/example/astx/errors/errors.go +++ b/example/astx/errors/errors.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/example/astx/token" + "github.com/johnkerl/gocc/example/astx/token" ) type ErrorSymbol interface { diff --git a/example/astx/lexer/acttab.go b/example/astx/lexer/acttab.go index 6f9994fb..cabec999 100755 --- a/example/astx/lexer/acttab.go +++ b/example/astx/lexer/acttab.go @@ -5,7 +5,7 @@ package lexer import ( "fmt" - "github.com/goccmack/gocc/example/astx/token" + "github.com/johnkerl/gocc/example/astx/token" ) type ActionTable [NumStates]ActionRow diff --git a/example/astx/lexer/lexer.go b/example/astx/lexer/lexer.go index acc0bda1..c3276b18 100755 --- a/example/astx/lexer/lexer.go +++ b/example/astx/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "unicode/utf8" - "github.com/goccmack/gocc/example/astx/token" + "github.com/johnkerl/gocc/example/astx/token" ) const ( diff --git a/example/astx/parser/parser.go b/example/astx/parser/parser.go index e02ff1f9..21b2f6de 100755 --- a/example/astx/parser/parser.go +++ b/example/astx/parser/parser.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - parseError "github.com/goccmack/gocc/example/astx/errors" - "github.com/goccmack/gocc/example/astx/token" + parseError "github.com/johnkerl/gocc/example/astx/errors" + "github.com/johnkerl/gocc/example/astx/token" ) const ( diff --git a/example/astx/parser/productionstable.go b/example/astx/parser/productionstable.go index 2f58c675..9916d2b4 100755 --- a/example/astx/parser/productionstable.go +++ b/example/astx/parser/productionstable.go @@ -2,7 +2,7 @@ package parser -import "github.com/goccmack/gocc/example/astx/ast" +import "github.com/johnkerl/gocc/example/astx/ast" type ( ProdTab [numProductions]ProdTabEntry diff --git a/example/bools/ast/ast.go b/example/bools/ast/ast.go index ac4e6b00..76ae8bb9 100644 --- a/example/bools/ast/ast.go +++ b/example/bools/ast/ast.go @@ -18,8 +18,8 @@ import ( "strconv" "strings" - "github.com/goccmack/gocc/example/bools/token" - "github.com/goccmack/gocc/example/bools/util" + "github.com/johnkerl/gocc/example/bools/token" + "github.com/johnkerl/gocc/example/bools/util" ) type Attrib interface{} diff --git a/example/bools/errors/errors.go b/example/bools/errors/errors.go index f5b52772..3aa59029 100755 --- a/example/bools/errors/errors.go +++ b/example/bools/errors/errors.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/example/bools/token" + "github.com/johnkerl/gocc/example/bools/token" ) type ErrorSymbol interface { diff --git a/example/bools/example.bnf b/example/bools/example.bnf index b800d3f9..c5c08150 100644 --- a/example/bools/example.bnf +++ b/example/bools/example.bnf @@ -20,7 +20,7 @@ string_lit : '"' {.} '"' ; !whitespace : ' ' | '\t' | '\n' | '\r' ; -<> +<> BoolExpr : BoolExpr1 << $0, nil >> diff --git a/example/bools/example_test.go b/example/bools/example_test.go index 64a16345..004e8b08 100644 --- a/example/bools/example_test.go +++ b/example/bools/example_test.go @@ -17,9 +17,9 @@ package example import ( "testing" - "github.com/goccmack/gocc/example/bools/ast" - "github.com/goccmack/gocc/example/bools/lexer" - "github.com/goccmack/gocc/example/bools/parser" + "github.com/johnkerl/gocc/example/bools/ast" + "github.com/johnkerl/gocc/example/bools/lexer" + "github.com/johnkerl/gocc/example/bools/parser" ) func testEval(t *testing.T, exampleStr string, output bool) { diff --git a/example/bools/lexer/acttab.go b/example/bools/lexer/acttab.go index 0ad87756..47c5136c 100755 --- a/example/bools/lexer/acttab.go +++ b/example/bools/lexer/acttab.go @@ -5,7 +5,7 @@ package lexer import ( "fmt" - "github.com/goccmack/gocc/example/bools/token" + "github.com/johnkerl/gocc/example/bools/token" ) type ActionTable [NumStates]ActionRow diff --git a/example/bools/lexer/lexer.go b/example/bools/lexer/lexer.go index 7a9808e9..bdf236c8 100755 --- a/example/bools/lexer/lexer.go +++ b/example/bools/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "unicode/utf8" - "github.com/goccmack/gocc/example/bools/token" + "github.com/johnkerl/gocc/example/bools/token" ) const ( diff --git a/example/bools/parser/parser.go b/example/bools/parser/parser.go index e2074579..e1b4e5cc 100755 --- a/example/bools/parser/parser.go +++ b/example/bools/parser/parser.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - parseError "github.com/goccmack/gocc/example/bools/errors" - "github.com/goccmack/gocc/example/bools/token" + parseError "github.com/johnkerl/gocc/example/bools/errors" + "github.com/johnkerl/gocc/example/bools/token" ) const ( diff --git a/example/bools/parser/productionstable.go b/example/bools/parser/productionstable.go index 7ee35c02..b0a2fe65 100755 --- a/example/bools/parser/productionstable.go +++ b/example/bools/parser/productionstable.go @@ -3,7 +3,7 @@ package parser import ( - "github.com/goccmack/gocc/example/bools/ast" + "github.com/johnkerl/gocc/example/bools/ast" ) type ( diff --git a/example/calc/calc.bnf b/example/calc/calc.bnf index d9469b05..71d81279 100644 --- a/example/calc/calc.bnf +++ b/example/calc/calc.bnf @@ -10,8 +10,8 @@ int64 : '1'-'9' {_digit} ; << import( - "github.com/goccmack/gocc/example/calc/token" - "github.com/goccmack/gocc/example/calc/util" + "github.com/johnkerl/gocc/example/calc/token" + "github.com/johnkerl/gocc/example/calc/util" ) >> diff --git a/example/calc/calc_test.go b/example/calc/calc_test.go index cc0288f4..9bb9317f 100644 --- a/example/calc/calc_test.go +++ b/example/calc/calc_test.go @@ -3,8 +3,8 @@ package calc import ( "testing" - "github.com/goccmack/gocc/example/calc/lexer" - "github.com/goccmack/gocc/example/calc/parser" + "github.com/johnkerl/gocc/example/calc/lexer" + "github.com/johnkerl/gocc/example/calc/parser" ) type TI struct { diff --git a/example/calc/errors/errors.go b/example/calc/errors/errors.go index 44b2ffc7..460a51b3 100755 --- a/example/calc/errors/errors.go +++ b/example/calc/errors/errors.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/example/calc/token" + "github.com/johnkerl/gocc/example/calc/token" ) type ErrorSymbol interface { diff --git a/example/calc/lexer/acttab.go b/example/calc/lexer/acttab.go index 1068fb15..a4bd6a2b 100755 --- a/example/calc/lexer/acttab.go +++ b/example/calc/lexer/acttab.go @@ -5,7 +5,7 @@ package lexer import ( "fmt" - "github.com/goccmack/gocc/example/calc/token" + "github.com/johnkerl/gocc/example/calc/token" ) type ActionTable [NumStates]ActionRow diff --git a/example/calc/lexer/lexer.go b/example/calc/lexer/lexer.go index 44fabe83..5c4f6d4d 100755 --- a/example/calc/lexer/lexer.go +++ b/example/calc/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "unicode/utf8" - "github.com/goccmack/gocc/example/calc/token" + "github.com/johnkerl/gocc/example/calc/token" ) const ( diff --git a/example/calc/parser/parser.go b/example/calc/parser/parser.go index dd2ca3e4..76a33cc0 100755 --- a/example/calc/parser/parser.go +++ b/example/calc/parser/parser.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - parseError "github.com/goccmack/gocc/example/calc/errors" - "github.com/goccmack/gocc/example/calc/token" + parseError "github.com/johnkerl/gocc/example/calc/errors" + "github.com/johnkerl/gocc/example/calc/token" ) const ( diff --git a/example/calc/parser/productionstable.go b/example/calc/parser/productionstable.go index 8350a73d..e74d43d7 100755 --- a/example/calc/parser/productionstable.go +++ b/example/calc/parser/productionstable.go @@ -3,8 +3,8 @@ package parser import ( - "github.com/goccmack/gocc/example/calc/token" - "github.com/goccmack/gocc/example/calc/util" + "github.com/johnkerl/gocc/example/calc/token" + "github.com/johnkerl/gocc/example/calc/util" ) type ( diff --git a/example/errorrecovery/ast/ast.go b/example/errorrecovery/ast/ast.go index df23f297..1657687c 100644 --- a/example/errorrecovery/ast/ast.go +++ b/example/errorrecovery/ast/ast.go @@ -1,7 +1,7 @@ package ast import ( - "github.com/goccmack/gocc/example/errorrecovery/token" + "github.com/johnkerl/gocc/example/errorrecovery/token" ) type ( diff --git a/example/errorrecovery/er.bnf b/example/errorrecovery/er.bnf index 47ec84b6..04c87706 100644 --- a/example/errorrecovery/er.bnf +++ b/example/errorrecovery/er.bnf @@ -12,7 +12,7 @@ id : (_letter | '_') {_idchar} ; /* Syntax elements */ -<< import "github.com/goccmack/gocc/example/errorrecovery/ast" >> +<< import "github.com/johnkerl/gocc/example/errorrecovery/ast" >> StmtList : Stmt << ast.NewStmtList($0) >> diff --git a/example/errorrecovery/er_test.go b/example/errorrecovery/er_test.go index 2aab5d65..cabd0942 100644 --- a/example/errorrecovery/er_test.go +++ b/example/errorrecovery/er_test.go @@ -4,10 +4,10 @@ import ( "fmt" "testing" - "github.com/goccmack/gocc/example/errorrecovery/ast" - "github.com/goccmack/gocc/example/errorrecovery/errors" - "github.com/goccmack/gocc/example/errorrecovery/lexer" - "github.com/goccmack/gocc/example/errorrecovery/parser" + "github.com/johnkerl/gocc/example/errorrecovery/ast" + "github.com/johnkerl/gocc/example/errorrecovery/errors" + "github.com/johnkerl/gocc/example/errorrecovery/lexer" + "github.com/johnkerl/gocc/example/errorrecovery/parser" ) func TestFail(t *testing.T) { diff --git a/example/errorrecovery/errors/errors.go b/example/errorrecovery/errors/errors.go index bd6f871a..28a031c4 100755 --- a/example/errorrecovery/errors/errors.go +++ b/example/errorrecovery/errors/errors.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/example/errorrecovery/token" + "github.com/johnkerl/gocc/example/errorrecovery/token" ) type ErrorSymbol interface { diff --git a/example/errorrecovery/lexer/acttab.go b/example/errorrecovery/lexer/acttab.go index 833036b1..d4eb42a4 100755 --- a/example/errorrecovery/lexer/acttab.go +++ b/example/errorrecovery/lexer/acttab.go @@ -5,7 +5,7 @@ package lexer import ( "fmt" - "github.com/goccmack/gocc/example/errorrecovery/token" + "github.com/johnkerl/gocc/example/errorrecovery/token" ) type ActionTable [NumStates]ActionRow diff --git a/example/errorrecovery/lexer/lexer.go b/example/errorrecovery/lexer/lexer.go index ea5244fb..5dfdb2b2 100755 --- a/example/errorrecovery/lexer/lexer.go +++ b/example/errorrecovery/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "unicode/utf8" - "github.com/goccmack/gocc/example/errorrecovery/token" + "github.com/johnkerl/gocc/example/errorrecovery/token" ) const ( diff --git a/example/errorrecovery/parser/parser.go b/example/errorrecovery/parser/parser.go index 1b50bcb6..218e9ef4 100755 --- a/example/errorrecovery/parser/parser.go +++ b/example/errorrecovery/parser/parser.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - parseError "github.com/goccmack/gocc/example/errorrecovery/errors" - "github.com/goccmack/gocc/example/errorrecovery/token" + parseError "github.com/johnkerl/gocc/example/errorrecovery/errors" + "github.com/johnkerl/gocc/example/errorrecovery/token" ) const ( diff --git a/example/errorrecovery/parser/productionstable.go b/example/errorrecovery/parser/productionstable.go index 26e23908..053cf9f9 100755 --- a/example/errorrecovery/parser/productionstable.go +++ b/example/errorrecovery/parser/productionstable.go @@ -2,7 +2,7 @@ package parser -import "github.com/goccmack/gocc/example/errorrecovery/ast" +import "github.com/johnkerl/gocc/example/errorrecovery/ast" type ( ProdTab [numProductions]ProdTabEntry diff --git a/example/mail/lexer/acttab.go b/example/mail/lexer/acttab.go index 18794c88..f529c720 100755 --- a/example/mail/lexer/acttab.go +++ b/example/mail/lexer/acttab.go @@ -5,7 +5,7 @@ package lexer import ( "fmt" - "github.com/goccmack/gocc/example/mail/token" + "github.com/johnkerl/gocc/example/mail/token" ) type ActionTable [NumStates]ActionRow diff --git a/example/mail/lexer/lexer.go b/example/mail/lexer/lexer.go index c5109165..4b71e41d 100755 --- a/example/mail/lexer/lexer.go +++ b/example/mail/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "unicode/utf8" - "github.com/goccmack/gocc/example/mail/token" + "github.com/johnkerl/gocc/example/mail/token" ) const ( diff --git a/example/mail/parser_test.go b/example/mail/parser_test.go index 581b7f6e..1d914aa8 100644 --- a/example/mail/parser_test.go +++ b/example/mail/parser_test.go @@ -3,8 +3,8 @@ package mail import ( "testing" - "github.com/goccmack/gocc/example/mail/lexer" - "github.com/goccmack/gocc/example/mail/token" + "github.com/johnkerl/gocc/example/mail/lexer" + "github.com/johnkerl/gocc/example/mail/token" ) var testData1 = map[string]bool{ diff --git a/example/nolexer/errors/errors.go b/example/nolexer/errors/errors.go index f57f2f03..3a462d4d 100755 --- a/example/nolexer/errors/errors.go +++ b/example/nolexer/errors/errors.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/example/nolexer/token" + "github.com/johnkerl/gocc/example/nolexer/token" ) type ErrorSymbol interface { diff --git a/example/nolexer/nolexer.bnf b/example/nolexer/nolexer.bnf index bf5e1f08..9e70bfc8 100644 --- a/example/nolexer/nolexer.bnf +++ b/example/nolexer/nolexer.bnf @@ -2,7 +2,7 @@ import ( "fmt" - "github.com/goccmack/gocc/example/nolexer/token" + "github.com/johnkerl/gocc/example/nolexer/token" ) >> diff --git a/example/nolexer/nolexer_test.go b/example/nolexer/nolexer_test.go index 1504ae14..c8670a55 100644 --- a/example/nolexer/nolexer_test.go +++ b/example/nolexer/nolexer_test.go @@ -3,8 +3,8 @@ package nolexer import ( "testing" - "github.com/goccmack/gocc/example/nolexer/parser" - "github.com/goccmack/gocc/example/nolexer/scanner" + "github.com/johnkerl/gocc/example/nolexer/parser" + "github.com/johnkerl/gocc/example/nolexer/scanner" ) func Test1(t *testing.T) { diff --git a/example/nolexer/parser/parser.go b/example/nolexer/parser/parser.go index 3d8f0a76..6a3102f2 100755 --- a/example/nolexer/parser/parser.go +++ b/example/nolexer/parser/parser.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - parseError "github.com/goccmack/gocc/example/nolexer/errors" - "github.com/goccmack/gocc/example/nolexer/token" + parseError "github.com/johnkerl/gocc/example/nolexer/errors" + "github.com/johnkerl/gocc/example/nolexer/token" ) const ( diff --git a/example/nolexer/parser/productionstable.go b/example/nolexer/parser/productionstable.go index 00e9b46f..1883c815 100755 --- a/example/nolexer/parser/productionstable.go +++ b/example/nolexer/parser/productionstable.go @@ -5,7 +5,7 @@ package parser import ( "fmt" - "github.com/goccmack/gocc/example/nolexer/token" + "github.com/johnkerl/gocc/example/nolexer/token" ) type ( diff --git a/example/nolexer/scanner/scanner.go b/example/nolexer/scanner/scanner.go index 2fe46fd8..f0ed3089 100644 --- a/example/nolexer/scanner/scanner.go +++ b/example/nolexer/scanner/scanner.go @@ -1,7 +1,7 @@ package scanner import ( - "github.com/goccmack/gocc/example/nolexer/token" + "github.com/johnkerl/gocc/example/nolexer/token" ) type Scanner struct { diff --git a/example/rr/errors/errors.go b/example/rr/errors/errors.go index 998d3b3f..f4715d40 100755 --- a/example/rr/errors/errors.go +++ b/example/rr/errors/errors.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/example/rr/token" + "github.com/johnkerl/gocc/example/rr/token" ) type ErrorSymbol interface { diff --git a/example/rr/lexer/acttab.go b/example/rr/lexer/acttab.go index c02f6b59..e2be08a5 100755 --- a/example/rr/lexer/acttab.go +++ b/example/rr/lexer/acttab.go @@ -5,7 +5,7 @@ package lexer import ( "fmt" - "github.com/goccmack/gocc/example/rr/token" + "github.com/johnkerl/gocc/example/rr/token" ) type ActionTable [NumStates]ActionRow diff --git a/example/rr/lexer/lexer.go b/example/rr/lexer/lexer.go index 68f06ea0..f06e9317 100755 --- a/example/rr/lexer/lexer.go +++ b/example/rr/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "unicode/utf8" - "github.com/goccmack/gocc/example/rr/token" + "github.com/johnkerl/gocc/example/rr/token" ) const ( diff --git a/example/rr/parser/parser.go b/example/rr/parser/parser.go index bab4383a..a36883c0 100755 --- a/example/rr/parser/parser.go +++ b/example/rr/parser/parser.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - parseError "github.com/goccmack/gocc/example/rr/errors" - "github.com/goccmack/gocc/example/rr/token" + parseError "github.com/johnkerl/gocc/example/rr/errors" + "github.com/johnkerl/gocc/example/rr/token" ) const ( diff --git a/example/rr/rr_test.go b/example/rr/rr_test.go index ce6d7ab9..d344d6f9 100644 --- a/example/rr/rr_test.go +++ b/example/rr/rr_test.go @@ -18,8 +18,8 @@ import ( "fmt" "testing" - "github.com/goccmack/gocc/example/rr/lexer" - "github.com/goccmack/gocc/example/rr/parser" + "github.com/johnkerl/gocc/example/rr/lexer" + "github.com/johnkerl/gocc/example/rr/parser" ) func parse(src string) (ast string, err error) { diff --git a/example/sr/ast/ast.go b/example/sr/ast/ast.go index f0c036ef..a605719b 100644 --- a/example/sr/ast/ast.go +++ b/example/sr/ast/ast.go @@ -1,7 +1,7 @@ package ast import ( - "github.com/goccmack/gocc/example/sr/token" + "github.com/johnkerl/gocc/example/sr/token" ) type ( diff --git a/example/sr/errors/errors.go b/example/sr/errors/errors.go index 7567b55c..e8df4140 100755 --- a/example/sr/errors/errors.go +++ b/example/sr/errors/errors.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/example/sr/token" + "github.com/johnkerl/gocc/example/sr/token" ) type ErrorSymbol interface { diff --git a/example/sr/lexer/acttab.go b/example/sr/lexer/acttab.go index 860bcbf1..70b9ba5c 100755 --- a/example/sr/lexer/acttab.go +++ b/example/sr/lexer/acttab.go @@ -5,7 +5,7 @@ package lexer import ( "fmt" - "github.com/goccmack/gocc/example/sr/token" + "github.com/johnkerl/gocc/example/sr/token" ) type ActionTable [NumStates]ActionRow diff --git a/example/sr/lexer/lexer.go b/example/sr/lexer/lexer.go index 65849251..c5d20b22 100755 --- a/example/sr/lexer/lexer.go +++ b/example/sr/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "unicode/utf8" - "github.com/goccmack/gocc/example/sr/token" + "github.com/johnkerl/gocc/example/sr/token" ) const ( diff --git a/example/sr/parser/parser.go b/example/sr/parser/parser.go index 5bbc8063..7225f534 100755 --- a/example/sr/parser/parser.go +++ b/example/sr/parser/parser.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - parseError "github.com/goccmack/gocc/example/sr/errors" - "github.com/goccmack/gocc/example/sr/token" + parseError "github.com/johnkerl/gocc/example/sr/errors" + "github.com/johnkerl/gocc/example/sr/token" ) const ( diff --git a/example/sr/parser/productionstable.go b/example/sr/parser/productionstable.go index 61b71d41..d2db7043 100755 --- a/example/sr/parser/productionstable.go +++ b/example/sr/parser/productionstable.go @@ -2,7 +2,7 @@ package parser -import "github.com/goccmack/gocc/example/sr/ast" +import "github.com/johnkerl/gocc/example/sr/ast" type ( ProdTab [numProductions]ProdTabEntry diff --git a/example/sr/sr.bnf b/example/sr/sr.bnf index 7228fc3b..9f6d8d99 100644 --- a/example/sr/sr.bnf +++ b/example/sr/sr.bnf @@ -26,7 +26,7 @@ id : (_letter | '_') {_idchar} ; /* Syntax elements */ -<< import "github.com/goccmack/gocc/example/sr/ast" >> +<< import "github.com/johnkerl/gocc/example/sr/ast" >> Stmt : "if" id "then" Stmt << ast.NewIf($1, $3), nil >> diff --git a/example/sr/sr_test.go b/example/sr/sr_test.go index 461b8d12..7c44369b 100644 --- a/example/sr/sr_test.go +++ b/example/sr/sr_test.go @@ -3,9 +3,9 @@ package sr import ( "testing" - "github.com/goccmack/gocc/example/sr/ast" - "github.com/goccmack/gocc/example/sr/lexer" - "github.com/goccmack/gocc/example/sr/parser" + "github.com/johnkerl/gocc/example/sr/ast" + "github.com/johnkerl/gocc/example/sr/lexer" + "github.com/johnkerl/gocc/example/sr/parser" ) func parse(src string) (stmt ast.Stmt, err error) { diff --git a/gen.sh b/gen.sh index 04ffde37..4718c6fc 100755 --- a/gen.sh +++ b/gen.sh @@ -1,2 +1,2 @@ #!/bin/bash -gocc -o internal/frontend -p "github.com/goccmack/gocc/internal/frontend" spec/gocc2.ebnf +gocc -o internal/frontend -p "github.com/johnkerl/gocc/internal/frontend" spec/gocc2.ebnf diff --git a/go.sum b/go.sum index 8575ad4b..154bbcf4 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/goccmack/gocc v0.0.0-20210125115340-e10e6bb557ea h1:Etza+UCu1wLJG70Jelw52NrEGNAXFxGR3I/aemE8IxQ= -github.com/goccmack/gocc v0.0.0-20210125115340-e10e6bb557ea/go.mod h1:I84p9QKqzBb+3xnWK2df6AbWU1O59t3EcPycuPGa6b4= +github.com/johnkerl/gocc v0.0.0-20210125115340-e10e6bb557ea h1:Etza+UCu1wLJG70Jelw52NrEGNAXFxGR3I/aemE8IxQ= +github.com/johnkerl/gocc v0.0.0-20210125115340-e10e6bb557ea/go.mod h1:I84p9QKqzBb+3xnWK2df6AbWU1O59t3EcPycuPGa6b4= github.com/goccmack/goutil v1.2.1 h1:gJTCh0lnUETPHuj/QrQ4BWtDwu9ax4fy5u/GH94ChsE= github.com/goccmack/goutil v1.2.1/go.mod h1:dPBoKv07AeI2DGYE3ECrSLOLpGaBIBGCUCGKHclOPyU= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= diff --git a/internal/ast/fileheader.go b/internal/ast/fileheader.go index bde65038..5023bd3e 100644 --- a/internal/ast/fileheader.go +++ b/internal/ast/fileheader.go @@ -17,7 +17,7 @@ package ast import ( "fmt" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) type FileHeader struct { diff --git a/internal/ast/lexcharlit.go b/internal/ast/lexcharlit.go index ba0c42f9..8c46a1cc 100644 --- a/internal/ast/lexcharlit.go +++ b/internal/ast/lexcharlit.go @@ -15,8 +15,8 @@ package ast import ( - "github.com/goccmack/gocc/internal/frontend/token" - "github.com/goccmack/gocc/internal/util" + "github.com/johnkerl/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/util" ) type LexCharLit struct { diff --git a/internal/ast/lexignoredtokdef.go b/internal/ast/lexignoredtokdef.go index d667f3b2..ae959778 100644 --- a/internal/ast/lexignoredtokdef.go +++ b/internal/ast/lexignoredtokdef.go @@ -18,7 +18,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) type LexIgnoredTokDef struct { diff --git a/internal/ast/leximport.go b/internal/ast/leximport.go index 055879ec..32f6d16f 100644 --- a/internal/ast/leximport.go +++ b/internal/ast/leximport.go @@ -17,7 +17,7 @@ package ast import ( "fmt" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) type LexImport struct { diff --git a/internal/ast/lexregdef.go b/internal/ast/lexregdef.go index 48855428..a861ba29 100644 --- a/internal/ast/lexregdef.go +++ b/internal/ast/lexregdef.go @@ -18,7 +18,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) type LexRegDef struct { diff --git a/internal/ast/lexregdefid.go b/internal/ast/lexregdefid.go index a3a518fa..9367c042 100644 --- a/internal/ast/lexregdefid.go +++ b/internal/ast/lexregdefid.go @@ -15,7 +15,7 @@ package ast import ( - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) type LexRegDefId struct { diff --git a/internal/ast/lextokdef.go b/internal/ast/lextokdef.go index 45a229d4..5d5a1f5c 100644 --- a/internal/ast/lextokdef.go +++ b/internal/ast/lextokdef.go @@ -19,7 +19,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) type LexTokDef struct { diff --git a/internal/ast/syntaxbody.go b/internal/ast/syntaxbody.go index 90609d1a..f679e192 100644 --- a/internal/ast/syntaxbody.go +++ b/internal/ast/syntaxbody.go @@ -17,7 +17,7 @@ package ast import ( "fmt" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) type SyntaxBody struct { diff --git a/internal/ast/syntaxprod.go b/internal/ast/syntaxprod.go index ed255225..7a9c521b 100644 --- a/internal/ast/syntaxprod.go +++ b/internal/ast/syntaxprod.go @@ -17,7 +17,7 @@ package ast import ( "fmt" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) type SyntaxProd struct { diff --git a/internal/ast/syntaxprodid.go b/internal/ast/syntaxprodid.go index 5e12d73b..8d798eee 100644 --- a/internal/ast/syntaxprodid.go +++ b/internal/ast/syntaxprodid.go @@ -15,7 +15,7 @@ package ast import ( - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) // Id or name of a grammar(syntax) production diff --git a/internal/ast/syntaxstringlit.go b/internal/ast/syntaxstringlit.go index fd2d1383..6cf9df23 100644 --- a/internal/ast/syntaxstringlit.go +++ b/internal/ast/syntaxstringlit.go @@ -17,7 +17,7 @@ package ast import ( "fmt" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) type SyntaxStringLit string diff --git a/internal/ast/syntaxtokid.go b/internal/ast/syntaxtokid.go index f2fa30cd..374fb302 100644 --- a/internal/ast/syntaxtokid.go +++ b/internal/ast/syntaxtokid.go @@ -15,7 +15,7 @@ package ast import ( - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) type SyntaxTokId string diff --git a/internal/frontend/errors/errors.go b/internal/frontend/errors/errors.go index 7e7f7321..b4ffd297 100644 --- a/internal/frontend/errors/errors.go +++ b/internal/frontend/errors/errors.go @@ -1,6 +1,6 @@ package errors -import "github.com/goccmack/gocc/internal/frontend/token" +import "github.com/johnkerl/gocc/internal/frontend/token" type ErrorSymbol interface { } diff --git a/internal/frontend/parser/parser.go b/internal/frontend/parser/parser.go index 619ca19f..f9f50dc2 100644 --- a/internal/frontend/parser/parser.go +++ b/internal/frontend/parser/parser.go @@ -5,8 +5,8 @@ import ( "fmt" "strconv" - errs "github.com/goccmack/gocc/internal/frontend/errors" - "github.com/goccmack/gocc/internal/frontend/token" + errs "github.com/johnkerl/gocc/internal/frontend/errors" + "github.com/johnkerl/gocc/internal/frontend/token" ) type ( diff --git a/internal/frontend/parser/parser_ut.go b/internal/frontend/parser/parser_ut.go index 4dace8f3..e61fb1fd 100644 --- a/internal/frontend/parser/parser_ut.go +++ b/internal/frontend/parser/parser_ut.go @@ -4,8 +4,8 @@ import ( "errors" "strconv" - errs "github.com/goccmack/gocc/internal/frontend/errors" - "github.com/goccmack/gocc/internal/frontend/token" + errs "github.com/johnkerl/gocc/internal/frontend/errors" + "github.com/johnkerl/gocc/internal/frontend/token" ) // ParserUTab diff --git a/internal/frontend/parser/tables.go b/internal/frontend/parser/tables.go index 1e3bfc83..e9383a71 100644 --- a/internal/frontend/parser/tables.go +++ b/internal/frontend/parser/tables.go @@ -1,6 +1,6 @@ package parser -import "github.com/goccmack/gocc/internal/ast" +import "github.com/johnkerl/gocc/internal/ast" var ProductionsTable = ProdTab{ // [0] diff --git a/internal/frontend/parser/tables_uncompressed.go b/internal/frontend/parser/tables_uncompressed.go index 0e9aa778..ae629dcf 100644 --- a/internal/frontend/parser/tables_uncompressed.go +++ b/internal/frontend/parser/tables_uncompressed.go @@ -1,6 +1,6 @@ package parser -import "github.com/goccmack/gocc/internal/ast" +import "github.com/johnkerl/gocc/internal/ast" const ( NUM_STATES = 120 diff --git a/internal/frontend/scanner/scanner.go b/internal/frontend/scanner/scanner.go index be393973..e3fb9ab2 100644 --- a/internal/frontend/scanner/scanner.go +++ b/internal/frontend/scanner/scanner.go @@ -14,7 +14,7 @@ import ( "unicode" "unicode/utf8" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) // A Scanner holds the scanner's internal state while processing diff --git a/internal/frontend/scanner/scanner_test.go b/internal/frontend/scanner/scanner_test.go index 57d86f79..1747bd6e 100644 --- a/internal/frontend/scanner/scanner_test.go +++ b/internal/frontend/scanner/scanner_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/frontend/token" ) type testRecord struct { diff --git a/internal/lexer/gen/golang/acttab.go b/internal/lexer/gen/golang/acttab.go index b68cc937..a2c4810a 100644 --- a/internal/lexer/gen/golang/acttab.go +++ b/internal/lexer/gen/golang/acttab.go @@ -19,9 +19,9 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/io" - "github.com/goccmack/gocc/internal/lexer/items" - "github.com/goccmack/gocc/internal/token" + "github.com/johnkerl/gocc/internal/io" + "github.com/johnkerl/gocc/internal/lexer/items" + "github.com/johnkerl/gocc/internal/token" ) func genActionTable(pkg, outDir string, itemsets *items.ItemSets, tokMap *token.TokenMap) { diff --git a/internal/lexer/gen/golang/asciitable.go b/internal/lexer/gen/golang/asciitable.go index 8ddf2639..3e434aef 100644 --- a/internal/lexer/gen/golang/asciitable.go +++ b/internal/lexer/gen/golang/asciitable.go @@ -19,8 +19,8 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/io" - "github.com/goccmack/gocc/internal/lexer/symbols" + "github.com/johnkerl/gocc/internal/io" + "github.com/johnkerl/gocc/internal/lexer/symbols" ) func genAsciiTable(outDir string, symbols *symbols.Symbols) { diff --git a/internal/lexer/gen/golang/chrranges.go b/internal/lexer/gen/golang/chrranges.go index 6a9f9232..d8bd2031 100644 --- a/internal/lexer/gen/golang/chrranges.go +++ b/internal/lexer/gen/golang/chrranges.go @@ -15,7 +15,7 @@ package golang import ( - "github.com/goccmack/gocc/internal/lexer/symbols" + "github.com/johnkerl/gocc/internal/lexer/symbols" ) type CharRange struct { diff --git a/internal/lexer/gen/golang/gen.go b/internal/lexer/gen/golang/gen.go index 00009454..8250e50e 100644 --- a/internal/lexer/gen/golang/gen.go +++ b/internal/lexer/gen/golang/gen.go @@ -15,9 +15,9 @@ package golang import ( - "github.com/goccmack/gocc/internal/config" - "github.com/goccmack/gocc/internal/lexer/items" - "github.com/goccmack/gocc/internal/token" + "github.com/johnkerl/gocc/internal/config" + "github.com/johnkerl/gocc/internal/lexer/items" + "github.com/johnkerl/gocc/internal/token" ) func Gen(pkg, outDir string, header string, itemsets *items.ItemSets, tokMap *token.TokenMap, cfg config.Config) { diff --git a/internal/lexer/gen/golang/imports.go b/internal/lexer/gen/golang/imports.go index 49d9cf50..b8e5934d 100644 --- a/internal/lexer/gen/golang/imports.go +++ b/internal/lexer/gen/golang/imports.go @@ -15,7 +15,7 @@ package golang import ( - "github.com/goccmack/gocc/internal/lexer/symbols" + "github.com/johnkerl/gocc/internal/lexer/symbols" ) type importType struct { diff --git a/internal/lexer/gen/golang/lexer.go b/internal/lexer/gen/golang/lexer.go index 0a1eec68..e052e1c2 100644 --- a/internal/lexer/gen/golang/lexer.go +++ b/internal/lexer/gen/golang/lexer.go @@ -19,9 +19,9 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/config" - "github.com/goccmack/gocc/internal/io" - "github.com/goccmack/gocc/internal/lexer/items" + "github.com/johnkerl/gocc/internal/config" + "github.com/johnkerl/gocc/internal/io" + "github.com/johnkerl/gocc/internal/lexer/items" ) func genLexer(pkg, outDir string, itemsets *items.ItemSets, cfg config.Config) { diff --git a/internal/lexer/gen/golang/transtab.go b/internal/lexer/gen/golang/transtab.go index 9f536d8d..46c405a8 100644 --- a/internal/lexer/gen/golang/transtab.go +++ b/internal/lexer/gen/golang/transtab.go @@ -20,8 +20,8 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/io" - "github.com/goccmack/gocc/internal/lexer/items" + "github.com/johnkerl/gocc/internal/io" + "github.com/johnkerl/gocc/internal/lexer/items" ) func genTransitionTable(pkg, outDir, header string, itemSets *items.ItemSets) { diff --git a/internal/lexer/items/charrange.go b/internal/lexer/items/charrange.go index e0ed391b..963b8b04 100644 --- a/internal/lexer/items/charrange.go +++ b/internal/lexer/items/charrange.go @@ -17,7 +17,7 @@ package items import ( "fmt" - "github.com/goccmack/gocc/internal/util" + "github.com/johnkerl/gocc/internal/util" ) type CharRange struct { diff --git a/internal/lexer/items/disjunctrangeset.go b/internal/lexer/items/disjunctrangeset.go index 51ee032d..8a802b44 100644 --- a/internal/lexer/items/disjunctrangeset.go +++ b/internal/lexer/items/disjunctrangeset.go @@ -18,7 +18,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/ast" ) // set is kept sorted diff --git a/internal/lexer/items/disjunctrangeset_test.go b/internal/lexer/items/disjunctrangeset_test.go index f5f42865..1ee0d0c5 100644 --- a/internal/lexer/items/disjunctrangeset_test.go +++ b/internal/lexer/items/disjunctrangeset_test.go @@ -18,7 +18,7 @@ import ( // "fmt" "testing" - "github.com/goccmack/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/ast" // "unicode" ) diff --git a/internal/lexer/items/item.go b/internal/lexer/items/item.go index 045aab98..11c22c79 100644 --- a/internal/lexer/items/item.go +++ b/internal/lexer/items/item.go @@ -19,9 +19,9 @@ import ( "io" "strings" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/lexer/symbols" - "github.com/goccmack/gocc/internal/util" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/lexer/symbols" + "github.com/johnkerl/gocc/internal/util" ) type Item struct { diff --git a/internal/lexer/items/item_test.go b/internal/lexer/items/item_test.go index 685b6347..6d3081e9 100644 --- a/internal/lexer/items/item_test.go +++ b/internal/lexer/items/item_test.go @@ -18,7 +18,7 @@ import ( "fmt" "testing" - "github.com/goccmack/gocc/internal/lexer/symbols" + "github.com/johnkerl/gocc/internal/lexer/symbols" ) /* diff --git a/internal/lexer/items/itemlist.go b/internal/lexer/items/itemlist.go index 218922c3..42fdfab1 100644 --- a/internal/lexer/items/itemlist.go +++ b/internal/lexer/items/itemlist.go @@ -18,8 +18,8 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/lexer/symbols" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/lexer/symbols" ) // Each Itemset element is a ItemList diff --git a/internal/lexer/items/itempos.go b/internal/lexer/items/itempos.go index ca628cd8..631bd808 100644 --- a/internal/lexer/items/itempos.go +++ b/internal/lexer/items/itempos.go @@ -18,7 +18,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/ast" ) type itemPos struct { diff --git a/internal/lexer/items/itempos_test.go b/internal/lexer/items/itempos_test.go index ae672e96..718542d6 100644 --- a/internal/lexer/items/itempos_test.go +++ b/internal/lexer/items/itempos_test.go @@ -16,7 +16,7 @@ package items import ( // "fmt" - // "github.com/goccmack/gocc/internal/ast" + // "github.com/johnkerl/gocc/internal/ast" "testing" ) diff --git a/internal/lexer/items/itemset.go b/internal/lexer/items/itemset.go index 0a996e47..efda32c5 100644 --- a/internal/lexer/items/itemset.go +++ b/internal/lexer/items/itemset.go @@ -18,8 +18,8 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/lexer/symbols" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/lexer/symbols" ) /* diff --git a/internal/lexer/items/itemsets.go b/internal/lexer/items/itemsets.go index b461bdff..543b541f 100644 --- a/internal/lexer/items/itemsets.go +++ b/internal/lexer/items/itemsets.go @@ -18,8 +18,8 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/lexer/symbols" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/lexer/symbols" ) type ItemSets struct { diff --git a/internal/lexer/items/testutils_test.go b/internal/lexer/items/testutils_test.go index debb62c6..066a9a8f 100644 --- a/internal/lexer/items/testutils_test.go +++ b/internal/lexer/items/testutils_test.go @@ -18,10 +18,10 @@ import ( "fmt" "testing" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/frontend/parser" - "github.com/goccmack/gocc/internal/frontend/scanner" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/frontend/parser" + "github.com/johnkerl/gocc/internal/frontend/scanner" + "github.com/johnkerl/gocc/internal/frontend/token" ) func findSet(sets *ItemSets, items []string) *ItemSet { diff --git a/internal/lexer/symbols/charlitsymbols.go b/internal/lexer/symbols/charlitsymbols.go index f9d98da2..c4348f56 100644 --- a/internal/lexer/symbols/charlitsymbols.go +++ b/internal/lexer/symbols/charlitsymbols.go @@ -15,7 +15,7 @@ package symbols import ( - "github.com/goccmack/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/ast" ) // key: string of symbols - string(ast.CharLit.Lit). E.g.: "'a'" diff --git a/internal/lexer/symbols/charrangesymbols.go b/internal/lexer/symbols/charrangesymbols.go index fe43e039..135c00a6 100644 --- a/internal/lexer/symbols/charrangesymbols.go +++ b/internal/lexer/symbols/charrangesymbols.go @@ -15,7 +15,7 @@ package symbols import ( - "github.com/goccmack/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/ast" ) // key: string of range, e.g.: 'a'-'z' diff --git a/internal/lexer/symbols/symbols.go b/internal/lexer/symbols/symbols.go index 1be7679c..13f22fea 100644 --- a/internal/lexer/symbols/symbols.go +++ b/internal/lexer/symbols/symbols.go @@ -18,7 +18,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/ast" ) type Symbols struct { diff --git a/internal/parser/first/first.go b/internal/parser/first/first.go index 8b6c1379..dd78522d 100644 --- a/internal/parser/first/first.go +++ b/internal/parser/first/first.go @@ -18,8 +18,8 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/parser/symbols" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/parser/symbols" ) /* diff --git a/internal/parser/gen/gen.go b/internal/parser/gen/gen.go index a9e7be6a..86dacde4 100644 --- a/internal/parser/gen/gen.go +++ b/internal/parser/gen/gen.go @@ -18,12 +18,12 @@ This package controls the generation of all parser-related code. package gen import ( - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/config" - "github.com/goccmack/gocc/internal/parser/gen/golang" - "github.com/goccmack/gocc/internal/parser/lr1/items" - "github.com/goccmack/gocc/internal/parser/symbols" - "github.com/goccmack/gocc/internal/token" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/config" + "github.com/johnkerl/gocc/internal/parser/gen/golang" + "github.com/johnkerl/gocc/internal/parser/lr1/items" + "github.com/johnkerl/gocc/internal/parser/symbols" + "github.com/johnkerl/gocc/internal/token" ) func Gen(pkg, outDir, header string, prods ast.SyntaxProdList, symbols *symbols.Symbols, diff --git a/internal/parser/gen/golang/action.go b/internal/parser/gen/golang/action.go index 020bf58b..6234dc27 100644 --- a/internal/parser/gen/golang/action.go +++ b/internal/parser/gen/golang/action.go @@ -17,7 +17,7 @@ package golang import ( "path" - "github.com/goccmack/gocc/internal/io" + "github.com/johnkerl/gocc/internal/io" ) func GenAction(outDir string) { diff --git a/internal/parser/gen/golang/actiontable.go b/internal/parser/gen/golang/actiontable.go index 9eb06915..cc5513e1 100644 --- a/internal/parser/gen/golang/actiontable.go +++ b/internal/parser/gen/golang/actiontable.go @@ -21,11 +21,11 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/io" - "github.com/goccmack/gocc/internal/parser/lr1/action" - "github.com/goccmack/gocc/internal/parser/lr1/items" - "github.com/goccmack/gocc/internal/token" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/io" + "github.com/johnkerl/gocc/internal/parser/lr1/action" + "github.com/johnkerl/gocc/internal/parser/lr1/items" + "github.com/johnkerl/gocc/internal/token" ) func GenActionTable(outDir string, prods ast.SyntaxProdList, itemSets *items.ItemSets, tokMap *token.TokenMap, zip bool) map[int]items.RowConflicts { diff --git a/internal/parser/gen/golang/errors.go b/internal/parser/gen/golang/errors.go index 965ba7cc..f5f94404 100644 --- a/internal/parser/gen/golang/errors.go +++ b/internal/parser/gen/golang/errors.go @@ -18,7 +18,7 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/io" + "github.com/johnkerl/gocc/internal/io" ) func GenErrors(pkg, outDir string) { diff --git a/internal/parser/gen/golang/gototable.go b/internal/parser/gen/golang/gototable.go index a4af8b93..2e0b2fd2 100644 --- a/internal/parser/gen/golang/gototable.go +++ b/internal/parser/gen/golang/gototable.go @@ -22,9 +22,9 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/io" - "github.com/goccmack/gocc/internal/parser/lr1/items" - "github.com/goccmack/gocc/internal/parser/symbols" + "github.com/johnkerl/gocc/internal/io" + "github.com/johnkerl/gocc/internal/parser/lr1/items" + "github.com/johnkerl/gocc/internal/parser/symbols" ) type gotoTableData struct { diff --git a/internal/parser/gen/golang/parser.go b/internal/parser/gen/golang/parser.go index f417cd44..06fede7c 100644 --- a/internal/parser/gen/golang/parser.go +++ b/internal/parser/gen/golang/parser.go @@ -19,11 +19,11 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/config" - "github.com/goccmack/gocc/internal/io" - "github.com/goccmack/gocc/internal/parser/lr1/items" - "github.com/goccmack/gocc/internal/parser/symbols" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/config" + "github.com/johnkerl/gocc/internal/io" + "github.com/johnkerl/gocc/internal/parser/lr1/items" + "github.com/johnkerl/gocc/internal/parser/symbols" ) func GenParser(pkg, outDir string, prods ast.SyntaxProdList, itemSets *items.ItemSets, symbols *symbols.Symbols, cfg config.Config) { diff --git a/internal/parser/gen/golang/productionstable.go b/internal/parser/gen/golang/productionstable.go index 5e6c04c8..50412059 100644 --- a/internal/parser/gen/golang/productionstable.go +++ b/internal/parser/gen/golang/productionstable.go @@ -20,11 +20,11 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/io" - "github.com/goccmack/gocc/internal/parser/lr1/items" - "github.com/goccmack/gocc/internal/parser/symbols" - "github.com/goccmack/gocc/internal/token" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/io" + "github.com/johnkerl/gocc/internal/parser/lr1/items" + "github.com/johnkerl/gocc/internal/parser/symbols" + "github.com/johnkerl/gocc/internal/token" ) func GenProductionsTable(pkg, outDir, header string, prods ast.SyntaxProdList, symbols *symbols.Symbols, diff --git a/internal/parser/lr1/items/item.go b/internal/parser/lr1/items/item.go index 280cd8d4..e4e321e1 100644 --- a/internal/parser/lr1/items/item.go +++ b/internal/parser/lr1/items/item.go @@ -18,8 +18,8 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/parser/lr1/action" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/parser/lr1/action" ) //An LR1 Item. diff --git a/internal/parser/lr1/items/itemset.go b/internal/parser/lr1/items/itemset.go index 71d977b2..3b7299ee 100644 --- a/internal/parser/lr1/items/itemset.go +++ b/internal/parser/lr1/items/itemset.go @@ -19,10 +19,10 @@ import ( "sort" "strings" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/parser/first" - "github.com/goccmack/gocc/internal/parser/lr1/action" - "github.com/goccmack/gocc/internal/parser/symbols" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/parser/first" + "github.com/johnkerl/gocc/internal/parser/lr1/action" + "github.com/johnkerl/gocc/internal/parser/symbols" ) type ItemSet struct { diff --git a/internal/parser/lr1/items/itemsets.go b/internal/parser/lr1/items/itemsets.go index 0242c381..08ac6c06 100644 --- a/internal/parser/lr1/items/itemsets.go +++ b/internal/parser/lr1/items/itemsets.go @@ -18,9 +18,9 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/parser/first" - "github.com/goccmack/gocc/internal/parser/symbols" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/parser/first" + "github.com/johnkerl/gocc/internal/parser/symbols" ) //A list of a list of Items. diff --git a/internal/parser/lr1/items/rowconflicts.go b/internal/parser/lr1/items/rowconflicts.go index 2a6ca010..8a5a2e55 100644 --- a/internal/parser/lr1/items/rowconflicts.go +++ b/internal/parser/lr1/items/rowconflicts.go @@ -15,7 +15,7 @@ package items import ( - "github.com/goccmack/gocc/internal/parser/lr1/action" + "github.com/johnkerl/gocc/internal/parser/lr1/action" ) /* diff --git a/internal/parser/lr1/items/testdata_test.go b/internal/parser/lr1/items/testdata_test.go index 692c6bb1..e1c15503 100644 --- a/internal/parser/lr1/items/testdata_test.go +++ b/internal/parser/lr1/items/testdata_test.go @@ -17,10 +17,10 @@ package items import ( "testing" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/frontend/parser" - "github.com/goccmack/gocc/internal/frontend/scanner" - "github.com/goccmack/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/frontend/parser" + "github.com/johnkerl/gocc/internal/frontend/scanner" + "github.com/johnkerl/gocc/internal/frontend/token" ) const G1 = ` diff --git a/internal/parser/symbols/symbols.go b/internal/parser/symbols/symbols.go index 518f268c..475ddd70 100644 --- a/internal/parser/symbols/symbols.go +++ b/internal/parser/symbols/symbols.go @@ -21,7 +21,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/ast" ) type Symbols struct { diff --git a/internal/test/t1/errors/errors.go b/internal/test/t1/errors/errors.go index baa0603d..8f0d9b2f 100755 --- a/internal/test/t1/errors/errors.go +++ b/internal/test/t1/errors/errors.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/goccmack/gocc/internal/test/t1/token" + "github.com/johnkerl/gocc/internal/test/t1/token" ) type ErrorSymbol interface { diff --git a/internal/test/t1/lexer/acttab.go b/internal/test/t1/lexer/acttab.go index 8e2fcd2c..2840cdde 100755 --- a/internal/test/t1/lexer/acttab.go +++ b/internal/test/t1/lexer/acttab.go @@ -5,7 +5,7 @@ package lexer import ( "fmt" - "github.com/goccmack/gocc/internal/test/t1/token" + "github.com/johnkerl/gocc/internal/test/t1/token" ) type ActionTable [NumStates]ActionRow diff --git a/internal/test/t1/lexer/lexer.go b/internal/test/t1/lexer/lexer.go index 27ea8ec0..619faa40 100755 --- a/internal/test/t1/lexer/lexer.go +++ b/internal/test/t1/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "io/ioutil" "unicode/utf8" - "github.com/goccmack/gocc/internal/test/t1/token" + "github.com/johnkerl/gocc/internal/test/t1/token" ) const ( diff --git a/internal/test/t1/parser/parser.go b/internal/test/t1/parser/parser.go index c30faef3..69b0630c 100755 --- a/internal/test/t1/parser/parser.go +++ b/internal/test/t1/parser/parser.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - parseError "github.com/goccmack/gocc/internal/test/t1/errors" - "github.com/goccmack/gocc/internal/test/t1/token" + parseError "github.com/johnkerl/gocc/internal/test/t1/errors" + "github.com/johnkerl/gocc/internal/test/t1/token" ) const ( diff --git a/internal/test/t1/t1_test.go b/internal/test/t1/t1_test.go index 2371d78e..e889e10b 100644 --- a/internal/test/t1/t1_test.go +++ b/internal/test/t1/t1_test.go @@ -3,9 +3,9 @@ package t1 import ( "testing" - "github.com/goccmack/gocc/internal/test/t1/errors" - "github.com/goccmack/gocc/internal/test/t1/lexer" - "github.com/goccmack/gocc/internal/test/t1/parser" + "github.com/johnkerl/gocc/internal/test/t1/errors" + "github.com/johnkerl/gocc/internal/test/t1/lexer" + "github.com/johnkerl/gocc/internal/test/t1/parser" ) func Test1(t *testing.T) { diff --git a/internal/token/gen/gen.go b/internal/token/gen/gen.go index eb7f2781..0f419d62 100644 --- a/internal/token/gen/gen.go +++ b/internal/token/gen/gen.go @@ -15,8 +15,8 @@ package gen import ( - "github.com/goccmack/gocc/internal/token" - "github.com/goccmack/gocc/internal/token/gen/golang" + "github.com/johnkerl/gocc/internal/token" + "github.com/johnkerl/gocc/internal/token/gen/golang" ) func Gen(pkg, outdir string, tokenMap *token.TokenMap) { diff --git a/internal/token/gen/golang/token.go b/internal/token/gen/golang/token.go index b0241c3f..dfe02ae2 100644 --- a/internal/token/gen/golang/token.go +++ b/internal/token/gen/golang/token.go @@ -21,8 +21,8 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/io" - "github.com/goccmack/gocc/internal/token" + "github.com/johnkerl/gocc/internal/io" + "github.com/johnkerl/gocc/internal/token" ) func GenToken(pkg, outdir string, tokMap *token.TokenMap) { diff --git a/internal/util/gen/gen.go b/internal/util/gen/gen.go index 39732005..d01c03f3 100644 --- a/internal/util/gen/gen.go +++ b/internal/util/gen/gen.go @@ -1,7 +1,7 @@ package gen import ( - "github.com/goccmack/gocc/internal/util/gen/golang" + "github.com/johnkerl/gocc/internal/util/gen/golang" ) func Gen(outDir string) { diff --git a/internal/util/gen/golang/litconv.go b/internal/util/gen/golang/litconv.go index c5f859ad..af010d94 100644 --- a/internal/util/gen/golang/litconv.go +++ b/internal/util/gen/golang/litconv.go @@ -3,7 +3,7 @@ package golang import ( "path" - "github.com/goccmack/gocc/internal/io" + "github.com/johnkerl/gocc/internal/io" ) func GenLitConv(outDir string) { diff --git a/internal/util/gen/golang/rune.go b/internal/util/gen/golang/rune.go index 4561801c..1b2afd9b 100644 --- a/internal/util/gen/golang/rune.go +++ b/internal/util/gen/golang/rune.go @@ -3,7 +3,7 @@ package golang import ( "path" - "github.com/goccmack/gocc/internal/io" + "github.com/johnkerl/gocc/internal/io" ) func GenRune(outDir string) { diff --git a/main.go b/main.go index a7a37c4b..00bf50bb 100644 --- a/main.go +++ b/main.go @@ -13,7 +13,7 @@ // limitations under the License. //Gocc is LR1 parser generator for go written in go. The generator uses a BNF with very easy to use SDT rules. -//Please see https://github.com/goccmack/gocc/ for more documentation. +//Please see https://github.com/johnkerl/gocc/ for more documentation. package main import ( @@ -25,23 +25,23 @@ import ( "path" "strings" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/config" - "github.com/goccmack/gocc/internal/frontend/parser" - "github.com/goccmack/gocc/internal/frontend/scanner" - "github.com/goccmack/gocc/internal/frontend/token" - "github.com/goccmack/gocc/internal/io" - genLexer "github.com/goccmack/gocc/internal/lexer/gen/golang" - lexItems "github.com/goccmack/gocc/internal/lexer/items" - "github.com/goccmack/gocc/internal/parser/first" - genParser "github.com/goccmack/gocc/internal/parser/gen" - lr1Action "github.com/goccmack/gocc/internal/parser/lr1/action" - lr1Items "github.com/goccmack/gocc/internal/parser/lr1/items" - "github.com/goccmack/gocc/internal/parser/symbols" - outToken "github.com/goccmack/gocc/internal/token" - genToken "github.com/goccmack/gocc/internal/token/gen" - genUtil "github.com/goccmack/gocc/internal/util/gen" - "github.com/goccmack/gocc/internal/util/md" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/config" + "github.com/johnkerl/gocc/internal/frontend/parser" + "github.com/johnkerl/gocc/internal/frontend/scanner" + "github.com/johnkerl/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/io" + genLexer "github.com/johnkerl/gocc/internal/lexer/gen/golang" + lexItems "github.com/johnkerl/gocc/internal/lexer/items" + "github.com/johnkerl/gocc/internal/parser/first" + genParser "github.com/johnkerl/gocc/internal/parser/gen" + lr1Action "github.com/johnkerl/gocc/internal/parser/lr1/action" + lr1Items "github.com/johnkerl/gocc/internal/parser/lr1/items" + "github.com/johnkerl/gocc/internal/parser/symbols" + outToken "github.com/johnkerl/gocc/internal/token" + genToken "github.com/johnkerl/gocc/internal/token/gen" + genUtil "github.com/johnkerl/gocc/internal/util/gen" + "github.com/johnkerl/gocc/internal/util/md" ) func main() { diff --git a/main.go.orig b/main.go.orig index c3bf4d05..9f9b2f24 100644 --- a/main.go.orig +++ b/main.go.orig @@ -13,7 +13,7 @@ // limitations under the License. //Gocc is LR1 parser generator for go written in go. The generator uses a BNF with very easy to use SDT rules. -//Please see https://github.com/goccmack/gocc/ for more documentation. +//Please see https://github.com/johnkerl/gocc/ for more documentation. package main import ( @@ -25,29 +25,29 @@ import ( "path" "strings" - "github.com/goccmack/gocc/internal/ast" - "github.com/goccmack/gocc/internal/config" - "github.com/goccmack/gocc/internal/frontend/parser" - "github.com/goccmack/gocc/internal/frontend/scanner" - "github.com/goccmack/gocc/internal/frontend/token" - "github.com/goccmack/gocc/internal/io" - genLexer "github.com/goccmack/gocc/internal/lexer/gen/golang" - lexItems "github.com/goccmack/gocc/internal/lexer/items" - "github.com/goccmack/gocc/internal/parser/first" - genParser "github.com/goccmack/gocc/internal/parser/gen" - lr1Action "github.com/goccmack/gocc/internal/parser/lr1/action" - lr1Items "github.com/goccmack/gocc/internal/parser/lr1/items" - "github.com/goccmack/gocc/internal/parser/symbols" - outToken "github.com/goccmack/gocc/internal/token" - genToken "github.com/goccmack/gocc/internal/token/gen" - genUtil "github.com/goccmack/gocc/internal/util/gen" + "github.com/johnkerl/gocc/internal/ast" + "github.com/johnkerl/gocc/internal/config" + "github.com/johnkerl/gocc/internal/frontend/parser" + "github.com/johnkerl/gocc/internal/frontend/scanner" + "github.com/johnkerl/gocc/internal/frontend/token" + "github.com/johnkerl/gocc/internal/io" + genLexer "github.com/johnkerl/gocc/internal/lexer/gen/golang" + lexItems "github.com/johnkerl/gocc/internal/lexer/items" + "github.com/johnkerl/gocc/internal/parser/first" + genParser "github.com/johnkerl/gocc/internal/parser/gen" + lr1Action "github.com/johnkerl/gocc/internal/parser/lr1/action" + lr1Items "github.com/johnkerl/gocc/internal/parser/lr1/items" + "github.com/johnkerl/gocc/internal/parser/symbols" + outToken "github.com/johnkerl/gocc/internal/token" + genToken "github.com/johnkerl/gocc/internal/token/gen" + genUtil "github.com/johnkerl/gocc/internal/util/gen" <<<<<<< HEAD - "github.com/goccmack/gocc/internal/util/md" + "github.com/johnkerl/gocc/internal/util/md" // "runtime/pprof" "time" - genParser "github.com/goccmack/gocc/internal/parser/gen" + genParser "github.com/johnkerl/gocc/internal/parser/gen" ======= >>>>>>> 7a292ad833c2ba6a29151456d8de06ac9ab2a505 ) diff --git a/spec/gocc2.ebnf b/spec/gocc2.ebnf index e9ada3e8..3ac067d0 100644 --- a/spec/gocc2.ebnf +++ b/spec/gocc2.ebnf @@ -14,7 +14,7 @@ /*** Syntactic items ***/ -<< import "github.com/goccmack/gocc/internal/ast" >> +<< import "github.com/johnkerl/gocc/internal/ast" >> Grammar : LexicalPart SyntaxPart << ast.NewGrammar($0, $1) >> | LexicalPart << ast.NewGrammar($0, nil) >> From 9ce492564270cbc6029b75c97e8da73dfd7e4c22 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sat, 10 Jan 2026 15:17:31 -0500 Subject: [PATCH 4/9] goccmack/gocc -> johnkerl/gocc after merge --- README.md | 14 +++++++------- doc/gocc_user_guide.tex | 4 ++-- example/astx/ast.bnf | 4 ++-- example/astx/parser/productionstable.go | 4 ++-- example/bools/example.bnf | 2 +- example/bools/parser/productionstable.go | 2 +- example/calc/calc.bnf | 4 ++-- example/errormsg/errormsg_test.go | 8 ++++---- example/errormsg/errors/errors.go | 2 +- example/errormsg/lexer/acttab.go | 2 +- example/errormsg/lexer/lexer.go | 2 +- example/errormsg/parser/parser.go | 4 ++-- example/nolexer/nolexer.bnf | 2 +- example/usercontext/ast/main.go | 2 +- example/usercontext/errors/errors.go | 2 +- example/usercontext/example.bnf | 2 +- example/usercontext/example_test.go | 6 +++--- example/usercontext/gen.sh | 2 +- example/usercontext/lexer/acttab.go | 2 +- example/usercontext/lexer/lexer.go | 2 +- example/usercontext/parser/parser.go | 4 ++-- example/usercontext/parser/productionstable.go | 2 +- internal/parser/gen/golang/context.go | 2 +- internal/test/t1/t1_test.go | 8 ++++---- internal/token/gen/golang/context.go | 2 +- main.go | 2 +- 26 files changed, 46 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 9052d1d2..285aa6b9 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ Have a look at [https://github.com/goccmack/gogll](https://github.com/goccmack/gogll) for scannerless GLL parser generation. # Gocc -![Build Status](https://github.com/goccmack/gocc/workflows/build/badge.svg) -[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/goccmack/gocc) -[![Go Report Card](https://goreportcard.com/badge/github.com/goccmack/gocc)](https://goreportcard.com/report/github.com/goccmack/gocc) +![Build Status](https://github.com/johnkerl/gocc/workflows/build/badge.svg) +[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/johnkerl/gocc) +[![Go Report Card](https://goreportcard.com/badge/github.com/johnkerl/gocc)](https://goreportcard.com/report/github.com/johnkerl/gocc) ## Introduction @@ -33,10 +33,10 @@ See the [README](example/bools/README) for an included example. * First download and Install Go From http://golang.org/ * Setup your GOPATH environment variable. -* Next in your command line run: go get github.com/goccmack/gocc (go get will - git clone gocc into GOPATH/src/github.com/goccmack/gocc and run go install) -* Alternatively clone the source: https://github.com/goccmack/gocc . Followed - by go install github.com/goccmack/gocc +* Next in your command line run: go get github.com/johnkerl/gocc (go get will + git clone gocc into GOPATH/src/github.com/johnkerl/gocc and run go install) +* Alternatively clone the source: https://github.com/johnkerl/gocc . Followed + by go install github.com/johnkerl/gocc * Finally, make sure that the bin folder where the gocc binary is located is in your PATH environment variable. diff --git a/doc/gocc_user_guide.tex b/doc/gocc_user_guide.tex index 38de2e0a..ada687f2 100644 --- a/doc/gocc_user_guide.tex +++ b/doc/gocc_user_guide.tex @@ -710,8 +710,8 @@ \section{Example: Using an AST} \label{sec:example ast} \begin{verbatim} << - import "github.com/goccmack/gocc/example/astx/ast" - import "github.com/goccmack/gocc/example/astx/token" + import "github.com/johnkerl/gocc/example/astx/ast" + import "github.com/johnkerl/gocc/example/astx/token" >> StmtList : diff --git a/example/astx/ast.bnf b/example/astx/ast.bnf index 59dd152b..ada6cf34 100644 --- a/example/astx/ast.bnf +++ b/example/astx/ast.bnf @@ -14,8 +14,8 @@ id : (_letter | '_') {_idchar} ; << import ( - "github.com/goccmack/gocc/example/astx/ast" - "github.com/goccmack/gocc/example/astx/token" + "github.com/johnkerl/gocc/example/astx/ast" + "github.com/johnkerl/gocc/example/astx/token" ) >> diff --git a/example/astx/parser/productionstable.go b/example/astx/parser/productionstable.go index 6cd2d986..ccc4e9a1 100755 --- a/example/astx/parser/productionstable.go +++ b/example/astx/parser/productionstable.go @@ -3,8 +3,8 @@ package parser import ( - "github.com/goccmack/gocc/example/astx/ast" - "github.com/goccmack/gocc/example/astx/token" + "github.com/johnkerl/gocc/example/astx/ast" + "github.com/johnkerl/gocc/example/astx/token" ) type ( diff --git a/example/bools/example.bnf b/example/bools/example.bnf index ef7ec9d1..56980967 100644 --- a/example/bools/example.bnf +++ b/example/bools/example.bnf @@ -20,7 +20,7 @@ string_lit : '"' {.} '"' ; !whitespace : ' ' | '\t' | '\n' | '\r' ; -<> +<> BoolExpr : BoolExpr1 << $0, nil >> diff --git a/example/bools/parser/productionstable.go b/example/bools/parser/productionstable.go index 01cc10cd..dca952c7 100755 --- a/example/bools/parser/productionstable.go +++ b/example/bools/parser/productionstable.go @@ -2,7 +2,7 @@ package parser -import "github.com/goccmack/gocc/example/bools/ast" +import "github.com/johnkerl/gocc/example/bools/ast" type ( ProdTab [numProductions]ProdTabEntry diff --git a/example/calc/calc.bnf b/example/calc/calc.bnf index 63a22275..cb963ce5 100644 --- a/example/calc/calc.bnf +++ b/example/calc/calc.bnf @@ -10,8 +10,8 @@ int64 : '1'-'9' {_digit} ; << import ( - "github.com/goccmack/gocc/example/calc/token" - "github.com/goccmack/gocc/example/calc/util" + "github.com/johnkerl/gocc/example/calc/token" + "github.com/johnkerl/gocc/example/calc/util" ) >> diff --git a/example/errormsg/errormsg_test.go b/example/errormsg/errormsg_test.go index d01ae255..f337e6dd 100644 --- a/example/errormsg/errormsg_test.go +++ b/example/errormsg/errormsg_test.go @@ -4,10 +4,10 @@ import ( "fmt" "testing" - "github.com/goccmack/gocc/example/errormsg/errors" - "github.com/goccmack/gocc/example/errormsg/lexer" - "github.com/goccmack/gocc/example/errormsg/parser" - "github.com/goccmack/gocc/example/errormsg/token" + "github.com/johnkerl/gocc/example/errormsg/errors" + "github.com/johnkerl/gocc/example/errormsg/lexer" + "github.com/johnkerl/gocc/example/errormsg/parser" + "github.com/johnkerl/gocc/example/errormsg/token" ) // assertEqual is a crude implementation of testify's assert.Equal. diff --git a/example/errormsg/errors/errors.go b/example/errormsg/errors/errors.go index 8ff27f03..0badf1c9 100644 --- a/example/errormsg/errors/errors.go +++ b/example/errormsg/errors/errors.go @@ -8,7 +8,7 @@ import ( "strings" "unicode" - "github.com/goccmack/gocc/example/errormsg/token" + "github.com/johnkerl/gocc/example/errormsg/token" ) type ErrorSymbol interface { diff --git a/example/errormsg/lexer/acttab.go b/example/errormsg/lexer/acttab.go index 8cdf1e58..3e43fd94 100644 --- a/example/errormsg/lexer/acttab.go +++ b/example/errormsg/lexer/acttab.go @@ -5,7 +5,7 @@ package lexer import ( "fmt" - "github.com/goccmack/gocc/example/errormsg/token" + "github.com/johnkerl/gocc/example/errormsg/token" ) type ActionTable [NumStates]ActionRow diff --git a/example/errormsg/lexer/lexer.go b/example/errormsg/lexer/lexer.go index e775468f..54ca6219 100644 --- a/example/errormsg/lexer/lexer.go +++ b/example/errormsg/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "os" "unicode/utf8" - "github.com/goccmack/gocc/example/errormsg/token" + "github.com/johnkerl/gocc/example/errormsg/token" ) const ( diff --git a/example/errormsg/parser/parser.go b/example/errormsg/parser/parser.go index 5edec7d1..e71cb9e9 100644 --- a/example/errormsg/parser/parser.go +++ b/example/errormsg/parser/parser.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - parseError "github.com/goccmack/gocc/example/errormsg/errors" - "github.com/goccmack/gocc/example/errormsg/token" + parseError "github.com/johnkerl/gocc/example/errormsg/errors" + "github.com/johnkerl/gocc/example/errormsg/token" ) const ( diff --git a/example/nolexer/nolexer.bnf b/example/nolexer/nolexer.bnf index a486283c..e49de8e4 100644 --- a/example/nolexer/nolexer.bnf +++ b/example/nolexer/nolexer.bnf @@ -2,7 +2,7 @@ import ( "fmt" - "github.com/goccmack/gocc/example/nolexer/token" + "github.com/johnkerl/gocc/example/nolexer/token" ) >> diff --git a/example/usercontext/ast/main.go b/example/usercontext/ast/main.go index f1b3ed89..433e64f4 100644 --- a/example/usercontext/ast/main.go +++ b/example/usercontext/ast/main.go @@ -3,7 +3,7 @@ package ast import ( "fmt" - "github.com/goccmack/gocc/example/usercontext/token" + "github.com/johnkerl/gocc/example/usercontext/token" ) type Attrib interface{} diff --git a/example/usercontext/errors/errors.go b/example/usercontext/errors/errors.go index 550a0c8e..77d328bb 100644 --- a/example/usercontext/errors/errors.go +++ b/example/usercontext/errors/errors.go @@ -8,7 +8,7 @@ import ( "strings" "unicode" - "github.com/goccmack/gocc/example/usercontext/token" + "github.com/johnkerl/gocc/example/usercontext/token" ) type ErrorSymbol interface { diff --git a/example/usercontext/example.bnf b/example/usercontext/example.bnf index 7d3596bf..ba3172fe 100644 --- a/example/usercontext/example.bnf +++ b/example/usercontext/example.bnf @@ -4,7 +4,7 @@ lowercase : 'a'-'z' { 'a'-'z' }; capitalized : 'A'-'Z' { 'a'-'z' | 'A'-'Z' }; -<< import "github.com/goccmack/gocc/example/usercontext/ast" >> +<< import "github.com/johnkerl/gocc/example/usercontext/ast" >> // This grammar supports some random number of identifiers (1,N), // and must be ended with the literal "...42..." diff --git a/example/usercontext/example_test.go b/example/usercontext/example_test.go index eaa97674..3a0f7b98 100644 --- a/example/usercontext/example_test.go +++ b/example/usercontext/example_test.go @@ -18,9 +18,9 @@ import ( "strings" "testing" - "github.com/goccmack/gocc/example/usercontext/ast" - "github.com/goccmack/gocc/example/usercontext/lexer" - "github.com/goccmack/gocc/example/usercontext/parser" + "github.com/johnkerl/gocc/example/usercontext/ast" + "github.com/johnkerl/gocc/example/usercontext/lexer" + "github.com/johnkerl/gocc/example/usercontext/parser" ) func tryParse(t *testing.T, code string, lexContext, parseContext interface{}) (interface{}, error) { diff --git a/example/usercontext/gen.sh b/example/usercontext/gen.sh index 780c170b..2631eeb6 100644 --- a/example/usercontext/gen.sh +++ b/example/usercontext/gen.sh @@ -1 +1 @@ -gocc -a -p github.com/goccmack/gocc/example/usercontext example.bnf +gocc -a -p github.com/johnkerl/gocc/example/usercontext example.bnf diff --git a/example/usercontext/lexer/acttab.go b/example/usercontext/lexer/acttab.go index 8b092d22..26fc074c 100644 --- a/example/usercontext/lexer/acttab.go +++ b/example/usercontext/lexer/acttab.go @@ -5,7 +5,7 @@ package lexer import ( "fmt" - "github.com/goccmack/gocc/example/usercontext/token" + "github.com/johnkerl/gocc/example/usercontext/token" ) type ActionTable [NumStates]ActionRow diff --git a/example/usercontext/lexer/lexer.go b/example/usercontext/lexer/lexer.go index ef02b93f..a884300b 100644 --- a/example/usercontext/lexer/lexer.go +++ b/example/usercontext/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "os" "unicode/utf8" - "github.com/goccmack/gocc/example/usercontext/token" + "github.com/johnkerl/gocc/example/usercontext/token" ) const ( diff --git a/example/usercontext/parser/parser.go b/example/usercontext/parser/parser.go index 07e13228..de555ac1 100644 --- a/example/usercontext/parser/parser.go +++ b/example/usercontext/parser/parser.go @@ -6,8 +6,8 @@ import ( "fmt" "strings" - parseError "github.com/goccmack/gocc/example/usercontext/errors" - "github.com/goccmack/gocc/example/usercontext/token" + parseError "github.com/johnkerl/gocc/example/usercontext/errors" + "github.com/johnkerl/gocc/example/usercontext/token" ) const ( diff --git a/example/usercontext/parser/productionstable.go b/example/usercontext/parser/productionstable.go index 46f0cf9f..d9dcf8a7 100644 --- a/example/usercontext/parser/productionstable.go +++ b/example/usercontext/parser/productionstable.go @@ -2,7 +2,7 @@ package parser -import "github.com/goccmack/gocc/example/usercontext/ast" +import "github.com/johnkerl/gocc/example/usercontext/ast" type ( ProdTab [numProductions]ProdTabEntry diff --git a/internal/parser/gen/golang/context.go b/internal/parser/gen/golang/context.go index db60fd1f..4e2f990e 100644 --- a/internal/parser/gen/golang/context.go +++ b/internal/parser/gen/golang/context.go @@ -19,7 +19,7 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/io" + "github.com/johnkerl/gocc/internal/io" ) func GenContext(pkg, outDir string) { diff --git a/internal/test/t1/t1_test.go b/internal/test/t1/t1_test.go index 7fc4a0d1..53eba8c7 100644 --- a/internal/test/t1/t1_test.go +++ b/internal/test/t1/t1_test.go @@ -3,10 +3,10 @@ package t1 import ( "testing" - "github.com/goccmack/gocc/internal/test/t1/errors" - "github.com/goccmack/gocc/internal/test/t1/lexer" - "github.com/goccmack/gocc/internal/test/t1/parser" - "github.com/goccmack/gocc/internal/test/t1/token" + "github.com/johnkerl/gocc/internal/test/t1/errors" + "github.com/johnkerl/gocc/internal/test/t1/lexer" + "github.com/johnkerl/gocc/internal/test/t1/parser" + "github.com/johnkerl/gocc/internal/test/t1/token" ) type Equals interface { diff --git a/internal/token/gen/golang/context.go b/internal/token/gen/golang/context.go index afc1a9ea..552952ff 100644 --- a/internal/token/gen/golang/context.go +++ b/internal/token/gen/golang/context.go @@ -19,7 +19,7 @@ import ( "path" "text/template" - "github.com/goccmack/gocc/internal/io" + "github.com/johnkerl/gocc/internal/io" ) func GenContext(pkg, outDir string) { diff --git a/main.go b/main.go index 7974683c..a652dffc 100644 --- a/main.go +++ b/main.go @@ -13,7 +13,7 @@ // limitations under the License. // Gocc is LR1 parser generator for go written in go. The generator uses a BNF with very easy to use SDT rules. -// Please see https://github.com/goccmack/gocc/ for more documentation. +// Please see https://github.com/johnkerl/gocc/ for more documentation. package main import ( From d074799de92b3d36fdd0d41e105c3029581ccfe0 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sat, 10 Jan 2026 15:19:49 -0500 Subject: [PATCH 5/9] Initial performance improvement --- internal/parser/lr1/items/itemset.go | 29 ++++++++++++++-- internal/parser/lr1/items/itemsets.go | 49 ++++++++++++++++++++------- 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/internal/parser/lr1/items/itemset.go b/internal/parser/lr1/items/itemset.go index 77183d70..425f2692 100644 --- a/internal/parser/lr1/items/itemset.go +++ b/internal/parser/lr1/items/itemset.go @@ -107,9 +107,9 @@ func (this *ItemSet) NextSetIndex(symbol string) int { return -1 } -//TODO: optimise loop /* Dragon book, 2nd ed, section 4.7.2, p261 + Closure(I) repeat for each item [A->x•By, a] in I @@ -124,6 +124,13 @@ func (this *ItemSet) Closure() (c *ItemSet) { } c = NewItemSet(this.Symbols, this.Prods, this.FS) c.AddItem(this.Items...) + + // Build a map from production ID to list of production indices for O(1) lookup + prodIdMap := make(map[string][]int) + for pi, prod := range this.Prods { + prodIdMap[prod.Id] = append(prodIdMap[prod.Id], pi) + } + included := -1 for again := true; again; { again = false @@ -132,8 +139,10 @@ func (this *ItemSet) Closure() (c *ItemSet) { if i.Pos >= i.Len || this.Symbols.IsTerminal(i.ExpectedSymbol) { continue } - for pi, prod := range this.Prods { - if prod.Id == i.ExpectedSymbol { + // Use the map for O(1) lookup instead of O(n) linear search + if prodIndices, exists := prodIdMap[i.ExpectedSymbol]; exists { + for _, pi := range prodIndices { + prod := this.Prods[pi] first := first1(this.FS, i.Body[i.Pos+1:], i.FollowingSymbol) for _, t := range first { if item := NewItem(pi, prod, 0, t); !c.Contain(item) { @@ -211,6 +220,20 @@ func (this *ItemSet) Size() int { return len(this.Items) } +// canonicalKey returns a canonical string representation of the item set +// used for efficient set equality comparisons. +func (this *ItemSet) canonicalKey() string { + if len(this.imap) == 0 { + return "" + } + keys := make([]string, 0, len(this.imap)) + for k := range this.imap { + keys = append(keys, k) + } + sort.Strings(keys) + return strings.Join(keys, "\x00") +} + func (this *ItemSet) String() string { buf := new(strings.Builder) fmt.Fprintf(buf, "{\n") diff --git a/internal/parser/lr1/items/itemsets.go b/internal/parser/lr1/items/itemsets.go index 636970a7..58a5a7a6 100644 --- a/internal/parser/lr1/items/itemsets.go +++ b/internal/parser/lr1/items/itemsets.go @@ -26,14 +26,21 @@ import ( // A list of a list of Items. type ItemSets struct { sets []*ItemSet + // Map from canonical key to set index for O(1) lookup + keyMap map[string]int } -// TODO: optimise loop // g is a BNF grammar. Items returns the sets of Items of the grammar g. func GetItemSets(g *ast.Grammar, s *symbols.Symbols, firstSets *first.FirstSets) *ItemSets { + initialSet := InitialItemSet(g, s, firstSets).Closure() S := &ItemSets{ - sets: []*ItemSet{InitialItemSet(g, s, firstSets).Closure()}, + sets: []*ItemSet{initialSet}, + keyMap: make(map[string]int), } + // Add initial set to the map + S.keyMap[initialSet.canonicalKey()] = 0 + initialSet.SetNo = 0 + symbols := s.List() included := -1 for again := true; again; { @@ -45,9 +52,11 @@ func GetItemSets(g *ast.Grammar, s *symbols.Symbols, firstSets *first.FirstSets) if gto.Size() > 0 { idx := S.GetIndex(gto) if idx == -1 { - S.sets, again = append(S.sets, gto), true - idx = len(S.sets) - 1 + idx = len(S.sets) + S.sets = append(S.sets, gto) + S.keyMap[gto.canonicalKey()] = idx gto.SetNo = idx + again = true } I.AddTransition(X, idx) } @@ -61,12 +70,21 @@ func GetItemSets(g *ast.Grammar, s *symbols.Symbols, firstSets *first.FirstSets) // Returns whether the list of a list of items contains the list of items. func (this *ItemSets) Contains(I *ItemSet) bool { - for _, i := range this.sets { - if i.Equal(I) { - return true + if I == nil || I.Size() == 0 { + return false + } + // Use map for O(1) lookup instead of O(n) linear search + if this.keyMap == nil { + // Fallback to linear search if keyMap not initialized (shouldn't happen normally) + for _, i := range this.sets { + if i.Equal(I) { + return true + } } + return false } - return false + _, exists := this.keyMap[I.canonicalKey()] + return exists } // Returns the index of the list of items. @@ -74,11 +92,18 @@ func (this *ItemSets) GetIndex(I *ItemSet) int { if I == nil || I.Size() == 0 { return -1 } - - for i, items := range this.sets { - if items.Equal(I) { - return i + // Use map for O(1) lookup instead of O(n) linear search + if this.keyMap == nil { + // Fallback to linear search if keyMap not initialized (shouldn't happen normally) + for i, items := range this.sets { + if items.Equal(I) { + return i + } } + return -1 + } + if idx, exists := this.keyMap[I.canonicalKey()]; exists { + return idx } return -1 } From 7f955aebe8e7c18f3d8bb35bd9ac29693219ca92 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sat, 10 Jan 2026 15:20:21 -0500 Subject: [PATCH 6/9] notes.txt --- notes.txt | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 notes.txt diff --git a/notes.txt b/notes.txt new file mode 100644 index 00000000..0802f62c --- /dev/null +++ b/notes.txt @@ -0,0 +1,65 @@ + 499 pbp|grep circumflex > x + 500 v x + 501 mkdir tmp + 502 cd tmp + 503 ll + 504 ll empty + 505 rmdir empty + 506 mkdir foo1 + 507 cd foo1 + 508 which gocc + 509 gocc + 510 ~/go/bin/gocc + 511 ~/go/bin/gocc -o . /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf + 512 ~/go/bin/gocc -o . /Users/kerl/git/johnkerl/miller//cmd/experiments/dsl_parser/two/temp.bnf + 513 fage + 514 fff + 515 cd ~/git + 516 ll -d */*gocc* + 517 oclone https://github.com/goccmark/gocc + 518 oclone https://github.com/goccmack/gocc + 519 cd goccmack/gocc/ + 520 lt + 521 go build + 522 lsr gocc + 523 ~/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller//cmd/experiments/dsl_parser/two/temp.bnf + 524 cursor . + 525 ./gocc -o foo1 /Users/kerl/git/johnkerl/miller//cmd/experiments/dsl_parser/two/temp.bnf + 526 ~/go/bin/gocc -o . /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf + 527 h + 528 h > notes.txt + +---------------------------------------------------------------- +{ + "cursor.automation.allowAutoRun": true, + "cursor.general.allowAutomation": true +} + +---------------------------------------------------------------- + +Please analyze and fix the performance problem with the following: + +``` +./gocc -o . /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +``` + +Please focus on the following spots the author flagged as needing optimization: + +``` +internal/parser/lr1/items/itemset.go +110://TODO: optimise loop + +internal/parser/lr1/items/itemsets.go +31:// TODO: optimise loop +``` + +================================================================ +justtime ~/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +justtime ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf + +PERF1 + ++ justtime /Users/kerl/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +TIME IN SECONDS 413.809 -- /Users/kerl/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf ++ justtime ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +TIME IN SECONDS 321.756 -- ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf From d042270027faf06dc0c9514d5fcff593a9f109ea Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sat, 10 Jan 2026 15:20:47 -0500 Subject: [PATCH 7/9] Second round --- internal/parser/lr1/items/itemset.go | 70 +++++++++++++++++++--------- notes.txt | 5 ++ 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/internal/parser/lr1/items/itemset.go b/internal/parser/lr1/items/itemset.go index 425f2692..a31f8169 100644 --- a/internal/parser/lr1/items/itemset.go +++ b/internal/parser/lr1/items/itemset.go @@ -35,6 +35,10 @@ type ItemSet struct { Symbols *symbols.Symbols Prods ast.SyntaxProdList FS *first.FirstSets + + // Cached canonical key to avoid recomputation + cachedKey string + keyDirty bool } // NewItemSet returns a newly cosntructed set of items. @@ -80,6 +84,7 @@ func (this *ItemSet) AddItem(items ...*Item) { if _, contain := this.imap[i.str]; !contain { this.imap[i.str] = i this.Items = append(this.Items, i) + this.keyDirty = true // Mark key as dirty when items are added } } } @@ -134,27 +139,34 @@ func (this *ItemSet) Closure() (c *ItemSet) { included := -1 for again := true; again; { again = false - for idx, i := range c.Items { - if idx > included { - if i.Pos >= i.Len || this.Symbols.IsTerminal(i.ExpectedSymbol) { - continue + // Process only items up to the current length (newly added items will be processed next iteration) + itemsLen := len(c.Items) + for idx := included + 1; idx < itemsLen; idx++ { + i := c.Items[idx] + if i.Pos >= i.Len || this.Symbols.IsTerminal(i.ExpectedSymbol) { + included = idx + continue + } + // Use the map for O(1) lookup instead of O(n) linear search + if prodIndices, exists := prodIdMap[i.ExpectedSymbol]; exists { + // Pre-compute the body suffix slice once per item + var bodySuffix []string + if i.Pos+1 < i.Len { + bodySuffix = i.Body[i.Pos+1:] } - // Use the map for O(1) lookup instead of O(n) linear search - if prodIndices, exists := prodIdMap[i.ExpectedSymbol]; exists { - for _, pi := range prodIndices { - prod := this.Prods[pi] - first := first1(this.FS, i.Body[i.Pos+1:], i.FollowingSymbol) - for _, t := range first { - if item := NewItem(pi, prod, 0, t); !c.Contain(item) { - c.AddItem(item) - again = true - } + // Compute first set once per item instead of per production + first := first1(this.FS, bodySuffix, i.FollowingSymbol) + for _, pi := range prodIndices { + prod := this.Prods[pi] + for _, t := range first { + if item := NewItem(pi, prod, 0, t); !c.Contain(item) { + c.AddItem(item) + again = true } } } - - included = idx } + included = idx } } return @@ -188,21 +200,28 @@ func (this *ItemSet) Equal(that *ItemSet) bool { return true } -// first1 returns the characters contained within the first set, sorted in -// alphabetical order. +// first1 returns the characters contained within the first set. +// We iterate over the map directly to avoid unnecessary sorting. func first1(firstSets *first.FirstSets, symbols []string, following string) []string { - firsts := first.FirstS(firstSets, append(symbols, following)) + // Pre-allocate with capacity for following symbol to avoid reallocation + symbolSeq := make([]string, len(symbols)+1) + copy(symbolSeq, symbols) + symbolSeq[len(symbols)] = following + + firsts := first.FirstS(firstSets, symbolSeq) + // Return keys directly from map iteration - order doesn't matter for this use case + // Removed sort.Strings() call which was O(n log n) and unnecessary keys := make([]string, 0, len(firsts)) for key := range firsts { keys = append(keys, key) } - sort.Strings(keys) return keys } // Goto implements Dragon book, 2nd ed, section 4.7.2, p261. func (I *ItemSet) Goto(X string) *ItemSet { J := NewItemSet(I.Symbols, I.Prods, I.FS) + // Pre-allocate Items slice capacity based on expected number of matching items for _, item := range I.Items { if item.Pos < item.Len && X == item.ExpectedSymbol { nextItem := item.Move() @@ -221,17 +240,24 @@ func (this *ItemSet) Size() int { } // canonicalKey returns a canonical string representation of the item set -// used for efficient set equality comparisons. +// used for efficient set equality comparisons. The result is cached. func (this *ItemSet) canonicalKey() string { if len(this.imap) == 0 { return "" } + // Return cached key if still valid + if !this.keyDirty && this.cachedKey != "" { + return this.cachedKey + } + // Recompute key keys := make([]string, 0, len(this.imap)) for k := range this.imap { keys = append(keys, k) } sort.Strings(keys) - return strings.Join(keys, "\x00") + this.cachedKey = strings.Join(keys, "\x00") + this.keyDirty = false + return this.cachedKey } func (this *ItemSet) String() string { diff --git a/notes.txt b/notes.txt index 0802f62c..26e61c01 100644 --- a/notes.txt +++ b/notes.txt @@ -63,3 +63,8 @@ PERF1 TIME IN SECONDS 413.809 -- /Users/kerl/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf + justtime ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf TIME IN SECONDS 321.756 -- ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf + +PERF2 + +justtime ./gocc -o foo3 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +TIME IN SECONDS 226.692 -- ./gocc -o foo3 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf From c9b213ed9b6aecd11d7a7ecef53f04720d37fbdb Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sat, 10 Jan 2026 15:21:17 -0500 Subject: [PATCH 8/9] Third round --- internal/parser/lr1/items/item.go | 45 ++++++++++++++++++++++------ internal/parser/lr1/items/itemset.go | 31 +++++++++++++++---- main.go | 26 ++++++++++++++++ notes.txt | 15 +++++++--- 4 files changed, 98 insertions(+), 19 deletions(-) diff --git a/internal/parser/lr1/items/item.go b/internal/parser/lr1/items/item.go index 9249e0f5..6043f390 100644 --- a/internal/parser/lr1/items/item.go +++ b/internal/parser/lr1/items/item.go @@ -105,7 +105,25 @@ func (this *Item) Equals(that *Item) bool { } func (this *Item) Move() (next *Item) { - return NewItem(this.ProdIdx, this.Prod, this.Pos+1, this.FollowingSymbol) + // Optimize Move() by reusing Body slice to avoid allocations + next = &Item{ + ProdIdx: this.ProdIdx, + Prod: this.Prod, + Id: this.Id, + Body: this.Body, // Reuse the Body slice + Pos: this.Pos + 1, + Len: this.Len, + FollowingSymbol: this.FollowingSymbol, + } + // Update ExpectedSymbol based on new position + if next.Pos < next.Len { + next.ExpectedSymbol = next.Body[next.Pos] + } else { + next.ExpectedSymbol = "" + } + // Recompute string representation + next.str = next.getString() + return next } // reduce returns true if this is a reduce item. @@ -118,25 +136,34 @@ func (this *Item) Symbol(i int) string { } func (this *Item) getString() string { - buf := new(strings.Builder) - fmt.Fprintf(buf, "%s : ", this.Id) + // Pre-allocate buffer with estimated capacity to avoid reallocations + // Estimate: Id (avg 10) + ": " + body symbols (avg 5 * 5 chars) + "• " + " «»" + following (avg 5) = ~50 + estimatedCap := len(this.Id) + 2 + this.Len*8 + 10 + len(this.FollowingSymbol) + buf := strings.Builder{} + buf.Grow(estimatedCap) + + // Use WriteString instead of fmt.Fprintf for better performance + buf.WriteString(this.Id) + buf.WriteString(" : ") if this.Len == 0 { - fmt.Fprintf(buf, "empty") + buf.WriteString("empty") } else { for i, s := range this.Body { if this.Pos == i { - fmt.Fprintf(buf, "•") + buf.WriteString("•") } - fmt.Fprint(buf, s) + buf.WriteString(s) if i < this.Len-1 { - fmt.Fprintf(buf, " ") + buf.WriteString(" ") } } } if this.Pos == this.Len { - fmt.Fprintf(buf, "•") + buf.WriteString("•") } - fmt.Fprintf(buf, " «%s»", this.FollowingSymbol) + buf.WriteString(" «") + buf.WriteString(this.FollowingSymbol) + buf.WriteString("»") return buf.String() } diff --git a/internal/parser/lr1/items/itemset.go b/internal/parser/lr1/items/itemset.go index a31f8169..223888af 100644 --- a/internal/parser/lr1/items/itemset.go +++ b/internal/parser/lr1/items/itemset.go @@ -203,12 +203,19 @@ func (this *ItemSet) Equal(that *ItemSet) bool { // first1 returns the characters contained within the first set. // We iterate over the map directly to avoid unnecessary sorting. func first1(firstSets *first.FirstSets, symbols []string, following string) []string { - // Pre-allocate with capacity for following symbol to avoid reallocation - symbolSeq := make([]string, len(symbols)+1) - copy(symbolSeq, symbols) - symbolSeq[len(symbols)] = following + // Build symbol sequence efficiently - avoid copy when possible + var symbolSeq []string + if len(symbols) == 0 { + symbolSeq = []string{following} + } else { + // Pre-allocate with exact size to avoid reallocation + symbolSeq = make([]string, len(symbols)+1) + copy(symbolSeq, symbols) + symbolSeq[len(symbols)] = following + } firsts := first.FirstS(firstSets, symbolSeq) + // Pre-allocate with exact capacity if known, otherwise reasonable estimate // Return keys directly from map iteration - order doesn't matter for this use case // Removed sort.Strings() call which was O(n log n) and unnecessary keys := make([]string, 0, len(firsts)) @@ -249,13 +256,25 @@ func (this *ItemSet) canonicalKey() string { if !this.keyDirty && this.cachedKey != "" { return this.cachedKey } - // Recompute key + // Recompute key - pre-allocate with exact size to avoid append reallocations keys := make([]string, 0, len(this.imap)) + totalLen := 0 + // Collect keys and compute total length in one pass for k := range this.imap { keys = append(keys, k) + totalLen += len(k) + 1 // +1 for separator } sort.Strings(keys) - this.cachedKey = strings.Join(keys, "\x00") + // Pre-allocate builder with exact capacity to avoid reallocation + buf := strings.Builder{} + buf.Grow(totalLen) + for i, k := range keys { + if i > 0 { + buf.WriteByte('\x00') + } + buf.WriteString(k) + } + this.cachedKey = buf.String() this.keyDirty = false return this.cachedKey } diff --git a/main.go b/main.go index a652dffc..49739952 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,7 @@ import ( "fmt" "os" "path" + "runtime/pprof" "strings" "github.com/johnkerl/gocc/internal/ast" @@ -44,6 +45,31 @@ import ( ) func main() { + // Handle CPU profiling flag manually (before config.New() calls flag.Parse()) + var cpuProfile string + for i, arg := range os.Args { + if arg == "-cpuprofile" && i+1 < len(os.Args) { + cpuProfile = os.Args[i+1] + // Remove cpuprofile flags from os.Args so config doesn't see them + os.Args = append(os.Args[:i], os.Args[i+2:]...) + break + } + } + + if cpuProfile != "" { + f, err := os.Create(cpuProfile) + if err != nil { + fmt.Fprintf(os.Stderr, "Error creating CPU profile: %v\n", err) + os.Exit(1) + } + defer f.Close() + if err := pprof.StartCPUProfile(f); err != nil { + fmt.Fprintf(os.Stderr, "Error starting CPU profile: %v\n", err) + os.Exit(1) + } + defer pprof.StopCPUProfile() + } + flag.Usage = usage cfg, err := config.New() if err != nil { diff --git a/notes.txt b/notes.txt index 26e61c01..a7e5c8cf 100644 --- a/notes.txt +++ b/notes.txt @@ -57,14 +57,21 @@ internal/parser/lr1/items/itemsets.go justtime ~/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf justtime ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +ORIGINAL +$ justtime /Users/kerl/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +TIME IN SECONDS 413.809 -- /Users/kerl/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf + PERF1 -+ justtime /Users/kerl/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf -TIME IN SECONDS 413.809 -- /Users/kerl/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf -+ justtime ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +$ justtime ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf TIME IN SECONDS 321.756 -- ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf PERF2 -justtime ./gocc -o foo3 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +$ justtime ./gocc -o foo3 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf TIME IN SECONDS 226.692 -- ./gocc -o foo3 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf + +PERF3 + +$ justtime ./gocc -o foo4 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +TIME IN SECONDS 155.959 -- ./gocc -o foo4 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf From 38efff71563b75281c1651b199d175f9825346be Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sat, 10 Jan 2026 15:21:43 -0500 Subject: [PATCH 9/9] Final round --- internal/parser/lr1/items/itemset.go | 24 +++++++++++++----------- notes.txt | 15 ++------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/internal/parser/lr1/items/itemset.go b/internal/parser/lr1/items/itemset.go index 223888af..a0748dd8 100644 --- a/internal/parser/lr1/items/itemset.go +++ b/internal/parser/lr1/items/itemset.go @@ -156,11 +156,17 @@ func (this *ItemSet) Closure() (c *ItemSet) { } // Compute first set once per item instead of per production first := first1(this.FS, bodySuffix, i.FollowingSymbol) + // Pre-allocate expected number of new items to reduce allocations for _, pi := range prodIndices { prod := this.Prods[pi] for _, t := range first { - if item := NewItem(pi, prod, 0, t); !c.Contain(item) { - c.AddItem(item) + // Create item and check containment + item := NewItem(pi, prod, 0, t) + // Use direct map lookup instead of Contain() for better performance + if _, exists := c.imap[item.str]; !exists { + c.imap[item.str] = item + c.Items = append(c.Items, item) + c.keyDirty = true again = true } } @@ -173,10 +179,8 @@ func (this *ItemSet) Closure() (c *ItemSet) { } func (this *ItemSet) Contain(item *Item) bool { - if _, contain := this.imap[item.str]; contain { - return true - } - return false + _, exists := this.imap[item.str] + return exists } func (this *ItemSet) ContainString(item string) bool { @@ -203,9 +207,9 @@ func (this *ItemSet) Equal(that *ItemSet) bool { // first1 returns the characters contained within the first set. // We iterate over the map directly to avoid unnecessary sorting. func first1(firstSets *first.FirstSets, symbols []string, following string) []string { - // Build symbol sequence efficiently - avoid copy when possible var symbolSeq []string if len(symbols) == 0 { + // Avoid allocation for the common case of empty symbols symbolSeq = []string{following} } else { // Pre-allocate with exact size to avoid reallocation @@ -215,9 +219,7 @@ func first1(firstSets *first.FirstSets, symbols []string, following string) []st } firsts := first.FirstS(firstSets, symbolSeq) - // Pre-allocate with exact capacity if known, otherwise reasonable estimate - // Return keys directly from map iteration - order doesn't matter for this use case - // Removed sort.Strings() call which was O(n log n) and unnecessary + // Pre-allocate keys slice with exact capacity to avoid reallocations keys := make([]string, 0, len(firsts)) for key := range firsts { keys = append(keys, key) @@ -228,7 +230,7 @@ func first1(firstSets *first.FirstSets, symbols []string, following string) []st // Goto implements Dragon book, 2nd ed, section 4.7.2, p261. func (I *ItemSet) Goto(X string) *ItemSet { J := NewItemSet(I.Symbols, I.Prods, I.FS) - // Pre-allocate Items slice capacity based on expected number of matching items + // Pre-filter items that match X to avoid unnecessary Move() calls for _, item := range I.Items { if item.Pos < item.Len && X == item.ExpectedSymbol { nextItem := item.Move() diff --git a/notes.txt b/notes.txt index a7e5c8cf..09b0e150 100644 --- a/notes.txt +++ b/notes.txt @@ -57,21 +57,10 @@ internal/parser/lr1/items/itemsets.go justtime ~/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf justtime ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf -ORIGINAL -$ justtime /Users/kerl/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf TIME IN SECONDS 413.809 -- /Users/kerl/go/bin/gocc -o foo1 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf -PERF1 - -$ justtime ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf TIME IN SECONDS 321.756 -- ./gocc -o foo2 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf - -PERF2 - -$ justtime ./gocc -o foo3 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf TIME IN SECONDS 226.692 -- ./gocc -o foo3 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf - -PERF3 - -$ justtime ./gocc -o foo4 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf TIME IN SECONDS 155.959 -- ./gocc -o foo4 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +TIME IN SECONDS 148.168 -- ./gocc -o foo5 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf +TIME IN SECONDS 135.048 -- ./gocc -o foo5 /Users/kerl/git/johnkerl/miller/pkg/parsing/mlr.bnf