Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/cmd/goyacc: goyacc does not support %code #56944

Open
pjbgf opened this issue Nov 26, 2022 · 3 comments
Open

x/tools/cmd/goyacc: goyacc does not support %code #56944

pjbgf opened this issue Nov 26, 2022 · 3 comments
Labels
FeatureRequest help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@pjbgf
Copy link

pjbgf commented Nov 26, 2022

What version of Go are you using (go version)?

$ go version
go version go1.19.3 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pjbgf/.cache/go-build"
GOENV="/home/pjbgf/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/levi/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/levi/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/pjbgf/go/src/github.com/pjbgf/go-apparmor/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2200620041=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ curl -o parser_yacc.y https://gitlab.apertis.org/pkg/apparmor/-/raw/ubuntu/master/parser/parser_yacc.y
$ goyacc -o output parser_yacc.y
invalid escape, or illegal reserved word: code: parser_yacc.y:182

What did you expect to see?

Successful processing of parser_yacc.y.

What did you see instead?

invalid escape, or illegal reserved word: code: parser_yacc.y:182

@robpike
Copy link
Contributor

robpike commented Nov 26, 2022

Goyacc is derived from the original Unix 7th Edition yacc, with a few tweaks along the way. The %code token was not part of that implementation and I am unfamiliar with it.

What does it do, where have you seen it supported, and why do you need it?

@pjbgf
Copy link
Author

pjbgf commented Nov 26, 2022

I found this about %code:

The %code directive inserts code verbatim into the output parser source at any of a predefined set of locations. It thus serves as a flexible and user-friendly alternative to the traditional Yacc prologue, %{code%}.

I am trying to use the official yacc parser definition for AppArmor, which currently uses it.
In terms of implementation, the GNU yacc CLI supports it.

@robpike
Copy link
Contributor

robpike commented Nov 26, 2022

The workaround is trivial, although it does require editing the grammar.

@seankhliao seankhliao changed the title tools/cmd/goyacc: goyacc does not support %code x/tools/cmd/goyacc: goyacc does not support %code Nov 26, 2022
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Nov 26, 2022
@gopherbot gopherbot added this to the Unreleased milestone Nov 26, 2022
@cherrymui cherrymui added FeatureRequest help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants