goprotobuf: Text parsing compatibility fixes:
        - accept semicolon and comma after fields
	- accept "inf" and "-inf" for float fields

R=iant
CC=golang-dev
https://codereview.appspot.com/6885045
diff --git a/proto/size_test.go b/proto/size_test.go
index 6774d39..9c60e4f 100644
--- a/proto/size_test.go
+++ b/proto/size_test.go
@@ -40,6 +40,8 @@
 )
 
 var messageWithExtension1 = &pb.MyMessage{Count: Int32(7)}
+
+// messageWithExtension2 is in equal_test.go.
 var messageWithExtension3 = &pb.MyMessage{Count: Int32(8)}
 
 func init() {
diff --git a/proto/testdata/test.proto b/proto/testdata/test.proto
index 0154940..a7f38d4 100644
--- a/proto/testdata/test.proto
+++ b/proto/testdata/test.proto
@@ -252,6 +252,8 @@
   // This field becomes [][]byte in the generated code.
   repeated bytes rep_bytes = 10;
 
+  optional double bigfloat = 11;
+
   extensions 100 to max;
 }
 
diff --git a/proto/text_parser.go b/proto/text_parser.go
index 3c79876..b4e4bc1 100644
--- a/proto/text_parser.go
+++ b/proto/text_parser.go
@@ -154,7 +154,7 @@
 	p.cur.offset, p.cur.line = p.offset, p.line
 	p.cur.unquoted = ""
 	switch p.s[0] {
-	case '<', '>', '{', '}', ':', '[', ']':
+	case '<', '>', '{', '}', ':', '[', ']', ';', ',':
 		// Single symbol
 		p.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)]
 	case '"', '\'':
@@ -525,6 +525,15 @@
 				reqCount--
 			}
 		}
+
+		// For backward compatibility, permit a semicolon or comma after a field.
+		tok = p.next()
+		if tok.err != nil {
+			return tok.err
+		}
+		if tok.value != ";" && tok.value != "," {
+			p.back()
+		}
 	}
 
 	if reqCount > 0 {
@@ -581,8 +590,9 @@
 		}
 	case reflect.Float32, reflect.Float64:
 		v := tok.value
-		if strings.HasSuffix(v, "f") {
-			// Ignore 'f' for compatibility with output generated by C++.
+		// Ignore 'f' for compatibility with output generated by C++, but don't
+		// remove 'f' when the value is "-inf" or "inf".
+		if strings.HasSuffix(v, "f") && tok.value != "-inf" && tok.value != "inf" {
 			v = v[:len(v)-1]
 		}
 		if f, err := strconv.ParseFloat(v, fv.Type().Bits()); err == nil {