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.
to make it behave sensibly when used in a non-main package, i've also renamed all ...
14 years, 12 months ago
(2010-04-01 15:32:50 UTC)
#2
to make it behave sensibly when used in a non-main package,
i've also renamed all global identifiers to begin with a lower
case letter so they're not exported automatically.
to that end, the externally visible interface must also change:
Parse() becomes yyParse(), and YYSTYPE becomes yySymType.
alternate spellings are of course possible.
LGTM but i'll wait for ken before submitting. http://codereview.appspot.com/879041/diff/13001/14003 File src/cmd/goyacc/units.y (right): http://codereview.appspot.com/879041/diff/13001/14003#newcode218 src/cmd/goyacc/units.y:218: func ...
14 years, 12 months ago
(2010-04-01 16:00:51 UTC)
#4
On 5 April 2010 22:47, <ken@google.com> wrote: > LGTM > > some nits - in ...
14 years, 12 months ago
(2010-04-06 11:09:22 UTC)
#6
On 5 April 2010 22:47, <ken@google.com> wrote:
> LGTM
>
> some nits - in the conversion from Error() to
> fmt.Print(), newlines were removed from
> some diagnostics.
"it weren't me guv". fixed.
> beyond the scope of this change:
> this change allows 2 usages of the same grammar,
> but still does not allow use of 2 grammars. it seems
> that a more general change could have fixed both
> problems.
this is something i've thought a little about. it seems to me
that allowing two grammars is more of a namespace issue
than a code issue. if you generate two grammars, you
are going to have to hang the static data and the code off
at least two names, and the only way of avoiding
a name clash is to specify the name (or a name prefix)
when calling goyacc.
we could do that, but i figured that
a) you can get the same effect by using two different packages
and
b) when you really need two grammars in one package, you can
perform the same trick that go uses with its hidden_import and
have a disjoint set of production names.
perhaps (very likely!) there's an approach i haven't thought of?
*** Submitted as http://code.google.com/p/go/source/detail?r=df523f06e5c7 *** Change goyacc to be reentrant. Instead of calling the package ...
14 years, 11 months ago
(2010-04-06 20:29:31 UTC)
#7
*** Submitted as http://code.google.com/p/go/source/detail?r=df523f06e5c7 ***
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
http://codereview.appspot.com/879041
Committer: Ken Thompson <ken@golang.org>
Issue 879041: code review 879041: Change goyacc to be reentrant.
(Closed)
Created 14 years, 12 months ago by rog
Modified 14 years, 11 months ago
Reviewers:
Base URL:
Comments: 5