From fb6dab658038153850eab2d84e46d66379acaf5e Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 14 Apr 2010 21:33:34 -0700 Subject: scanner: implement Peek() to look at the next char w/o advancing R=rsc CC=golang-dev http://codereview.appspot.com/840045 --- src/pkg/scanner/scanner.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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 { -- cgit v1.2.3