diff --git a/pql/parser_test.go b/pql/parser_test.go index f63bc3763..e88244f70 100644 --- a/pql/parser_test.go +++ b/pql/parser_test.go @@ -88,7 +88,7 @@ func TestParser_Parse(t *testing.T) { "bool0": true, "bool1": false, "x": nil, - "escape": `\" \\escape\n`, + "escape": "\" \\escape\n", }, }, ) { diff --git a/pql/pql.peg b/pql/pql.peg index 1d07798a2..3f151c334 100644 --- a/pql/pql.peg +++ b/pql/pql.peg @@ -46,7 +46,7 @@ item <- ( 'null' &(comma / sp close) { p.addVal(nil) } / < '-'? '.'[0-9]+ > { p.addNumVal(buffer[begin:end]) } / < ([[A-Z]] / [0-9] / '-' / '_' / ':')+ > { p.addVal(buffer[begin:end]) } / < '"' doublequotedstring '"' > { s, _ := strconv.Unquote(buffer[begin:end]); p.addVal(s) } - / < '\'' singlequotedstring '\'' > { s, _ := strconv.Unquote(buffer[begin:end]); p.addVal(s) } + / '\'' < singlequotedstring > '\'' { p.addVal(buffer[begin:end]) } ) doublequotedstring <- ( '\\\"' / [^"] )* diff --git a/pql/pql.peg.go b/pql/pql.peg.go index a108bc985..7bc7de6fc 100644 --- a/pql/pql.peg.go +++ b/pql/pql.peg.go @@ -486,8 +486,7 @@ func (p *PQL) Execute() { s, _ := strconv.Unquote(buffer[begin:end]) p.addVal(s) case ruleAction41: - s, _ := strconv.Unquote(buffer[begin:end]) - p.addVal(s) + p.addVal(buffer[begin:end]) case ruleAction42: p.addField(buffer[begin:end]) case ruleAction43: @@ -1723,7 +1722,7 @@ func (p *PQL) Init() { position, tokenIndex = position136, tokenIndex136 return false }, - /* 13 item <- <(('n' 'u' 'l' 'l' &(comma / (sp close)) Action34) / ('t' 'r' 'u' 'e' &(comma / (sp close)) Action35) / ('f' 'a' 'l' 's' 'e' &(comma / (sp close)) Action36) / (<('-'? [0-9]+ ('.' [0-9]*)?)> Action37) / (<('-'? '.' [0-9]+)> Action38) / (<([a-z] / [A-Z] / [0-9] / '-' / '_' / ':')+> Action39) / (<('"' doublequotedstring '"')> Action40) / (<('\'' singlequotedstring '\'')> Action41))> */ + /* 13 item <- <(('n' 'u' 'l' 'l' &(comma / (sp close)) Action34) / ('t' 'r' 'u' 'e' &(comma / (sp close)) Action35) / ('f' 'a' 'l' 's' 'e' &(comma / (sp close)) Action36) / (<('-'? [0-9]+ ('.' [0-9]*)?)> Action37) / (<('-'? '.' [0-9]+)> Action38) / (<([a-z] / [A-Z] / [0-9] / '-' / '_' / ':')+> Action39) / (<('"' doublequotedstring '"')> Action40) / ('\'' '\'' Action41))> */ func() bool { position140, tokenIndex140 := position, tokenIndex { @@ -2082,21 +2081,21 @@ func (p *PQL) Init() { goto l142 l193: position, tokenIndex = position142, tokenIndex142 + if buffer[position] != rune('\'') { + goto l140 + } + position++ { position196 := position - if buffer[position] != rune('\'') { - goto l140 - } - position++ if !_rules[rulesinglequotedstring]() { goto l140 } - if buffer[position] != rune('\'') { - goto l140 - } - position++ add(rulePegText, position196) } + if buffer[position] != rune('\'') { + goto l140 + } + position++ { add(ruleAction41, position) } @@ -2909,7 +2908,7 @@ func (p *PQL) Init() { nil, /* 76 Action40 <- <{ s, _ := strconv.Unquote(buffer[begin:end]); p.addVal(s) }> */ nil, - /* 77 Action41 <- <{ s, _ := strconv.Unquote(buffer[begin:end]); p.addVal(s) }> */ + /* 77 Action41 <- <{ p.addVal(buffer[begin:end]) }> */ nil, /* 78 Action42 <- <{ p.addField(buffer[begin:end]) }> */ nil,