1
0
mirror of https://github.com/golang/go synced 2024-11-22 03:44:39 -07:00
The Go programming language
Go to file
Roger Peppe 80e17d6797 the AST walker currently provides no way to find out how the
nodes in the tree are nested with respect to one another.
a simple change to the Visitor interface makes it possible
to do this (for example to maintain a current node-depth, or a
knowledge of the name of the current function).

Visit(nil) is called at the end of a node's children;
this make possible the channel-based interface below,
amongst other possibilities.

It is still just as simple to get the original behaviour - just
return the same Visitor from Visit.

Here are a couple of possible Visitor types.

// closure-based
type FVisitor func(n interface{}) FVisitor
func (f FVisitor) Visit(n interface{}) Visitor {
	return f(n);
}

// channel-based
type CVisitor chan Visit;
type Visit struct {
	node interface{};
	reply chan CVisitor;
};
func (v CVisitor) Visit(n interface{}) Visitor
{
	if n == nil {
		close(v);
	} else {
		reply := make(chan CVisitor);
		v <- Visit{n, reply};
		r := <-reply;
		if r == nil {
			return nil;
		}
		return r;
	}
	return nil;
}

R=gri
CC=rsc
https://golang.org/cl/166047
2009-12-07 10:33:45 -08:00
doc spec: document that built-ins cannot be used as func values 2009-12-04 10:23:12 -08:00
include Ports of lib9, libbio and libmach to Windows. 2009-11-30 11:53:11 -08:00
lib codereview: do not gofmt deleted files 2009-12-03 17:23:11 -08:00
misc Add 'copy' as a Go builtin function for Vim syntax highlighter spec. 2009-12-01 16:45:21 -08:00
pkg more description 2009-10-15 23:08:46 -07:00
src the AST walker currently provides no way to find out how the 2009-12-07 10:33:45 -08:00
test changes necessary to get the new chameneosredux onto shootout.alioth.debian.org . 2009-12-07 10:06:51 -08:00
.hgignore build Make.deps during make.bash instead 2009-11-19 16:27:13 -08:00
.hgtags release.2009-11-17: tag as of earlier this evening 2009-11-17 22:00:17 -08:00
AUTHORS A/C: add Charles L. Dorian 2009-12-01 12:45:41 -08:00
CONTRIBUTORS A/C: add Charles L. Dorian 2009-12-01 12:45:41 -08:00
favicon.ico add a favicon plus a couple of hi-res versions of gordon 2009-10-26 10:13:07 -07:00
LICENSE Add AUTHORS and LICENSE files. 2009-08-13 09:21:28 -07:00
README add a README file, so that if someone finds a 2009-11-08 09:57:37 -08:00

This is the source code repository for the Go programming language.  

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

After installing Go, you can view a nicely formatted
doc/install.html by running godoc --http=:6060
and then visiting http://localhost:6060/doc/install.html.

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