diff --git a/README.md b/README.md index 9dcf6574..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 @@ -27,16 +27,16 @@ in the BNF. 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. diff --git a/doc/gocc_user_guide.tex b/doc/gocc_user_guide.tex index a9a1f060..ada687f2 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: @@ -352,8 +352,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" ) @@ -402,16 +402,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. @@ -428,8 +428,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} @@ -437,7 +437,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: @@ -495,8 +495,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" ) @@ -580,7 +580,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 ; @@ -591,7 +591,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 @@ -600,8 +600,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 @@ -654,7 +654,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: @@ -665,7 +665,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 @@ -704,14 +704,14 @@ \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/goccmack/gocc/example/astx/token" + import "github.com/johnkerl/gocc/example/astx/ast" + import "github.com/johnkerl/gocc/example/astx/token" >> StmtList : @@ -725,20 +725,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 ( @@ -776,7 +776,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: @@ -793,7 +793,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]|. @@ -806,10 +806,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) >> @@ -828,18 +828,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 @@ -859,11 +859,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|. @@ -877,19 +877,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" ) >> @@ -909,7 +909,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| @@ -937,7 +937,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: @@ -945,11 +945,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} @@ -961,13 +961,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 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/ast/ast.go b/example/astx/ast/ast.go index bdffacb6..cbd78cd0 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 208e111e..ae26c11f 100755 --- a/example/astx/errors/errors.go +++ b/example/astx/errors/errors.go @@ -8,7 +8,7 @@ import ( "strings" "unicode" - "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 cc9f24de..c6988bde 100755 --- a/example/astx/lexer/lexer.go +++ b/example/astx/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "os" "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 b383dd8c..0f9561e4 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 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/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 ac8a1e4c..35c1c135 100755 --- a/example/bools/errors/errors.go +++ b/example/bools/errors/errors.go @@ -8,7 +8,7 @@ import ( "strings" "unicode" - "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 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/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 73ba8ecf..3fc9cd66 100755 --- a/example/bools/lexer/lexer.go +++ b/example/bools/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "os" "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 165f1323..55e30625 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 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/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 46a52a9c..249ff3b0 100755 --- a/example/calc/errors/errors.go +++ b/example/calc/errors/errors.go @@ -8,7 +8,7 @@ import ( "strings" "unicode" - "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 7f6e5403..d94018bb 100755 --- a/example/calc/lexer/lexer.go +++ b/example/calc/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "os" "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 c2ed4ae1..a13bc234 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 d904e61f..3b2da594 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/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/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 43260810..c1de5e9d 100755 --- a/example/errorrecovery/errors/errors.go +++ b/example/errorrecovery/errors/errors.go @@ -8,7 +8,7 @@ import ( "strings" "unicode" - "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 714c1eeb..6dd5eb04 100755 --- a/example/errorrecovery/lexer/lexer.go +++ b/example/errorrecovery/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "os" "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 7b324d8d..5ee9f447 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 e1238611..98f8d73c 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 0ed19738..69716a17 100755 --- a/example/mail/lexer/lexer.go +++ b/example/mail/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "os" "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 50539554..da201d0b 100755 --- a/example/nolexer/errors/errors.go +++ b/example/nolexer/errors/errors.go @@ -8,7 +8,7 @@ import ( "strings" "unicode" - "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 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/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 ea9c8c40..78838439 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 65a67d1b..4c9db290 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 4754ed4b..a3887e99 100755 --- a/example/rr/errors/errors.go +++ b/example/rr/errors/errors.go @@ -8,7 +8,7 @@ import ( "strings" "unicode" - "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 c80abfe1..fb3e12df 100755 --- a/example/rr/lexer/lexer.go +++ b/example/rr/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "os" "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 a8013cda..6dde7ff9 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 9f682314..74a96c6e 100755 --- a/example/sr/errors/errors.go +++ b/example/sr/errors/errors.go @@ -8,7 +8,7 @@ import ( "strings" "unicode" - "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 dc2b9fb5..35c2bce7 100755 --- a/example/sr/lexer/lexer.go +++ b/example/sr/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "os" "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 f39196cd..68ba88ee 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 69411092..72220fe0 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/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/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.mod b/go.mod index 571fd5c8..6b974703 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/goccmack/gocc +module github.com/johnkerl/gocc go 1.24 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 c7cefa50..fa28c78f 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 51d7bb09..af555b40 100644 --- a/internal/frontend/scanner/scanner.go +++ b/internal/frontend/scanner/scanner.go @@ -13,7 +13,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 d3dd86e0..ed772153 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 c7ac37af..6fc611f9 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 08473a15..65f78989 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 12bb68a8..6a28074b 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 7405c571..62d9195c 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 2c7563c5..c51800ec 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 1b62b3d6..38a52c39 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 f3549941..a6012ae7 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 7214d62c..94decb4b 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 26cde10c..88b476e1 100644 --- a/internal/lexer/items/testutils_test.go +++ b/internal/lexer/items/testutils_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" ) 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 d933a77a..ee67949d 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 1350faa1..91c6900b 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" ) // FirstSets represents a map of id->production. diff --git a/internal/parser/gen/gen.go b/internal/parser/gen/gen.go index 8f24c202..7dfcefee 100644 --- a/internal/parser/gen/gen.go +++ b/internal/parser/gen/gen.go @@ -16,12 +16,12 @@ 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/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/parser/gen/golang/errors.go b/internal/parser/gen/golang/errors.go index 0ebc0f7c..7d5b0e43 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 ebd85d5c..6659652f 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 d55f0196..3f89da02 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 7363342b..6043f390 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. @@ -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 acff130a..a0748dd8 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 { @@ -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 } } } @@ -107,9 +112,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,38 +129,58 @@ 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 - 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:] } - for pi, prod := range this.Prods { - if prod.Id == i.ExpectedSymbol { - 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) + // Pre-allocate expected number of new items to reduce allocations + for _, pi := range prodIndices { + prod := this.Prods[pi] + for _, t := range first { + // 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 } } } - - included = idx } + included = idx } } return } 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 { @@ -179,21 +204,33 @@ 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)) + 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 + symbolSeq = make([]string, len(symbols)+1) + copy(symbolSeq, symbols) + symbolSeq[len(symbols)] = following + } + + firsts := first.FirstS(firstSets, symbolSeq) + // Pre-allocate keys slice with exact capacity to avoid reallocations 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-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() @@ -211,6 +248,39 @@ 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. 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 - 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) + // 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 +} + 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 c0d998d4..58a5a7a6 100644 --- a/internal/parser/lr1/items/itemsets.go +++ b/internal/parser/lr1/items/itemsets.go @@ -18,22 +18,29 @@ 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. 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 } diff --git a/internal/parser/lr1/items/rowconflicts.go b/internal/parser/lr1/items/rowconflicts.go index 00b767b0..9ffb712c 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" ) // key: symbol; value: list of actions. 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 10cde1f8..91fa5ce2 100644 --- a/internal/parser/symbols/symbols.go +++ b/internal/parser/symbols/symbols.go @@ -19,7 +19,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 4ea80a33..ca615da5 100755 --- a/internal/test/t1/errors/errors.go +++ b/internal/test/t1/errors/errors.go @@ -8,7 +8,7 @@ import ( "strings" "unicode" - "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 a02460af..ef84a873 100755 --- a/internal/test/t1/lexer/lexer.go +++ b/internal/test/t1/lexer/lexer.go @@ -6,7 +6,7 @@ import ( "os" "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 e203b7a3..3d5a4ea8 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 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/gen.go b/internal/token/gen/gen.go index b675429c..b6e5de5b 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/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/internal/token/gen/golang/token.go b/internal/token/gen/golang/token.go index db3a33ec..a27d4a68 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 28b6f49e..bc7d6a34 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 d7237281..49739952 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 ( @@ -22,28 +22,54 @@ import ( "fmt" "os" "path" + "runtime/pprof" "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() { + // 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 new file mode 100644 index 00000000..09b0e150 --- /dev/null +++ b/notes.txt @@ -0,0 +1,66 @@ + 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 + +TIME IN SECONDS 413.809 -- /Users/kerl/go/bin/gocc -o foo1 /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 +TIME IN SECONDS 226.692 -- ./gocc -o foo3 /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 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) >>