OSDN Git Service

Update Go compiler, library, and testsuite on gcc 4.7 branch.
[pf3gnuchains/gcc-fork.git] / libgo / go / regexp / syntax / parse.go
index ba5c0a1..71b07b9 100644 (file)
@@ -2,13 +2,17 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Package syntax parses regular expressions into parse trees and compiles
+// parse trees into programs. Most clients of regular expressions will use
+// the facilities of package regexp (such as Compile and Match) instead of
+// this package.
 package syntax
 
 import (
        "sort"
        "strings"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // An Error describes a failure to parse a regular expression
@@ -648,6 +652,9 @@ func literalRegexp(s string, flags Flags) *Regexp {
 
 // Parsing.
 
+// Parse parses a regular expression string s, controlled by the specified
+// Flags, and returns a regular expression parse tree. The syntax is
+// described in the top-level comment for package regexp.
 func Parse(s string, flags Flags) (*Regexp, error) {
        if flags&Literal != 0 {
                // Trivial parser for literal string.
@@ -1377,8 +1384,8 @@ func (p *parser) appendGroup(r []rune, g charGroup) []rune {
 }
 
 var anyTable = &unicode.RangeTable{
-       []unicode.Range16{{0, 1<<16 - 1, 1}},
-       []unicode.Range32{{1 << 16, unicode.MaxRune, 1}},
+       R16: []unicode.Range16{{Lo: 0, Hi: 1<<16 - 1, Stride: 1}},
+       R32: []unicode.Range32{{Lo: 1 << 16, Hi: unicode.MaxRune, Stride: 1}},
 }
 
 // unicodeTable returns the unicode.RangeTable identified by name
@@ -1694,7 +1701,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 +1742,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 +1784,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 {