Commit 3857747d authored by Robert Griesemer's avatar Robert Griesemer

go/scanner: remove some code

R=r
CC=golang-dev
https://golang.org/cl/4550077
parent 3c7271f0
...@@ -22,6 +22,7 @@ package scanner ...@@ -22,6 +22,7 @@ package scanner
import ( import (
"bytes" "bytes"
"fmt"
"go/token" "go/token"
"path/filepath" "path/filepath"
"strconv" "strconv"
...@@ -134,36 +135,6 @@ func (S *Scanner) Init(file *token.File, src []byte, err ErrorHandler, mode uint ...@@ -134,36 +135,6 @@ func (S *Scanner) Init(file *token.File, src []byte, err ErrorHandler, mode uint
} }
func charString(ch int) string {
var s string
switch ch {
case -1:
return `EOF`
case '\a':
s = `\a`
case '\b':
s = `\b`
case '\f':
s = `\f`
case '\n':
s = `\n`
case '\r':
s = `\r`
case '\t':
s = `\t`
case '\v':
s = `\v`
case '\\':
s = `\\`
case '\'':
s = `\'`
default:
s = string(ch)
}
return "'" + s + "' (U+" + strconv.Itob(ch, 16) + ")"
}
func (S *Scanner) error(offs int, msg string) { func (S *Scanner) error(offs int, msg string) {
if S.err != nil { if S.err != nil {
S.err.Error(S.file.Position(S.file.Pos(offs)), msg) S.err.Error(S.file.Position(S.file.Pos(offs)), msg)
...@@ -700,7 +671,7 @@ scanAgain: ...@@ -700,7 +671,7 @@ scanAgain:
tok = S.switch3(token.OR, token.OR_ASSIGN, '|', token.LOR) tok = S.switch3(token.OR, token.OR_ASSIGN, '|', token.LOR)
default: default:
if S.mode&AllowIllegalChars == 0 { if S.mode&AllowIllegalChars == 0 {
S.error(offs, "illegal character "+charString(ch)) S.error(offs, fmt.Sprintf("illegal character '%c' (%U)", ch, ch))
} }
insertSemi = S.insertSemi // preserve insertSemi info insertSemi = S.insertSemi // preserve insertSemi info
} }
......
...@@ -650,7 +650,8 @@ var errors = []struct { ...@@ -650,7 +650,8 @@ var errors = []struct {
pos int pos int
err string err string
}{ }{
{`#`, token.ILLEGAL, 0, "illegal character '#' (U+23)"}, {"\a", token.ILLEGAL, 0, "illegal character '\a' (U+0007)"},
{`#`, token.ILLEGAL, 0, "illegal character '#' (U+0023)"},
{`' '`, token.CHAR, 0, ""}, {`' '`, token.CHAR, 0, ""},
{`''`, token.CHAR, 0, "illegal character literal"}, {`''`, token.CHAR, 0, "illegal character literal"},
{`'\8'`, token.CHAR, 2, "unknown escape sequence"}, {`'\8'`, token.CHAR, 2, "unknown escape sequence"},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment