]> Cypherpunks repositories - gostls13.git/commitdiff
update tree for new default type rule
authorRuss Cox <rsc@golang.org>
Fri, 9 Dec 2011 03:08:03 +0000 (22:08 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 9 Dec 2011 03:08:03 +0000 (22:08 -0500)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5448091

13 files changed:
src/cmd/cgo/gcc.go
src/cmd/godoc/dirtrees.go
src/pkg/bytes/bytes.go
src/pkg/exp/types/gcimporter.go
src/pkg/fmt/scan_test.go
src/pkg/go/build/dir.go
src/pkg/html/escape.go
src/pkg/html/template/css.go
src/pkg/math/big/nat.go
src/pkg/regexp/syntax/parse.go
src/pkg/strings/strings.go
src/pkg/strings/strings_test.go
src/pkg/unicode/letter.go

index 646857419d4adab0f6d9d233f325057aeec38120..dc18abfcca68cb4d6fc7c599f0c8ef02916f5d9c 100644 (file)
@@ -201,7 +201,7 @@ func splitQuoted(s string) (r []string, err error) {
        arg := make([]rune, len(s))
        escaped := false
        quoted := false
-       quote := rune(0)
+       quote := '\x00'
        i := 0
        for _, r := range s {
                switch {
index 7f063489387bab1eb1c43ffb81f729b80c1e6a39..4be9107eb835797699ecc49b785bd360065b52ef 100644 (file)
@@ -47,7 +47,7 @@ func isPkgDir(fi os.FileInfo) bool {
 func firstSentence(s string) string {
        i := -1 // index+1 of first terminator (punctuation ending a sentence)
        j := -1 // index+1 of first terminator followed by white space
-       prev := rune('A')
+       prev := 'A'
        for k, ch := range s {
                k1 := k + 1
                if ch == '.' || ch == '!' || ch == '?' {
index 307c89aa3d6d4189b01195385da0c8bb5c1300f3..e94a0ec5c4f950feec36cce66e66cdc362bbbf0f 100644 (file)
@@ -470,7 +470,7 @@ func Title(s []byte) []byte {
        // Use a closure here to remember state.
        // Hackish but effective. Depends on Map scanning in order and calling
        // the closure once per rune.
-       prev := rune(' ')
+       prev := ' '
        return Map(
                func(r rune) rune {
                        if isSeparator(prev) {
index 6adcc2a9ad2018db5b46ea4eb56effd480880de6..150c6edb3c6f65d558181b6af2446b669e57aafa 100644 (file)
@@ -81,7 +81,7 @@ type gcParser struct {
 func (p *gcParser) init(filename, id string, src io.Reader, imports map[string]*ast.Object) {
        p.scanner.Init(src)
        p.scanner.Error = func(_ *scanner.Scanner, msg string) { p.error(msg) }
-       p.scanner.Mode = scanner.ScanIdents | scanner.ScanInts | scanner.ScanStrings | scanner.ScanComments | scanner.SkipComments
+       p.scanner.Mode = scanner.ScanIdents | scanner.ScanInts | scanner.ScanChars | scanner.ScanStrings | scanner.ScanComments | scanner.SkipComments
        p.scanner.Whitespace = 1<<'\t' | 1<<' '
        p.scanner.Filename = filename // for good error messages
        p.next()
@@ -206,7 +206,7 @@ func (p *gcParser) expect(tok rune) string {
 }
 
 func (p *gcParser) expectSpecial(tok string) {
-       sep := rune('x') // not white space
+       sep := 'x' // not white space
        i := 0
        for i < len(tok) && p.tok == rune(tok[i]) && sep > ' ' {
                sep = p.scanner.Peek() // if sep <= ' ', there is white space before the next token
@@ -261,7 +261,7 @@ func (p *gcParser) parsePkgId() *ast.Object {
 func (p *gcParser) parseDotIdent() string {
        ident := ""
        if p.tok != scanner.Int {
-               sep := rune('x') // not white space
+               sep := 'x' // not white space
                for (p.tok == scanner.Ident || p.tok == scanner.Int || p.tok == 'ยท') && sep > ' ' {
                        ident += p.lit
                        sep = p.scanner.Peek() // if sep <= ' ', there is white space before the next token
@@ -645,6 +645,7 @@ func (p *gcParser) parseNumber() Const {
 // Literal     = bool_lit | int_lit | float_lit | complex_lit | string_lit .
 // bool_lit    = "true" | "false" .
 // complex_lit = "(" float_lit "+" float_lit ")" .
+// rune_lit = "(" int_lit "+" int_lit ")" .
 // string_lit  = `"` { unicode_char } `"` .
 //
 func (p *gcParser) parseConstDecl() {
@@ -674,21 +675,32 @@ func (p *gcParser) parseConstDecl() {
                        typ = Float64.Underlying
                }
        case '(':
-               // complex_lit
+               // complex_lit or rune_lit
                p.next()
+               if p.tok == scanner.Char {
+                       p.next()
+                       p.expect('+')
+                       p.parseNumber()
+                       // TODO: x = ...
+                       break
+               }
                re := p.parseNumber()
                p.expect('+')
                im := p.parseNumber()
                p.expect(')')
                x = Const{cmplx{re.val.(*big.Rat), im.val.(*big.Rat)}}
                typ = Complex128.Underlying
+       case scanner.Char:
+               // TODO: x = ...
+               p.next()
        case scanner.String:
                // string_lit
                x = MakeConst(token.STRING, p.lit)
                p.next()
                typ = String.Underlying
        default:
-               p.error("expected literal")
+               println(p.tok)
+               p.errorf("expected literal got %s", scanner.TokenString(p.tok))
        }
        if obj.Type == nil {
                obj.Type = typ
index 0689bf3b6e4e35f6508962ec64a0dd0b38ea54df..b26c828cbfc12989c774f5112f94ad40bfb6fb5f 100644 (file)
@@ -56,6 +56,7 @@ var (
        stringVal            string
        stringVal1           string
        bytesVal             []byte
+       runeVal              rune
        complex64Val         complex64
        complex128Val        complex128
        renamedBoolVal       renamedBool
@@ -225,9 +226,9 @@ var scanfTests = []ScanfTest{
        {"%v", "0377\n", &intVal, 0377},
        {"%v", "0x44\n", &intVal, 0x44},
        {"%d", "72\n", &intVal, 72},
-       {"%c", "a\n", &intVal, 'a'},
-       {"%c", "\u5072\n", &intVal, 0x5072},
-       {"%c", "\u1234\n", &intVal, '\u1234'},
+       {"%c", "a\n", &runeVal, 'a'},
+       {"%c", "\u5072\n", &runeVal, '\u5072'},
+       {"%c", "\u1234\n", &runeVal, '\u1234'},
        {"%d", "73\n", &int8Val, int8(73)},
        {"%d", "+74\n", &int16Val, int16(74)},
        {"%d", "75\n", &int32Val, int32(75)},
@@ -322,6 +323,7 @@ var s, t string
 var c complex128
 var x, y Xs
 var z IntString
+var r1, r2, r3 rune
 
 var multiTests = []ScanfMultiTest{
        {"", "", []interface{}{}, []interface{}{}, ""},
@@ -333,7 +335,7 @@ var multiTests = []ScanfMultiTest{
        {"%3d22%3d", "33322333", args(&i, &j), args(333, 333), ""},
        {"%6vX=%3fY", "3+2iX=2.5Y", args(&c, &f), args((3 + 2i), 2.5), ""},
        {"%d%s", "123abc", args(&i, &s), args(123, "abc"), ""},
-       {"%c%c%c", "2\u50c2X", args(&i, &j, &k), args('2', '\u50c2', 'X'), ""},
+       {"%c%c%c", "2\u50c2X", args(&r1, &r2, &r3), args('2', '\u50c2', 'X'), ""},
 
        // Custom scanners.
        {"%e%f", "eefffff", args(&x, &y), args(Xs("ee"), Xs("fffff")), ""},
@@ -347,7 +349,7 @@ var multiTests = []ScanfMultiTest{
        {"X%d", "10X", args(&intVal), nil, "input does not match format"},
 
        // Bad UTF-8: should see every byte.
-       {"%c%c%c", "\xc2X\xc2", args(&i, &j, &k), args(utf8.RuneError, 'X', utf8.RuneError), ""},
+       {"%c%c%c", "\xc2X\xc2", args(&r1, &r2, &r3), args(utf8.RuneError, 'X', utf8.RuneError), ""},
 }
 
 func testScan(name string, t *testing.T, scan func(r io.Reader, a ...interface{}) (int, error)) {
index 12dc99942a742de3db84817b5c2d0332fe9ef598..2c89224fd4bb0056a557c0bdf176bea6622d3ea4 100644 (file)
@@ -466,7 +466,7 @@ func splitQuoted(s string) (r []string, err error) {
        arg := make([]rune, len(s))
        escaped := false
        quoted := false
-       quote := rune(0)
+       quote := '\x00'
        i := 0
        for _, rune := range s {
                switch {
@@ -475,9 +475,9 @@ func splitQuoted(s string) (r []string, err error) {
                case rune == '\\':
                        escaped = true
                        continue
-               case quote != 0:
+               case quote != '\x00':
                        if rune == quote {
-                               quote = 0
+                               quote = '\x00'
                                continue
                        }
                case rune == '"' || rune == '\'':
index ac9e100df0cb3c8fc1553fa7d5e5a7146502c105..42be865ef080ad0b7c2a843da63dac852f40f25c 100644 (file)
@@ -78,7 +78,7 @@ func unescapeEntity(b []byte, dst, src int, attribute bool) (dst1, src1 int) {
                        i++
                }
 
-               x := rune(0)
+               x := '\x00'
                for i < len(s) {
                        c = s[i]
                        i++
index b0a2f013d2909b0b8e453e58b6eed459849b628c..3bcd984983109fade7ce5a72920f30eeb7418aec 100644 (file)
@@ -106,7 +106,7 @@ func isHex(c byte) bool {
 
 // hexDecode decodes a short hex digit sequence: "10" -> 16.
 func hexDecode(s []byte) rune {
-       n := rune(0)
+       n := '\x00'
        for _, c := range s {
                n <<= 4
                switch {
index 680445dc9a73a30d24f4020b8fcd57a99b877d3d..ead1a881a6a957d000d764062875b72d2923492a 100644 (file)
@@ -592,7 +592,7 @@ func (x nat) bitLen() int {
 const MaxBase = 'z' - 'a' + 10 + 1 // = hexValue('z') + 1
 
 func hexValue(ch rune) Word {
-       d := MaxBase + 1 // illegal base
+       d := int(MaxBase + 1) // illegal base
        switch {
        case '0' <= ch && ch <= '9':
                d = int(ch - '0')
index 6c37df97078e0220fed30eb2f50770969fe188fb..6f8acbbefbd930a0e7298d081b118ca4064ec0e3 100644 (file)
@@ -1694,7 +1694,7 @@ func appendFoldedClass(r []rune, x []rune) []rune {
 // appendNegatedClass returns the result of appending the negation of the class x to the class r.
 // It assumes x is clean.
 func appendNegatedClass(r []rune, x []rune) []rune {
-       nextLo := rune('\u0000')
+       nextLo := '\u0000'
        for i := 0; i < len(x); i += 2 {
                lo, hi := x[i], x[i+1]
                if nextLo <= lo-1 {
@@ -1735,7 +1735,7 @@ func appendTable(r []rune, x *unicode.RangeTable) []rune {
 
 // appendNegatedTable returns the result of appending the negation of x to the class r.
 func appendNegatedTable(r []rune, x *unicode.RangeTable) []rune {
-       nextLo := rune('\u0000') // lo end of next class to add
+       nextLo := '\u0000' // lo end of next class to add
        for _, xr := range x.R16 {
                lo, hi, stride := rune(xr.Lo), rune(xr.Hi), rune(xr.Stride)
                if stride == 1 {
@@ -1777,8 +1777,8 @@ func appendNegatedTable(r []rune, x *unicode.RangeTable) []rune {
 // negateClass overwrites r and returns r's negation.
 // It assumes the class r is already clean.
 func negateClass(r []rune) []rune {
-       nextLo := rune('\u0000') // lo end of next class to add
-       w := 0                   // write index
+       nextLo := '\u0000' // lo end of next class to add
+       w := 0             // write index
        for i := 0; i < len(r); i += 2 {
                lo, hi := r[i], r[i+1]
                if nextLo <= lo-1 {
index 53fdeadf97b42659e501e24bc504cee533d84c67..b411ba5d8b3b43d4b0e4b84585568aae253dde0d 100644 (file)
@@ -434,7 +434,7 @@ func Title(s string) string {
        // Use a closure here to remember state.
        // Hackish but effective. Depends on Map scanning in order and calling
        // the closure once per rune.
-       prev := rune(' ')
+       prev := ' '
        return Map(
                func(r rune) rune {
                        if isSeparator(prev) {
index 957af67b2ba5d4aa4505bfc409a4e19cb1015394..8866d220c00d92b8362e314a8b37f2a7ba0d0646 100644 (file)
@@ -642,7 +642,7 @@ func equal(m string, s1, s2 string, t *testing.T) bool {
 
 func TestCaseConsistency(t *testing.T) {
        // Make a string of all the runes.
-       numRunes := unicode.MaxRune + 1
+       numRunes := int(unicode.MaxRune + 1)
        if testing.Short() {
                numRunes = 1000
        }
index 01c485b6931ad700a43618a7698ea8cc506a20c9..dcc160a5b7d1ab67e45d9cc0364cfe32ee4cdca8 100644 (file)
@@ -7,10 +7,10 @@
 package unicode
 
 const (
-       MaxRune         = 0x10FFFF // Maximum valid Unicode code point.
-       ReplacementChar = 0xFFFD   // Represents invalid code points.
-       MaxASCII        = 0x7F     // maximum ASCII value.
-       MaxLatin1       = 0xFF     // maximum Latin-1 value.
+       MaxRune         = '\U0010FFFF' // Maximum valid Unicode code point.
+       ReplacementChar = '\uFFFD'     // Represents invalid code points.
+       MaxASCII        = '\u007F'     // maximum ASCII value.
+       MaxLatin1       = '\u00FF'     // maximum Latin-1 value.
 )
 
 // RangeTable defines a set of Unicode code points by listing the ranges of