Change goyacc to be reentrant.
Instead of calling the package scope Lex function,
Parse now takes an argument which is used to
do the lexing.
I reverted to having the generated switch
code inside Parse rather than a separate function because
the function needs 7 arguments or a context structure,
which seems unnecessary.
I used yyrun(), not the original $A so that
it's possible to run the backquoted code through gofmt.
R=rsc, ken2, ken3
CC=golang-dev
https://golang.org/cl/879041
diff --git a/src/cmd/goyacc/doc.go b/src/cmd/goyacc/doc.go
index a3cf075..eea70ad 100644
--- a/src/cmd/goyacc/doc.go
+++ b/src/cmd/goyacc/doc.go
@@ -19,5 +19,18 @@
the Unix tool units, also written in Go and largely transliterated
from the Plan 9 C version.
+The generated parser is reentrant. Parse expects to be given an
+argument that conforms to the following interface:
+
+ type yyLexer interface {
+ Lex(lval *yySymType) int
+ }
+
+Lex should return the token identifier, and place other token
+information in lval (which replaces the usual yylval).
+
+Code inside the parser may refer to the variable yylex
+which holds the yyLexer passed to Parse.
+
*/
package documentation