]> Cypherpunks repositories - gostls13.git/commitdiff
scanner: implement Peek() to look at the next char w/o advancing
authorRobert Griesemer <gri@golang.org>
Thu, 15 Apr 2010 04:33:34 +0000 (21:33 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 15 Apr 2010 04:33:34 +0000 (21:33 -0700)
R=rsc
CC=golang-dev
https://golang.org/cl/840045

src/pkg/scanner/scanner.go

index 25544f667e55179d7955f21abe819c4406b51924..f60a4eed27bbe18e007c3b7f154fd7103e3807e5 100644 (file)
@@ -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 {