Is pyparsing really a recursive descent parser?

Just Another Victim of the Ambient Morality ihatespam at hotmail.com
Thu Nov 8 00:15:40 CET 2007


"Chris Mellon" <arkanes at gmail.com> wrote in message 
news:mailman.945.1194471797.13605.python-list at python.org...
> On Nov 7, 2007 3:15 PM, Just Another Victim of the Ambient Morality
> <ihatespam at hotmail.com> wrote:
>
>> > In short, it hasn't really evovled into a user-friendly package
>> > yet.
>>
>>     Thank you.
>>     How is it that I seem to be the only one in the market for a correct
>> parser?  Earley has a runtine of O(n^3) in the worst case and O(n^2)
>> typically.  I have trouble believing that everyone else in the world has
>> such intense run-time requirements that they're willing to forego
>> correctness.  Why can't I find a pyparsing-esque library with this
>> implementation?  I'm tempted to roll my own except that it's a fairly
>> complicated algorithm and I don't really understand how it's any more
>> efficient than the naive approach...
>
> You have an unusual definition of correctness. Many people would say
> that an ambiguous grammar is a bug, not something to support.

    I don't think I do.  Besides, you assume too much...
    First off, we've already established that there are unambiguous grammars 
for which pyparsing will fail to parse.  One might consider that a bug in 
pyparsing...
    Secondly, I get the impression you want to consider ambiguous grammars, 
in some sense, "wrong."  They are not.  Even if they were, if you are 
parsing something for which you are not the creator and that something 
employs an ambiguous grammar, what choice do you have?  Furthermore, given a 
set of possible parsings, you might be able to decide which one you favour 
given the context of what was parsed!  There's a plethora of applications 
for parsing ambiguous grammars yet there are no tools for doing so?


> In fact, I often use pyparsing precisely in order to disambiguate
> (according to specific rules, which are embodied by the parser)
> ambiguous input, like bizarre hand-entered datetime value.

    What do you mean?  How do you use pyparsing to disambiguate:


    01-01-08


    ...? 





More information about the Python-list mailing list