summaryrefslogtreecommitdiff
path: root/src/pkg/scanner/scanner.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-01-17 12:40:45 +0100
committerOndřej Surý <ondrej@sury.org>2011-01-17 12:40:45 +0100
commit3e45412327a2654a77944249962b3652e6142299 (patch)
treebc3bf69452afa055423cbe0c5cfa8ca357df6ccf /src/pkg/scanner/scanner.go
parentc533680039762cacbc37db8dc7eed074c3e497be (diff)
downloadgolang-3e45412327a2654a77944249962b3652e6142299.tar.gz
Imported Upstream version 2011.01.12upstream/2011.01.12
Diffstat (limited to 'src/pkg/scanner/scanner.go')
-rw-r--r--src/pkg/scanner/scanner.go24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/pkg/scanner/scanner.go b/src/pkg/scanner/scanner.go
index f60a4eed2..11aa9f43f 100644
--- a/src/pkg/scanner/scanner.go
+++ b/src/pkg/scanner/scanner.go
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// A general-purpose scanner for UTF-8 encoded text. Takes an io.Reader
-// providing the source which then can be tokenized through repeated
-// calls to the Scan function. For compatibility with existing tools,
-// the NUL character is not allowed (implementation restriction).
+// A scanner and tokenizer for UTF-8-encoded text. Takes an io.Reader
+// providing the source, which then can be tokenized through repeated calls
+// to the Scan function. For compatibility with existing tools, the NUL
+// character is not allowed (implementation restriction).
//
-// By default, a Scanner skips white space and comments and
-// recognizes literals as defined by the Go language spec.
-// It may be customized to recognize only a subset of those
-// literals and to recognize different white space characters.
+// By default, a Scanner skips white space and Go comments and recognizes all
+// literals as defined by the Go language specification. It may be
+// customized to recognize only a subset of those literals and to recognize
+// different white space characters.
//
// Basic usage pattern:
//
@@ -158,7 +158,7 @@ type Scanner struct {
ErrorCount int
// The Mode field controls which tokens are recognized. For instance,
- // to recognize Ints, set the (1<<-Int) bit in Mode. The field may be
+ // to recognize Ints, set the ScanInts bit in Mode. The field may be
// changed at any time.
Mode uint
@@ -236,8 +236,10 @@ func (s *Scanner) next() int {
if s.srcEnd == 0 {
return EOF
}
- s.error(err.String())
- break
+ if err != os.EOF {
+ s.error(err.String())
+ break
+ }
}
}
// at least one byte