-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
- What version of Go are you using (
go version
)?
go version go1.6.2 windows/amd64
- What operating system and processor architecture are you using (
go env
)?
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\rillig\go
set GORACE=
set GOROOT=C:\Program Files (x86)\Go1.6.2
set GOTOOLDIR=C:\Program Files (x86)\Go1.6.2\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=1
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
- What did you do?
I wrote a Yacc parser for parsing shell commands into an AST.
I accessed the resulting AST via yyParserImpl.stack[1]
.
For small examples, this worked well.
More complicated examples resulted in nil
being on the stack.
- What did you expect to see?
yyParserImpl.stack[1]
should always contain the result, no matter how deeply nested the grammar is.
- What did you see instead?
When the Yacc parser needs more stack, it grows it. The code is after the yystack:
label. This new stack is then local to the current function, and it is not written back into the parser. This means that calling Parse
multiple times will create unnecessary copies of the stack. And, more importantly, accessing the actual stack becomes impossible.
References: http://stackoverflow.com/questions/36822702/accessing-result-of-a-golang-yacc-generated-parser