mirror of
https://github.com/golang/go
synced 2024-11-21 18:04:40 -07:00
go/scanner: remove some code
R=r CC=golang-dev https://golang.org/cl/4550077
This commit is contained in:
parent
3c7271f057
commit
3857747dce
@ -22,6 +22,7 @@ package scanner
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/token"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@ -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) {
|
||||
if S.err != nil {
|
||||
S.err.Error(S.file.Position(S.file.Pos(offs)), msg)
|
||||
@ -700,7 +671,7 @@ scanAgain:
|
||||
tok = S.switch3(token.OR, token.OR_ASSIGN, '|', token.LOR)
|
||||
default:
|
||||
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
|
||||
}
|
||||
|
@ -650,7 +650,8 @@ var errors = []struct {
|
||||
pos int
|
||||
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, "illegal character literal"},
|
||||
{`'\8'`, token.CHAR, 2, "unknown escape sequence"},
|
||||
|
Loading…
Reference in New Issue
Block a user