OXIESEC PANEL
- Current Dir:
/
/
opt
/
gsutil
/
third_party
/
pyparsing
/
examples
Server IP: 2a02:4780:11:1594:0:ef5:22d7:a
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
12/11/2024 09:39:44 AM
rwxr-xr-x
📄
0README.html
10.75 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
AcManForm.dfm
38.22 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
LAparser.py
20.62 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
Setup.ini
1.41 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
SimpleCalc.py
3.58 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
SingleForm.dfm
42.7 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
TAP.py
7.42 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
__init__.py
0 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
adventureEngine.py
21.59 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
antlr_grammar.py
10.88 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
antlr_grammar_tests.py
2.89 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
apicheck.py
2.2 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
bf.py
4.15 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
bigquery_view_parser.py
62.51 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
booleansearchparser.py
15.26 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
btpyparse.py
4.16 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
builtin_parse_action_demo.py
817 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
cLibHeader.py
853 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
chemical_formulas.py
3.17 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
commasep.py
707 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
configParse.py
2 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
cpp_enum_parser.py
1.35 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
cuneiform_python.py
2.57 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
datetime_parse_actions.py
1.9 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
decaf_parser.py
6.87 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
delta_time.py
21.49 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
dfmparse.py
7.05 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
dhcpd_leases_parser.py
2.98 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
dictExample.py
1.73 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
dictExample2.py
2.1 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
directx_x_file_parser.py
5.54 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
ebnf.py
4.15 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
ebnftest.py
2.35 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
email_address_parser.py
1.18 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
eval_arith.py
6.15 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
excel_expr.py
2.2 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
fourFn.py
10.27 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
gen_ctypes.py
5.28 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
getNTPserversNew.py
1.11 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
greeting.py
518 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
greetingInGreek.py
425 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
greetingInKorean.py
495 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
groupUsingListAllMatches.py
509 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
hola_mundo.py
2.02 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
html_stripper.py
1.68 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
html_table_parser.py
2.16 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
httpServerLogParser.py
3.48 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
idlParse.py
7.53 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
include_preprocessor.py
2.63 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
indentedGrammarExample.py
1022 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
indented_block_example.py
712 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
inv_regex.py
8.08 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
javascript_grammar.g
18.1 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
jsonParser.py
4.7 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
left_recursion.py
1.41 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
lineno_example.py
1.49 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
listAllMatches.py
1.57 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
lua_parser.py
7.96 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
lucene_grammar.py
8.46 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
macro_expander.py
1.77 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
make_diagram.py
1.62 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
matchPreviousDemo.py
586 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
mongodb_query_expression.py
8.46 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
mozilla.ics
752 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
mozillaCalendarParser.py
2.71 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
nested.py
579 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
nested_markup.py
1.85 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
number_words.py
3.77 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
numerics.py
1.34 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
oc.py
4.34 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
one_to_ninety_nine.py
1.88 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
parseTabularData.py
1.68 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
parse_python_value.py
2.5 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
parse_results_sum_example.py
853 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
partial_gene_match.py
2.33 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
pgn.py
3.34 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
position.py
2.17 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
protobuf_parser.py
3.89 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
pythonGrammarParser.py
8.08 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
railroad_diagram_demo.py
1.55 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
range_check.py
2.84 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
readJson.py
120.73 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
removeLineBreaks.py
1.8 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
roman_numerals.py
3.57 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
rosettacode.py
7.43 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
scanExamples.py
2.36 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
searchParserAppDemo.py
962 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
searchparser.py
10.4 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
select_parser.py
8.32 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
sexpParser.py
5.23 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
shapes.py
1.69 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
simpleArith.py
2.42 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
simpleBool.py
3.19 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
simpleSQL.py
3.16 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
simpleWiki.py
1.08 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
snmp_api.h
28.69 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
sql2dot.py
3.07 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
stackish.py
2.71 KB
08/25/2024 02:43:42 PM
rw-r--r--
📁
statemachine
-
08/25/2024 02:43:42 PM
rwxr-xr-x
📄
tag_emitter.py
1.17 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
tag_metadata.py
805 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
test_bibparse.py
8.72 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
unicode_denormalizer.py
5.02 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
urlExtractor.py
1.03 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
urlExtractorNew.py
2.4 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
verilog_parse.py
31.15 KB
08/25/2024 02:43:42 PM
rw-r--r--
📄
withAttribute.py
912 bytes
08/25/2024 02:43:42 PM
rw-r--r--
📄
wordsToNum.py
2.92 KB
08/25/2024 02:43:42 PM
rw-r--r--
Editing: lucene_grammar.py
Close
# # lucene_grammar.py # # Copyright 2011, Paul McGuire # Updated 2023 # # implementation of Lucene grammar, as described # at https://lucene.apache.org/core/2_9_4/queryparsersyntax.html # import pyparsing as pp from pyparsing import pyparsing_common as ppc pp.ParserElement.enable_packrat() COLON, LBRACK, RBRACK, LBRACE, RBRACE, TILDE, CARAT = pp.Literal.using_each(":[]{}~^") LPAR, RPAR = pp.Suppress.using_each("()") and_, or_, not_, to_ = pp.CaselessKeyword.using_each("AND OR NOT TO".split()) keyword = and_ | or_ | not_ | to_ expression = pp.Forward() valid_word = pp.Regex( r'([a-zA-Z0-9_.-]|\\\\|\\([+\-!(){}\[\]^"~*?:]|\|\||&&))' r'([a-zA-Z0-9*_+.-]|\\\\|\\([+\-!(){}\[\]^"~*?:]|\|\||&&)|\*|\?)*' ).setName("word") valid_word.set_parse_action( lambda t: t[0].replace("\\\\", chr(127)).replace("\\", "").replace(chr(127), "\\") ) string = pp.QuotedString('"') required_modifier = pp.Literal("+")("required") prohibit_modifier = pp.Literal("-")("prohibit") integer = ppc.integer() proximity_modifier = pp.Group(TILDE + integer("proximity")) number = ppc.fnumber() fuzzy_modifier = TILDE + pp.Opt(number, default=0.5)("fuzzy") term = pp.Forward().set_name("field") field_name = valid_word().set_name("fieldname") incl_range_search = pp.Group(LBRACK - term("lower") + to_ + term("upper") + RBRACK) excl_range_search = pp.Group(LBRACE - term("lower") + to_ + term("upper") + RBRACE) range_search = incl_range_search("incl_range") | excl_range_search("excl_range") boost = CARAT - number("boost") string_expr = pp.Group(string + proximity_modifier) | string word_expr = pp.Group(valid_word + fuzzy_modifier) | valid_word term <<= ( ~keyword + pp.Opt(field_name("field") + COLON) + (word_expr | string_expr | range_search | pp.Group(LPAR + expression + RPAR)) + pp.Opt(boost) ) term.set_parse_action(lambda t: [t] if "field" in t or "boost" in t else None) expression <<= pp.infixNotation( term, [ (required_modifier | prohibit_modifier, 1, pp.OpAssoc.RIGHT), ((not_ | "!").set_parse_action(lambda: "NOT"), 1, pp.OpAssoc.RIGHT), ((and_ | "&&").set_parse_action(lambda: "AND"), 2, pp.OpAssoc.LEFT), ( pp.Opt(or_ | "||").setName("or").set_parse_action(lambda: "OR"), 2, pp.OpAssoc.LEFT, ), ], ).set_name("query expression") def main(): # test strings taken from grammar description doc, and TestQueryParser.java tests = r""" # Success tests a and b a and not b a and !b a && !b a&&!b name:a name:a and not title:b (a^100 c d f) and !z name:"blah de blah" title:(+return +"pink panther") title:"The Right Way" AND text:go title:"Do it right" AND right title:Do it right te?t test* te*t roam~ roam~0.8 "jakarta apache"~10 mod_date:[20020101 TO 20030101] title:{Aida TO Carmen} jakarta apache jakarta^4 apache "jakarta apache"^4 "Apache Lucene" "jakarta apache" jakarta "jakarta apache" OR jakarta "jakarta apache" AND "Apache Lucene" +jakarta lucene "jakarta apache" NOT "Apache Lucene" "jakarta apache" -"Apache Lucene" (jakarta OR apache) AND website title:(+return +"pink panther") \(1+1\)\:2 c\:\\windows (fieldX:xxxxx OR fieldy:xxxxxxxx)^2 AND (fieldx:the OR fieldy:foo) (fieldX:xxxxx fieldy:xxxxxxxx)^2 AND (fieldx:the fieldy:foo) (fieldX:xxxxx~0.5 fieldy:xxxxxxxx)^2 AND (fieldx:the fieldy:foo) +term -term term foo:term AND field:anotherTerm germ term^2.0 (term)^2.0 (foo OR bar) AND (baz OR boo) +(apple \"steve jobs\") -(foo bar baz) +title:(dog OR cat) -author:\"bob dole\" a AND b +a +b (a AND b) c OR (a AND b) c (+a +b) a AND NOT b +a -b a AND -b a AND !b a && b a && ! b a OR b a b a || b a OR !b a -b a OR ! b a OR -b a - b a + b a ! b +foo:term +anotherterm hello term^2.0 (germ term)^2.0 term^2 +(foo bar) +(baz boo) ((a OR b) AND NOT c) OR d (+(a b) -c) d field a&&b .NET term germ 3 term 1.0 1 2 term term1 term2 term term term term* term*^2 term*^2.0 term~ term~2.0 term~0.7 term~^3 term~2.0^3.0 term*germ term*germ^3 term*germ^3.0 term~1.1 [A TO C] t*erm* term term^3.0 term term stop^3.0 term term +stop term term -stop term drop AND (stop) AND roll +drop +roll term +(stop) term term -(stop) term drop AND stop AND roll term phrase term term (phrase1 phrase2) term term AND NOT phrase term +term -(phrase1 phrase2) term stop^3 stop (stop)^3 ((stop))^3 (stop^3) ((stop)^3) (stop) ((stop)) term +stop [ a TO z] [a TO z] [ a TO z ] { a TO z} {a TO z} { a TO z } { a TO z }^2.0 {a TO z}^2.0 [ a TO z] OR bar [a TO z] bar [ a TO z] AND bar +[a TO z] +bar ( bar blar { a TO z}) bar blar {a TO z} gack ( bar blar { a TO z}) gack (bar blar {a TO z}) [\* TO \*] \!blah \:blah blah \~blah \*blah a a-b:c a+b:c a\:b:c a\\b:c a:b-c a:b+c a:b\:c a:b\\c a:b-c* a:b+c* a:b\:c* a:b\\c* a:b-c~2.0 a:b+c~2.0 a:b\:c~ a:b\\c~ [a- TO a+] [ a\\ TO a\* ] c\:\\temp\\\~foo.txt abc XYZ (item:\\ item:ABCD\\) \* blah*blah blah?blah \\ \|| \&& a\:b\:c a\\b\:c a\:b\\c a\:b\:c\* a\:b\\\\c\* a:b-c~ a:b+c~ a\:b\:c\~ a\:b\\c\~ +weltbank +worlbank +term +term +term term +term term term term +term term +term +term -term term term -term +term +term on on^1.0 hello^2.0 the^3 the some phrase xunit~ one two three A AND B OR C AND D +A +B +C +D foo:zoo* foo:zoo*^2 zoo a:the OR a:foo a:woo OR a:the "the wizard of ozzy" """ failtests = r""" # Failure tests # multiple ':'s in term field:term:with:colon some more terms # multiple '^'s in term (sub query)^5.0^2.0 plus more # cannot start with * or ? *term1 AND term2 ?term3 OR term4 * # unbounded '*' range terms [* TO Z] [* TO z] [A TO *] [a TO *] [* TO *] # unbounded field values foo:* foo:*^2 *:foo *:* (*:*) +*:* -*:* a:b:c a:b:c~ a:b:c* a:b:c~2.0 """ # strings with backslashes still to be tested z = r""" \+blah \-blah foo \|| bar foo \AND bar \a a\-b:c a\+b:c a\b:c a:b\-c a:b\+c a\-b\:c a\+b\:c a:b\c* a:b\-c~ a:b\+c~ a:b\c a:b\-c* a:b\+c* [ a\- TO a\+ ] [a\ TO a*] a\\\+b a\+b c:\temp\~foo.txt XY\ a\u0062c a:b\c~2.0 XY\u005a XY\u005A item:\ item:ABCD\ \ a\ or b a\:b\-c a\:b\+c a\:b\-c\* a\:b\+c\* a\:b\-c\~ a\:b\+c\~ a:b\c~ [ a\ TO a* ] """ success1, _ = expression.runTests(tests) success2, _ = expression.runTests(failtests, failureTests=True) print("\n") print(f"Success tests: {'OK' if success1 else 'FAIL'}") print(f"Fail tests: {'OK' if success2 else 'FAIL'}") print(f"All tests: {'OK' if (success1 and success2) else 'FAIL'}") if not (success1 and success2): import sys sys.exit(1) if __name__ == "__main__": main()