diff --git a/http/handler_test.go b/http/handler_test.go index a6bd2b98e..5f7913f94 100644 --- a/http/handler_test.go +++ b/http/handler_test.go @@ -653,7 +653,7 @@ func TestHandler_Query_ErrParse(t *testing.T) { h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/idx0/query?slices=0,1", strings.NewReader("bad_fn("))) if w.Code != gohttp.StatusBadRequest { t.Fatalf("unexpected status code: %d", w.Code) - } else if body := w.Body.String(); body != `{"error":"parsing: parsing: \nparse error near PegText (line 1 symbol 1 - line 1 symbol 4):\n\"bad\"\n"}`+"\n" { + } else if body := w.Body.String(); body != `{"error":"parsing: parsing: \nparse error near open (line 1 symbol 7 - line 1 symbol 8):\n\"(\"\n"}`+"\n" { t.Fatalf("unexpected body: \n%s", body) } } diff --git a/pql/ast.go b/pql/ast.go index 7a91ef987..6d1b206b0 100644 --- a/pql/ast.go +++ b/pql/ast.go @@ -72,11 +72,8 @@ func (q *Query) addVal(val interface{}) { return } if q.lastCond != ILLEGAL { - if val != nil || q.lastCond != NEQ { - panic(fmt.Sprintf("can't add val %s with condition %s", val, q.lastCond)) - } call.Args[q.lastField] = &Condition{ - Op: NEQ, + Op: q.lastCond, Value: val, } } else { diff --git a/pql/fuzz/README.txt b/pql/fuzz/README.txt new file mode 100644 index 000000000..e94c88830 --- /dev/null +++ b/pql/fuzz/README.txt @@ -0,0 +1,8 @@ +See https://github.com/dvyukov/go-fuzz + + +Quickstart: + +go get -u github.com/dvyukov/go-fuzz/... +go-fuzz-build github.com/pilosa/pilosa/pql +go-fuzz -bin=./pql-fuzz.zip -workdir=$GOPATH/src/github.com/pilosa/pilosa/pql/fuzz diff --git a/pql/fuzz/corpus/02ad499148a94f93101dbebda5111cd061137d28-1 b/pql/fuzz/corpus/02ad499148a94f93101dbebda5111cd061137d28-1 new file mode 100644 index 000000000..b38d50137 --- /dev/null +++ b/pql/fuzz/corpus/02ad499148a94f93101dbebda5111cd061137d28-1 @@ -0,0 +1 @@ +e(rT03 \ No newline at end of file diff --git a/pql/fuzz/corpus/077a5923c7f6ff1b697b556611a3593e725d515f-1 b/pql/fuzz/corpus/077a5923c7f6ff1b697b556611a3593e725d515f-1 new file mode 100644 index 000000000..c4507e8e4 --- /dev/null +++ b/pql/fuzz/corpus/077a5923c7f6ff1b697b556611a3593e725d515f-1 @@ -0,0 +1 @@ +e(d=f2002-01-01T03:00 \ No newline at end of file diff --git a/pql/fuzz/corpus/0eb3a86490e4bb0a031ed5c33b2f3a8c90785746 b/pql/fuzz/corpus/0eb3a86490e4bb0a031ed5c33b2f3a8c90785746 new file mode 100644 index 000000000..be461611e --- /dev/null +++ b/pql/fuzz/corpus/0eb3a86490e4bb0a031ed5c33b2f3a8c90785746 @@ -0,0 +1 @@ +e(other!=-2) \ No newline at end of file diff --git a/pql/fuzz/corpus/1 b/pql/fuzz/corpus/1 new file mode 100644 index 000000000..a8ccc9f85 --- /dev/null +++ b/pql/fuzz/corpus/1 @@ -0,0 +1 @@ +Bitmap() \ No newline at end of file diff --git a/pql/fuzz/corpus/10 b/pql/fuzz/corpus/10 new file mode 100644 index 000000000..21ff4c59c --- /dev/null +++ b/pql/fuzz/corpus/10 @@ -0,0 +1 @@ +Bitmap(row=10, field=f) \ No newline at end of file diff --git a/pql/fuzz/corpus/11 b/pql/fuzz/corpus/11 new file mode 100644 index 000000000..7636ec48c --- /dev/null +++ b/pql/fuzz/corpus/11 @@ -0,0 +1 @@ +Difference(Bitmap(row=10), Bitmap(row=11)) \ No newline at end of file diff --git a/pql/fuzz/corpus/11f674c766421132650bcbf8ccc265a013a3409f b/pql/fuzz/corpus/11f674c766421132650bcbf8ccc265a013a3409f new file mode 100644 index 000000000..425e9d1d3 --- /dev/null +++ b/pql/fuzz/corpus/11f674c766421132650bcbf8ccc265a013a3409f @@ -0,0 +1 @@ +Range(foo<0) \ No newline at end of file diff --git a/pql/fuzz/corpus/12 b/pql/fuzz/corpus/12 new file mode 100644 index 000000000..0d59771c6 --- /dev/null +++ b/pql/fuzz/corpus/12 @@ -0,0 +1 @@ +Difference() \ No newline at end of file diff --git a/pql/fuzz/corpus/13 b/pql/fuzz/corpus/13 new file mode 100644 index 000000000..d5102d6fe --- /dev/null +++ b/pql/fuzz/corpus/13 @@ -0,0 +1 @@ +Intersect(Bitmap(row=10), Bitmap(row=11)) \ No newline at end of file diff --git a/pql/fuzz/corpus/131cfdaafbd04db9dd2aa37fb23a656500ed1333 b/pql/fuzz/corpus/131cfdaafbd04db9dd2aa37fb23a656500ed1333 new file mode 100644 index 000000000..d8c6af7ea --- /dev/null +++ b/pql/fuzz/corpus/131cfdaafbd04db9dd2aa37fb23a656500ed1333 @@ -0,0 +1 @@ +SV(invalid_column_name=10,f=100) \ No newline at end of file diff --git a/pql/fuzz/corpus/14 b/pql/fuzz/corpus/14 new file mode 100644 index 000000000..08695e949 --- /dev/null +++ b/pql/fuzz/corpus/14 @@ -0,0 +1 @@ +Intersect() \ No newline at end of file diff --git a/pql/fuzz/corpus/15 b/pql/fuzz/corpus/15 new file mode 100644 index 000000000..2ade2207e --- /dev/null +++ b/pql/fuzz/corpus/15 @@ -0,0 +1 @@ +Union(Bitmap(row=10), Bitmap(row=11)) \ No newline at end of file diff --git a/pql/fuzz/corpus/16 b/pql/fuzz/corpus/16 new file mode 100644 index 000000000..c3b496bb4 --- /dev/null +++ b/pql/fuzz/corpus/16 @@ -0,0 +1 @@ +Union() \ No newline at end of file diff --git a/pql/fuzz/corpus/17 b/pql/fuzz/corpus/17 new file mode 100644 index 000000000..55062ba4c --- /dev/null +++ b/pql/fuzz/corpus/17 @@ -0,0 +1 @@ +Xor(Bitmap(row=10), Bitmap(row=11)) \ No newline at end of file diff --git a/pql/fuzz/corpus/18 b/pql/fuzz/corpus/18 new file mode 100644 index 000000000..ea7190ed6 --- /dev/null +++ b/pql/fuzz/corpus/18 @@ -0,0 +1 @@ +Count(Bitmap(row=10, field=f)) \ No newline at end of file diff --git a/pql/fuzz/corpus/19 b/pql/fuzz/corpus/19 new file mode 100644 index 000000000..bde6e75ac --- /dev/null +++ b/pql/fuzz/corpus/19 @@ -0,0 +1 @@ +SetBit(row=11, field=f, col=1) \ No newline at end of file diff --git a/pql/fuzz/corpus/2 b/pql/fuzz/corpus/2 new file mode 100644 index 000000000..48ffdc060 --- /dev/null +++ b/pql/fuzz/corpus/2 @@ -0,0 +1 @@ +Union( Bitmap() , Count() ) \ No newline at end of file diff --git a/pql/fuzz/corpus/20 b/pql/fuzz/corpus/20 new file mode 100644 index 000000000..76679c897 --- /dev/null +++ b/pql/fuzz/corpus/20 @@ -0,0 +1 @@ +SetValue(col=10, f=25) \ No newline at end of file diff --git a/pql/fuzz/corpus/21 b/pql/fuzz/corpus/21 new file mode 100644 index 000000000..4ad8fba18 --- /dev/null +++ b/pql/fuzz/corpus/21 @@ -0,0 +1 @@ +SetValue(invalid_column_name=10, f=100) \ No newline at end of file diff --git a/pql/fuzz/corpus/22 b/pql/fuzz/corpus/22 new file mode 100644 index 000000000..123a4e7b2 --- /dev/null +++ b/pql/fuzz/corpus/22 @@ -0,0 +1 @@ +SetRowAttrs(row=10, field=f, baz=123, bat=true) \ No newline at end of file diff --git a/pql/fuzz/corpus/23 b/pql/fuzz/corpus/23 new file mode 100644 index 000000000..31333c37b --- /dev/null +++ b/pql/fuzz/corpus/23 @@ -0,0 +1,5 @@ + SetBit(field=f, row=1, col=2, timestamp="1999-12-31T00:00") + SetBit(field=f, row=1, col=7, timestamp="2002-01-01T02:00") + + SetBit(field=f, row=1, col=2, timestamp="1999-12-30T00:00") + diff --git a/pql/fuzz/corpus/24 b/pql/fuzz/corpus/24 new file mode 100644 index 000000000..527b67ddc --- /dev/null +++ b/pql/fuzz/corpus/24 @@ -0,0 +1 @@ +Range(row=1, field=f, start="1999-12-31T00:00", end="2002-01-01T03:00") \ No newline at end of file diff --git a/pql/fuzz/corpus/25 b/pql/fuzz/corpus/25 new file mode 100644 index 000000000..32c0405c1 --- /dev/null +++ b/pql/fuzz/corpus/25 @@ -0,0 +1,2 @@ + +Range(foo == 20) diff --git a/pql/fuzz/corpus/26 b/pql/fuzz/corpus/26 new file mode 100644 index 000000000..4cad8028b --- /dev/null +++ b/pql/fuzz/corpus/26 @@ -0,0 +1 @@ +Range(other != null) \ No newline at end of file diff --git a/pql/fuzz/corpus/27 b/pql/fuzz/corpus/27 new file mode 100644 index 000000000..c858f1930 --- /dev/null +++ b/pql/fuzz/corpus/27 @@ -0,0 +1 @@ +Range(foo != 20) \ No newline at end of file diff --git a/pql/fuzz/corpus/2751bda09fe203e30e9d5f214f9425e2dface095 b/pql/fuzz/corpus/2751bda09fe203e30e9d5f214f9425e2dface095 new file mode 100644 index 000000000..f02ab7e3d --- /dev/null +++ b/pql/fuzz/corpus/2751bda09fe203e30e9d5f214f9425e2dface095 @@ -0,0 +1 @@ +N(p(d=0,l=other), d=f,n=3) \ No newline at end of file diff --git a/pql/fuzz/corpus/28 b/pql/fuzz/corpus/28 new file mode 100644 index 000000000..212663384 --- /dev/null +++ b/pql/fuzz/corpus/28 @@ -0,0 +1 @@ +Range(other != -20) \ No newline at end of file diff --git a/pql/fuzz/corpus/29 b/pql/fuzz/corpus/29 new file mode 100644 index 000000000..3d2e5b82b --- /dev/null +++ b/pql/fuzz/corpus/29 @@ -0,0 +1 @@ +Range(foo < 20) \ No newline at end of file diff --git a/pql/fuzz/corpus/3 b/pql/fuzz/corpus/3 new file mode 100644 index 000000000..aef5a7a75 --- /dev/null +++ b/pql/fuzz/corpus/3 @@ -0,0 +1 @@ +Count( Bitmap( id=100)) \ No newline at end of file diff --git a/pql/fuzz/corpus/30 b/pql/fuzz/corpus/30 new file mode 100644 index 000000000..3e3f37870 --- /dev/null +++ b/pql/fuzz/corpus/30 @@ -0,0 +1 @@ +Range(foo <= 20) diff --git a/pql/fuzz/corpus/31 b/pql/fuzz/corpus/31 new file mode 100644 index 000000000..13b7e9347 --- /dev/null +++ b/pql/fuzz/corpus/31 @@ -0,0 +1 @@ +SetRowAttrs(row=10, field=f, baz=12.3, bat=.21, bak=-.27, zaz=-0.27 , q=0, zoo="0", do='0') diff --git a/pql/fuzz/corpus/338717d7ceeb78f7b8b864547fcb87cd62334783 b/pql/fuzz/corpus/338717d7ceeb78f7b8b864547fcb87cd62334783 new file mode 100644 index 000000000..a03a91bd9 --- /dev/null +++ b/pql/fuzz/corpus/338717d7ceeb78f7b8b864547fcb87cd62334783 @@ -0,0 +1 @@ +t( p( )) \ No newline at end of file diff --git a/pql/fuzz/corpus/33fae0740e470344699582c2c8c6f3825de66007 b/pql/fuzz/corpus/33fae0740e470344699582c2c8c6f3825de66007 new file mode 100644 index 000000000..23e1bc1de --- /dev/null +++ b/pql/fuzz/corpus/33fae0740e470344699582c2c8c6f3825de66007 @@ -0,0 +1 @@ +SetRowAttrs(row=10,field=f,baz=123,bat=true) \ No newline at end of file diff --git a/pql/fuzz/corpus/374b9d8c1d285b57c3fe1f99b76472714cc2c69c b/pql/fuzz/corpus/374b9d8c1d285b57c3fe1f99b76472714cc2c69c new file mode 100644 index 000000000..c65d51e92 --- /dev/null +++ b/pql/fuzz/corpus/374b9d8c1d285b57c3fe1f99b76472714cc2c69c @@ -0,0 +1,2 @@ + +e(o == 0) diff --git a/pql/fuzz/corpus/392027b3a650e05b0bc4ca185143138585702c5c b/pql/fuzz/corpus/392027b3a650e05b0bc4ca185143138585702c5c new file mode 100644 index 000000000..2b2542414 --- /dev/null +++ b/pql/fuzz/corpus/392027b3a650e05b0bc4ca185143138585702c5c @@ -0,0 +1 @@ +e(r!=-2) \ No newline at end of file diff --git a/pql/fuzz/corpus/3c9cda1dd6ed289bdec524bb9f4995a9c175d656 b/pql/fuzz/corpus/3c9cda1dd6ed289bdec524bb9f4995a9c175d656 new file mode 100644 index 000000000..822aa982c --- /dev/null +++ b/pql/fuzz/corpus/3c9cda1dd6ed289bdec524bb9f4995a9c175d656 @@ -0,0 +1 @@ +MyCall( y=-12.25, o= -13) \ No newline at end of file diff --git a/pql/fuzz/corpus/4 b/pql/fuzz/corpus/4 new file mode 100644 index 000000000..22982532c --- /dev/null +++ b/pql/fuzz/corpus/4 @@ -0,0 +1 @@ +MyCall( key= value, foo="bar", age = 12 , bool0=true, bool1=false, x=null ) \ No newline at end of file diff --git a/pql/fuzz/corpus/452308054231977c3f6e551b72437500215019b5 b/pql/fuzz/corpus/452308054231977c3f6e551b72437500215019b5 new file mode 100644 index 000000000..65f6e27b8 --- /dev/null +++ b/pql/fuzz/corpus/452308054231977c3f6e551b72437500215019b5 @@ -0,0 +1 @@ +t(p(w=1,l=f)) \ No newline at end of file diff --git a/pql/fuzz/corpus/5 b/pql/fuzz/corpus/5 new file mode 100644 index 000000000..8075673eb --- /dev/null +++ b/pql/fuzz/corpus/5 @@ -0,0 +1 @@ +MyCall( key=12.25, foo= 13.167, bar=2., baz=0.9) \ No newline at end of file diff --git a/pql/fuzz/corpus/57e5daa393a1de6405e0315abf57cf061bd5dc44 b/pql/fuzz/corpus/57e5daa393a1de6405e0315abf57cf061bd5dc44 new file mode 100644 index 000000000..d2042629e --- /dev/null +++ b/pql/fuzz/corpus/57e5daa393a1de6405e0315abf57cf061bd5dc44 @@ -0,0 +1 @@ +e(row=1,field=f,start="1999-12-31T00:00",end="2002-01-01T03:00") \ No newline at end of file diff --git a/pql/fuzz/corpus/597ed3d1cef06f73136921bdd89fc2916cdd287c b/pql/fuzz/corpus/597ed3d1cef06f73136921bdd89fc2916cdd287c new file mode 100644 index 000000000..b22ab81d2 --- /dev/null +++ b/pql/fuzz/corpus/597ed3d1cef06f73136921bdd89fc2916cdd287c @@ -0,0 +1 @@ +MyCall(ke=foo, x =5, y >= 100, z >< [4,8], m != null) \ No newline at end of file diff --git a/pql/fuzz/corpus/5e982cd2a4acb990e97675afabce72032c1d08ef b/pql/fuzz/corpus/5e982cd2a4acb990e97675afabce72032c1d08ef new file mode 100644 index 000000000..a7c359cfc --- /dev/null +++ b/pql/fuzz/corpus/5e982cd2a4acb990e97675afabce72032c1d08ef @@ -0,0 +1 @@ +SetValue(invalid_column_name=10,f=100) \ No newline at end of file diff --git a/pql/fuzz/corpus/5f6b6920de296ca3a34d3ee14477a9d623d4efc2 b/pql/fuzz/corpus/5f6b6920de296ca3a34d3ee14477a9d623d4efc2 new file mode 100644 index 000000000..e8d9b2dc2 --- /dev/null +++ b/pql/fuzz/corpus/5f6b6920de296ca3a34d3ee14477a9d623d4efc2 @@ -0,0 +1 @@ +Range(other!=null) \ No newline at end of file diff --git a/pql/fuzz/corpus/6 b/pql/fuzz/corpus/6 new file mode 100644 index 000000000..919a949ac --- /dev/null +++ b/pql/fuzz/corpus/6 @@ -0,0 +1 @@ +MyCall( key=-12.25, foo= -13) \ No newline at end of file diff --git a/pql/fuzz/corpus/6078ffa2c7287a2fdbb9bca63274a414fd7bc83d b/pql/fuzz/corpus/6078ffa2c7287a2fdbb9bca63274a414fd7bc83d new file mode 100644 index 000000000..87168a0b5 --- /dev/null +++ b/pql/fuzz/corpus/6078ffa2c7287a2fdbb9bca63274a414fd7bc83d @@ -0,0 +1 @@ +tRowAttrs(row=1, field=f, baz=13,bat=true) \ No newline at end of file diff --git a/pql/fuzz/corpus/6711a6c9ab125b4444c9c03b14e49f416f25180c-1 b/pql/fuzz/corpus/6711a6c9ab125b4444c9c03b14e49f416f25180c-1 new file mode 100644 index 000000000..00c36326c --- /dev/null +++ b/pql/fuzz/corpus/6711a6c9ab125b4444c9c03b14e49f416f25180c-1 @@ -0,0 +1 @@ +e(w=: \ No newline at end of file diff --git a/pql/fuzz/corpus/7 b/pql/fuzz/corpus/7 new file mode 100644 index 000000000..b5a946470 --- /dev/null +++ b/pql/fuzz/corpus/7 @@ -0,0 +1 @@ +TopN(field="f", ids=[0,10,30]) \ No newline at end of file diff --git a/pql/fuzz/corpus/7209e30b65fb8aa3e31bb84f8f0a2e116af26184-1 b/pql/fuzz/corpus/7209e30b65fb8aa3e31bb84f8f0a2e116af26184-1 new file mode 100644 index 000000000..9170e620a --- /dev/null +++ b/pql/fuzz/corpus/7209e30b65fb8aa3e31bb84f8f0a2e116af26184-1 @@ -0,0 +1 @@ +n(p() , C \ No newline at end of file diff --git a/pql/fuzz/corpus/7282523da2bd624500932760375168ac6d95b08b b/pql/fuzz/corpus/7282523da2bd624500932760375168ac6d95b08b new file mode 100644 index 000000000..966f30ab4 --- /dev/null +++ b/pql/fuzz/corpus/7282523da2bd624500932760375168ac6d95b08b @@ -0,0 +1 @@ +t(p(d=100)) \ No newline at end of file diff --git a/pql/fuzz/corpus/72fca46b66ab75b1b215d42c1f97a6a601e11383-1 b/pql/fuzz/corpus/72fca46b66ab75b1b215d42c1f97a6a601e11383-1 new file mode 100644 index 000000000..229ba77a9 --- /dev/null +++ b/pql/fuzz/corpus/72fca46b66ab75b1b215d42c1f97a6a601e11383-1 @@ -0,0 +1 @@ +U(B(,C \ No newline at end of file diff --git a/pql/fuzz/corpus/755ea2169f42a7facac54c6d4228abad4ffdb840-1 b/pql/fuzz/corpus/755ea2169f42a7facac54c6d4228abad4ffdb840-1 new file mode 100644 index 000000000..882c1dac8 --- /dev/null +++ b/pql/fuzz/corpus/755ea2169f42a7facac54c6d4228abad4ffdb840-1 @@ -0,0 +1 @@ +e(w=12002 \ No newline at end of file diff --git a/pql/fuzz/corpus/75dcc3426aa51753b37f34acaab56815ae00af91 b/pql/fuzz/corpus/75dcc3426aa51753b37f34acaab56815ae00af91 new file mode 100644 index 000000000..201e6ddaa --- /dev/null +++ b/pql/fuzz/corpus/75dcc3426aa51753b37f34acaab56815ae00af91 @@ -0,0 +1 @@ +e(o <= 0) diff --git a/pql/fuzz/corpus/7cb88de80a430fd4c411e469ded68c8ec2f8fcd3 b/pql/fuzz/corpus/7cb88de80a430fd4c411e469ded68c8ec2f8fcd3 new file mode 100644 index 000000000..394c6b092 --- /dev/null +++ b/pql/fuzz/corpus/7cb88de80a430fd4c411e469ded68c8ec2f8fcd3 @@ -0,0 +1 @@ +t(p(w=0), p(w=1)) \ No newline at end of file diff --git a/pql/fuzz/corpus/7e03f5068158432ddc5faa0579f6cbfc09718884-1 b/pql/fuzz/corpus/7e03f5068158432ddc5faa0579f6cbfc09718884-1 new file mode 100644 index 000000000..0bf263b2e --- /dev/null +++ b/pql/fuzz/corpus/7e03f5068158432ddc5faa0579f6cbfc09718884-1 @@ -0,0 +1 @@ +n(p(),C( \ No newline at end of file diff --git a/pql/fuzz/corpus/8 b/pql/fuzz/corpus/8 new file mode 100644 index 000000000..29ce05cfd --- /dev/null +++ b/pql/fuzz/corpus/8 @@ -0,0 +1 @@ +TopN(Bitmap(id=100, field=other), field=f, n=3) \ No newline at end of file diff --git a/pql/fuzz/corpus/80899f5b5670badaff1d2c1820ad1d6c5ece8bf9 b/pql/fuzz/corpus/80899f5b5670badaff1d2c1820ad1d6c5ece8bf9 new file mode 100644 index 000000000..dd54822fe --- /dev/null +++ b/pql/fuzz/corpus/80899f5b5670badaff1d2c1820ad1d6c5ece8bf9 @@ -0,0 +1 @@ +C(y=12.25,o=13.167,r=2.,z=0.9) \ No newline at end of file diff --git a/pql/fuzz/corpus/9 b/pql/fuzz/corpus/9 new file mode 100644 index 000000000..870c1835c --- /dev/null +++ b/pql/fuzz/corpus/9 @@ -0,0 +1 @@ +MyCall(key=foo, x == 12.25, y >= 100, z >< [4,8], m != null) \ No newline at end of file diff --git a/pql/fuzz/corpus/9456f79011b99928233a5c43c89d9bcabc788a9d b/pql/fuzz/corpus/9456f79011b99928233a5c43c89d9bcabc788a9d new file mode 100644 index 000000000..f7c988077 --- /dev/null +++ b/pql/fuzz/corpus/9456f79011b99928233a5c43c89d9bcabc788a9d @@ -0,0 +1 @@ +t(p( )) \ No newline at end of file diff --git a/pql/fuzz/corpus/94ebe178c54a1ed5eced6ee363799261b18740c7-1 b/pql/fuzz/corpus/94ebe178c54a1ed5eced6ee363799261b18740c7-1 new file mode 100644 index 000000000..10e6841d0 --- /dev/null +++ b/pql/fuzz/corpus/94ebe178c54a1ed5eced6ee363799261b18740c7-1 @@ -0,0 +1 @@ +e(invalid_column_name<0,f=0) \ No newline at end of file diff --git a/pql/fuzz/corpus/9cbc01e0a28e963310a3e6b80eeb094a3de77c06 b/pql/fuzz/corpus/9cbc01e0a28e963310a3e6b80eeb094a3de77c06 new file mode 100644 index 000000000..090a8a693 --- /dev/null +++ b/pql/fuzz/corpus/9cbc01e0a28e963310a3e6b80eeb094a3de77c06 @@ -0,0 +1 @@ +tV(f=5) \ No newline at end of file diff --git a/pql/fuzz/corpus/9f974590bac2e9aa23f6e93128263403ca9d109f b/pql/fuzz/corpus/9f974590bac2e9aa23f6e93128263403ca9d109f new file mode 100644 index 000000000..4b2b7b2bb --- /dev/null +++ b/pql/fuzz/corpus/9f974590bac2e9aa23f6e93128263403ca9d109f @@ -0,0 +1 @@ +t(Ba(w=0,d=f)) \ No newline at end of file diff --git a/pql/fuzz/corpus/a5ef2ba5c1423d9d03d8293be378b48af8dee79e b/pql/fuzz/corpus/a5ef2ba5c1423d9d03d8293be378b48af8dee79e new file mode 100644 index 000000000..dcf964fd5 --- /dev/null +++ b/pql/fuzz/corpus/a5ef2ba5c1423d9d03d8293be378b48af8dee79e @@ -0,0 +1 @@ +Range(o < 0) \ No newline at end of file diff --git a/pql/fuzz/corpus/af209066ba9b25655fadd130ec30aa42f9a6c606 b/pql/fuzz/corpus/af209066ba9b25655fadd130ec30aa42f9a6c606 new file mode 100644 index 000000000..74ac16027 --- /dev/null +++ b/pql/fuzz/corpus/af209066ba9b25655fadd130ec30aa42f9a6c606 @@ -0,0 +1 @@ +n() \ No newline at end of file diff --git a/pql/fuzz/corpus/b9258eb89acc5c62232f5e482449cc155a215125 b/pql/fuzz/corpus/b9258eb89acc5c62232f5e482449cc155a215125 new file mode 100644 index 000000000..a9bb8167b --- /dev/null +++ b/pql/fuzz/corpus/b9258eb89acc5c62232f5e482449cc155a215125 @@ -0,0 +1 @@ +Intersect(Bitmap(row=10),Bitmap(row=11)) \ No newline at end of file diff --git a/pql/fuzz/corpus/c0d2d3099c28dc8b6e838f1d95a5fd314d6caff5 b/pql/fuzz/corpus/c0d2d3099c28dc8b6e838f1d95a5fd314d6caff5 new file mode 100644 index 000000000..420a255a2 --- /dev/null +++ b/pql/fuzz/corpus/c0d2d3099c28dc8b6e838f1d95a5fd314d6caff5 @@ -0,0 +1 @@ +Cl( k=-12.25, f= -13) \ No newline at end of file diff --git a/pql/fuzz/corpus/c7b63c3044a6dd7981d72573a970e9f1ac42f5b4 b/pql/fuzz/corpus/c7b63c3044a6dd7981d72573a970e9f1ac42f5b4 new file mode 100644 index 000000000..990d4e833 --- /dev/null +++ b/pql/fuzz/corpus/c7b63c3044a6dd7981d72573a970e9f1ac42f5b4 @@ -0,0 +1 @@ +e(o<0) \ No newline at end of file diff --git a/pql/fuzz/corpus/cd414eb16b1530ef1b9aa16a3b60abc932c4ca6c b/pql/fuzz/corpus/cd414eb16b1530ef1b9aa16a3b60abc932c4ca6c new file mode 100644 index 000000000..6e6fab1ca --- /dev/null +++ b/pql/fuzz/corpus/cd414eb16b1530ef1b9aa16a3b60abc932c4ca6c @@ -0,0 +1 @@ +Difference(Bitmap(row=10),Bitmap(row=11)) \ No newline at end of file diff --git a/pql/fuzz/corpus/d20407c02c966d0cac76b72486e892158dce4ba7-1 b/pql/fuzz/corpus/d20407c02c966d0cac76b72486e892158dce4ba7-1 new file mode 100644 index 000000000..789a07fc4 --- /dev/null +++ b/pql/fuzz/corpus/d20407c02c966d0cac76b72486e892158dce4ba7-1 @@ -0,0 +1 @@ +j(w=10375035658,t=R) \ No newline at end of file diff --git a/pql/fuzz/corpus/d4a4d133499f09ad2d91114f55ed7235e985f7fd b/pql/fuzz/corpus/d4a4d133499f09ad2d91114f55ed7235e985f7fd new file mode 100644 index 000000000..95edd6a6f --- /dev/null +++ b/pql/fuzz/corpus/d4a4d133499f09ad2d91114f55ed7235e985f7fd @@ -0,0 +1 @@ +Range(other!=l) \ No newline at end of file diff --git a/pql/fuzz/corpus/d5dd3b391afdce17c47a2644e536431e3b5b6825 b/pql/fuzz/corpus/d5dd3b391afdce17c47a2644e536431e3b5b6825 new file mode 100644 index 000000000..e0dfe5315 --- /dev/null +++ b/pql/fuzz/corpus/d5dd3b391afdce17c47a2644e536431e3b5b6825 @@ -0,0 +1 @@ +e(o<=0) diff --git a/pql/fuzz/corpus/da588debce70733e48a0f1728ac248ce65e9e8c2-1 b/pql/fuzz/corpus/da588debce70733e48a0f1728ac248ce65e9e8c2-1 new file mode 100644 index 000000000..3c37e86b7 --- /dev/null +++ b/pql/fuzz/corpus/da588debce70733e48a0f1728ac248ce65e9e8c2-1 @@ -0,0 +1 @@ +e(w=T \ No newline at end of file diff --git a/pql/fuzz/corpus/e2c94a638563108995f18d0daadb9d2bd8a5f0c6 b/pql/fuzz/corpus/e2c94a638563108995f18d0daadb9d2bd8a5f0c6 new file mode 100644 index 000000000..cdc7903a6 --- /dev/null +++ b/pql/fuzz/corpus/e2c94a638563108995f18d0daadb9d2bd8a5f0c6 @@ -0,0 +1 @@ +l(key=oo, x == 12.25, y >= 100, z >< [4,8], m != null) \ No newline at end of file diff --git a/pql/fuzz/corpus/e373d8c28776b2d1c8740807ffbe46cdd0260f98 b/pql/fuzz/corpus/e373d8c28776b2d1c8740807ffbe46cdd0260f98 new file mode 100644 index 000000000..a692598ed --- /dev/null +++ b/pql/fuzz/corpus/e373d8c28776b2d1c8740807ffbe46cdd0260f98 @@ -0,0 +1 @@ +SB(ow=1, f=f, c=1) \ No newline at end of file diff --git a/pql/fuzz/corpus/ee78db5d4e2231cadcf5957d169657ef4658c343 b/pql/fuzz/corpus/ee78db5d4e2231cadcf5957d169657ef4658c343 new file mode 100644 index 000000000..beb610cd7 --- /dev/null +++ b/pql/fuzz/corpus/ee78db5d4e2231cadcf5957d169657ef4658c343 @@ -0,0 +1 @@ +Setalue(invalidcolumnnamf=0) \ No newline at end of file diff --git a/pql/fuzz/corpus/f1c3a3daa6e74cf6ba1b8a494a21a34aa2aab41d b/pql/fuzz/corpus/f1c3a3daa6e74cf6ba1b8a494a21a34aa2aab41d new file mode 100644 index 000000000..5cac44705 --- /dev/null +++ b/pql/fuzz/corpus/f1c3a3daa6e74cf6ba1b8a494a21a34aa2aab41d @@ -0,0 +1 @@ +N(field="f",ids=[0,10,30]) \ No newline at end of file diff --git a/pql/fuzz/corpus/f8f3c39e99db75ff5c8772a9871185a821a75f29 b/pql/fuzz/corpus/f8f3c39e99db75ff5c8772a9871185a821a75f29 new file mode 100644 index 000000000..b13f3aff7 --- /dev/null +++ b/pql/fuzz/corpus/f8f3c39e99db75ff5c8772a9871185a821a75f29 @@ -0,0 +1 @@ +U( B() , C() ) \ No newline at end of file diff --git a/pql/fuzz/corpus/ff41d50e5926d166b2adc0596339201274509856 b/pql/fuzz/corpus/ff41d50e5926d166b2adc0596339201274509856 new file mode 100644 index 000000000..adca39514 --- /dev/null +++ b/pql/fuzz/corpus/ff41d50e5926d166b2adc0596339201274509856 @@ -0,0 +1 @@ +Range(r!=null) \ No newline at end of file diff --git a/pql/internal/oldpql/parser_test.go b/pql/internal/oldpql/parser_test.go index 7aa8fafe1..31613429c 100644 --- a/pql/internal/oldpql/parser_test.go +++ b/pql/internal/oldpql/parser_test.go @@ -190,5 +190,4 @@ func TestParser_Parse(t *testing.T) { t.Fatalf("unexpected call: %#v", q.Calls[0]) } }) - } diff --git a/pql/internal/oldpql/scanner.go b/pql/internal/oldpql/scanner.go index dd7f9126d..27e321a0c 100644 --- a/pql/internal/oldpql/scanner.go +++ b/pql/internal/oldpql/scanner.go @@ -71,7 +71,7 @@ func (s *Scanner) Scan() (tok Token, pos Pos, lit string) { return NEQ, pos, "!=" } s.unread() - return ASSIGN, pos, string(ch) + return ILLEGAL, pos, string(ch) case '<': if next := s.read(); next == '=' { return LTE, pos, "<=" diff --git a/pql/parser_fuzz.go b/pql/parser_fuzz.go new file mode 100644 index 000000000..ffcea44ab --- /dev/null +++ b/pql/parser_fuzz.go @@ -0,0 +1,115 @@ +// +build gofuzz + +package pql + +import ( + "bytes" + "fmt" + "reflect" + + "github.com/pilosa/pilosa/pql/internal/oldpql" + "github.com/pkg/errors" +) + +func Fuzz(data []byte) int { + p1 := NewParser(bytes.NewReader(data)) + q1, err1 := p1.Parse() + p2 := oldpql.NewParser(bytes.NewReader(data)) + q2, err2 := p2.Parse() + if err1 != nil && err2 != nil { + return 0 // both error - this is fine + } + if err1 != nil || err2 != nil { + // error in one but not both - need to know this + panic(fmt.Sprintf("Query: '%s' errored one but not both.\n%v\n%v\n", data, err1, err2)) + } + + // if parsers got different results + if err := queriesEqual(q1, q2); err != nil { + panic(fmt.Sprintf(`Query: '%s' parsed, but got different results: +Result New (string) +%s +Result New (hashv) +%#v +Result Old (string) +%s +Result Old (hashv) +%#v +err: +%v +`, data, q1, q1, q2, q2, err)) + } + + // both queries parsed succesfully and got equivalent results + return 1 +} + +func queriesEqual(q1 *Query, q2 *oldpql.Query) (err error) { + if q1.String() != q2.String() { + defer func() { + // golang black magic + if err == nil { + err = errors.New("string reps unequal") + } else { + err = errors.Wrap(err, "string reps unequal") + } + }() + } + if len(q1.Calls) != len(q2.Calls) { + return errors.Errorf("call lengths unequal: %d and %d", len(q1.Calls), len(q2.Calls)) + } + for i, c1 := range q1.Calls { + c2 := q2.Calls[i] + if err := callsEqual(c1, c2); err != nil { + return errors.Wrapf(err, "calls at %d not equal", i) + } + } + return nil +} + +func callsEqual(c1 *Call, c2 *oldpql.Call) error { + if err := argsEqual(c1.Args, c2.Args); err != nil { + return errors.Wrap(err, "args unequal") + } + if c1.Name != c2.Name { + return errors.Errorf("names unequal '%s' != '%s'", c1.Name, c2.Name) + } + if len(c1.Children) != len(c2.Children) { + return errors.Errorf("different child lengths %d and %d", len(c1.Children), len(c2.Children)) + } + + for i, child1 := range c1.Children { + child2 := c2.Children[i] + if err := callsEqual(child1, child2); err != nil { + return errors.Wrapf(err, "children at %d not equal", i) + } + } + + return nil +} + +func argsEqual(a1 map[string]interface{}, a2 map[string]interface{}) error { + if len(a1) != len(a2) { + return errors.Errorf("lengths unequal %d and %d", len(a1), len(a2)) + } + + for k, v1 := range a1 { + v2 := a1[k] + if c1, ok := v1.(Condition); ok { + if c2, ok := v2.(oldpql.Condition); ok { + if int(c1.Op) != int(c2.Op) { + return errors.Errorf("condition ops unequal %d %d", c1, c2) + } + if !reflect.DeepEqual(c1.Value, c2.Value) { + return errors.Errorf("condition values unequal '%v' '%v'", c1.Value, c2.Value) + } + continue + } + return errors.Errorf("values at %s unequal '%v' '%v'", k, v1, v2) + } + if !reflect.DeepEqual(v1, v2) { + return errors.Errorf("values at %s unequal '%v' '%v'", k, v1, v2) + } + } + return nil +} diff --git a/pql/pql.peg b/pql/pql.peg index b909c4450..3602f8cc1 100644 --- a/pql/pql.peg +++ b/pql/pql.peg @@ -6,10 +6,10 @@ type PQL Peg { Calls <- Call* !. -Call <- newline* < [[A-Z]]+ > { p.startCall(buffer[begin:end] ) } open args close newline* { p.endCall() } -args <- arg (comma args)? sp / sp -arg <- ( Call - / field sp '=' sp value +Call <- whitesp < IDENT > { p.startCall(buffer[begin:end] ) } open allargs comma? close whitesp { p.endCall() } +allargs <- Call (comma Call)* (comma args)? / comma? args / sp +args <- arg (comma args)? sp +arg <- ( field sp '=' sp value / field sp COND sp value ) COND <- ( '><' { p.addBTWN() } @@ -25,9 +25,9 @@ value <- ( item / lbrack { p.startList() } list rbrack { p.endList() } ) list <- item (comma list)? -item <- ( 'null' { p.addVal(nil) } - / 'true' { p.addVal(true) } - / 'false' { p.addVal(false) } +item <- ( 'null' &(comma / sp close) { p.addVal(nil) } + / 'true' &(comma / sp close) { p.addVal(true) } + / 'false' &(comma / sp close) { p.addVal(false) } / < '-'? [0-9]+ ('.'[0-9]*)? > { p.addNumVal(buffer[begin:end]) } / < '-'? '.'[0-9]+ > { p.addNumVal(buffer[begin:end]) } / < ([[A-Z]] / [0-9] / '-' / '_' / ':')+ > { p.addVal(buffer[begin:end]) } @@ -44,4 +44,5 @@ sp <- ( ' ' / '\t' )* comma <- sp ',' sp lbrack <- '[' sp rbrack <- sp ']' sp -newline <- sp '\n' sp \ No newline at end of file +whitesp <- ( ' ' / '\t' / '\n' )* +IDENT <- [[A-Z]] ([[A-Z]] / [0-9] / '-' / '_' / '.')* \ No newline at end of file diff --git a/pql/pql.peg.go b/pql/pql.peg.go index 02ce64918..e4680d613 100644 --- a/pql/pql.peg.go +++ b/pql/pql.peg.go @@ -18,6 +18,7 @@ const ( ruleUnknown pegRule = iota ruleCalls ruleCall + ruleallargs ruleargs rulearg ruleCOND @@ -33,7 +34,8 @@ const ( rulecomma rulelbrack rulerbrack - rulenewline + rulewhitesp + ruleIDENT rulePegText ruleAction0 ruleAction1 @@ -61,6 +63,7 @@ var rul3s = [...]string{ "Unknown", "Calls", "Call", + "allargs", "args", "arg", "COND", @@ -76,7 +79,8 @@ var rul3s = [...]string{ "comma", "lbrack", "rbrack", - "newline", + "whitesp", + "IDENT", "PegText", "Action0", "Action1", @@ -214,7 +218,7 @@ type PQL struct { Buffer string buffer []rune - rules [40]func() bool + rules [42]func() bool parse func(rule ...int) error reset func() Pretty bool @@ -451,67 +455,92 @@ func (p *PQL) Init() { position, tokenIndex = position0, tokenIndex0 return false }, - /* 1 Call <- <(newline* <([a-z] / [A-Z])+> Action0 open args close newline* Action1)> */ + /* 1 Call <- <(whitesp Action0 open allargs comma? close whitesp Action1)> */ func() bool { position5, tokenIndex5 := position, tokenIndex { position6 := position - l7: - { - position8, tokenIndex8 := position, tokenIndex - if !_rules[rulenewline]() { - goto l8 - } - goto l7 - l8: - position, tokenIndex = position8, tokenIndex8 + if !_rules[rulewhitesp]() { + goto l5 } { - position9 := position + position7 := position { - position12, tokenIndex12 := position, tokenIndex - if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l13 - } - position++ - goto l12 - l13: - position, tokenIndex = position12, tokenIndex12 - if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l5 - } - position++ - } - l12: - l10: - { - position11, tokenIndex11 := position, tokenIndex + position8 := position { - position14, tokenIndex14 := position, tokenIndex + position9, tokenIndex9 := position, tokenIndex if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l15 + goto l10 } position++ - goto l14 - l15: - position, tokenIndex = position14, tokenIndex14 + goto l9 + l10: + position, tokenIndex = position9, tokenIndex9 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l11 + goto l5 } position++ } - l14: - goto l10 + l9: l11: - position, tokenIndex = position11, tokenIndex11 + { + position12, tokenIndex12 := position, tokenIndex + { + position13, tokenIndex13 := position, tokenIndex + if c := buffer[position]; c < rune('a') || c > rune('z') { + goto l14 + } + position++ + goto l13 + l14: + position, tokenIndex = position13, tokenIndex13 + if c := buffer[position]; c < rune('A') || c > rune('Z') { + goto l15 + } + position++ + goto l13 + l15: + position, tokenIndex = position13, tokenIndex13 + if c := buffer[position]; c < rune('0') || c > rune('9') { + goto l16 + } + position++ + goto l13 + l16: + position, tokenIndex = position13, tokenIndex13 + if buffer[position] != rune('-') { + goto l17 + } + position++ + goto l13 + l17: + position, tokenIndex = position13, tokenIndex13 + if buffer[position] != rune('_') { + goto l18 + } + position++ + goto l13 + l18: + position, tokenIndex = position13, tokenIndex13 + if buffer[position] != rune('.') { + goto l12 + } + position++ + } + l13: + goto l11 + l12: + position, tokenIndex = position12, tokenIndex12 + } + add(ruleIDENT, position8) } - add(rulePegText, position9) + add(rulePegText, position7) } { add(ruleAction0, position) } { - position17 := position + position20 := position if buffer[position] != rune('(') { goto l5 } @@ -519,31 +548,82 @@ func (p *PQL) Init() { if !_rules[rulesp]() { goto l5 } - add(ruleopen, position17) + add(ruleopen, position20) } - if !_rules[ruleargs]() { + { + position21 := position + { + position22, tokenIndex22 := position, tokenIndex + if !_rules[ruleCall]() { + goto l23 + } + l24: + { + position25, tokenIndex25 := position, tokenIndex + if !_rules[rulecomma]() { + goto l25 + } + if !_rules[ruleCall]() { + goto l25 + } + goto l24 + l25: + position, tokenIndex = position25, tokenIndex25 + } + { + position26, tokenIndex26 := position, tokenIndex + if !_rules[rulecomma]() { + goto l26 + } + if !_rules[ruleargs]() { + goto l26 + } + goto l27 + l26: + position, tokenIndex = position26, tokenIndex26 + } + l27: + goto l22 + l23: + position, tokenIndex = position22, tokenIndex22 + { + position29, tokenIndex29 := position, tokenIndex + if !_rules[rulecomma]() { + goto l29 + } + goto l30 + l29: + position, tokenIndex = position29, tokenIndex29 + } + l30: + if !_rules[ruleargs]() { + goto l28 + } + goto l22 + l28: + position, tokenIndex = position22, tokenIndex22 + if !_rules[rulesp]() { + goto l5 + } + } + l22: + add(ruleallargs, position21) + } + { + position31, tokenIndex31 := position, tokenIndex + if !_rules[rulecomma]() { + goto l31 + } + goto l32 + l31: + position, tokenIndex = position31, tokenIndex31 + } + l32: + if !_rules[ruleclose]() { goto l5 } - { - position18 := position - if buffer[position] != rune(')') { - goto l5 - } - position++ - if !_rules[rulesp]() { - goto l5 - } - add(ruleclose, position18) - } - l19: - { - position20, tokenIndex20 := position, tokenIndex - if !_rules[rulenewline]() { - goto l20 - } - goto l19 - l20: - position, tokenIndex = position20, tokenIndex20 + if !_rules[rulewhitesp]() { + goto l5 } { add(ruleAction1, position) @@ -555,968 +635,1048 @@ func (p *PQL) Init() { position, tokenIndex = position5, tokenIndex5 return false }, - /* 2 args <- <((arg (comma args)? sp) / sp)> */ + /* 2 allargs <- <((Call (comma Call)* (comma args)?) / (comma? args) / sp)> */ + nil, + /* 3 args <- <(arg (comma args)? sp)> */ func() bool { - position22, tokenIndex22 := position, tokenIndex + position35, tokenIndex35 := position, tokenIndex { - position23 := position + position36 := position { - position24, tokenIndex24 := position, tokenIndex + position37 := position { - position26 := position - { - position27, tokenIndex27 := position, tokenIndex - if !_rules[ruleCall]() { - goto l28 - } - goto l27 - l28: - position, tokenIndex = position27, tokenIndex27 - if !_rules[rulefield]() { - goto l29 - } - if !_rules[rulesp]() { - goto l29 - } - if buffer[position] != rune('=') { - goto l29 - } - position++ - if !_rules[rulesp]() { - goto l29 - } - if !_rules[rulevalue]() { - goto l29 - } - goto l27 - l29: - position, tokenIndex = position27, tokenIndex27 - if !_rules[rulefield]() { - goto l25 - } - if !_rules[rulesp]() { - goto l25 - } - { - position30 := position - { - position31, tokenIndex31 := position, tokenIndex - if buffer[position] != rune('>') { - goto l32 - } - position++ - if buffer[position] != rune('<') { - goto l32 - } - position++ - { - add(ruleAction2, position) - } - goto l31 - l32: - position, tokenIndex = position31, tokenIndex31 - if buffer[position] != rune('<') { - goto l34 - } - position++ - if buffer[position] != rune('=') { - goto l34 - } - position++ - { - add(ruleAction3, position) - } - goto l31 - l34: - position, tokenIndex = position31, tokenIndex31 - if buffer[position] != rune('>') { - goto l36 - } - position++ - if buffer[position] != rune('=') { - goto l36 - } - position++ - { - add(ruleAction4, position) - } - goto l31 - l36: - position, tokenIndex = position31, tokenIndex31 - if buffer[position] != rune('=') { - goto l38 - } - position++ - if buffer[position] != rune('=') { - goto l38 - } - position++ - { - add(ruleAction5, position) - } - goto l31 - l38: - position, tokenIndex = position31, tokenIndex31 - if buffer[position] != rune('!') { - goto l40 - } - position++ - if buffer[position] != rune('=') { - goto l40 - } - position++ - { - add(ruleAction6, position) - } - goto l31 - l40: - position, tokenIndex = position31, tokenIndex31 - if buffer[position] != rune('<') { - goto l42 - } - position++ - { - add(ruleAction7, position) - } - goto l31 - l42: - position, tokenIndex = position31, tokenIndex31 - if buffer[position] != rune('>') { - goto l25 - } - position++ - { - add(ruleAction8, position) - } - } - l31: - add(ruleCOND, position30) - } - if !_rules[rulesp]() { - goto l25 - } - if !_rules[rulevalue]() { - goto l25 - } + position38, tokenIndex38 := position, tokenIndex + if !_rules[rulefield]() { + goto l39 } - l27: - add(rulearg, position26) - } - { - position45, tokenIndex45 := position, tokenIndex - if !_rules[rulecomma]() { - goto l45 + if !_rules[rulesp]() { + goto l39 } - if !_rules[ruleargs]() { - goto l45 - } - goto l46 - l45: - position, tokenIndex = position45, tokenIndex45 - } - l46: - if !_rules[rulesp]() { - goto l25 - } - goto l24 - l25: - position, tokenIndex = position24, tokenIndex24 - if !_rules[rulesp]() { - goto l22 - } - } - l24: - add(ruleargs, position23) - } - return true - l22: - position, tokenIndex = position22, tokenIndex22 - return false - }, - /* 3 arg <- <(Call / (field sp '=' sp value) / (field sp COND sp value))> */ - nil, - /* 4 COND <- <(('>' '<' Action2) / ('<' '=' Action3) / ('>' '=' Action4) / ('=' '=' Action5) / ('!' '=' Action6) / ('<' Action7) / ('>' Action8))> */ - nil, - /* 5 open <- <('(' sp)> */ - nil, - /* 6 value <- <(item / (lbrack Action9 list rbrack Action10))> */ - func() bool { - position50, tokenIndex50 := position, tokenIndex - { - position51 := position - { - position52, tokenIndex52 := position, tokenIndex - if !_rules[ruleitem]() { - goto l53 - } - goto l52 - l53: - position, tokenIndex = position52, tokenIndex52 - { - position54 := position - if buffer[position] != rune('[') { - goto l50 + if buffer[position] != rune('=') { + goto l39 } position++ if !_rules[rulesp]() { - goto l50 + goto l39 } - add(rulelbrack, position54) + if !_rules[rulevalue]() { + goto l39 + } + goto l38 + l39: + position, tokenIndex = position38, tokenIndex38 + if !_rules[rulefield]() { + goto l35 + } + if !_rules[rulesp]() { + goto l35 + } + { + position40 := position + { + position41, tokenIndex41 := position, tokenIndex + if buffer[position] != rune('>') { + goto l42 + } + position++ + if buffer[position] != rune('<') { + goto l42 + } + position++ + { + add(ruleAction2, position) + } + goto l41 + l42: + position, tokenIndex = position41, tokenIndex41 + if buffer[position] != rune('<') { + goto l44 + } + position++ + if buffer[position] != rune('=') { + goto l44 + } + position++ + { + add(ruleAction3, position) + } + goto l41 + l44: + position, tokenIndex = position41, tokenIndex41 + if buffer[position] != rune('>') { + goto l46 + } + position++ + if buffer[position] != rune('=') { + goto l46 + } + position++ + { + add(ruleAction4, position) + } + goto l41 + l46: + position, tokenIndex = position41, tokenIndex41 + if buffer[position] != rune('=') { + goto l48 + } + position++ + if buffer[position] != rune('=') { + goto l48 + } + position++ + { + add(ruleAction5, position) + } + goto l41 + l48: + position, tokenIndex = position41, tokenIndex41 + if buffer[position] != rune('!') { + goto l50 + } + position++ + if buffer[position] != rune('=') { + goto l50 + } + position++ + { + add(ruleAction6, position) + } + goto l41 + l50: + position, tokenIndex = position41, tokenIndex41 + if buffer[position] != rune('<') { + goto l52 + } + position++ + { + add(ruleAction7, position) + } + goto l41 + l52: + position, tokenIndex = position41, tokenIndex41 + if buffer[position] != rune('>') { + goto l35 + } + position++ + { + add(ruleAction8, position) + } + } + l41: + add(ruleCOND, position40) + } + if !_rules[rulesp]() { + goto l35 + } + if !_rules[rulevalue]() { + goto l35 + } + } + l38: + add(rulearg, position37) + } + { + position55, tokenIndex55 := position, tokenIndex + if !_rules[rulecomma]() { + goto l55 + } + if !_rules[ruleargs]() { + goto l55 + } + goto l56 + l55: + position, tokenIndex = position55, tokenIndex55 + } + l56: + if !_rules[rulesp]() { + goto l35 + } + add(ruleargs, position36) + } + return true + l35: + position, tokenIndex = position35, tokenIndex35 + return false + }, + /* 4 arg <- <((field sp '=' sp value) / (field sp COND sp value))> */ + nil, + /* 5 COND <- <(('>' '<' Action2) / ('<' '=' Action3) / ('>' '=' Action4) / ('=' '=' Action5) / ('!' '=' Action6) / ('<' Action7) / ('>' Action8))> */ + nil, + /* 6 open <- <('(' sp)> */ + nil, + /* 7 value <- <(item / (lbrack Action9 list rbrack Action10))> */ + func() bool { + position60, tokenIndex60 := position, tokenIndex + { + position61 := position + { + position62, tokenIndex62 := position, tokenIndex + if !_rules[ruleitem]() { + goto l63 + } + goto l62 + l63: + position, tokenIndex = position62, tokenIndex62 + { + position64 := position + if buffer[position] != rune('[') { + goto l60 + } + position++ + if !_rules[rulesp]() { + goto l60 + } + add(rulelbrack, position64) } { add(ruleAction9, position) } if !_rules[rulelist]() { - goto l50 + goto l60 } { - position56 := position + position66 := position if !_rules[rulesp]() { - goto l50 + goto l60 } if buffer[position] != rune(']') { - goto l50 + goto l60 } position++ if !_rules[rulesp]() { - goto l50 + goto l60 } - add(rulerbrack, position56) + add(rulerbrack, position66) } { add(ruleAction10, position) } } - l52: - add(rulevalue, position51) + l62: + add(rulevalue, position61) } return true - l50: - position, tokenIndex = position50, tokenIndex50 + l60: + position, tokenIndex = position60, tokenIndex60 return false }, - /* 7 list <- <(item (comma list)?)> */ + /* 8 list <- <(item (comma list)?)> */ func() bool { - position58, tokenIndex58 := position, tokenIndex + position68, tokenIndex68 := position, tokenIndex { - position59 := position + position69 := position if !_rules[ruleitem]() { - goto l58 + goto l68 } { - position60, tokenIndex60 := position, tokenIndex + position70, tokenIndex70 := position, tokenIndex if !_rules[rulecomma]() { - goto l60 + goto l70 } if !_rules[rulelist]() { - goto l60 + goto l70 } - goto l61 - l60: - position, tokenIndex = position60, tokenIndex60 + goto l71 + l70: + position, tokenIndex = position70, tokenIndex70 } - l61: - add(rulelist, position59) + l71: + add(rulelist, position69) } return true - l58: - position, tokenIndex = position58, tokenIndex58 + l68: + position, tokenIndex = position68, tokenIndex68 return false }, - /* 8 item <- <(('n' 'u' 'l' 'l' Action11) / ('t' 'r' 'u' 'e' Action12) / ('f' 'a' 'l' 's' 'e' Action13) / (<('-'? [0-9]+ ('.' [0-9]*)?)> Action14) / (<('-'? '.' [0-9]+)> Action15) / (<([a-z] / [A-Z] / [0-9] / '-' / '_' / ':')+> Action16) / ('"' '"' Action17) / ('\'' '\'' Action18))> */ + /* 9 item <- <(('n' 'u' 'l' 'l' &(comma / (sp close)) Action11) / ('t' 'r' 'u' 'e' &(comma / (sp close)) Action12) / ('f' 'a' 'l' 's' 'e' &(comma / (sp close)) Action13) / (<('-'? [0-9]+ ('.' [0-9]*)?)> Action14) / (<('-'? '.' [0-9]+)> Action15) / (<([a-z] / [A-Z] / [0-9] / '-' / '_' / ':')+> Action16) / ('"' '"' Action17) / ('\'' '\'' Action18))> */ func() bool { - position62, tokenIndex62 := position, tokenIndex + position72, tokenIndex72 := position, tokenIndex { - position63 := position + position73 := position { - position64, tokenIndex64 := position, tokenIndex + position74, tokenIndex74 := position, tokenIndex if buffer[position] != rune('n') { - goto l65 + goto l75 } position++ if buffer[position] != rune('u') { - goto l65 + goto l75 } position++ if buffer[position] != rune('l') { - goto l65 + goto l75 } position++ if buffer[position] != rune('l') { - goto l65 + goto l75 } position++ + { + position76, tokenIndex76 := position, tokenIndex + { + position77, tokenIndex77 := position, tokenIndex + if !_rules[rulecomma]() { + goto l78 + } + goto l77 + l78: + position, tokenIndex = position77, tokenIndex77 + if !_rules[rulesp]() { + goto l75 + } + if !_rules[ruleclose]() { + goto l75 + } + } + l77: + position, tokenIndex = position76, tokenIndex76 + } { add(ruleAction11, position) } - goto l64 - l65: - position, tokenIndex = position64, tokenIndex64 + goto l74 + l75: + position, tokenIndex = position74, tokenIndex74 if buffer[position] != rune('t') { - goto l67 + goto l80 } position++ if buffer[position] != rune('r') { - goto l67 + goto l80 } position++ if buffer[position] != rune('u') { - goto l67 + goto l80 } position++ if buffer[position] != rune('e') { - goto l67 + goto l80 } position++ + { + position81, tokenIndex81 := position, tokenIndex + { + position82, tokenIndex82 := position, tokenIndex + if !_rules[rulecomma]() { + goto l83 + } + goto l82 + l83: + position, tokenIndex = position82, tokenIndex82 + if !_rules[rulesp]() { + goto l80 + } + if !_rules[ruleclose]() { + goto l80 + } + } + l82: + position, tokenIndex = position81, tokenIndex81 + } { add(ruleAction12, position) } - goto l64 - l67: - position, tokenIndex = position64, tokenIndex64 + goto l74 + l80: + position, tokenIndex = position74, tokenIndex74 if buffer[position] != rune('f') { - goto l69 + goto l85 } position++ if buffer[position] != rune('a') { - goto l69 + goto l85 } position++ if buffer[position] != rune('l') { - goto l69 + goto l85 } position++ if buffer[position] != rune('s') { - goto l69 + goto l85 } position++ if buffer[position] != rune('e') { - goto l69 + goto l85 } position++ + { + position86, tokenIndex86 := position, tokenIndex + { + position87, tokenIndex87 := position, tokenIndex + if !_rules[rulecomma]() { + goto l88 + } + goto l87 + l88: + position, tokenIndex = position87, tokenIndex87 + if !_rules[rulesp]() { + goto l85 + } + if !_rules[ruleclose]() { + goto l85 + } + } + l87: + position, tokenIndex = position86, tokenIndex86 + } { add(ruleAction13, position) } - goto l64 - l69: - position, tokenIndex = position64, tokenIndex64 + goto l74 + l85: + position, tokenIndex = position74, tokenIndex74 { - position72 := position + position91 := position { - position73, tokenIndex73 := position, tokenIndex + position92, tokenIndex92 := position, tokenIndex if buffer[position] != rune('-') { - goto l73 + goto l92 } position++ - goto l74 - l73: - position, tokenIndex = position73, tokenIndex73 + goto l93 + l92: + position, tokenIndex = position92, tokenIndex92 } - l74: + l93: if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l71 + goto l90 } position++ - l75: + l94: { - position76, tokenIndex76 := position, tokenIndex + position95, tokenIndex95 := position, tokenIndex if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l76 + goto l95 } position++ - goto l75 - l76: - position, tokenIndex = position76, tokenIndex76 + goto l94 + l95: + position, tokenIndex = position95, tokenIndex95 } { - position77, tokenIndex77 := position, tokenIndex + position96, tokenIndex96 := position, tokenIndex if buffer[position] != rune('.') { - goto l77 + goto l96 } position++ - l79: + l98: { - position80, tokenIndex80 := position, tokenIndex + position99, tokenIndex99 := position, tokenIndex if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l80 + goto l99 } position++ - goto l79 - l80: - position, tokenIndex = position80, tokenIndex80 + goto l98 + l99: + position, tokenIndex = position99, tokenIndex99 } - goto l78 - l77: - position, tokenIndex = position77, tokenIndex77 + goto l97 + l96: + position, tokenIndex = position96, tokenIndex96 } - l78: - add(rulePegText, position72) + l97: + add(rulePegText, position91) } { add(ruleAction14, position) } - goto l64 - l71: - position, tokenIndex = position64, tokenIndex64 + goto l74 + l90: + position, tokenIndex = position74, tokenIndex74 { - position83 := position + position102 := position { - position84, tokenIndex84 := position, tokenIndex + position103, tokenIndex103 := position, tokenIndex if buffer[position] != rune('-') { - goto l84 + goto l103 } position++ - goto l85 - l84: - position, tokenIndex = position84, tokenIndex84 + goto l104 + l103: + position, tokenIndex = position103, tokenIndex103 } - l85: + l104: if buffer[position] != rune('.') { - goto l82 + goto l101 } position++ if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l82 + goto l101 } position++ - l86: + l105: { - position87, tokenIndex87 := position, tokenIndex + position106, tokenIndex106 := position, tokenIndex if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l87 + goto l106 } position++ - goto l86 - l87: - position, tokenIndex = position87, tokenIndex87 + goto l105 + l106: + position, tokenIndex = position106, tokenIndex106 } - add(rulePegText, position83) + add(rulePegText, position102) } { add(ruleAction15, position) } - goto l64 - l82: - position, tokenIndex = position64, tokenIndex64 + goto l74 + l101: + position, tokenIndex = position74, tokenIndex74 { - position90 := position + position109 := position { - position93, tokenIndex93 := position, tokenIndex + position112, tokenIndex112 := position, tokenIndex if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l94 + goto l113 } position++ - goto l93 - l94: - position, tokenIndex = position93, tokenIndex93 + goto l112 + l113: + position, tokenIndex = position112, tokenIndex112 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l95 + goto l114 } position++ - goto l93 - l95: - position, tokenIndex = position93, tokenIndex93 + goto l112 + l114: + position, tokenIndex = position112, tokenIndex112 if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l96 + goto l115 } position++ - goto l93 - l96: - position, tokenIndex = position93, tokenIndex93 + goto l112 + l115: + position, tokenIndex = position112, tokenIndex112 if buffer[position] != rune('-') { - goto l97 + goto l116 } position++ - goto l93 - l97: - position, tokenIndex = position93, tokenIndex93 + goto l112 + l116: + position, tokenIndex = position112, tokenIndex112 if buffer[position] != rune('_') { - goto l98 + goto l117 } position++ - goto l93 - l98: - position, tokenIndex = position93, tokenIndex93 + goto l112 + l117: + position, tokenIndex = position112, tokenIndex112 if buffer[position] != rune(':') { - goto l89 + goto l108 } position++ } - l93: - l91: + l112: + l110: { - position92, tokenIndex92 := position, tokenIndex + position111, tokenIndex111 := position, tokenIndex { - position99, tokenIndex99 := position, tokenIndex + position118, tokenIndex118 := position, tokenIndex if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l100 + goto l119 } position++ - goto l99 - l100: - position, tokenIndex = position99, tokenIndex99 + goto l118 + l119: + position, tokenIndex = position118, tokenIndex118 if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l101 + goto l120 } position++ - goto l99 - l101: - position, tokenIndex = position99, tokenIndex99 + goto l118 + l120: + position, tokenIndex = position118, tokenIndex118 if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l102 + goto l121 } position++ - goto l99 - l102: - position, tokenIndex = position99, tokenIndex99 + goto l118 + l121: + position, tokenIndex = position118, tokenIndex118 if buffer[position] != rune('-') { - goto l103 + goto l122 } position++ - goto l99 - l103: - position, tokenIndex = position99, tokenIndex99 + goto l118 + l122: + position, tokenIndex = position118, tokenIndex118 if buffer[position] != rune('_') { - goto l104 + goto l123 } position++ - goto l99 - l104: - position, tokenIndex = position99, tokenIndex99 + goto l118 + l123: + position, tokenIndex = position118, tokenIndex118 if buffer[position] != rune(':') { - goto l92 + goto l111 } position++ } - l99: - goto l91 - l92: - position, tokenIndex = position92, tokenIndex92 + l118: + goto l110 + l111: + position, tokenIndex = position111, tokenIndex111 } - add(rulePegText, position90) + add(rulePegText, position109) } { add(ruleAction16, position) } - goto l64 - l89: - position, tokenIndex = position64, tokenIndex64 + goto l74 + l108: + position, tokenIndex = position74, tokenIndex74 if buffer[position] != rune('"') { - goto l106 + goto l125 } position++ { - position107 := position + position126 := position { - position108 := position - l109: + position127 := position + l128: { - position110, tokenIndex110 := position, tokenIndex + position129, tokenIndex129 := position, tokenIndex { - position111, tokenIndex111 := position, tokenIndex + position130, tokenIndex130 := position, tokenIndex { - position113, tokenIndex113 := position, tokenIndex + position132, tokenIndex132 := position, tokenIndex { - position114, tokenIndex114 := position, tokenIndex + position133, tokenIndex133 := position, tokenIndex if buffer[position] != rune('"') { - goto l115 + goto l134 } position++ - goto l114 - l115: - position, tokenIndex = position114, tokenIndex114 + goto l133 + l134: + position, tokenIndex = position133, tokenIndex133 if buffer[position] != rune('\\') { - goto l116 + goto l135 } position++ - goto l114 - l116: - position, tokenIndex = position114, tokenIndex114 + goto l133 + l135: + position, tokenIndex = position133, tokenIndex133 if buffer[position] != rune('\n') { - goto l113 + goto l132 } position++ } - l114: - goto l112 - l113: - position, tokenIndex = position113, tokenIndex113 + l133: + goto l131 + l132: + position, tokenIndex = position132, tokenIndex132 } if !matchDot() { - goto l112 + goto l131 } - goto l111 - l112: - position, tokenIndex = position111, tokenIndex111 + goto l130 + l131: + position, tokenIndex = position130, tokenIndex130 if buffer[position] != rune('\\') { - goto l117 + goto l136 } position++ if buffer[position] != rune('n') { - goto l117 + goto l136 } position++ - goto l111 - l117: - position, tokenIndex = position111, tokenIndex111 + goto l130 + l136: + position, tokenIndex = position130, tokenIndex130 if buffer[position] != rune('\\') { - goto l118 + goto l137 } position++ if buffer[position] != rune('"') { - goto l118 + goto l137 } position++ - goto l111 - l118: - position, tokenIndex = position111, tokenIndex111 + goto l130 + l137: + position, tokenIndex = position130, tokenIndex130 if buffer[position] != rune('\\') { - goto l119 + goto l138 } position++ if buffer[position] != rune('\'') { - goto l119 + goto l138 } position++ - goto l111 - l119: - position, tokenIndex = position111, tokenIndex111 + goto l130 + l138: + position, tokenIndex = position130, tokenIndex130 if buffer[position] != rune('\\') { - goto l110 + goto l129 } position++ if buffer[position] != rune('\\') { - goto l110 + goto l129 } position++ } - l111: - goto l109 - l110: - position, tokenIndex = position110, tokenIndex110 + l130: + goto l128 + l129: + position, tokenIndex = position129, tokenIndex129 } - add(ruledoublequotedstring, position108) + add(ruledoublequotedstring, position127) } - add(rulePegText, position107) + add(rulePegText, position126) } if buffer[position] != rune('"') { - goto l106 + goto l125 } position++ { add(ruleAction17, position) } - goto l64 - l106: - position, tokenIndex = position64, tokenIndex64 + goto l74 + l125: + position, tokenIndex = position74, tokenIndex74 if buffer[position] != rune('\'') { - goto l62 + goto l72 } position++ { - position121 := position + position140 := position { - position122 := position - l123: + position141 := position + l142: { - position124, tokenIndex124 := position, tokenIndex + position143, tokenIndex143 := position, tokenIndex { - position125, tokenIndex125 := position, tokenIndex + position144, tokenIndex144 := position, tokenIndex { - position127, tokenIndex127 := position, tokenIndex + position146, tokenIndex146 := position, tokenIndex { - position128, tokenIndex128 := position, tokenIndex + position147, tokenIndex147 := position, tokenIndex if buffer[position] != rune('\'') { - goto l129 + goto l148 } position++ - goto l128 - l129: - position, tokenIndex = position128, tokenIndex128 + goto l147 + l148: + position, tokenIndex = position147, tokenIndex147 if buffer[position] != rune('\\') { - goto l130 + goto l149 } position++ - goto l128 - l130: - position, tokenIndex = position128, tokenIndex128 + goto l147 + l149: + position, tokenIndex = position147, tokenIndex147 if buffer[position] != rune('\n') { - goto l127 + goto l146 } position++ } - l128: - goto l126 - l127: - position, tokenIndex = position127, tokenIndex127 + l147: + goto l145 + l146: + position, tokenIndex = position146, tokenIndex146 } if !matchDot() { - goto l126 + goto l145 } - goto l125 - l126: - position, tokenIndex = position125, tokenIndex125 + goto l144 + l145: + position, tokenIndex = position144, tokenIndex144 if buffer[position] != rune('\\') { - goto l131 + goto l150 } position++ if buffer[position] != rune('n') { - goto l131 + goto l150 } position++ - goto l125 - l131: - position, tokenIndex = position125, tokenIndex125 + goto l144 + l150: + position, tokenIndex = position144, tokenIndex144 if buffer[position] != rune('\\') { - goto l132 + goto l151 } position++ if buffer[position] != rune('"') { - goto l132 + goto l151 } position++ - goto l125 - l132: - position, tokenIndex = position125, tokenIndex125 + goto l144 + l151: + position, tokenIndex = position144, tokenIndex144 if buffer[position] != rune('\\') { - goto l133 + goto l152 } position++ if buffer[position] != rune('\'') { - goto l133 + goto l152 } position++ - goto l125 - l133: - position, tokenIndex = position125, tokenIndex125 + goto l144 + l152: + position, tokenIndex = position144, tokenIndex144 if buffer[position] != rune('\\') { - goto l124 + goto l143 } position++ if buffer[position] != rune('\\') { - goto l124 + goto l143 } position++ } - l125: - goto l123 - l124: - position, tokenIndex = position124, tokenIndex124 + l144: + goto l142 + l143: + position, tokenIndex = position143, tokenIndex143 } - add(rulesinglequotedstring, position122) + add(rulesinglequotedstring, position141) } - add(rulePegText, position121) + add(rulePegText, position140) } if buffer[position] != rune('\'') { - goto l62 + goto l72 } position++ { add(ruleAction18, position) } } - l64: - add(ruleitem, position63) + l74: + add(ruleitem, position73) } return true - l62: - position, tokenIndex = position62, tokenIndex62 + l72: + position, tokenIndex = position72, tokenIndex72 return false }, - /* 9 doublequotedstring <- <((!('"' / '\\' / '\n') .) / ('\\' 'n') / ('\\' '"') / ('\\' '\'') / ('\\' '\\'))*> */ + /* 10 doublequotedstring <- <((!('"' / '\\' / '\n') .) / ('\\' 'n') / ('\\' '"') / ('\\' '\'') / ('\\' '\\'))*> */ nil, - /* 10 singlequotedstring <- <((!('\'' / '\\' / '\n') .) / ('\\' 'n') / ('\\' '"') / ('\\' '\'') / ('\\' '\\'))*> */ + /* 11 singlequotedstring <- <((!('\'' / '\\' / '\n') .) / ('\\' 'n') / ('\\' '"') / ('\\' '\'') / ('\\' '\\'))*> */ nil, - /* 11 field <- <(<(([a-z] / [A-Z]) ([a-z] / [A-Z] / [0-9] / '_')*)> Action19)> */ - func() bool { - position137, tokenIndex137 := position, tokenIndex - { - position138 := position - { - position139 := position - { - position140, tokenIndex140 := position, tokenIndex - if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l141 - } - position++ - goto l140 - l141: - position, tokenIndex = position140, tokenIndex140 - if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l137 - } - position++ - } - l140: - l142: - { - position143, tokenIndex143 := position, tokenIndex - { - position144, tokenIndex144 := position, tokenIndex - if c := buffer[position]; c < rune('a') || c > rune('z') { - goto l145 - } - position++ - goto l144 - l145: - position, tokenIndex = position144, tokenIndex144 - if c := buffer[position]; c < rune('A') || c > rune('Z') { - goto l146 - } - position++ - goto l144 - l146: - position, tokenIndex = position144, tokenIndex144 - if c := buffer[position]; c < rune('0') || c > rune('9') { - goto l147 - } - position++ - goto l144 - l147: - position, tokenIndex = position144, tokenIndex144 - if buffer[position] != rune('_') { - goto l143 - } - position++ - } - l144: - goto l142 - l143: - position, tokenIndex = position143, tokenIndex143 - } - add(rulePegText, position139) - } - { - add(ruleAction19, position) - } - add(rulefield, position138) - } - return true - l137: - position, tokenIndex = position137, tokenIndex137 - return false - }, - /* 12 close <- <(')' sp)> */ - nil, - /* 13 sp <- <(' ' / '\t')*> */ - func() bool { - { - position151 := position - l152: - { - position153, tokenIndex153 := position, tokenIndex - { - position154, tokenIndex154 := position, tokenIndex - if buffer[position] != rune(' ') { - goto l155 - } - position++ - goto l154 - l155: - position, tokenIndex = position154, tokenIndex154 - if buffer[position] != rune('\t') { - goto l153 - } - position++ - } - l154: - goto l152 - l153: - position, tokenIndex = position153, tokenIndex153 - } - add(rulesp, position151) - } - return true - }, - /* 14 comma <- <(sp ',' sp)> */ + /* 12 field <- <(<(([a-z] / [A-Z]) ([a-z] / [A-Z] / [0-9] / '_')*)> Action19)> */ func() bool { position156, tokenIndex156 := position, tokenIndex { position157 := position - if !_rules[rulesp]() { - goto l156 + { + position158 := position + { + position159, tokenIndex159 := position, tokenIndex + if c := buffer[position]; c < rune('a') || c > rune('z') { + goto l160 + } + position++ + goto l159 + l160: + position, tokenIndex = position159, tokenIndex159 + if c := buffer[position]; c < rune('A') || c > rune('Z') { + goto l156 + } + position++ + } + l159: + l161: + { + position162, tokenIndex162 := position, tokenIndex + { + position163, tokenIndex163 := position, tokenIndex + if c := buffer[position]; c < rune('a') || c > rune('z') { + goto l164 + } + position++ + goto l163 + l164: + position, tokenIndex = position163, tokenIndex163 + if c := buffer[position]; c < rune('A') || c > rune('Z') { + goto l165 + } + position++ + goto l163 + l165: + position, tokenIndex = position163, tokenIndex163 + if c := buffer[position]; c < rune('0') || c > rune('9') { + goto l166 + } + position++ + goto l163 + l166: + position, tokenIndex = position163, tokenIndex163 + if buffer[position] != rune('_') { + goto l162 + } + position++ + } + l163: + goto l161 + l162: + position, tokenIndex = position162, tokenIndex162 + } + add(rulePegText, position158) } - if buffer[position] != rune(',') { - goto l156 + { + add(ruleAction19, position) } - position++ - if !_rules[rulesp]() { - goto l156 - } - add(rulecomma, position157) + add(rulefield, position157) } return true l156: position, tokenIndex = position156, tokenIndex156 return false }, - /* 15 lbrack <- <('[' sp)> */ - nil, - /* 16 rbrack <- <(sp ']' sp)> */ - nil, - /* 17 newline <- <(sp '\n' sp)> */ + /* 13 close <- <(')' sp)> */ func() bool { - position160, tokenIndex160 := position, tokenIndex + position168, tokenIndex168 := position, tokenIndex { - position161 := position - if !_rules[rulesp]() { - goto l160 - } - if buffer[position] != rune('\n') { - goto l160 + position169 := position + if buffer[position] != rune(')') { + goto l168 } position++ if !_rules[rulesp]() { - goto l160 + goto l168 } - add(rulenewline, position161) + add(ruleclose, position169) } return true - l160: - position, tokenIndex = position160, tokenIndex160 + l168: + position, tokenIndex = position168, tokenIndex168 return false }, + /* 14 sp <- <(' ' / '\t')*> */ + func() bool { + { + position171 := position + l172: + { + position173, tokenIndex173 := position, tokenIndex + { + position174, tokenIndex174 := position, tokenIndex + if buffer[position] != rune(' ') { + goto l175 + } + position++ + goto l174 + l175: + position, tokenIndex = position174, tokenIndex174 + if buffer[position] != rune('\t') { + goto l173 + } + position++ + } + l174: + goto l172 + l173: + position, tokenIndex = position173, tokenIndex173 + } + add(rulesp, position171) + } + return true + }, + /* 15 comma <- <(sp ',' sp)> */ + func() bool { + position176, tokenIndex176 := position, tokenIndex + { + position177 := position + if !_rules[rulesp]() { + goto l176 + } + if buffer[position] != rune(',') { + goto l176 + } + position++ + if !_rules[rulesp]() { + goto l176 + } + add(rulecomma, position177) + } + return true + l176: + position, tokenIndex = position176, tokenIndex176 + return false + }, + /* 16 lbrack <- <('[' sp)> */ nil, - /* 20 Action0 <- <{ p.startCall(buffer[begin:end] ) }> */ + /* 17 rbrack <- <(sp ']' sp)> */ nil, - /* 21 Action1 <- <{ p.endCall() }> */ + /* 18 whitesp <- <(' ' / '\t' / '\n')*> */ + func() bool { + { + position181 := position + l182: + { + position183, tokenIndex183 := position, tokenIndex + { + position184, tokenIndex184 := position, tokenIndex + if buffer[position] != rune(' ') { + goto l185 + } + position++ + goto l184 + l185: + position, tokenIndex = position184, tokenIndex184 + if buffer[position] != rune('\t') { + goto l186 + } + position++ + goto l184 + l186: + position, tokenIndex = position184, tokenIndex184 + if buffer[position] != rune('\n') { + goto l183 + } + position++ + } + l184: + goto l182 + l183: + position, tokenIndex = position183, tokenIndex183 + } + add(rulewhitesp, position181) + } + return true + }, + /* 19 IDENT <- <(([a-z] / [A-Z]) ([a-z] / [A-Z] / [0-9] / '-' / '_' / '.')*)> */ nil, - /* 22 Action2 <- <{ p.addBTWN() }> */ nil, - /* 23 Action3 <- <{ p.addLTE() }> */ + /* 22 Action0 <- <{ p.startCall(buffer[begin:end] ) }> */ nil, - /* 24 Action4 <- <{ p.addGTE() }> */ + /* 23 Action1 <- <{ p.endCall() }> */ nil, - /* 25 Action5 <- <{ p.addEQ() }> */ + /* 24 Action2 <- <{ p.addBTWN() }> */ nil, - /* 26 Action6 <- <{ p.addNEQ() }> */ + /* 25 Action3 <- <{ p.addLTE() }> */ nil, - /* 27 Action7 <- <{ p.addLT() }> */ + /* 26 Action4 <- <{ p.addGTE() }> */ nil, - /* 28 Action8 <- <{ p.addGT() }> */ + /* 27 Action5 <- <{ p.addEQ() }> */ nil, - /* 29 Action9 <- <{ p.startList() }> */ + /* 28 Action6 <- <{ p.addNEQ() }> */ nil, - /* 30 Action10 <- <{ p.endList() }> */ + /* 29 Action7 <- <{ p.addLT() }> */ nil, - /* 31 Action11 <- <{ p.addVal(nil) }> */ + /* 30 Action8 <- <{ p.addGT() }> */ nil, - /* 32 Action12 <- <{ p.addVal(true) }> */ + /* 31 Action9 <- <{ p.startList() }> */ nil, - /* 33 Action13 <- <{ p.addVal(false) }> */ + /* 32 Action10 <- <{ p.endList() }> */ nil, - /* 34 Action14 <- <{ p.addNumVal(buffer[begin:end]) }> */ + /* 33 Action11 <- <{ p.addVal(nil) }> */ nil, - /* 35 Action15 <- <{ p.addNumVal(buffer[begin:end]) }> */ + /* 34 Action12 <- <{ p.addVal(true) }> */ nil, - /* 36 Action16 <- <{ p.addVal(buffer[begin:end]) }> */ + /* 35 Action13 <- <{ p.addVal(false) }> */ nil, - /* 37 Action17 <- <{ p.addVal(buffer[begin:end]) }> */ + /* 36 Action14 <- <{ p.addNumVal(buffer[begin:end]) }> */ nil, - /* 38 Action18 <- <{ p.addVal(buffer[begin:end]) }> */ + /* 37 Action15 <- <{ p.addNumVal(buffer[begin:end]) }> */ nil, - /* 39 Action19 <- <{ p.addField(buffer[begin:end]) }> */ + /* 38 Action16 <- <{ p.addVal(buffer[begin:end]) }> */ + nil, + /* 39 Action17 <- <{ p.addVal(buffer[begin:end]) }> */ + nil, + /* 40 Action18 <- <{ p.addVal(buffer[begin:end]) }> */ + nil, + /* 41 Action19 <- <{ p.addField(buffer[begin:end]) }> */ nil, } p.rules = _rules diff --git a/pql/pqlpeg_test.go b/pql/pqlpeg_test.go index a38d451d0..2288c3aeb 100644 --- a/pql/pqlpeg_test.go +++ b/pql/pqlpeg_test.go @@ -20,4 +20,27 @@ SetBit(Union(Zitmap(row==4), Intersect(Qitmap(blah>4), Ritmap(field="http://zoo9 if err == nil { t.Fatalf("should have been an error because of the interior unescaped double quote") } + + q, err := ParseString("TopN(Bitmap(id==other), field=f, n=0)") + if err != nil { + t.Fatalf("should have parsed: %v", err) + } + if q.String() != `TopN(Bitmap(id == "other"), field="f", n=0)` { + t.Fatalf("Failed, got: %s", q) + } + + q, err = ParseString("C(a=falsen0)") + if err != nil { + t.Fatalf("falsen0 should have been parsed as a string") + } + + q, err = ParseString("Bitmap(row=4, did==other)") + if err != nil { + t.Fatalf("should have parsed: %v", err) + } + + if q.String() != `Bitmap(did == "other", row=4)` { + t.Fatalf("got %s", q) + } + }