This is a great update! I found your PEG Explorer tool to be very interesting, as I have wondered exactly whether it was possible to detect possible out-of-order terms in ordered choice clauses, due to unintentional prefix matches.
http://mousepeg.sourceforge.net/explorer.htm I have added an operator `Longest` to my parser, which works like `First`, except that it tries matching all options, and then returns the longest of all matches. This makes sense to me as a useful extension to PEG, particularly for a parser that is able to expand left recursive matches, since the stopping criterion for most left recursion handling algorithms is triggered when a longer match cannot be found for grammar clauses in the cycle. It is actually much easier to write rules for PEG if you don't have to worry about the prefix problem (i.e. the subclause ordering problem), for subclauses of an "ordered choice" operator -- and in fact, there are conceivably cases where there is no correct ordering for all strings you want the parser to match. Generally picking the longest match out of a set of options also matches the grammar-writer's intent. Therefore from a practical point of view, I think the `Longest` operator is a good addition to PEG. I am curious though whether you think that the addition of the `Longest` operator would bring the language matched by this new rule system (let's call it "PEG+") closer to EBNF, based on what you wrote on the above-linked page? (I appreciate you raising the issue of E→E+E|n in your paper, since it became an interesting testcase for my own parser, and it turns out this gets expanded into a right-associative tree in most parsers that can handle left recursion. This made no intuitive sense to me; however, this appears to actually be correct (despite the claims to the contrary in Tratt 2010), since non-left-recursive recursive descent parsing also recurses as far as possible down the "left edge" of the recursion tree, then expands outwards to the right before returning from each recursion frame.) On Tue, May 11, 2021 at 8:01 AM Roman Redz <ro...@redz.se> wrote: > An improved version of my paper on left recursion in "Mouse" (not > accepted yet by Fundamenta Informaticae) is found here: > http://www.romanredz.se/papers/FI2020.pdf . > > Version 2.3 of "Mouse" (found at > https://sourceforge.net/projects/mousepeg, project page > http://mousepeg.sourceforge.net) > introduced a new operation that helps the PEG Explorer to distinguish > between identifiers and keywords. > > Regards > Roman > > > _______________________________________________ > PEG mailing list > PEG@lists.csail.mit.edu > https://lists.csail.mit.edu/mailman/listinfo/peg >
_______________________________________________ PEG mailing list PEG@lists.csail.mit.edu https://lists.csail.mit.edu/mailman/listinfo/peg