summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@users.noreply.github.com>2020-06-06 16:14:01 -0500
committerPaul McGuire <ptmcg@users.noreply.github.com>2020-06-06 16:14:01 -0500
commit2a4938131618a4599468041f194a2f288f4c35e4 (patch)
treeee45a9ec5e93355db821cbfc6be3a8124236e615
parent22940c8f44162641ff4000a463f99134a28a9a5a (diff)
downloadpyparsing-git-2a4938131618a4599468041f194a2f288f4c35e4.tar.gz
Add CHANGES blurb for new railroad-diagram parser documentation feature
-rw-r--r--CHANGES23
1 files changed, 23 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index feac25b..36691e8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -71,6 +71,29 @@ Version 3.0.0a2
the array items are no long 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!
+
- 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