summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2010-04-14 21:33:34 -0700
committerRobert Griesemer <gri@golang.org>2010-04-14 21:33:34 -0700
commitfb6dab658038153850eab2d84e46d66379acaf5e (patch)
tree07a97f13438f0cf2094abcf969556ce661d72b90
parent39656bb7a4553416504d2cbbf5d7ef9e0e0904b9 (diff)
downloadgolang-fb6dab658038153850eab2d84e46d66379acaf5e.tar.gz
scanner: implement Peek() to look at the next char w/o advancing
R=rsc CC=golang-dev http://codereview.appspot.com/840045
-rw-r--r--src/pkg/scanner/scanner.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/pkg/scanner/scanner.go b/src/pkg/scanner/scanner.go
index 25544f667..f60a4eed2 100644
--- a/src/pkg/scanner/scanner.go
+++ b/src/pkg/scanner/scanner.go
@@ -282,6 +282,14 @@ func (s *Scanner) Next() int {
}
+// Peek returns the next Unicode character in the source without advancing
+// the scanner. It returns EOF if the scanner's position is at the last
+// character of the source.
+func (s *Scanner) Peek() int {
+ return s.ch
+}
+
+
func (s *Scanner) error(msg string) {
s.ErrorCount++
if s.Error != nil {