Open eric-s-raymond opened 6 years ago
It's available as [prefix]Symname
here: https://github.com/cznic/goyacc/blob/fceb47475462725e1e3e19538ba062e87ca4d902/main.go#L566
The prefix defaults to yy
. Most of the time the generated parser is not imported, but part of the package where it's used. To change the prefix and make it optionally an "exporting" one, use the -p
flag as in, for example, -p MyParser
.
Would that handle your use case?
Also, FTR, I've started the process of migrating my repositories away from Github, please consider using the new "canonical" path modernc.org/goyacc in your project(s).
I'm confused. Nothing with a name containing SymName exists in my generated parser code. I don't have a main.go. How do I get to that function?
I'm fetching from golang.org/x/tools/cmd/goyacc
Should I expect that to continue to work?
golang.org/x/tools/cmd/goyacc is not the same tool as github.com/cznic/goyacc nor modernc.org/goyacc.
The tool in this repository has a lot of enhacements wrt golang.org/x/tools/cmd/goyacc.
I'm just leaving home, will get back to you later this evening (CET).
I've installed the modernc version.
Ok, the main.go is the source of the tool per se. The earlier link into main go shows the embedded template. The produced parser goes to where the -y flag directs, the decaukt is y.go. Pretty much what the real unix yacc does.
So the yySymName function is to be found in the y.go file if you're using the defaults.
If your project is available somewhere for me to look at, I may be able to provide more useful hints.
Here it is:
https://gitlab.com/esr/cgoparse
Note that I'm using the -o option in my go generate command; expect to find the generated grammar in src/cparse/c-grammar.go.
You will need to do "make setup" before "make".
Thanks for the link. Your project seems to at least partaally overlap in functionality with https://godoc.org/modernc.org/cc/v2 (hosted at https://gitlab.com/cznic/cc/v2). You might want to take a look at it. If you do so, please provide feedback if you may possibly use the existing cc/v2 package. I'd be happy to welcome you as another author/contributor of the project.
The core function of interest is https://godoc.org/modernc.org/cc/v2#Translate.
Currently comments are not preserved, but that's easy to add. Actually, the v1.0.0 did that, so it's only a question of porting the relevant code also to v2.0.0.
edit: s/cc/cc\/v2/
Very interesting. Yes, cooperating with you on this looks like it would save me a lot of work.
I actually have a use in mind for the AST that I have not talked about because I don't want to imply any promises in public that I can't keep. Plesae email me at esr@thyrus.com so I can brief you and we can figure out what needs to be finished to acieve both our objectives.
Plesae email me at esr@thyrus.com ...
@eric-s-raymond
I tried about 10 minutes ago, but:
The response from the remote server was:
550 5.1.1 esr@thyrus.com Recipient not found. http://x.co/irbounce
You emailed me while my house net was screwed up by the aftermath of a power outage. Took me a week to recover - kept getting false clues because my downstairs Ethernet switch lost its marbles.
You should be able to email me now.
I feel as though I should not have had to write this:
That magic number is particularly annoying.
Would you please make something equivalent a public method?