( ( ) ) may be valid Lucene, but it isn't valid as far as infixNotation is concerned. There have to be some operands in the string to be parsed, not just empty grouping ()'s. That is what that ParseException is trying to say. Your definition of term is just the parens around expression, which is unnecessary since infixNotation does this recursive part for you. Plus, you haven't defined just what a valid operand looks like. Reading your comments, a valid query string would look like ( (role:foo) ||...
contributor name spelling
Fixed ages ago
Exceptions when used under heavy load with ratpacking enbabled
Packrat cache has been completely rewritten
packrat caching can not be disabled
Packrat parsing has undergone major rewrite/improvements
Simplify code and support Python 3.5a0
Fixed in 2.2.1 release
Deprecation Warnings using Python 3.7 beta
Released in 2.2.1
https://github.com/pyparsing/pyparsing/pull/16 has been merged and released in https://github.com/pyparsing/pyparsing/releases/tag/pyparsing_2.2.1. This issue can be closed. (If Sourceforge is still active.)
Packrat is already enabled: https://github.com/mozilla/moz-sql-parser/blob/dev/moz_sql_parser/sql_parser.py#L19 I suspect the number of KNOWN_OPS passed to infixNotation https://github.com/mozilla/moz-sql-parser/blob/dev/moz_sql_parser/sql_parser.py#L275 is too great for the given sys.setrecursionlimit(1500). Increasing the recursion limit solves the problem for simple cases, but real life expressions can quite a bit longer. infixNotation is a piece of elgant code, but creates a parser that runs...
I just spotted the project has moved to GitHub, here's a PR: https://github.com/pyparsing/pyparsing/pull/16 (It might be useful to add a notice about the move on https://sourceforge.net/projects/pyparsing/.)
Looks like this has been included in the 2.2.0 release. Can this be closed? Thanks!
I'm running into this in Pillow tests which depend on Pyroma which depend on Setuptools which vendors Pyparsing. Something like the attached should fix it. (Sorry, I'm not sure how to submit a PR/patch through Sourceforge/SVN.)
If you have a sub-expression that is being repeatedly matched, try enabling packrat parsing: https://pythonhosted.org/pyparsing/pyparsing.ParserElement-class.html#enablePackrat
infixNotation() might be made better
nestedExpr is splitting on QuotedString by default
FWIW this affects setuptools' pkg_resources module as well: https://github.com/pypa/setuptools/issues/1401
Bug Using ZeroOrMore and And
Fixed October, 2016 in 2.1.10 release
ParseResults.pop() - NameError: global name 'index' is not defined
traceParseAction() AttributeError: no attribute 'func_name'
Wrong column number of error reported in certain cases
cols behavior was fixed in 2.1.10
It's a bug! Here is the fixed code, to be released in 2.2.1: select_core = (SELECT + Optional(DISTINCT | ALL) + Group(delimitedList(result_column))("columns") + Optional(FROM + join_source("from*")) + Optional(WHERE + expr("where_expr")) + Optional(GROUP + BY + Group(delimitedList(ordering_term))("group_by_terms") + Optional(HAVING + expr("having_expr"))))
weird Or expression behavior
thank you Paul for your very detailed answer!
Deprecation Warnings using Python 3.7 beta
nestedExpr is provided in pyparsing as a shortcut for more complex expressions that support nesting on opening and closing grouping strings. But as a shortcut, it does not really do much meaningful with the contents within the groups. So the question is, what should nestedExpr make of the strings that are inside the nested groups? By default, nestedExpr will look for space-delimited words of printables, so that (a b c (dd ee) ff) will parse into ['a', 'b', 'c', ['dd', 'ee'], 'ff'] (if you call asList()...
Pyparsing tries to be helpful when creating expressions with lists, to intuit what the developer's intent is. When passing a list of strings to Or (or And, Each, or any other ParseExpression subclass), it will automatically convert them to a list of Literals. This is similar to the auto-conversion to Literal when adding a string to an expression, as in something like negative_int = Combine('-' + Word(nums)) Pyparsing will auto-convert the '-' string to a Literal, and then use the '+' to create an...
weird Or expression behavior
I think this should be fixed but if there is other way around, please tell.
nestedExpr is splitting on QuotedString by default
Deprecation Warnings using Python 3.7 beta
+ matches invalid token
If you want to completely disable whitespace skipping, use ParserElement.setDefaultWhitespaceChars("") right after importing pyparsing. But whitespace skipping is a basic feature (no air quotes necessary) of pyparsing, and helps avoid having to sprinkle \s* all over your regexes. Closing this as "works as designed".
Okay, I've now determined this is down to how pyparsing behaves… it defaults to matching (and discarding) proceeding whitespace. The fix to this was somewhat ugly, but in essence, I had to wrap each pyparsing object with a wrapper that would call leaveWhitespace before returning it. Since it's nearly impossible to know where this is being applied, I've resorted to doing it on all pyparsing objects I use so I don't get caught out. The result is visually messy, but works. I think this "feature" could...
+ matches invalid token
High thread stack causes segfault on Alpine linux
Ah, I could have sworn I installed the newest version when I reinstalled my Anaconda suite! I'll reinstall and retry it, thanks! And as many have said, great module and support!
Good catch on the missing ')' though, thanks!
You are using an old version of pyparsing - this was fixed in version 2.1.4, released in May, 2016.
traceParseAction() AttributeError: no attribute 'func_name'
zeroOrMore in Each with setResultsName
We have been using pyparsing for a generic config file parser for some time now. The inner blocks of the config parser look something like this: { key1 = [ value1.1, value1.2, value1.3 ]; key2 = [ value2.1, value2.2, value2.3 ]; } Using dictOf and delimitedList, we end up with the equivalent of a dictionary mapping keys (key1 and key2) to the corresponding list of value tokens. Recently, I was hoping to extend the parser to support: { key1 = [ value1.1, value1.2, value1.3 ]; key1 += [ value1.4, value1.5...
No native support for unicode printables
this is my idea https://github.com/aleivag/pyparsing/pull/1/commits/6e3e704f46ef2b7b0126380c8d0957a5188a087d
I think this is a bug, but it may be intended behaivure, just dont seems right o me (by the way love pyparsing!!!). concider opt1 and opt2, defined as follow: from pyparsing import Literal, pyparsing_common ipv6 = (Literal('[') + pyparsing_common.ipv6_address + Literal(']')) ipv4 = pyparsing_common.ipv4_address opt1 = ipv6.setResultsName('ip') opt2 = (ipv4 | ipv6).setResultsName('ip') print(opt1.parseString('[::1]').get('ip')) print(opt2.parseString('[::1]').get('ip')) Both cases should print the...
I think this is a bug, but it may be intended behaivure, just dont seems right o me (by the way love pyparsing!!!). concider opt1 and opt2, defined as follow: from pyparsing import Literal, pyparsing_common ipv6 = (Literal('[') + pyparsing_common.ipv6_address + Literal(']')) ipv4 = pyparsing_common.ipv4_address opt1 = ipv6.setResultsName('ip') opt2 = (ipv4 | ipv6).setResultsName('ip') print(opt1.parseString('[::1]').get('ip')) print(opt2.parseString('[::1]').get('ip')) Both cases should print the...
Update oc.py example: fix regex for '==' operator, add packrat parsing and function call as expression operand
Update oc.py example: fix regex for '==' operator, add packrat parsing and function call as expression operand
Thank you, Paul! The first solution works nice, while in the second I had to leave...
It looks like you are on Python 2, the unicode handling in Python 3 is much better....
I need to perform simple text parsing and everything works fine except printing the...
FYI I first reported this issue to pip, but they asked to report it to pyparsing...
Simplify code and support Python 3.5a0
Hi, First of all, thanks a lot for creating pyparsing! :) Made the parsing part of...
Tag for 2.2.0 release
Add minor enht for infixNotation, to accept a s...
Allow installing without setuptools
Thanks, this will be included in 2.2.0, coming out shortly
Python 3.6 invalid escape sequence deprecation fixes
Will be included in version 2.2.0, coming out soon
Prep for 2.2.0 release
Fix error and expand docstring examples for Par...
Fix deprecated use of '\' as described in https...
Fix deprecated use of '\' as described in https...
Updated setup.py to address recursive import pr...
Minor change when using '-' operator, to be com...
Fix KeyError when packrat cache gets updated re...
Thanks! I have a busy weekend with family business, but I have a pyparsing 2.2.0...
Python 3.6 invalid escape sequence deprecation fixes
Thanks for submitting this! I will try to push out a 2.2.0 version this weekend that...
Allow installing without setuptools
Yes it is possible to define an adaptive parser, that, in an expression "A B" modifies...
Maybe an example of a varInt: f3 08 would break down to x*128 + 115 (=0xf3 & 0x7f)....
Complicated parse rule. Is this possible at all?
Tag for 2.1.10 release
Add 2.1.10 release date to CHANGES
Fix docstring formatting for epydoc compatibility