1
0
mirror of https://github.com/golang/go synced 2024-10-02 06:28:33 -06:00
The Go programming language
Go to file
Russ Cox c7fa3c625e [dev.cc] cmd/yacc: introduce yyParser to expose parser state
Historically, yacc has supported various kinds of inspections
and manipulations of the parser state, exposed as global variables.
The Go implementation of yacc puts that state (properly) in local
stack variables, so it can only be exposed explicitly.

There is now an explicit parser type, yyParser, returned by a
constructor, yyNewParser.

	type yyParser interface {
		Parse(yyLexer) int
		Lookahead() int
	}

Parse runs a parse. A call to the top-level func Parse
is equivalent to calling yyNewParser().Parse, but constructing
the parser explicitly makes it possible to access additional
parser methods, such as Lookahead.

Lookahead can be called during grammar actions to read
(but not consume) the value of the current lookahead token,
as returned by yylex.Lex. If there is no current lookahead token,
Lookahead returns -1. Invoking Lookahead corresponds to
reading the global variable yychar in a traditional Unix yacc grammar.

To support Lookahead, the internal parsing code now separates
the return value from Lex (yychar) from the reencoding used
by the parsing tables (yytoken). This has the effect that grammars
that read yychar directly in the action (possible since the actions
are in the same function that declares yychar) now correctly see values
from the Lex return value space, not the internal reencoding space.
This can fix bugs in ported grammars not even using SetParse and Lookahead.
(The reencoding was added on Plan 9 for large character sets.
No Plan 9 programs using yacc looked at yychar.)

Other methods may be added to yyParser later as needed.
Obvious candidates include equivalents for the traditional
yyclearin and yyerrok macros.

Change-Id: Iaf7649efcf97e09f44d1f5bc74bb563a11f225de
Reviewed-on: https://go-review.googlesource.com/4850
Reviewed-by: Rob Pike <r@golang.org>
2015-02-18 02:39:48 +00:00
api runtime: add GODEBUG=gccheckmark=0/1 2015-01-12 16:36:50 +00:00
doc [dev.cc] doc/go1.5.txt: assembler changes 2015-02-13 23:12:33 +00:00
include [dev.cc] all: merge master (5f1efe7) into dev.cc 2015-02-13 12:51:56 -05:00
lib/time remove the obsolete lib/codereview. 2014-12-08 07:51:54 +00:00
misc [dev.cc] misc/cgo/test: fix PC reference in arm assembler 2015-02-17 21:42:27 +00:00
src [dev.cc] cmd/yacc: introduce yyParser to expose parser state 2015-02-18 02:39:48 +00:00
test cmd/gc: transform closure calls to function calls 2015-02-13 12:12:18 +00:00
.gitattributes .gitattributes: prevent all magic line ending changes 2014-12-12 23:14:54 +00:00
.gitignore [dev.cc] cmd/new5a etc, cmd/internal/asm: edit to produce working Go code 2015-01-21 19:42:58 +00:00
AUTHORS A+C: add another email address for Emil Hessman 2014-11-12 10:01:23 -08:00
CONTRIBUTING.md doc: direct people to the mailing list 2015-01-18 21:27:07 +00:00
CONTRIBUTORS C: add Nick Cooper (Google CLA). 2014-11-14 17:03:17 +11:00
favicon.ico godoc: update favicon 2012-10-11 17:02:36 +11:00
LICENSE doc: update licensing text one more time 2012-03-27 15:09:13 +11:00
PATENTS
README.md README: emphasize that we don't accept pull requests 2015-01-08 18:50:47 +00:00
robots.txt godoc: serve robots.txt raw 2011-02-19 05:46:20 +11:00

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image

For documentation about how to install and use Go, visit https://golang.org/ or load doc/install-source.html in your web browser.

Our canonical Git repository is located at https://go.googlesource.com/go. (There is a mirror of the repository at https://github.com/golang/go.)

Please report issues here: https://golang.org/issue/new

Go is the work of hundreds of contributors. We appreciate your help!

To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html

Please note that we do not use pull requests.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

--

Binary Distribution Notes

If you have just untarred a binary Go distribution, you need to set the environment variable $GOROOT to the full path of the go directory (the one containing this file). You can omit the variable if you unpack it into /usr/local/go, or if you rebuild from sources by running all.bash (see doc/install-source.html). You should also add the Go binary directory $GOROOT/bin to your shell's path.

For example, if you extracted the tar file into $HOME/go, you might put the following in your .profile:

export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin

See https://golang.org/doc/install or doc/install.html for more details.