Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(23)

Issue 4256044: code review 4256044: goyacc: provide -p flag to set prefix for names. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years ago by r
Modified:
14 years ago
Reviewers:
rog
CC:
rsc, r2, golang-dev
Visibility:
Public.

Description

goyacc: provide -p flag to set prefix for names. This should allow multiple goyacc grammars to be compiled into the same binary. There's a chance it Fixes issue 1562.

Patch Set 1 #

Patch Set 2 : diff -r 4c0a44d9a0f6 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 4c0a44d9a0f6 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+180 lines, -166 lines) Patch
M src/cmd/goyacc/Makefile View 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/goyacc/doc.go View 1 2 chunks +9 lines, -2 lines 0 comments Download
M src/cmd/goyacc/goyacc.go View 1 21 chunks +164 lines, -160 lines 0 comments Download
M src/cmd/goyacc/units.y View 4 chunks +6 lines, -3 lines 0 comments Download

Messages

Total messages: 14
r
Hello rsc (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
14 years ago (2011-03-01 00:52:18 UTC) #1
rsc
> (Some local hidden symbols may still begin "yy".) codereview won't let me log in. ...
14 years ago (2011-03-01 01:03:56 UTC) #2
r2
On Feb 28, 2011, at 5:03 PM, Russ Cox wrote: >> (Some local hidden symbols ...
14 years ago (2011-03-01 01:18:34 UTC) #3
rsc
> the important word is 'local'. i could rename all local variables if you like. ...
14 years ago (2011-03-01 01:19:08 UTC) #4
r2
On Feb 28, 2011, at 5:19 PM, Russ Cox wrote: >> the important word is ...
14 years ago (2011-03-01 01:20:16 UTC) #5
r2
tubenose=% 6nm units | grep -i yy 4fb88 D go.string."yys" 442f8 D string."yys" tubenose=% not ...
14 years ago (2011-03-01 01:28:12 UTC) #6
r
Hello rsc, r2 (cc: golang-dev@googlegroups.com), Please take another look.
14 years ago (2011-03-01 01:35:24 UTC) #7
rsc
On Mon, Feb 28, 2011 at 20:28, Rob 'Commander' Pike <r@google.com> wrote: > tubenose=% 6nm ...
14 years ago (2011-03-01 01:39:41 UTC) #8
rsc
LGTM
14 years ago (2011-03-01 01:40:12 UTC) #9
r
*** Submitted as http://code.google.com/p/go/source/detail?r=f7eb42f2a25c *** goyacc: provide -p flag to set prefix for names. This ...
14 years ago (2011-03-01 01:43:27 UTC) #10
r2
hold on why did i just submit this? why not just use generate each grammar ...
14 years ago (2011-03-01 01:45:15 UTC) #11
rsc
> why did i just submit this? why not just use generate each grammar into ...
14 years ago (2011-03-01 02:22:50 UTC) #12
r2
that's a nice idea the thing i did today mimics the flags in bison, so ...
14 years ago (2011-03-01 04:51:44 UTC) #13
rog
14 years ago (2011-03-01 08:51:03 UTC) #14
On 1 March 2011 02:22, Russ Cox <rsc@golang.org> wrote:
>> why did i just submit this? why not just use generate each grammar into a
separate package.
>
> i think it's a good thing to avoid any requirements that
> you can only have one foo per package.  for example,
> we allow multiple types per package (in contrast to java).
>
> i have a separate change i'd like to see to goyacc,
> but it is more involved: goyacc should have a
>
> %receiver x *T  (or x *t, doesn't have to be exported)
>
> line that makes Parse() a method on (x *T) that calls
> x.Lex and x.Error instead of taking an interface value.

the down side of this is that it would become impossible
to use a lexer type declared in a separate package,
although this probably isn't a problem as you can
always embed.

there's no particular reason to conflate
the lexer and the parser. %receiver x *T
could create this parse method

func (x *T) Parse(yylex yyLexer) int

having the lexer separate means that it's easier
to use the same parser with different lexer types,
but there's no reason x and yylex might not actually be
the same object.

i wouldn't object either way.

> the main benefit of the %receiver change would be
> that the actions could refer to and store data in x.

you can use yylex for that. for instance, a reentrant
parser i wrote ages ago does this to return the
final value of the parse (in fact it was the above example
that motivated me to make go yacc reentrant in the first place.)

here, for example, is the top level production:

unit: line ';' {
		yylex.(*abcLex).result = $line;
		return 0
	}
	| line tEND {
		yylex.(*abcLex).result = $line;
		return 0
	}

no need for panic abuse, although you might not like
this either, and you're right that it's not obvious.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b