commit - c70734fe8966e035a2b2e1d7d3d543bc552b33a8
commit + 9a479d01b991c04bb98e67b646037baba6394b60
blob - /dev/null
blob + 3a5bd90f68bfd046e33c9c01b38eb55497d04f5b (mode 644)
--- /dev/null
+++ src/parse_query.l
+/*
+ * Copyright © 2018 Sergey Bronnikov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/*
+ * https://github.com/jgarzik/sqlfun/blob/master/sql.l
+ * https://github.com/itechbear/SimpleQueryParser/blob/master/lexer.l
+ * https://github.com/wclever/NdYaccLexTool/tree/master/progs
+ *
+ */
+
+%{
+#include <stdio.h>
+#include "parse_query.tab.h"
+extern int yylval;
+extern void yyerror(char *s);
+%}
+
+%option yylineno
+%option noyywrap
+
+FORMAT "junit"|"testanything"|"subunit_v1"|"subunit_v2"
+FMT "fmt"
+SUITE "suite"
+TEST "test"
+PASSRATE "passrate"
+CREATED "created"
+HOSTNAME "hostname"
+HOST [A-Za-z][A-Za-z0-9\.\-]+
+DIGIT [0-9]
+SYMBOLS [A-Za-z0-9_\-]
+
+%%
+">" return GT;
+"<" return LT;
+"=" return EQ;
+"<=" return LE;
+">=" return GE;
+":" return COLON;
+{FMT}{1} return FMT;
+{SUITE}{1} return SUITE;
+{TEST}{1} return TEST;
+{HOSTNAME}{1} return HOSTNAME;
+{CREATED}{1} return CREATED;
+{PASSRATE}{1} return PASSRATE;
+{FORMAT}{1} return FORMAT;
+{DIGIT}{8} return DATE;
+{DIGIT}+ return NUMBER;
+{HOST}{1} return HOST;
+{SYMBOLS}+ return NAME;
+\n return NL;
+[ \t]+ /* skip whitespace */;
+. { yyerror("Unrecognized character"); }
+
+%%
blob - /dev/null
blob + 14b76966b8e93ea45f68dee3fa72536c324eb772 (mode 644)
--- /dev/null
+++ src/parse_query.y
+/*
+ * Copyright © 2018 Sergey Bronnikov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+%{
+ #include <stdio.h>
+ void yyerror(char *);
+ int yylex(void);
+%}
+
+%token GT LT LE GE EQ COLON NL
+%token FMT SUITE TEST HOSTNAME HOST CREATED PASSRATE
+%token FORMAT DATE NAME NUMBER
+
+/*
+ * https://github.com/jgarzik/sqlfun/blob/master/sql.y
+ * https://github.com/itechbear/SimpleQueryParser/blob/master/parser.y
+ * https://github.com/wclever/NdYaccLexTool/tree/master/progs
+ *
+ */
+
+%%
+
+program : program expression NL
+ | error NL { yyerrok; }
+ |
+ ;
+
+expression : TEST COLON NAME {
+ printf("TEST\n");
+ }
+ | SUITE COLON NAME {
+ printf("SUITE\n");
+ }
+ | FMT COLON FORMAT {
+ printf("FMT\n");
+ }
+ | HOSTNAME COLON HOST {
+ printf("HOSTNAME\n");
+ }
+ | CREATED compare_op DATE {
+ printf("CREATED\n");
+ }
+ | PASSRATE compare_op NUMBER {
+ printf("PASSRATE\n");
+ }
+ ;
+
+compare_op : EQ
+ | GT
+ | LT
+ | LE
+ | GE
+ ;
+%%
+
+#include <ctype.h>
+
+char *progname;
+extern int yylex();
+extern int yyparse();
+extern int yylineno;
+extern FILE *yyin;
+
+void yyerror(char *s)
+{
+ fprintf(stderr, "Warning: %s, line %d\n", s, yylineno);
+}
+
+int main( int argc, char **argv ) {
+
+ progname = argv[0];
+
+ if (argc > 1)
+ {
+ yyin = fopen(argv[1], "r");
+ yylineno = 0;
+ if (!yyin) {
+ printf("Can't open file %s\n", argv[1]);
+ return -1;
+ }
+ }
+
+ yyparse();
+
+ /* close(yyin); */
+ return 0;
+}
blob - /dev/null
blob + c7c2346a1e6087468e37a291121b5111f58ea697 (mode 644)
--- /dev/null
+++ src/t/t1
+fmt:junit
+fmt:testanything
+fmt:subunit_v2
+fmt:subunit_v1
blob - /dev/null
blob + 858c428b9cf087b1df95c71604c1d10222d542c7 (mode 644)
--- /dev/null
+++ src/t/t2
+test:sampletest
+test:sample_test1
+test:1sample_test
blob - /dev/null
blob + 2728221dbec027afd0c117603b0d9afdbe135326 (mode 644)
--- /dev/null
+++ src/t/t3
+suite:samplesuite
+suite:1sample_suite
+suite:sample_suite1
blob - /dev/null
blob + 2d37d34b6f03da6e625392892be9011ca4f150a7 (mode 644)
--- /dev/null
+++ src/t/t4
+passrate = 3
+passrate > 10
+passrate >= 455
+passrate < 99
+passrate <= 100
blob - /dev/null
blob + bc2e8f40cb76d9e0e3998c1fe86d17a7d9e9a272 (mode 644)
--- /dev/null
+++ src/t/t5
+created = 20120101
+created > 20150209
+created < 20150211
+created >= 20150209
+created <= 20150211