Extend the text format parser to allow concatenation of string literals in single quotes.
Signed-off-by: David Symonds <dsymonds@golang.org>
diff --git a/proto/text_parser.go b/proto/text_parser.go
index 6d0cf25..4513232 100644
--- a/proto/text_parser.go
+++ b/proto/text_parser.go
@@ -119,6 +119,14 @@
return false
}
+func isQuote(c byte) bool {
+ switch c {
+ case '"', '\'':
+ return true
+ }
+ return false
+}
+
func (p *textParser) skipWhitespace() {
i := 0
for i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') {
@@ -333,13 +341,13 @@
p.advance()
if p.done {
p.cur.value = ""
- } else if len(p.cur.value) > 0 && p.cur.value[0] == '"' {
+ } else if len(p.cur.value) > 0 && isQuote(p.cur.value[0]) {
// Look for multiple quoted strings separated by whitespace,
// and concatenate them.
cat := p.cur
for {
p.skipWhitespace()
- if p.done || p.s[0] != '"' {
+ if p.done || !isQuote(p.s[0]) {
break
}
p.advance()