diff options
author | ptmcg <ptmcg@austin.rr.com> | 2020-06-27 08:26:16 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2020-06-27 08:26:16 -0500 |
commit | 20dfaac6b80ad42851d82f9d2be376e098f0a5ba (patch) | |
tree | 2cf9ef8ceee535a069a05399575ef763b2a6e066 /examples/lucene_grammar.py | |
parent | b3edef08a38b45c3a5fe74968e3589996761660c (diff) | |
download | pyparsing-git-20dfaac6b80ad42851d82f9d2be376e098f0a5ba.tar.gz |
Add make_diagram.py to examples to demonstrate creating railroad diags for selected examples
Diffstat (limited to 'examples/lucene_grammar.py')
-rw-r--r-- | examples/lucene_grammar.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/lucene_grammar.py b/examples/lucene_grammar.py index ee4633c..39b9eb8 100644 --- a/examples/lucene_grammar.py +++ b/examples/lucene_grammar.py @@ -35,7 +35,7 @@ proximity_modifier = pp.Group(TILDE + integer("proximity")) number = ppc.fnumber() fuzzy_modifier = TILDE + pp.Optional(number, default=0.5)("fuzzy") -term = pp.Forward() +term = pp.Forward().setName("field") field_name = valid_word().setName("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) @@ -57,7 +57,11 @@ expression << pp.infixNotation( (required_modifier | prohibit_modifier, 1, pp.opAssoc.RIGHT), ((not_ | "!").setParseAction(lambda: "NOT"), 1, pp.opAssoc.RIGHT), ((and_ | "&&").setParseAction(lambda: "AND"), 2, pp.opAssoc.LEFT), - (pp.Optional(or_ | "||").setParseAction(lambda: "OR"), 2, pp.opAssoc.LEFT), + ( + pp.Optional(or_ | "||").setName("or").setParseAction(lambda: "OR"), + 2, + pp.opAssoc.LEFT, + ), ], ) |