aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/scanner/scanner.go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-04-07 17:09:10 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-04-07 17:09:10 +0000
commit405ca10418216fc078ecb29ff13a39c911e8d806 (patch)
tree39c2c0da7b6c220dd344f134fae07fba0d0266b2 /libgo/go/scanner/scanner.go
parenta751005d50fa7347131660e562c5fd9ce3dff75d (diff)
downloadgcc-405ca10418216fc078ecb29ff13a39c911e8d806.zip
gcc-405ca10418216fc078ecb29ff13a39c911e8d806.tar.gz
gcc-405ca10418216fc078ecb29ff13a39c911e8d806.tar.bz2
libgo: Update to current Go library.
From-SVN: r172106
Diffstat (limited to 'libgo/go/scanner/scanner.go')
-rw-r--r--libgo/go/scanner/scanner.go43
1 files changed, 16 insertions, 27 deletions
diff --git a/libgo/go/scanner/scanner.go b/libgo/go/scanner/scanner.go
index 2396cdd..560e595 100644
--- a/libgo/go/scanner/scanner.go
+++ b/libgo/go/scanner/scanner.go
@@ -331,7 +331,7 @@ func (s *Scanner) error(msg string) {
s.Error(s, msg)
return
}
- fmt.Fprintf(os.Stderr, "%s: %s", s.Position, msg)
+ fmt.Fprintf(os.Stderr, "%s: %s\n", s.Position, msg)
}
@@ -503,41 +503,32 @@ func (s *Scanner) scanChar() {
}
-func (s *Scanner) scanLineComment() {
- ch := s.next() // read character after "//"
- for ch != '\n' {
- if ch < 0 {
- s.error("comment not terminated")
- return
+func (s *Scanner) scanComment(ch int) int {
+ // ch == '/' || ch == '*'
+ if ch == '/' {
+ // line comment
+ ch = s.next() // read character after "//"
+ for ch != '\n' && ch >= 0 {
+ ch = s.next()
}
- ch = s.next()
+ return ch
}
-}
-
-func (s *Scanner) scanGeneralComment() {
- ch := s.next() // read character after "/*"
+ // general comment
+ ch = s.next() // read character after "/*"
for {
if ch < 0 {
s.error("comment not terminated")
- return
+ break
}
ch0 := ch
ch = s.next()
if ch0 == '*' && ch == '/' {
+ ch = s.next()
break
}
}
-}
-
-
-func (s *Scanner) scanComment(ch int) {
- // ch == '/' || ch == '*'
- if ch == '/' {
- s.scanLineComment()
- return
- }
- s.scanGeneralComment()
+ return ch
}
@@ -619,13 +610,11 @@ redo:
if (ch == '/' || ch == '*') && s.Mode&ScanComments != 0 {
if s.Mode&SkipComments != 0 {
s.tokPos = -1 // don't collect token text
- s.scanComment(ch)
- ch = s.next()
+ ch = s.scanComment(ch)
goto redo
}
- s.scanComment(ch)
+ ch = s.scanComment(ch)
tok = Comment
- ch = s.next()
}
case '`':
if s.Mode&ScanRawStrings != 0 {