Commit 6c3befc8 authored by Roger Peppe's avatar Roger Peppe Committed by Ken Thompson

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
parent 29c6c09f
...@@ -19,5 +19,18 @@ The file units.y in this directory is a yacc grammar for a version of ...@@ -19,5 +19,18 @@ The file units.y in this directory is a yacc grammar for a version of
the Unix tool units, also written in Go and largely transliterated the Unix tool units, also written in Go and largely transliterated
from the Plan 9 C version. 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 package documentation
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment