pyparsing v3.0.0.a2 Release Notes

Release Date: 2020-06-01 // almost 4 years ago
    • ๐Ÿ“œ Summary of changes for 3.0.0 can be found in "What's New in Pyparsing 3.0.0" documentation.

    • API CHANGE Changed result returned when parsing using countedArray, the array items are no longer returned in a doubly-nested list.

    • An excellent new enhancement is the new railroad diagram generator for documenting pyparsing parsers:

      import pyparsing as pp
      from pyparsing.diagram import to_railroad, railroad_to_html
      from pathlib import Path
      
      # define a simple grammar for parsing street addresses such
      # as "123 Main Street"
      #     number word...
      number = pp.Word(pp.nums).setName("number")
      name = pp.Word(pp.alphas).setName("word")[1, ...]
      
      parser = number("house_number") + name("street")
      parser.setName("street address")
      
      # construct railroad track diagram for this parser and
      # save as HTML
      rr = to_railroad(parser)
      Path('parser_rr_diag.html').write_text(railroad_to_html(rr))
      

    Very nice work provided by Michael Milton, thanks a ton!

    • โœจ Enhanced default strings created for Word expressions, now showing string ranges if possible. Word(alphas) would formerly print as W:(ABCD...), now prints as W:(A-Za-z).

    • โž• Added ignoreWhitespace(recurse:bool = True) and added a recurse argument to leaveWhitespace, both added to provide finer control over pyparsing's whitespace skipping. Also contributed by Michael Milton.

    • The unicode range definitions for the various languages were recalculated by interrogating the unicodedata module by character name, selecting characters that contained that language in their Unicode name. (Issue #227)

    Also, pyparsing_unicode.Korean was renamed to Hangul (Korean is also defined as a synonym for compatibility).

    • โœจ Enhanced ParseResults dump() to show both results names and list subitems. Fixes bug where adding a results name would hide lower-level structures in the ParseResults.

    • Added new diag warnings:

      "warn_on_parse_using_empty_Forward" - warns that a Forward has been included in a grammar, but no expression was attached to it using '<<=' or '<<'

      "warn_on_assignment_to_Forward" - warns that a Forward has been created, but was probably later overwritten by erroneously using '=' instead of '<<=' (this is a common mistake when using Forwards) (currently not working on PyPy)

    • โž• Added ParserElement.recurse() method to make it simpler for grammar utilities to navigate through the tree of expressions in a pyparsing grammar.

    • ๐Ÿ›  Fixed bug in ParseResults repr() which showed all matching entries for a results name, even if listAllMatches was set to False when creating the ParseResults originally. Reported by Nicholas42 on GitHub, good catch! (Issue #205)

    • ๐Ÿ”จ Modified refactored modules to use relative imports, as pointed out by setuptools project member jaraco, thank you!

    • Off-by-one bug found in the roman_numerals.py example, a bug that has been there for about 14 years! PR submitted by Jay Pedersen, nice catch!

    • ๐Ÿ“œ A simplified Lua parser has been added to the examples (lua_parser.py).

    • โž• Added make_diagram.py to the examples directory to demonstrate creation of railroad diagrams for selected pyparsing examples. Also restructured some examples to make their parsers importable without running their embedded tests.