Debian Codegraph @

CHANGES

raw
1 ==========
2 Change Log
3 ==========
4
5 RELEASE PLANNING NOTES:
6
7 In the pyparsing release 3.3.0, use of many of the pre-PEP8 methods (such as
8 `ParserElement.parseString`) will start to raise `DeprecationWarnings`. I plan to
9 completely drop the pre-PEP8 methods in pyparsing 4.0, though we won't see that release
10 until some time later in 2026. So there is plenty of time to convert existing parsers to
11 the new function names before the legacy functions are completely removed.
12
13 Required Python versions by pyparsing version
14 ---------------------------------------------
15
16 +--------------------------------------------------+-------------------+
17 | pyparsing version | Required Python |
18 +==================================================+===================+
19 | 3.3.0 and later | 3.9 or later |
20 | 3.2.0 - 3.2.4 | 3.9 or later |
21 | 3.0.8 - 3.1.4 | 3.6.8 or later |
22 | 3.0.0 - 3.0.7 (these versions are discouraged) | 3.6 or later |
23 | 2.4.7 | 2.7 or later |
24 | 1.5.7 | 2.6 - 2.7 |
25 +--------------------------------------------------+-------------------+
26
27
28 Version 3.3.2 - January, 2026
29 -----------------------------
30 - Defined pyparsing-specific warning classes so that they can be selectively enabled
31 or disabled without affecting warnings raised by other libraries in the same Python
32 app:
33 - `PyparsingWarning` - base warning for all pyparsing-specific warnings (inherits
34 from `UserWarning`)
35 - `PyparsingDeprecationWarning` - warning for using deprecated features (inherits
36 from `PyparsingWarning` and `DeprecationWarning`)
37 - `PyparsingDiagnosticWarning` - warning raised when pyparsing diagnostics are
38 enabled and a diagnostic feature is used (inherits from `PyparsingWarning`)
39
40 - Added `as_datetime` parse action to `pyparsing.common` - a more generalized
41 version of the `convert_to_datetime` parse action (supports any expression that extracts
42 date/time fields into "year", "month", "day", etc. results names), and validates
43 that the parsed fields represent a valid date and time.
44
45 - Added `iso8601_date_validated` and `iso8601_datetime_validated` expressions to
46 `pyparsing.common`, which return a Python `datetime.datetime`
47
48 - Various performance improvements in `ParseResults` class and core functions, with
49 10-20% performance overall.
50
51 - Added `regex_inverter` web page (using PyScript) to demonstrate using the `inv_regex.py`
52 example.
53
54 - Expanded regex forms handled by the `examples/inv_regex.py` example:
55 - named capturing groups (`?P<name>`)
56 - partial repetition (`{m,}` and `{,n}`)
57 - negated character classes (`[^...]`)
58
59 - Added `SPy` (Simplified Python) parser to examples.
60
61
62 Version 3.3.1 - December, 2025
63 ------------------------------
64 - Added license info to metadata, following PEP-639. Thanks to Gedalia Pasternak and
65 Marc Mueller for submitted issue and PR. Fixes #626.
66
67
68 Version 3.3.0 - December, 2025
69 ------------------------------
70 ===========================================================================================
71 The version 3.3.0 release will begin emitting `DeprecationWarnings` for pyparsing methods
72 that have been renamed to PEP8-compliant names (introduced in pyparsing 3.0.0, in August,
73 2021, with legacy names retained as aliases). In preparation, I added in pyparsing
74 3.2.2 a utility for finding and replacing the legacy method names with the new names.
75 This utility is located at `pyparsing/tools/cvt_pep8_names.py`. This script will scan all
76 Python files specified on the command line, and if the `-u` option is selected, will
77 replace all occurrences of the old method names with the new PEP8-compliant names,
78 updating the files in place.
79
80 Here is an example that converts all the files in the pyparsing `/examples` directory:
81
82 python -m pyparsing.tools.cvt_pyparsing_pep8_names -u examples/*.py
83
84 The new names are compatible with pyparsing versions 3.0.0 and later.
85 ===========================================================================================
86
87 - Deprecated `indentedBlock`, when converted using the `cvt_pyparsing_pep8_names`
88 utility, will emit `UserWarnings` that additional code changes will be required.
89 This is because the new `IndentedBlock` class no longer requires the calling code
90 to supply an indent stack, while adding support for nested indentation levels
91 and grouping.
92
93 - Deprecated `locatedExpr`, when converted using the `cvt_pyparsing_pep8_names`
94 utility, will emit `UserWarnings` that additional code changes may be required.
95 The new `Located` class removes the extra grouping level of the parsed values.
96 (If the original `locatedExpr` parser was defined with a results name, then
97 the extra grouping is retained, so that the results name nesting works properly;
98 in this case, no code changes would be required.)
99
100 - Updated all examples and test cases to use PEP8 names (unless the test case is specifically
101 designed to test behavior of a legacy method). Added railroad diagrams for some examples.
102
103 - Added exception handling when calling `formatted_message()`, so that `str(exception)`
104 always returns at least _something_.
105
106 - All unit tests pass with Python 3.14, including 3.14t. This does _not_ necessarily
107 mean that pyparsing is now thread-safe, just that when run in the free-threaded
108 interpreter, there were no errors. None of the unit tests try to do any parsing
109 with multiple threads - they test the basic functionality of the library, under various
110 versions of packrat and left-recursive parsing.
111
112 - Added AI instructions so that AI agents can be prompted with best practices
113 for generating parsers using pyparsing code. These instructions are in the
114 `ai/best_practices.md` file, and can be accessed programmatically by calling
115 `pyparsing.show_best_practices()` or running `python -m pyparsing.ai.show_best_practices`
116 from the command line, after installing the `pyparsing` package.
117
118 - Implemented a TINY language parser/interpreter using pyparsing, in the `examples/tiny`
119 directory. This is a little tutorial language that I used to demonstrate how to use pyparsing to
120 build a simple interpreter, following a recommended parser+AST+engine+run structure.
121 The `docs` sub-directory also includes transcripts of the AI session used to create the
122 parser and the interpreter. The `samples` sub-directory includes a few sample TINY programs.
123
124 - Fixed minor formatting bugs in `pyparsing.testing.with_line_numbers`, found during development
125 of the TINY language example.
126
127 - Added test in `DelimitedList` and `nested_expr` which auto-suppress delimiting commas to
128 avoid wrapping in a `Suppress` if delimiter is already a `Suppress`.
129
130 - Added performance benchmarking tools and documentation:
131 - `tests/perf_pyparsing.py` runs a series of benchmark parsing tests, exercising different
132 aspects of the pyparsing package. For cross-version analysis, this script can export
133 results as CSV and append to a consolidated data file.
134 - Runner scripts `run_perf_all_tags.bat` (Windows) and `run_perf_all_tags.sh` (Ubuntu/bash)
135 execute the benchmark across multiple Python versions (3.9–3.14) and pyparsing versions
136 (3.1.1 through 3.3.0), aggregating results into `perf_pyparsing.csv` at the repo root.
137 - See `tests/README.md` for usage instructions.
138
139 - Used performance benchmarking to identify and revert an inefficient utility method used in
140 `transform_string` (introduced in pyparsing 3.2.0b2).
141
142
143 Version 3.2.5 - September, 2025
144 -------------------------------
145 - JINX! Well, 3.2.4 had a bug for `Word` expressions that include a space
146 character, if that expression was then copied, either directly with .copy() or
147 by adding a results name, or included in another construct (like `DelimitedList`)
148 that makes a copy internally. Issue #618, reported by mstinberg, among others -
149 thanks, and sorry for the inconvenience.
150
151
152 Version 3.2.4 - September, 2025
153 -------------------------------
154 - Barring any catastrophic bugs in this release, this will be the last release in
155 the 3.2.x line. The next release, 3.3.0, will begin emitting `DeprecationWarnings`
156 when the pre-PEP8 methods are used (see header notes above for more information,
157 including available automation for converting any existing code using
158 pyparsing with the old names).
159
160 - Fixed bug when using a copy of a `Word` expression (either by using the explicit
161 `copy()` method, or attaching a results name), and setting a new expression name,
162 a raised `ParseException` still used the original expression name. Also affected
163 `Regex` expressions with `as_match` or `as_group_list` = True. Reported by
164 Waqas Ilyas, in Issue #612 - good catch!
165
166 - Fixed type annotation for `replace_with`, to accept `Any` type. Fixes Issue #602,
167 reported by esquonk.
168
169 - Added locking around potential race condition in `ParserElement.reset_cache`, as
170 well as other cache-related methods. Fixes Issue #604, reported by CarlosDescalziIM.
171
172 - Substantial update to docstrings and doc generation in preparation for 3.3.0,
173 great effort by FeRD, thanks!
174
175 - Notable addition by FeRD to convert docstring examples to work with doctest! This
176 was long overdue, thanks so much!
177
178
179 Version 3.2.3 - March, 2025
180 ---------------------------
181 - Fixed bug released in 3.2.2 in which `nested_expr` could overwrite parse actions
182 for defined content, and could truncate list of items within a nested list.
183 Fixes Issue #600, reported by hoxbro and luisglft, with helpful diag logs and
184 repro code.
185
186
187 Version 3.2.2 - March, 2025
188 ---------------------------
189 - Released `cvt_pyparsing_pep8_names.py` conversion utility to upgrade pyparsing-based
190 programs and libraries that use legacy camelCase names to use the new PEP8-compliant
191 snake_case method names. The converter can also be imported into other scripts as
192
193 from pyparsing.tools.cvt_pyparsing_pep8_names import pep8_converter
194
195 - Fixed bug in `nested_expr` where nested contents were stripped of whitespace when
196 the default whitespace characters were cleared (raised in this StackOverflow
197 question https://stackoverflow.com/questions/79327649 by Ben Alan). Also addressed
198 bug in resolving PEP8 compliant argument name and legacy argument name.
199
200 - Fixed bug in `rest_of_line` and the underlying `Regex` class, in which matching a
201 pattern that could match an empty string (such as `".*"` or `"[A-Z]*"` would not raise
202 a `ParseException` at or beyond the end of the input string. This could cause an
203 infinite parsing loop when parsing `rest_of_line` at the end of the input string.
204 Reported by user Kylotan, thanks! (Issue #593)
205
206 - Enhancements and extra input validation for `pyparsing.util.make_compressed_re` - see
207 usage in `examples/complex_chemical_formulas.py` and result in the generated railroad
208 diagram `examples/complex_chemical_formulas_diagram.html`. Properly escapes characters
209 like "." and "*" that have special meaning in regular expressions.
210
211 - Fixed bug in `one_of()` to properly escape characters that are regular expression markers
212 (such as '*', '+', '?', etc.) before building the internal regex.
213
214 - Better exception message for `MatchFirst` and `Or` expressions, showing all alternatives
215 rather than just the first one. Fixes Issue #592, reported by Focke, thanks!
216
217 - Added return type annotation of "-> None" for all `__init__()` methods, to satisfy
218 `mypy --strict` type checking. PR submitted by FeRD, thank you!
219
220 - Added optional argument `show_hidden` to `create_diagram` to show
221 elements that are used internally by pyparsing, but are not part of the actual
222 parser grammar. For instance, the `Tag` class can insert values into the parsed
223 results but it does not actually parse any input, so by default it is not included
224 in a railroad diagram. By calling `create_diagram` with `show_hidden = True`,
225 these internal elements will be included. (You can see this in the tag_metadata.py
226 script in the examples directory.)
227
228 - Fixed bug in `number_words.py` example. Also added `ebnf_number_words.py` to demonstrate
229 using the `ebnf.py` EBNF parser generator to build a similar parser directly from
230 EBNF.
231
232 - Fixed syntax warning raised in `bigquery_view_parser.py`, invalid escape sequence "\s".
233 Reported by sameer-google, nice catch! (Issue #598)
234
235 - Added support for Python 3.14.
236
237
238 Version 3.2.1 - December, 2024
239 ------------------------------
240 - Updated generated railroad diagrams to make non-terminal elements links to their related
241 sub-diagrams. This _greatly_ improves navigation of the diagram, especially for
242 large, complex parsers.
243
244 - Simplified railroad diagrams emitted for parsers using `infix_notation`, by hiding
245 lookahead terms. Renamed internally generated expressions for clarity, and improved
246 diagramming.
247
248 - Improved performance of `cpp_style_comment`, `c_style_comment`, `common.fnumber`
249 and `common.ieee_float` `Regex` expressions. PRs submitted by Gabriel Gerlero,
250 nice work, thanks!
251
252 - Add missing type annotations to `match_only_at_col`, `replace_with`, `remove_quotes`,
253 `with_attribute`, and `with_class`. Issue #585 reported by rafrafrek.
254
255 - Added generated diagrams for many of the examples.
256
257 - Replaced old `examples/0README.html` file with `examples/README.md` file.
258
259
260 Version 3.2.0 - October, 2024
261 -------------------------------
262 - Discontinued support for Python 3.6, 3.7, and 3.8. Adopted new Python features from
263 Python versions 3.7-3.9:
264 - Updated type annotations to use built-in container types instead of names
265 imported from the `typing` module (e.g., `list[str]` vs `List[str]`).
266 - Reworked portions of the packrat cache to leverage insertion-preserving ordering
267 in dicts (including removal of uses of `OrderedDict`).
268 - Changed `pdb.set_trace()` call in `ParserElement.set_break()` to `breakpoint()`.
269 - Converted `typing.NamedTuple` to `dataclasses.dataclass` in railroad diagramming
270 code.
271 - Added `from __future__ import annotations` to clean up some type annotations.
272 (with assistance from ISyncWithFoo, issue #535, thanks for the help!)
273
274 - POSSIBLE BREAKING CHANGES
275
276 The following bugfixes may result in subtle changes in the results returned or
277 exceptions raised by pyparsing.
278
279 - Fixed code in `ParseElementEnhance` subclasses that
280 replaced detailed exception messages raised in contained expressions with a
281 less-specific and less-informative generic exception message and location.
282
283 If your code has conditional logic based on the message content in raised
284 `ParseExceptions`, this bugfix may require changes in your code.
285
286 - Fixed bug in `transform_string()` where whitespace
287 in the input string was not properly preserved in the output string.
288
289 If your code uses `transform_string`, this bugfix may require changes in
290 your code.
291
292 - Fixed bug where an `IndexError` raised in a parse action was
293 incorrectly handled as an `IndexError` raised as part of the `ParserElement`
294 parsing methods, and reraised as a `ParseException`. Now an `IndexError`
295 that raises inside a parse action will properly propagate out as an `IndexError`.
296 (Issue #573, reported by August Karlstedt, thanks!)
297
298 If your code raises `IndexError`s in parse actions, this bugfix may require
299 changes in your code.
300
301 - FIXES AND NEW FEATURES
302
303 - Added type annotations to remainder of `pyparsing` package, and added `mypy`
304 run to `tox.ini`, so that type annotations are now run as part of pyparsing's CI.
305 Addresses Issue #373, raised by Iwan Aucamp, thanks!
306
307 - Exception message format can now be customized, by overriding
308 `ParseBaseException.format_message`:
309
310 def custom_exception_message(exc) -> str:
311 found_phrase = f", found {exc.found}" if exc.found else ""
312 return f"{exc.lineno}:{exc.column} {exc.msg}{found_phrase}"
313
314 ParseBaseException.formatted_message = custom_exception_message
315
316 (PR #571 submitted by Odysseyas Krystalakos, nice work!)
317
318 - `run_tests` now detects if an exception is raised in a parse action, and will
319 report it with an enhanced error message, with the exception type, string,
320 and parse action name.
321
322 - `QuotedString` now handles translation of escaped integer, hex, octal, and
323 Unicode sequences to their corresponding characters.
324
325 - Fixed the displayed output of `Regex` terms to deduplicate repeated backslashes,
326 for easier reading in debugging, printing, and railroad diagrams.
327
328 - Fixed (or at least reduced) elusive bug when generating railroad diagrams,
329 where some diagram elements were just empty blocks. Fix submitted by RoDuth,
330 thanks a ton!
331
332 - Fixed railroad diagrams that get generated with a parser containing a `Regex` element
333 defined using a verbose pattern - the pattern gets flattened and comments removed
334 before creating the corresponding diagram element.
335
336 - Defined a more performant regular expression used internally by `common_html_entity`.
337
338 - `Regex` instances can now be created using a callable that takes no arguments
339 and just returns a string or a compiled regular expression, so that creating complex
340 regular expression patterns can be deferred until they are actually used for the first
341 time in the parser.
342
343 - Added optional `flatten` Boolean argument to `ParseResults.as_list()`, to
344 return the parsed values in a flattened list.
345
346 - Added `indent` and `base_1` arguments to `pyparsing.testing.with_line_numbers`. When
347 using `with_line_numbers` inside a parse action, set `base_1`=False, since the
348 reported `loc` value is 0-based. `indent` can be a leading string (typically of
349 spaces or tabs) to indent the numbered string passed to `with_line_numbers`.
350 Added while working on #557, reported by Bernd Wechner.
351
352 - NEW/ENHANCED EXAMPLES
353
354 - Added query syntax to `mongodb_query_expression.py` with:
355 - better support for array fields ("contains all",
356 "contains any", and "contains none")
357 - "like" and "not like" operators to support SQL "%" wildcard matching
358 and "=~" operator to support regex matching
359 - text search using "search for"
360 - dates and datetimes as query values
361 - `a[0]` style array referencing
362
363 - Added `lox_parser.py` example, a parser for the Lox language used as a tutorial in
364 Robert Nystrom's "Crafting Interpreters" (http://craftinginterpreters.com/).
365 With helpful corrections from RoDuth.
366
367 - Added `complex_chemical_formulas.py` example, to add parsing capability for
368 formulas such as "3(C₆H₅OH)₂".
369
370 - Updated `tag_emitter.py` to use new `Tag` class, introduced in pyparsing
371 3.1.3.
372
373
374 Version 3.1.4 - August, 2024
375 ----------------------------
376 - Fixed a regression introduced in pyparsing 3.1.3, addition of a type annotation that
377 referenced `re.Pattern`. Since this type was introduced in Python 3.7, using this type
378 definition broke Python 3.6 installs of pyparsing 3.1.3. PR submitted by Felix Fontein,
379 nice work!
380
381
382 Version 3.1.3 - August, 2024
383 ----------------------------
384 - Added new `Tag` ParserElement, for inserting metadata into the parsed results.
385 This allows a parser to add metadata or annotations to the parsed tokens.
386 The `Tag` element also accepts an optional `value` parameter, defaulting to `True`.
387 See the new `tag_metadata.py` example in the `examples` directory.
388
389 Example:
390
391 # add tag indicating mood
392 end_punc = "." | ("!" + Tag("enthusiastic"))
393 greeting = "Hello" + Word(alphas) + end_punc
394
395 result = greeting.parse_string("Hello World.")
396 print(result.dump())
397
398 result = greeting.parse_string("Hello World!")
399 print(result.dump())
400
401 prints:
402
403 ['Hello', 'World', '.']
404
405 ['Hello', 'World', '!']
406 - enthusiastic: True
407
408 - Added example `mongodb_query_expression.py`, to convert human-readable infix query
409 expressions (such as `a==100 and b>=200`) and transform them into the equivalent
410 query argument for the pymongo package (`{'$and': [{'a': 100}, {'b': {'$gte': 200}}]}`).
411 Supports many equality and inequality operators - see the docstring for the
412 `transform_query` function for more examples.
413
414 - Fixed issue where PEP8 compatibility names for `ParserElement` static methods were
415 not themselves defined as `staticmethods`. When called using a `ParserElement` instance,
416 this resulted in a `TypeError` exception. Reported by eylenburg (#548).
417
418 - To address a compatibility issue in RDFLib, added a property setter for the
419 `ParserElement.name` property, to call `ParserElement.set_name`.
420
421 - Modified `ParserElement.set_name()` to accept a None value, to clear the defined
422 name and corresponding error message for a `ParserElement`.
423
424 - Updated railroad diagram generation for `ZeroOrMore` and `OneOrMore` expressions with
425 `stop_on` expressions, while investigating #558, reported by user Gu_f.
426
427 - Added `<META>` tag to HTML generated for railroad diagrams to force UTF-8 encoding
428 with older browsers, to better display Unicode parser characters.
429
430 - Fixed some cosmetics/bugs in railroad diagrams:
431 - fixed groups being shown even when `show_groups`=False
432 - show results names as quoted strings when `show_results_names`=True
433 - only use integer loop counter if repetition > 2
434
435 - Some type annotations added for parse action related methods, thanks August
436 Karlstedt (#551).
437
438 - Added exception type to `trace_parse_action` exception output, while investigating
439 SO question posted by medihack.
440
441 - Added `set_name` calls to internal expressions generated in `infix_notation`, for
442 improved railroad diagramming.
443
444 - `delta_time`, `lua_parser`, `decaf_parser`, and `roman_numerals` examples cleaned up
445 to use latest PEP8 names and add minor enhancements.
446
447 - Fixed bug (and corresponding test code) in `delta_time` example that did not handle
448 weekday references in time expressions (like "Monday at 4pm") when the weekday was
449 the same as the current weekday.
450
451 - Minor performance speedup in `trim_arity`, to benefit any parsers using parse actions.
452
453 - Added early testing support for Python 3.13 with JIT enabled.
454
455
456 Version 3.1.2 - March, 2024
457 ---------------------------
458 - Added `ieee_float` expression to `pyparsing.common`, which parses float values,
459 plus "NaN", "Inf", "Infinity". PR submitted by Bob Peterson (#538).
460
461 - Updated pep8 synonym wrappers for better type checking compatibility. PR submitted
462 by Ricardo Coccioli (#507).
463
464 - Fixed empty error message bug, PR submitted by InSync (#534). This _should_ return
465 pyparsing's exception messages to a former, more helpful form. If you have code that
466 parses the exception messages returned by pyparsing, this may require some code
467 changes.
468
469 - Added unit tests to test for exception message contents, with enhancement to
470 `pyparsing.testing.assertRaisesParseException` to accept an expected exception message.
471
472 - Updated example `select_parser.py` to use PEP8 names and added Groups for better retrieval
473 of parsed values from multiple SELECT clauses.
474
475 - Added example `email_address_parser.py`, as suggested by John Byrd (#539).
476
477 - Added example `directx_x_file_parser.py` to parse DirectX template definitions, and
478 generate a Pyparsing parser from a template to parse .x files.
479
480 - Some code refactoring to reduce code nesting, PRs submitted by InSync.
481
482 - All internal string expressions using '%' string interpolation and `str.format()`
483 converted to f-strings.
484
485
486 Version 3.1.1 - July, 2023
487 --------------------------
488 - Fixed regression in Word(min), reported by Ricardo Coccioli, good catch! (Issue #502)
489
490 - Fixed bug in bad exception messages raised by Forward expressions. PR submitted
491 by Kyle Sunden, thanks for your patience and collaboration on this (#493).
492
493 - Fixed regression in SkipTo, where ignored expressions were not checked when looking
494 for the target expression. Reported by catcombo, Issue #500.
495
496 - Fixed type annotation for enable_packrat, PR submitted by Mike Urbach, thanks! (Issue #498)
497
498 - Some general internal code cleanup. (Instigated by Michal Čihař, Issue #488)
499
500
501 Version 3.1.0 - June, 2023
502 --------------------------
503 - Added `tag_emitter.py` to examples. This example demonstrates how to insert
504 tags into your parsed results that are not part of the original parsed text.
505
506
507 Version 3.1.0b2 - May, 2023
508 ---------------------------
509 - Updated `create_diagram()` code to be compatible with railroad-diagrams package
510 version 3.0. Fixes Issue #477 (railroad diagrams generated with black bars),
511 reported by Sam Morley-Short.
512
513 - Fixed bug in `NotAny`, where parse actions on the negated expr were not being run.
514 This could cause `NotAny` to incorrectly fail if the expr would normally match,
515 but would fail to match if a condition used as a parse action returned False.
516 Fixes Issue #482, raised by byaka, thank you!
517
518 - Fixed `create_diagram()` to accept keyword args, to be passed through to the
519 `template.render()` method to generate the output HTML (PR submitted by Aussie Schnore,
520 good catch!)
521
522 - Fixed bug in `python_quoted_string` regex.
523
524 - Added `examples/bf.py` Brainf*ck parser/executor example. Illustrates using
525 a pyparsing grammar to parse language syntax, and attach executable AST nodes to
526 the parsed results.
527
528
529 Version 3.1.0b1 - April, 2023
530 -----------------------------
531 - Added support for Python 3.12.
532
533 - API CHANGE: A slight change has been implemented when unquoting a quoted string
534 parsed using the `QuotedString` class. Formerly, when unquoting and processing
535 whitespace markers such as \t and \n, these substitutions would occur first, and
536 then any additional '\' escaping would be done on the resulting string. This would
537 parse "\\n" as "\<newline>". Now escapes and whitespace markers are all processed
538 in a single pass working left to right, so the quoted string "\\n" would get unquoted
539 to "\n" (a backslash followed by "n"). Fixes issue #474 raised by jakeanq,
540 thanks!
541
542 - Added named field "url" to `pyparsing.common.url`, returning the entire
543 parsed URL string.
544
545 - Fixed bug when parse actions returned an empty string for an expression that
546 had a results name, that the results name was not saved. That is:
547
548 expr = Literal("X").add_parse_action(lambda tokens: "")("value")
549 result = expr.parse_string("X")
550 print(result["value"])
551
552 would raise a `KeyError`. Now empty strings will be saved with the associated
553 results name. Raised in Issue #470 by Nicco Kunzmann, thank you.
554
555 - Fixed bug in `SkipTo` where ignore expressions were not properly handled while
556 scanning for the target expression. Issue #475, reported by elkniwt, thanks
557 (this bug has been there for a looooong time!).
558
559 - Updated `ci.yml` permissions to limit default access to source - submitted by Joyce
560 Brum of Google. Thanks so much!
561
562 - Updated the `lucene_grammar.py` example (better support for '*' and '?' wildcards)
563 and corrected the test cases - brought to my attention by Elijah Nicol, good catch!
564
565
566 Version 3.1.0a1 - March, 2023
567 -----------------------------
568 - API ENHANCEMENT: `Optional(expr)` may now be written as `expr | ""`
569
570 This will make this code:
571
572 "{" + Optional(Literal("A") | Literal("a")) + "}"
573
574 writable as:
575
576 "{" + (Literal("A") | Literal("a") | "") + "}"
577
578 Some related changes implemented as part of this work:
579 - `Literal("")` now internally generates an `Empty()` (and no longer raises an exception)
580 - `Empty` is now a subclass of `Literal`
581
582 Suggested by Antony Lee (issue #412), PR (#413) by Devin J. Pohly.
583
584 - Added new class property `identifier` to all Unicode set classes in `pyparsing.unicode`,
585 using the class's values for `cls.identchars` and `cls.identbodychars`. Now Unicode-aware
586 parsers that formerly wrote:
587
588 ppu = pyparsing.unicode
589 ident = Word(ppu.Greek.identchars, ppu.Greek.identbodychars)
590
591 can now write:
592
593 ident = ppu.Greek.identifier
594 # or
595 # ident = ppu.Ελληνικά.identifier
596
597 - `ParseResults` now has a new method `deepcopy()`, in addition to the current
598 `copy()` method. `copy()` only makes a shallow copy - any contained `ParseResults`
599 are copied as references - changes in the copy will be seen as changes in the original.
600 In many cases, a shallow copy is sufficient, but some applications require a deep copy.
601 `deepcopy()` makes a deeper copy: any contained `ParseResults` or other mappings or
602 containers are built with copies from the original, and do not get changed if the
603 original is later changed. Addresses issue #463, reported by Bryn Pickering.
604
605 - Reworked `delimited_list` function into the new `DelimitedList` class.
606 `DelimitedList` has the same constructor interface as `delimited_list`, and
607 in this release, `delimited_list` changes from a function to a synonym for
608 `DelimitedList`. `delimited_list` and the older `delimitedList` method will be
609 deprecated in a future release, in favor of `DelimitedList`.
610
611 - Error messages from `MatchFirst` and `Or` expressions will try to give more details
612 if one of the alternatives matches better than the others, but still fails.
613 Question raised in Issue #464 by msdemlei, thanks!
614
615 - Added new class method `ParserElement.using_each`, to simplify code
616 that creates a sequence of `Literals`, `Keywords`, or other `ParserElement`
617 subclasses.
618
619 For instance, to define suppressible punctuation, you would previously
620 write:
621
622 LPAR, RPAR, LBRACE, RBRACE, SEMI = map(Suppress, "(){};")
623
624 You can now write:
625
626 LPAR, RPAR, LBRACE, RBRACE, SEMI = Suppress.using_each("(){};")
627
628 `using_each` will also accept optional keyword args, which it will
629 pass through to the class initializer. Here is an expression for
630 single-letter variable names that might be used in an algebraic
631 expression:
632
633 algebra_var = MatchFirst(
634 Char.using_each(string.ascii_lowercase, as_keyword=True)
635 )
636
637 - Added new builtin `python_quoted_string`, which will match any form
638 of single-line or multiline quoted strings defined in Python. (Inspired
639 by discussion with Andreas Schörgenhumer in Issue #421.)
640
641 - Extended `expr[]` notation for repetition of `expr` to accept a
642 slice, where the slice's stop value indicates a `stop_on`
643 expression:
644
645 test = "BEGIN aaa bbb ccc END"
646 BEGIN, END = Keyword.using_each("BEGIN END".split())
647 body_word = Word(alphas)
648
649 expr = BEGIN + Group(body_word[...:END]) + END
650 # equivalent to
651 # expr = BEGIN + Group(ZeroOrMore(body_word, stop_on=END)) + END
652
653 print(expr.parse_string(test))
654
655 Prints:
656
657 ['BEGIN', ['aaa', 'bbb', 'ccc'], 'END']
658
659 - `ParserElement.validate()` is deprecated. It predates the support for left-recursive
660 parsers, and was prone to false positives (warning that a grammar was invalid when
661 it was in fact valid). It will be removed in a future pyparsing release. In its
662 place, developers should use debugging and analytical tools, such as `ParserElement.set_debug()`
663 and `ParserElement.create_diagram()`.
664 (Raised in Issue #444, thanks Andrea Micheli!)
665
666 - Added bool `embed` argument to `ParserElement.create_diagram()`.
667 When passed as True, the resulting diagram will omit the `<DOCTYPE>`,
668 `<HEAD>`, and `<BODY>` tags so that it can be embedded in other
669 HTML source. (Useful when embedding a call to `create_diagram()` in
670 a PyScript HTML page.)
671
672 - Added `recurse` argument to `ParserElement.set_debug` to set the
673 debug flag on an expression and all of its sub-expressions. Requested
674 by multimeric in Issue #399.
675
676 - Added '·' (Unicode MIDDLE DOT) to the set of Latin1.identbodychars.
677
678 - Fixed bug in `Word` when `max=2`. Also added performance enhancement
679 when specifying `exact` argument. Reported in issue #409 by
680 panda-34, nice catch!
681
682 - `Word` arguments are now validated if `min` and `max` are both
683 given, that `min` <= `max`; raises `ValueError` if values are invalid.
684
685 - Fixed bug in srange, when parsing escaped '/' and '\' inside a
686 range set.
687
688 - Fixed exception messages for some `ParserElements` with custom names,
689 which instead showed their contained expression names.
690
691 - Fixed bug in pyparsing.common.url, when input URL is not alone
692 on an input line. Fixes Issue #459, reported by David Kennedy.
693
694 - Multiple added and corrected type annotations. With much help from
695 Stephen Rosen, thanks!
696
697 - Some documentation and error message clarifications on pyparsing's
698 keyword logic, cited by Basil Peace.
699
700 - General docstring cleanup for Sphinx doc generation, PRs submitted
701 by Devin J. Pohly. A dirty job, but someone has to do it - much
702 appreciated!
703
704 - `invRegex.py` example renamed to `inv_regex.py` and updated to PEP-8
705 variable and method naming. PR submitted by Ross J. Duff, thanks!
706
707 - Removed examples `sparser.py` and `pymicko.py`, since each included its
708 own GPL license in the header. Since this conflicts with pyparsing's
709 MIT license, they were removed from the distribution to avoid
710 confusion among those making use of them in their own projects.
711
712
713 Version 3.0.9 - May, 2022
714 -------------------------
715 - Added Unicode set `BasicMultilingualPlane` (may also be referenced
716 as `BMP`) representing the Basic Multilingual Plane (Unicode
717 characters up to code point 65535). Can be used to parse
718 most language characters, but omits emojis, wingdings, etc.
719 Raised in discussion with Dave Tapley (issue #392).
720
721 - To address mypy confusion of `pyparsing.Optional` and `typing.Optional`
722 resulting in `error: "_SpecialForm" not callable` message
723 reported in issue #365, fixed the import in `exceptions.py`. Nice
724 sleuthing by Iwan Aucamp and Dominic Davis-Foster, thank you!
725 (Removed definitions of `OptionalType`, `DictType`, and `IterableType`
726 and replaced them with `typing.Optional`, `typing.Dict`, and
727 `typing.Iterable` throughout.)
728
729 - Fixed typo in jinja2 template for railroad diagrams, thanks for the
730 catch Nioub (issue #388).
731
732 - Removed use of deprecated `pkg_resources` package in
733 railroad diagramming code (issue #391).
734
735 - Updated `bigquery_view_parser.py` example to parse examples at
736 https://cloud.google.com/bigquery/docs/reference/legacy-sql
737
738
739 Version 3.0.8 - April, 2022
740 ---------------------------
741 - API CHANGE: modified `pyproject.toml` to require Python version
742 3.6.8 or later for pyparsing 3.x. Earlier minor versions of 3.6
743 fail in evaluating the `version_info` class (implemented using
744 `typing.NamedTuple`). If you are using an earlier version of Python
745 3.6, you will need to use pyparsing 2.4.7.
746
747 - Improved pyparsing import time by deferring regex pattern compiles.
748 PR submitted by Anthony Sottile to fix issue #362, thanks!
749
750 - Updated build to use flit, PR by Michał Górny, added `BUILDING.md`
751 doc and removed old Windows build scripts - nice cleanup work!
752
753 - More type-hinting added for all arithmetic and logical operator
754 methods in `ParserElement`. PR from Kazantcev Andrey, thank you.
755
756 - Fixed `infix_notation`'s definitions of `lpar` and `rpar`, to accept
757 parse expressions such that they do not get suppressed in the parsed
758 results. PR submitted by Philippe Prados, nice work.
759
760 - Fixed bug in railroad diagramming with expressions containing `Combine`
761 elements. Reported by Jeremy White, thanks!
762
763 - Added `show_groups` argument to `create_diagram` to highlight grouped
764 elements with an unlabeled bounding box.
765
766 - Added `unicode_denormalizer.py` to the examples as a demonstration
767 of how Python's interpreter will accept Unicode characters in
768 identifiers, but normalizes them back to ASCII so that identifiers
769 `print` and `𝕡𝓻ᵢ𝓃𝘁` and `𝖕𝒓𝗂𝑛ᵗ` are all equivalent.
770
771 - Removed imports of deprecated `sre_constants` module for catching
772 exceptions when compiling regular expressions. PR submitted by
773 Serhiy Storchaka, thank you.
774
775
776 Version 3.0.7 - January, 2022
777 -----------------------------
778 - Fixed bug #345, in which delimitedList changed expressions in place
779 using `expr.streamline()`. Reported by Kim Gräsman, thanks!
780
781 - Fixed bug #346, when a string of word characters was passed to WordStart
782 or `WordEnd` instead of just taking the default value. Originally posted
783 as a question by Parag on StackOverflow, good catch!
784
785 - Fixed bug #350, in which `White` expressions could fail to match due to
786 unintended whitespace-skipping. Reported by Fu Hanxi, thank you!
787
788 - Fixed bug #355, when a `QuotedString` is defined with characters in its
789 quoteChar string containing regex-significant characters such as ., *,
790 ?, [, ], etc.
791
792 - Fixed bug in `ParserElement.run_tests` where comments would be displayed
793 using `with_line_numbers`.
794
795 - Added optional "min" and "max" arguments to `delimited_list`. PR
796 submitted by Marius, thanks!
797
798 - Added new API change note in `whats_new_in_pyparsing_3_0_0`, regarding
799 a bug fix in the `bool()` behavior of `ParseResults`.
800
801 Prior to pyparsing 3.0.x, the `ParseResults` class implementation of
802 `__bool__` would return `False` if the `ParseResults` item list was empty,
803 even if it contained named results. In 3.0.0 and later, `ParseResults` will
804 return `True` if either the item list is not empty *or* if the named
805 results dict is not empty.
806
807 # generate an empty ParseResults by parsing a blank string with
808 # a ZeroOrMore
809 result = Word(alphas)[...].parse_string("")
810 print(result.as_list())
811 print(result.as_dict())
812 print(bool(result))
813
814 # add a results name to the result
815 result["name"] = "empty result"
816 print(result.as_list())
817 print(result.as_dict())
818 print(bool(result))
819
820 Prints:
821
822 []
823 {}
824 False
825
826 []
827 {'name': 'empty result'}
828 True
829
830 In previous versions, the second call to `bool()` would return `False`.
831
832 - Minor enhancement to Word generation of internal regular expression, to
833 emit consecutive characters in range, such as "ab", as "ab", not "a-b".
834
835 - Fixed character ranges for search terms using non-Western characters
836 in booleansearchparser, PR submitted by tc-yu, nice work!
837
838 - Additional type annotations on public methods.
839
840
841 Version 3.0.6 - November, 2021
842 ------------------------------
843 - Added `suppress_warning()` method to individually suppress a warning on a
844 specific ParserElement. Used to refactor `original_text_for` to preserve
845 internal results names, which, while undocumented, had been adopted by
846 some projects.
847
848 - Fix bug when `delimited_list` was called with a str literal instead of a
849 parse expression.
850
851
852 Version 3.0.5 - November, 2021
853 ------------------------------
854 - Added return type annotations for `col`, `line`, and `lineno`.
855
856 - Fixed bug when `warn_ungrouped_named_tokens_in_collection` warning was raised
857 when assigning a results name to an `original_text_for` expression.
858 (Issue #110, would raise warning in packaging.)
859
860 - Fixed internal bug where `ParserElement.streamline()` would not return self if
861 already streamlined.
862
863 - Changed `run_tests()` output to default to not showing line and column numbers.
864 If line numbering is desired, call with `with_line_numbers=True`. Also fixed
865 minor bug where separating line was not included after a test failure.
866
867
868 Version 3.0.4 - October, 2021
869 -----------------------------
870 - Fixed bug in which `Dict` classes did not correctly return tokens as nested
871 `ParseResults`, reported by and fix identified by Bu Sun Kim, many thanks!!!
872
873 - Documented API-changing side-effect of converting `ParseResults` to use `__slots__`
874 to pre-define instance attributes. This means that code written like this (which
875 was allowed in pyparsing 2.4.7):
876
877 result = Word(alphas).parseString("abc")
878 result.xyz = 100
879
880 now raises this Python exception:
881
882 AttributeError: 'ParseResults' object has no attribute 'xyz'
883
884 To add new attribute values to ParseResults object in 3.0.0 and later, you must
885 assign them using indexed notation:
886
887 result["xyz"] = 100
888
889 You will still be able to access this new value as an attribute or as an
890 indexed item.
891
892 - Fixed bug in railroad diagramming where the vertical limit would count all
893 expressions in a group, not just those that would create visible railroad
894 elements.
895
896
897 Version 3.0.3 - October, 2021
898 -----------------------------
899 - Fixed regex typo in `one_of` fix for `as_keyword=True`.
900
901 - Fixed a whitespace-skipping bug, Issue #319, introduced as part of the revert
902 of the `LineStart` changes. Reported by Marc-Alexandre Côté,
903 thanks!
904
905 - Added header column labeling > 100 in `with_line_numbers` - some input lines
906 are longer than others.
907
908
909 Version 3.0.2 - October, 2021
910 -----------------------------
911 - Reverted change in behavior with `LineStart` and `StringStart`, which changed the
912 interpretation of when and how `LineStart` and `StringStart` should match when
913 a line starts with spaces. In 3.0.0, the `xxxStart` expressions were not
914 really treated like expressions in their own right, but as modifiers to the
915 following expression when used like `LineStart() + expr`, so that if there
916 were whitespace on the line before `expr` (which would match in versions prior
917 to 3.0.0), the match would fail.
918
919 3.0.0 implemented this by automatically promoting `LineStart() + expr` to
920 `AtLineStart(expr)`, which broke existing parsers that did not expect `expr` to
921 necessarily be right at the start of the line, but only be the first token
922 found on the line. This was reported as a regression in Issue #317.
923
924 In 3.0.2, pyparsing reverts to the previous behavior, but will retain the new
925 `AtLineStart` and `AtStringStart` expression classes, so that parsers can chose
926 whichever behavior applies in their specific instance. Specifically:
927
928 # matches expr if it is the first token on the line
929 # (allows for leading whitespace)
930 LineStart() + expr
931
932 # matches only if expr is found in column 1
933 AtLineStart(expr)
934
935 - Performance enhancement to `one_of` to always generate an internal `Regex`,
936 even if `caseless` or `as_keyword` args are given as `True` (unless explicitly
937 disabled by passing `use_regex=False`).
938
939 - `IndentedBlock` class now works with `recursive` flag. By default, the
940 results parsed by an `IndentedBlock` are grouped. This can be disabled by constructing
941 the `IndentedBlock` with `grouped=False`.
942
943
944 Version 3.0.1 - October, 2021
945 -----------------------------
946 - Fixed bug where `Word(max=n)` did not match word groups less than length 'n'.
947 Thanks to Joachim Metz for catching this!
948
949 - Fixed bug where `ParseResults` accidentally created recursive contents.
950 Joachim Metz on this one also!
951
952 - Fixed bug where `warn_on_multiple_string_args_to_oneof` warning is raised
953 even when not enabled.
954
955
956 Version 3.0.0 - October, 2021
957 -----------------------------
958 - A consolidated list of all the changes in the 3.0.0 release can be found in
959 `docs/whats_new_in_3_0_0.rst`.
960 (https://github.com/pyparsing/pyparsing/blob/master/docs/whats_new_in_3_0_0.rst)
961
962
963 Version 3.0.0.final - October, 2021
964 -----------------------------------
965 - Added support for python `-W` warning option to call `enable_all_warnings`() at startup.
966 Also detects setting of `PYPARSINGENABLEALLWARNINGS` environment variable to any non-blank
967 value. (If using `-Wd` for testing, but wishing to disable pyparsing warnings, add
968 `-Wi:::pyparsing`.)
969
970 - Fixed named results returned by `url` to match fields as they would be parsed
971 using `urllib.parse.urlparse`.
972
973 - Early response to `with_line_numbers` was positive, with some requested enhancements:
974 . added a trailing "|" at the end of each line (to show presence of trailing spaces);
975 can be customized using `eol_mark` argument
976 . added expand_tabs argument, to control calling str.expandtabs (defaults to True
977 to match `parseString`)
978 . added mark_spaces argument to support display of a printing character in place of
979 spaces, or Unicode symbols for space and tab characters
980 . added mark_control argument to support highlighting of control characters using
981 '.' or Unicode symbols, such as "␍" and "␊".
982
983 - Modified helpers `common_html_entity` and `replace_html_entity()` to use the HTML
984 entity definitions from `html.entities.html5`.
985
986 - Updated the class diagram in the pyparsing docs directory, along with the supporting
987 .puml file (PlantUML markup) used to create the diagram.
988
989 - Added global method `autoname_elements()` to call `set_name()` on all locally
990 defined `ParserElements` that haven't been explicitly named using `set_name()`, using
991 their local variable name. Useful for setting names on multiple elements when
992 creating a railroad diagram.
993
994 a = pp.Literal("a")
995 b = pp.Literal("b").set_name("bbb")
996 pp.autoname_elements()
997
998 `a` will get named "a", while `b` will keep its name "bbb".
999
1000
1001 Version 3.0.0rc2 - October, 2021
1002 --------------------------------
1003 - Added `url` expression to `pyparsing_common`. (Sample code posted by Wolfgang Fahl,
1004 very nice!)
1005
1006 This new expression has been added to the `urlExtractorNew.py` example, to show how
1007 it extracts URL fields into separate results names.
1008
1009 - Added method to `pyparsing_test` to help debugging, `with_line_numbers`.
1010 Returns a string with line and column numbers corresponding to values shown
1011 when parsing with expr.set_debug():
1012
1013 data = """\
1014 A
1015 100"""
1016 expr = pp.Word(pp.alphanums).set_name("word").set_debug()
1017 print(ppt.with_line_numbers(data))
1018 expr[...].parseString(data)
1019
1020 prints:
1021
1022 1
1023 1234567890
1024 1: A
1025 2: 100
1026 Match word at loc 3(1,4)
1027 A
1028 ^
1029 Matched word -> ['A']
1030 Match word at loc 11(2,7)
1031 100
1032 ^
1033 Matched word -> ['100']
1034
1035 - Added new example `cuneiform_python.py` to demonstrate creating a new Unicode
1036 range, and writing a Cuneiform->Python transformer (inspired by zhpy).
1037
1038 - Fixed issue #272, reported by PhasecoreX, when `LineStart`() expressions would match
1039 input text that was not necessarily at the beginning of a line.
1040
1041 As part of this fix, two new classes have been added: AtLineStart and AtStringStart.
1042 The following expressions are equivalent:
1043
1044 LineStart() + expr and AtLineStart(expr)
1045 StringStart() + expr and AtStringStart(expr)
1046
1047 [`LineStart` and `StringStart` changes reverted in 3.0.2.]
1048
1049 - Fixed `ParseFatalExceptions` failing to override normal exceptions or expression
1050 matches in `MatchFirst` expressions. Addresses issue #251, reported by zyp-rgb.
1051
1052 - Fixed bug in which `ParseResults` replaces a collection type value with an invalid
1053 type annotation (as a result of changed behavior in Python 3.9). Addresses issue #276, reported by
1054 Rob Shuler, thanks.
1055
1056 - Fixed bug in `ParseResults` when calling `__getattr__` for special double-underscored
1057 methods. Now raises `AttributeError` for non-existent results when accessing a
1058 name starting with '__'. Addresses issue #208, reported by Joachim Metz.
1059
1060 - Modified debug fail messages to include the expression name to make it easier to sync
1061 up match vs success/fail debug messages.
1062
1063
1064 Version 3.0.0rc1 - September, 2021
1065 ----------------------------------
1066 - Railroad diagrams have been reformatted:
1067 . creating diagrams is easier - call
1068
1069 expr.create_diagram("diagram_output.html")
1070
1071 create_diagram() takes 3 arguments:
1072 . the filename to write the diagram HTML
1073 . optional 'vertical' argument, to specify the minimum number of items in a path
1074 to be shown vertically; default=3
1075 . optional 'show_results_names' argument, to specify whether results name
1076 annotations should be shown; default=False
1077 . every expression that gets a name using `setName()` gets separated out as
1078 a separate subdiagram
1079 . results names can be shown as annotations to diagram items
1080 . `Each`, `FollowedBy`, and `PrecededBy` elements get [ALL], [LOOKAHEAD], and [LOOKBEHIND]
1081 annotations
1082 . removed annotations for Suppress elements
1083 . some diagram cleanup when a grammar contains Forward elements
1084 . check out the examples make_diagram.py and railroad_diagram_demo.py
1085
1086 - Type annotations have been added to most public API methods and classes.
1087
1088 - Better exception messages to show full word where an exception occurred.
1089
1090 Word(alphas, alphanums)[...].parseString("ab1 123", parseAll=True)
1091
1092 Was:
1093 pyparsing.ParseException: Expected end of text, found '1' (at char 4), (line:1, col:5)
1094 Now:
1095 pyparsing.exceptions.ParseException: Expected end of text, found '123' (at char 4), (line:1, col:5)
1096
1097 - Suppress can be used to suppress text skipped using "...".
1098
1099 source = "lead in START relevant text END trailing text"
1100 start_marker = Keyword("START")
1101 end_marker = Keyword("END")
1102 find_body = Suppress(...) + start_marker + ... + end_marker
1103 print(find_body.parseString(source).dump())
1104
1105 Prints:
1106
1107 ['START', 'relevant text ', 'END']
1108 - _skipped: ['relevant text ']
1109
1110 - New string constants `identchars` and `identbodychars` to help in defining identifier Word expressions
1111
1112 Two new module-level strings have been added to help when defining identifiers, `identchars` and `identbodychars`.
1113
1114 Instead of writing::
1115
1116 import pyparsing as pp
1117 identifier = pp.Word(pp.alphas + "_", pp.alphanums + "_")
1118
1119 you will be able to write::
1120
1121 identifier = pp.Word(pp.identchars, pp.identbodychars)
1122
1123 Those constants have also been added to all the Unicode string classes::
1124
1125 import pyparsing as pp
1126 ppu = pp.pyparsing_unicode
1127
1128 cjk_identifier = pp.Word(ppu.CJK.identchars, ppu.CJK.identbodychars)
1129 greek_identifier = pp.Word(ppu.Greek.identchars, ppu.Greek.identbodychars)
1130
1131 - Added a caseless parameter to the `CloseMatch` class to allow for casing to be
1132 ignored when checking for close matches. (Issue #281) (PR by Adrian Edwards, thanks!)
1133
1134 - Fixed bug in Located class when used with a results name. (Issue #294)
1135
1136 - Fixed bug in `QuotedString` class when the escaped quote string is not a
1137 repeated character. (Issue #263)
1138
1139 - `parseFile()` and `create_diagram()` methods now will accept `pathlib.Path`
1140 arguments.
1141
1142
1143 Version 3.0.0b3 - August, 2021
1144 ------------------------------
1145 - PEP-8 compatible names are being introduced in pyparsing version 3.0!
1146 All methods such as `parseString` have been replaced with the PEP-8
1147 compliant name `parse_string`. In addition, arguments such as `parseAll`
1148 have been renamed to `parse_all`. For backward-compatibility, synonyms for
1149 all renamed methods and arguments have been added, so that existing
1150 pyparsing parsers will not break. These synonyms will be removed in a future
1151 release.
1152
1153 In addition, the Optional class has been renamed to Opt, since it clashes
1154 with the common typing.Optional type specifier that is used in the Python
1155 type annotations. A compatibility synonym is defined for now, but will be
1156 removed in a future release.
1157
1158 - HUGE NEW FEATURE - Support for left-recursive parsers!
1159 Following the method used in Python's PEG parser, pyparsing now supports
1160 left-recursive parsers when left recursion is enabled.
1161
1162 import pyparsing as pp
1163 pp.ParserElement.enable_left_recursion()
1164
1165 # a common left-recursion definition
1166 # define a list of items as 'list + item | item'
1167 # BNF:
1168 # item_list := item_list item | item
1169 # item := word of alphas
1170 item_list = pp.Forward()
1171 item = pp.Word(pp.alphas)
1172 item_list <<= item_list + item | item
1173
1174 item_list.run_tests("""\
1175 To parse or not to parse that is the question
1176 """)
1177 Prints:
1178
1179 ['To', 'parse', 'or', 'not', 'to', 'parse', 'that', 'is', 'the', 'question']
1180
1181 Great work contributed by Max Fischer!
1182
1183 - `delimited_list` now supports an additional flag `allow_trailing_delim`,
1184 to optionally parse an additional delimiter at the end of the list.
1185 Contributed by Kazantcev Andrey, thanks!
1186
1187 - Removed internal comparison of results values against b"", which
1188 raised a `BytesWarning` when run with `python -bb`. Fixes issue #271 reported
1189 by Florian Bruhin, thank you!
1190
1191 - Fixed STUDENTS table in sql2dot.py example, fixes issue #261 reported by
1192 legrandlegrand - much better.
1193
1194 - Python 3.5 will not be supported in the pyparsing 3 releases. This will allow
1195 for future pyparsing releases to add parameter type annotations, and to take
1196 advantage of dict key ordering in internal results name tracking.
1197
1198
1199 Version 3.0.0b2 - December, 2020
1200 --------------------------------
1201 - API CHANGE
1202 `locatedExpr` is being replaced by the class `Located`. `Located` has the same
1203 constructor interface as `locatedExpr`, but fixes bugs in the returned
1204 `ParseResults` when the searched expression contains multiple tokens, or
1205 has internal results names.
1206
1207 `locatedExpr` is deprecated, and will be removed in a future release.
1208
1209
1210 Version 3.0.0b1 - November, 2020
1211 --------------------------------
1212 - API CHANGE
1213 Diagnostic flags have been moved to an enum, `pyparsing.Diagnostics`, and
1214 they are enabled through module-level methods:
1215 - `pyparsing.enable_diag()`
1216 - `pyparsing.disable_diag()`
1217 - `pyparsing.enable_all_warnings()`
1218
1219 - API CHANGE
1220 Most previous `SyntaxWarnings` that were warned when using pyparsing
1221 classes incorrectly have been converted to `TypeError` and `ValueError` exceptions,
1222 consistent with Python calling conventions. All warnings warned by diagnostic
1223 flags have been converted from `SyntaxWarnings` to `UserWarnings`.
1224
1225 - To support parsers that are intended to generate native Python collection
1226 types such as lists and dicts, the `Group` and `Dict` classes now accept an
1227 additional boolean keyword argument `aslist` and `asdict` respectively. See
1228 the `jsonParser.py` example in the `pyparsing/examples` source directory for
1229 how to return types as `ParseResults` and as Python collection types, and the
1230 distinctions in working with the different types.
1231
1232 In addition parse actions that must return a value of list type (which would
1233 normally be converted internally to a `ParseResults`) can override this default
1234 behavior by returning their list wrapped in the new `ParseResults.List` class:
1235
1236 # this parse action tries to return a list, but pyparsing
1237 # will convert to a ParseResults
1238 def return_as_list_but_still_get_parse_results(tokens):
1239 return tokens.asList()
1240
1241 # this parse action returns the tokens as a list, and pyparsing will
1242 # maintain its list type in the final parsing results
1243 def return_as_list(tokens):
1244 return ParseResults.List(tokens.asList())
1245
1246 This is the mechanism used internally by the `Group` class when defined
1247 using `aslist=True`.
1248
1249 - A new `IndentedBlock` class is introduced, to eventually replace the
1250 current `indentedBlock` helper method. The interface is largely the same,
1251 however, the new class manages its own internal indentation stack, so
1252 it is no longer necessary to maintain an external `indentStack` variable.
1253
1254 - API CHANGE
1255 Added `cache_hit` keyword argument to debug actions. Previously, if packrat
1256 parsing was enabled, the debug methods were not called in the event of cache
1257 hits. Now these methods will be called, with an added argument
1258 `cache_hit=True`.
1259
1260 If you are using packrat parsing and enable debug on expressions using a
1261 custom debug method, you can add the `cache_hit=False` keyword argument,
1262 and your method will be called on packrat cache hits. If you choose not
1263 to add this keyword argument, the debug methods will fail silently,
1264 behaving as they did previously.
1265
1266 - When using `setDebug` with packrat parsing enabled, packrat cache hits will
1267 now be included in the output, shown with a leading '*'. (Previously, cache
1268 hits and responses were not included in debug output.) For those using custom
1269 debug actions, see the previous item regarding an optional API change
1270 for those methods.
1271
1272 - `setDebug` output will also show more details about what expression
1273 is about to be parsed (the current line of text being parsed, and
1274 the current parse position):
1275
1276 Match integer at loc 0(1,1)
1277 1 2 3
1278 ^
1279 Matched integer -> ['1']
1280
1281 The current debug location will also be indicated after whitespace
1282 has been skipped (was previously inconsistent, reported in Issue #244,
1283 by Frank Goyens, thanks!).
1284
1285 - Modified the repr() output for `ParseResults` to include the class
1286 name as part of the output. This is to clarify for new pyparsing users
1287 who misread the repr output as a tuple of a list and a dict. pyparsing
1288 results will now read like:
1289
1290 ParseResults(['abc', 'def'], {'qty': 100}]
1291
1292 instead of just:
1293
1294 (['abc', 'def'], {'qty': 100}]
1295
1296 - Fixed bugs in Each when passed `OneOrMore` or `ZeroOrMore` expressions:
1297 . first expression match could be enclosed in an extra nesting level
1298 . out-of-order expressions now handled correctly if mixed with required
1299 expressions
1300 . results names are maintained correctly for these expressions
1301
1302 - Fixed traceback trimming, and added `ParserElement.verbose_traceback`
1303 save/restore to `reset_pyparsing_context()`.
1304
1305 - Default string for `Word` expressions now also include indications of
1306 `min` and `max` length specification, if applicable, similar to regex length
1307 specifications:
1308
1309 Word(alphas) -> "W:(A-Za-z)"
1310 Word(nums) -> "W:(0-9)"
1311 Word(nums, exact=3) -> "W:(0-9){3}"
1312 Word(nums, min=2) -> "W:(0-9){2,...}"
1313 Word(nums, max=3) -> "W:(0-9){1,3}"
1314 Word(nums, min=2, max=3) -> "W:(0-9){2,3}"
1315
1316 For expressions of the `Char` class (similar to `Word(..., exact=1)`, the expression
1317 is simply the character range in parentheses:
1318
1319 Char(nums) -> "(0-9)"
1320 Char(alphas) -> "(A-Za-z)"
1321
1322 - Removed `copy()` override in `Keyword` class which did not preserve definition
1323 of ident chars from the original expression. PR #233 submitted by jgrey4296,
1324 thanks!
1325
1326 - In addition to `pyparsing.__version__`, there is now also a `pyparsing.__version_info__`,
1327 following the same structure and field names as in `sys.version_info`.
1328
1329
1330 Version 3.0.0a2 - June, 2020
1331 ----------------------------
1332 - Summary of changes for 3.0.0 can be found in "What's New in Pyparsing 3.0.0"
1333 documentation.
1334
1335 - API CHANGE
1336 Changed result returned when parsing using `countedArray`,
1337 the array items are no longer returned in a doubly-nested
1338 list.
1339
1340 - An excellent new enhancement is the new railroad diagram
1341 generator for documenting pyparsing parsers:
1342
1343 import pyparsing as pp
1344 from pyparsing.diagram import to_railroad, railroad_to_html
1345 from pathlib import Path
1346
1347 # define a simple grammar for parsing street addresses such
1348 # as "123 Main Street"
1349 # number word...
1350 number = pp.Word(pp.nums).setName("number")
1351 name = pp.Word(pp.alphas).setName("word")[1, ...]
1352
1353 parser = number("house_number") + name("street")
1354 parser.setName("street address")
1355
1356 # construct railroad track diagram for this parser and
1357 # save as HTML
1358 rr = to_railroad(parser)
1359 Path('parser_rr_diag.html').write_text(railroad_to_html(rr))
1360
1361 Very nice work provided by Michael Milton, thanks a ton!
1362
1363 - Enhanced default strings created for Word expressions, now showing
1364 string ranges if possible. `Word(alphas)` would formerly
1365 print as `W:(ABCD...)`, now prints as `W:(A-Za-z)`.
1366
1367 - Added `ignoreWhitespace(recurse:bool = True)`` and added a
1368 recurse argument to `leaveWhitespace`, both added to provide finer
1369 control over pyparsing's whitespace skipping. Also contributed
1370 by Michael Milton.
1371
1372 - The unicode range definitions for the various languages were
1373 recalculated by interrogating the unicodedata module by character
1374 name, selecting characters that contained that language in their
1375 Unicode name. (Issue #227)
1376
1377 Also, pyparsing_unicode.Korean was renamed to Hangul (Korean
1378 is also defined as a synonym for compatibility).
1379
1380 - Enhanced `ParseResults` dump() to show both results names and list
1381 subitems. Fixes bug where adding a results name would hide
1382 lower-level structures in the `ParseResults`.
1383
1384 - Added new __diag__ warnings:
1385
1386 "warn_on_parse_using_empty_Forward" - warns that a Forward
1387 has been included in a grammar, but no expression was
1388 attached to it using '<<=' or '<<'
1389
1390 "warn_on_assignment_to_Forward" - warns that a Forward has
1391 been created, but was probably later overwritten by
1392 erroneously using '=' instead of '<<=' (this is a common
1393 mistake when using Forwards)
1394 (**currently not working on PyPy**)
1395
1396 - Added `ParserElement`.recurse() method to make it simpler for
1397 grammar utilities to navigate through the tree of expressions in
1398 a pyparsing grammar.
1399
1400 - Fixed bug in `ParseResults` repr() which showed all matching
1401 entries for a results name, even if `listAllMatches` was set
1402 to False when creating the `ParseResults` originally. Reported
1403 by Nicholas42 on GitHub, good catch! (Issue #205)
1404
1405 - Modified refactored modules to use relative imports, as
1406 pointed out by setuptools project member jaraco, thank you!
1407
1408 - Off-by-one bug found in the roman_numerals.py example, a bug
1409 that has been there for about 14 years! PR submitted by
1410 Jay Pedersen, nice catch!
1411
1412 - A simplified Lua parser has been added to the examples
1413 (lua_parser.py).
1414
1415 - Added make_diagram.py to the examples directory to demonstrate
1416 creation of railroad diagrams for selected pyparsing examples.
1417 Also restructured some examples to make their parsers importable
1418 without running their embedded tests.
1419
1420
1421 Version 3.0.0a1 - April, 2020
1422 -----------------------------
1423 - Removed Py2.x support and other deprecated features. Pyparsing
1424 now requires Python 3.5 or later. If you are using an earlier
1425 version of Python, you must use a Pyparsing 2.4.x version
1426
1427 Deprecated features removed:
1428 . `ParseResults.asXML()` - if used for debugging, switch
1429 to using `ParseResults.dump()`; if used for data transfer,
1430 use `ParseResults.asDict()` to convert to a nested Python
1431 dict, which can then be converted to XML or JSON or
1432 other transfer format
1433
1434 . `operatorPrecedence` synonym for `infixNotation` -
1435 convert to calling `infixNotation`
1436
1437 . `commaSeparatedList` - convert to using
1438 pyparsing_common.comma_separated_list
1439
1440 . `upcaseTokens` and `downcaseTokens` - convert to using
1441 `pyparsing_common.upcaseTokens` and `downcaseTokens`
1442
1443 . __compat__.collect_all_And_tokens will not be settable to
1444 False to revert to pre-2.3.1 results name behavior -
1445 review use of names for `MatchFirst` and Or expressions
1446 containing And expressions, as they will return the
1447 complete list of parsed tokens, not just the first one.
1448 Use `__diag__.warn_multiple_tokens_in_named_alternation`
1449 to help identify those expressions in your parsers that
1450 will have changed as a result.
1451
1452 - Removed support for running `python setup.py test`. The setuptools
1453 maintainers consider the test command deprecated (see
1454 <https://github.com/pypa/setuptools/issues/1684>). To run the Pyparsing test,
1455 use the command `tox`.
1456
1457 - API CHANGE:
1458 The staticmethod `ParseException.explain` has been moved to
1459 `ParseBaseException.explain_exception`, and a new `explain` instance
1460 method added to `ParseBaseException`. This will make calls to `explain`
1461 much more natural:
1462
1463 try:
1464 expr.parseString("...")
1465 except ParseException as pe:
1466 print(pe.explain())
1467
1468 - POTENTIAL API CHANGE:
1469 `ZeroOrMore` expressions that have results names will now
1470 include empty lists for their name if no matches are found.
1471 Previously, no named result would be present. Code that tested
1472 for the presence of any expressions using "if name in results:"
1473 will now always return True. This code will need to change to
1474 "if name in results and results[name]:" or just
1475 "if results[name]:". Also, any parser unit tests that check the
1476 `asDict()` contents will now see additional entries for parsers
1477 having named `ZeroOrMore` expressions, whose values will be `[]`.
1478
1479 - POTENTIAL API CHANGE:
1480 Fixed a bug in which calls to `ParserElement.setDefaultWhitespaceChars`
1481 did not change whitespace definitions on any pyparsing built-in
1482 expressions defined at import time (such as `quotedString`, or those
1483 defined in pyparsing_common). This would lead to confusion when
1484 built-in expressions would not use updated default whitespace
1485 characters. Now a call to `ParserElement.setDefaultWhitespaceChars`
1486 will also go and update all pyparsing built-ins to use the new
1487 default whitespace characters. (Note that this will only modify
1488 expressions defined within the pyparsing module.) Prompted by
1489 work on a StackOverflow question posted by jtiai.
1490
1491 - Expanded __diag__ and __compat__ to actual classes instead of
1492 just namespaces, to add some helpful behavior:
1493 - enable() and .disable() methods to give extra
1494 help when setting or clearing flags (detects invalid
1495 flag names, detects when trying to set a __compat__ flag
1496 that is no longer settable). Use these methods now to
1497 set or clear flags, instead of directly setting to True or
1498 False.
1499
1500 import pyparsing as pp
1501 pp.__diag__.enable("warn_multiple_tokens_in_named_alternation")
1502
1503 - __diag__.enable_all_warnings() is another helper that sets
1504 all "warn*" diagnostics to True.
1505
1506 pp.__diag__.enable_all_warnings()
1507
1508 - added new warning, "warn_on_match_first_with_lshift_operator" to
1509 warn when using '<<' with a '|' `MatchFirst` operator, which will
1510 create an unintended expression due to precedence of operations.
1511
1512 Example: This statement will erroneously define the `fwd` expression
1513 as just `expr_a`, even though `expr_a | expr_b` was intended,
1514 since '<<' operator has precedence over '|':
1515
1516 fwd << expr_a | expr_b
1517
1518 To correct this, use the '<<=' operator (preferred) or parentheses
1519 to override operator precedence:
1520
1521 fwd <<= expr_a | expr_b
1522 or
1523 fwd << (expr_a | expr_b)
1524
1525 - Cleaned up default tracebacks when getting a `ParseException` when calling
1526 `parseString`. Exception traces should now stop at the call in `parseString`,
1527 and not include the internal traceback frames. (If the full traceback
1528 is desired, then set `ParserElement`.verbose_traceback to True.)
1529
1530 - Fixed `FutureWarnings` that sometimes are raised when '[' passed as a
1531 character to Word.
1532
1533 - New namespace, assert methods and classes added to support writing
1534 unit tests.
1535 - `assertParseResultsEquals`
1536 - `assertParseAndCheckList`
1537 - `assertParseAndCheckDict`
1538 - `assertRunTestResults`
1539 - `assertRaisesParseException`
1540 - `reset_pyparsing_context` context manager, to restore pyparsing
1541 config settings
1542
1543 - Enhanced error messages and error locations when parsing fails on
1544 the Keyword or `CaselessKeyword` classes due to the presence of a
1545 preceding or trailing keyword character. Surfaced while
1546 working with metaperl on issue #201.
1547
1548 - Enhanced the `Regex` class to be compatible with re's compiled with the
1549 re-equivalent regex module. Individual expressions can be built with
1550 regex compiled expressions using:
1551
1552 import pyparsing as pp
1553 import regex
1554
1555 # would use regex for this expression
1556 integer_parser = pp.Regex(regex.compile(r'\d+'))
1557
1558 Inspired by PR submitted by bjrnfrdnnd on GitHub, very nice!
1559
1560 - Fixed handling of `ParseSyntaxExceptions` raised as part of Each
1561 expressions, when sub-expressions contain '-' backtrack
1562 suppression. As part of resolution to a question posted by John
1563 Greene on StackOverflow.
1564
1565 - Potentially *huge* performance enhancement when parsing Word
1566 expressions built from pyparsing_unicode character sets. Word now
1567 internally converts ranges of consecutive characters to regex
1568 character ranges (converting "0123456789" to "0-9" for instance),
1569 resulting in as much as 50X improvement in performance! Work
1570 inspired by a question posted by Midnighter on StackOverflow.
1571
1572 - Improvements in select_parser.py, to include new SQL syntax
1573 from SQLite. PR submitted by Robert Coup, nice work!
1574
1575 - Fixed bug in `PrecededBy` which caused infinite recursion, issue #127
1576 submitted by EdwardJB.
1577
1578 - Fixed bug in `CloseMatch` where end location was incorrectly
1579 computed; and updated partial_gene_match.py example.
1580
1581 - Fixed bug in `indentedBlock` with a parser using two different
1582 types of nested indented blocks with different indent values,
1583 but sharing the same indent stack, submitted by renzbagaporo.
1584
1585 - Fixed bug in `Each` when using `Regex`, when `Regex` expression would
1586 get parsed twice; issue #183 submitted by scauligi, thanks!
1587
1588 - `BigQueryViewParser.py` added to examples directory, PR submitted
1589 by Michael Smedberg, nice work!
1590
1591 - booleansearchparser.py added to examples directory, PR submitted
1592 by xecgr. Builds on searchparser.py, adding support for '*'
1593 wildcards and non-Western alphabets.
1594
1595 - Fixed bug in delta_time.py example, when using a quantity
1596 of seconds/minutes/hours/days > 999.
1597
1598 - Fixed bug in regex definitions for real and sci_real expressions in
1599 pyparsing_common. Issue #194, reported by Michael Wayne Goodman, thanks!
1600
1601 - Fixed `FutureWarning` raised beginning in Python 3.7 for `Regex` expressions
1602 containing '[' within a regex set.
1603
1604 - Minor reformatting of output from `runTests` to make embedded
1605 comments more visible.
1606
1607 - And finally, many thanks to those who helped in the restructuring
1608 of the pyparsing code base as part of this release. Pyparsing now
1609 has more standard package structure, more standard unit tests,
1610 and more standard code formatting (using black). Special thanks
1611 to jdufresne, klahnakoski, mattcarmody, and ckeygusuz, to name just
1612 a few.
1613
1614
1615 Version 2.4.7 - April, 2020
1616 ---------------------------
1617 - Backport of selected fixes from 3.0.0 work:
1618 . Each bug with `Regex` expressions
1619 . And expressions not properly constructing with generator
1620 . Traceback abbreviation
1621 . Bug in delta_time example
1622 . Fix regexen in pyparsing_common.real and .sci_real
1623 . Avoid FutureWarning on Python 3.7 or later
1624 . Cleanup output in runTests if comments are embedded in test string
1625
1626
1627 Version 2.4.6 - December, 2019
1628 ------------------------------
1629 - Fixed typos in White mapping of whitespace characters, to use
1630 correct "\u" prefix instead of "u\".
1631
1632 - Fix bug in left-associative ternary operators defined using
1633 infixNotation. First reported on StackOverflow by user Jeronimo.
1634
1635 - Backport of pyparsing_test namespace from 3.0.0, including
1636 TestParseResultsAsserts mixin class defining unittest-helper
1637 methods:
1638 . def assertParseResultsEquals(
1639 self, result, expected_list=None, expected_dict=None, msg=None)
1640 . def assertParseAndCheckList(
1641 self, expr, test_string, expected_list, msg=None, verbose=True)
1642 . def assertParseAndCheckDict(
1643 self, expr, test_string, expected_dict, msg=None, verbose=True)
1644 . def assertRunTestResults(
1645 self, run_tests_report, expected_parse_results=None, msg=None)
1646 . def assertRaisesParseException(self, exc_type=ParseException, msg=None)
1647
1648 To use the methods in this mixin class, declare your unittest classes as:
1649
1650 from pyparsing import pyparsing_test as ppt
1651 class MyParserTest(ppt.TestParseResultsAsserts, unittest.TestCase):
1652 ...
1653
1654
1655 Version 2.4.5 - November, 2019
1656 ------------------------------
1657 - NOTE: final release compatible with Python 2.x.
1658
1659 - Fixed issue with reading README.rst as part of setup.py's
1660 initialization of the project's long_description, with a
1661 non-ASCII space character causing errors when installing from
1662 source on platforms where UTF-8 is not the default encoding.
1663
1664
1665 Version 2.4.4 - November, 2019
1666 --------------------------------
1667 - Unresolved symbol reference in 2.4.3 release was masked by stdout
1668 buffering in unit tests, thanks for the prompt heads-up, Ned
1669 Batchelder!
1670
1671
1672 Version 2.4.3 - November, 2019
1673 ------------------------------
1674 - Fixed a bug in ParserElement.__eq__ that would for some parsers
1675 create a recursion error at parser definition time. Thanks to
1676 Michael Clerx for the assist. (Addresses issue #123)
1677
1678 - Fixed bug in indentedBlock where a block that ended at the end
1679 of the input string could cause pyparsing to loop forever. Raised
1680 as part of discussion on StackOverflow with geckos.
1681
1682 - Backports from pyparsing 3.0.0:
1683 . __diag__.enable_all_warnings()
1684 . Fixed bug in PrecededBy which caused infinite recursion, issue #127
1685 . support for using regex-compiled RE to construct `Regex` expressions
1686
1687
1688 Version 2.4.2 - July, 2019
1689 --------------------------
1690 - Updated the shorthand notation that has been added for repetition
1691 expressions: expr[min, max], with '...' valid as a min or max value:
1692 - expr[...] and expr[0, ...] are equivalent to ZeroOrMore(expr)
1693 - expr[1, ...] is equivalent to OneOrMore(expr)
1694 - expr[n, ...] or expr[n,] is equivalent
1695 to expr*n + ZeroOrMore(expr)
1696 (read as "n or more instances of expr")
1697 - expr[..., n] is equivalent to expr*(0, n)
1698 - expr[m, n] is equivalent to expr*(m, n)
1699 Note that expr[..., n] and expr[m, n] do not raise an exception
1700 if more than n exprs exist in the input stream. If this
1701 behavior is desired, then write expr[..., n] + ~expr.
1702
1703 Better interpretation of [...] as ZeroOrMore raised by crowsonkb,
1704 thanks for keeping me in line!
1705
1706 If upgrading from 2.4.1 or 2.4.1.1 and you have used `expr[...]`
1707 for `OneOrMore(expr)`, it must be updated to `expr[1, ...]`.
1708
1709 - The defaults on all the `__diag__` switches have been set to False,
1710 to avoid getting alarming warnings. To use these diagnostics, set
1711 them to True after importing pyparsing.
1712
1713 Example:
1714
1715 import pyparsing as pp
1716 pp.__diag__.warn_multiple_tokens_in_named_alternation = True
1717
1718 - Fixed bug introduced by the use of __getitem__ for repetition,
1719 overlooking Python's legacy implementation of iteration
1720 by sequentially calling __getitem__ with increasing numbers until
1721 getting an IndexError. Found during investigation of problem
1722 reported by murlock, merci!
1723
1724
1725 Version 2.4.2a1 - July, 2019
1726 ----------------------------
1727 It turns out I got the meaning of `[...]` absolutely backwards,
1728 so I've deleted 2.4.1 and am repushing this release as 2.4.2a1
1729 for people to give it a try before I can call it ready to go.
1730
1731 The `expr[...]` notation was pushed out to be synonymous with
1732 `OneOrMore(expr)`, but this is really counter to most Python
1733 notations (and even other internal pyparsing notations as well).
1734 It should have been defined to be equivalent to ZeroOrMore(expr).
1735
1736 - Changed [...] to emit ZeroOrMore instead of OneOrMore.
1737
1738 - Removed code that treats ParserElements like iterables.
1739
1740 - Change all __diag__ switches to False.
1741
1742
1743 Version 2.4.1.1 - July 24, 2019
1744 -------------------------------
1745 This is a re-release of version 2.4.1 to restore the release history
1746 in PyPI, since the 2.4.1 release was deleted.
1747
1748 There are 3 known issues in this release, which are fixed in
1749 the upcoming 2.4.2:
1750
1751 - API change adding support for `expr[...]` - the original
1752 code in 2.4.1 incorrectly implemented this as OneOrMore.
1753 Code using this feature under this release should explicitly
1754 use `expr[0, ...]` for ZeroOrMore and `expr[1, ...]` for
1755 OneOrMore. In 2.4.2 you will be able to write `expr[...]`
1756 equivalent to `ZeroOrMore(expr)`.
1757
1758 - Bug if composing And, Or, MatchFirst, or Each expressions
1759 using an expression. This only affects code which uses
1760 explicit expression construction using the And, Or, etc.
1761 classes instead of using overloaded operators '+', '^', and
1762 so on. If constructing an And using a single expression,
1763 you may get an error that "cannot multiply ParserElement by
1764 0 or (0, 0)" or a Python `IndexError`. Change code like
1765
1766 cmd = Or(Word(alphas))
1767
1768 to
1769
1770 cmd = Or([Word(alphas)])
1771
1772 (Note that this is not the recommended style for constructing
1773 Or expressions.)
1774
1775 - Some newly-added `__diag__` switches are enabled by default,
1776 which may give rise to noisy user warnings for existing parsers.
1777 You can disable them using:
1778
1779 import pyparsing as pp
1780 pp.__diag__.warn_multiple_tokens_in_named_alternation = False
1781 pp.__diag__.warn_ungrouped_named_tokens_in_collection = False
1782 pp.__diag__.warn_name_set_on_empty_Forward = False
1783 pp.__diag__.warn_on_multiple_string_args_to_oneof = False
1784 pp.__diag__.enable_debug_on_named_expressions = False
1785
1786 In 2.4.2 these will all be set to False by default.
1787
1788
1789 Version 2.4.1 - July, 2019
1790 --------------------------
1791 - NOTE: Deprecated functions and features that will be dropped
1792 in pyparsing 2.5.0 (planned next release):
1793
1794 . support for Python 2 - ongoing users running with
1795 Python 2 can continue to use pyparsing 2.4.1
1796
1797 . ParseResults.asXML() - if used for debugging, switch
1798 to using ParseResults.dump(); if used for data transfer,
1799 use ParseResults.asDict() to convert to a nested Python
1800 dict, which can then be converted to XML or JSON or
1801 other transfer format
1802
1803 . operatorPrecedence synonym for infixNotation -
1804 convert to calling infixNotation
1805
1806 . commaSeparatedList - convert to using
1807 pyparsing_common.comma_separated_list
1808
1809 . upcaseTokens and downcaseTokens - convert to using
1810 pyparsing_common.upcaseTokens and downcaseTokens
1811
1812 . __compat__.collect_all_And_tokens will not be settable to
1813 False to revert to pre-2.3.1 results name behavior -
1814 review use of names for MatchFirst and Or expressions
1815 containing And expressions, as they will return the
1816 complete list of parsed tokens, not just the first one.
1817 Use __diag__.warn_multiple_tokens_in_named_alternation
1818 (described below) to help identify those expressions
1819 in your parsers that will have changed as a result.
1820
1821 - A new shorthand notation has been added for repetition
1822 expressions: expr[min, max], with '...' valid as a min
1823 or max value:
1824 - expr[...] is equivalent to OneOrMore(expr)
1825 - expr[0, ...] is equivalent to ZeroOrMore(expr)
1826 - expr[1, ...] is equivalent to OneOrMore(expr)
1827 - expr[n, ...] or expr[n,] is equivalent
1828 to expr*n + ZeroOrMore(expr)
1829 (read as "n or more instances of expr")
1830 - expr[..., n] is equivalent to expr*(0, n)
1831 - expr[m, n] is equivalent to expr*(m, n)
1832 Note that expr[..., n] and expr[m, n] do not raise an exception
1833 if more than n exprs exist in the input stream. If this
1834 behavior is desired, then write expr[..., n] + ~expr.
1835
1836 - '...' can also be used as short hand for SkipTo when used
1837 in adding parse expressions to compose an And expression.
1838
1839 Literal('start') + ... + Literal('end')
1840 And(['start', ..., 'end'])
1841
1842 are both equivalent to:
1843
1844 Literal('start') + SkipTo('end')("_skipped*") + Literal('end')
1845
1846 The '...' form has the added benefit of not requiring repeating
1847 the skip target expression. Note that the skipped text is
1848 returned with '_skipped' as a results name, and that the contents of
1849 `_skipped` will contain a list of text from all `...`s in the expression.
1850
1851 - '...' can also be used as a "skip forward in case of error" expression:
1852
1853 expr = "start" + (Word(nums).setName("int") | ...) + "end"
1854
1855 expr.parseString("start 456 end")
1856 ['start', '456', 'end']
1857
1858 expr.parseString("start 456 foo 789 end")
1859 ['start', '456', 'foo 789 ', 'end']
1860 - _skipped: ['foo 789 ']
1861
1862 expr.parseString("start foo end")
1863 ['start', 'foo ', 'end']
1864 - _skipped: ['foo ']
1865
1866 expr.parseString("start end")
1867 ['start', '', 'end']
1868 - _skipped: ['missing <int>']
1869
1870 Note that in all the error cases, the '_skipped' results name is
1871 present, showing a list of the extra or missing items.
1872
1873 This form is only valid when used with the '|' operator.
1874
1875 - Improved exception messages to show what was actually found, not
1876 just what was expected.
1877
1878 word = pp.Word(pp.alphas)
1879 pp.OneOrMore(word).parseString("aaa bbb 123", parseAll=True)
1880
1881 Former exception message:
1882
1883 pyparsing.ParseException: Expected end of text (at char 8), (line:1, col:9)
1884
1885 New exception message:
1886
1887 pyparsing.ParseException: Expected end of text, found '1' (at char 8), (line:1, col:9)
1888
1889 - Added diagnostic switches to help detect and warn about common
1890 parser construction mistakes, or enable additional parse
1891 debugging. Switches are attached to the pyparsing.__diag__
1892 namespace object:
1893 - warn_multiple_tokens_in_named_alternation - flag to enable warnings when a results
1894 name is defined on a MatchFirst or Or expression with one or more And subexpressions
1895 (default=True)
1896 - warn_ungrouped_named_tokens_in_collection - flag to enable warnings when a results
1897 name is defined on a containing expression with ungrouped subexpressions that also
1898 have results names (default=True)
1899 - warn_name_set_on_empty_Forward - flag to enable warnings when a Forward is defined
1900 with a results name, but has no contents defined (default=False)
1901 - warn_on_multiple_string_args_to_oneof - flag to enable warnings when oneOf is
1902 incorrectly called with multiple str arguments (default=True)
1903 - enable_debug_on_named_expressions - flag to auto-enable debug on all subsequent
1904 calls to ParserElement.setName() (default=False)
1905
1906 warn_multiple_tokens_in_named_alternation is intended to help
1907 those who currently have set __compat__.collect_all_And_tokens to
1908 False as a workaround for using the pre-2.3.1 code with named
1909 MatchFirst or Or expressions containing an And expression.
1910
1911 - Added ParseResults.from_dict classmethod, to simplify creation
1912 of a ParseResults with results names using a dict, which may be nested.
1913 This makes it easy to add a sub-level of named items to the parsed
1914 tokens in a parse action.
1915
1916 - Added asKeyword argument (default=False) to oneOf, to force
1917 keyword-style matching on the generated expressions.
1918
1919 - ParserElement.runTests now accepts an optional 'file' argument to
1920 redirect test output to a file-like object (such as a StringIO,
1921 or opened file). Default is to write to sys.stdout.
1922
1923 - conditionAsParseAction is a helper method for constructing a
1924 parse action method from a predicate function that simply
1925 returns a boolean result. Useful for those places where a
1926 predicate cannot be added using addCondition, but must be
1927 converted to a parse action (such as in infixNotation). May be
1928 used as a decorator if default message and exception types
1929 can be used. See ParserElement.addCondition for more details
1930 about the expected signature and behavior for predicate condition
1931 methods.
1932
1933 - While investigating issue #93, I found that Or and
1934 addCondition could interact to select an alternative that
1935 is not the longest match. This is because Or first checks
1936 all alternatives for matches without running attached
1937 parse actions or conditions, orders by longest match, and
1938 then rechecks for matches with conditions and parse actions.
1939 Some expressions, when checking with conditions, may end
1940 up matching on a shorter token list than originally matched,
1941 but would be selected because of its original priority.
1942 This matching code has been expanded to do more extensive
1943 searching for matches when a second-pass check matches a
1944 smaller list than in the first pass.
1945
1946 - Fixed issue #87, a regression in indented block.
1947 Reported by Renz Bagaporo, who submitted a very nice repro
1948 example, which makes the bug-fixing process a lot easier,
1949 thanks!
1950
1951 - Fixed MemoryError issue #85 and #91 with str generation for
1952 Forwards. Thanks decalage2 and Harmon758 for your patience.
1953
1954 - Modified setParseAction to accept None as an argument,
1955 indicating that all previously-defined parse actions for the
1956 expression should be cleared.
1957
1958 - Modified pyparsing_common.real and sci_real to parse reals
1959 without leading integer digits before the decimal point,
1960 consistent with Python real number formats. Original PR #98
1961 submitted by ansobolev.
1962
1963 - Modified runTests to call postParse function before dumping out
1964 the parsed results - allows for postParse to add further results,
1965 such as indications of additional validation success/failure.
1966
1967 - Updated statemachine example: refactored state transitions to use
1968 overridden classmethods; added <statename>Mixin class to simplify
1969 definition of application classes that "own" the state object and
1970 delegate to it to model state-specific properties and behavior.
1971
1972 - Added example nested_markup.py, showing a simple wiki markup with
1973 nested markup directives, and illustrating the use of '...' for
1974 skipping over input to match the next expression. (This example
1975 uses syntax that is not valid under Python 2.)
1976
1977 - Rewrote delta_time.py example (renamed from deltaTime.py) to
1978 fix some omitted formats and upgrade to latest pyparsing idioms,
1979 beginning with writing an actual BNF.
1980
1981 - With the help and encouragement from several contributors, including
1982 Matěj Cepl and Cengiz Kaygusuz, I've started cleaning up the internal
1983 coding styles in core pyparsing, bringing it up to modern coding
1984 practices from pyparsing's early development days dating back to
1985 2003. Whitespace has been largely standardized along PEP8 guidelines,
1986 removing extra spaces around parentheses, and adding them around
1987 arithmetic operators and after colons and commas. I was going to hold
1988 off on doing this work until after 2.4.1, but after cleaning up a
1989 few trial classes, the difference was so significant that I continued
1990 on to the rest of the core code base. This should facilitate future
1991 work and submitted PRs, allowing them to focus on substantive code
1992 changes, and not get sidetracked by whitespace issues.
1993
1994
1995 Version 2.4.0 - April, 2019
1996 ---------------------------
1997 - Well, it looks like the API change that was introduced in 2.3.1 was more
1998 drastic than expected, so for a friendlier forward upgrade path, this
1999 release:
2000 . Bumps the current version number to 2.4.0, to reflect this
2001 incompatible change.
2002 . Adds a pyparsing.__compat__ object for specifying compatibility with
2003 future breaking changes.
2004 . Conditionalizes the API-breaking behavior, based on the value
2005 pyparsing.__compat__.collect_all_And_tokens. By default, this value
2006 will be set to True, reflecting the new bugfixed behavior. To set this
2007 value to False, add to your code:
2008
2009 import pyparsing
2010 pyparsing.__compat__.collect_all_And_tokens = False
2011
2012 . User code that is dependent on the pre-bugfix behavior can restore
2013 it by setting this value to False.
2014
2015 In 2.5 and later versions, the conditional code will be removed and
2016 setting the flag to True or False in these later versions will have no
2017 effect.
2018
2019 - Updated unitTests.py and simple_unit_tests.py to be compatible with
2020 "python setup.py test". To run tests using setup, do:
2021
2022 python setup.py test
2023 python setup.py test -s unitTests.suite
2024 python setup.py test -s simple_unit_tests.suite
2025
2026 Prompted by issue #83 and PR submitted by bdragon28, thanks.
2027
2028 - Fixed bug in runTests handling '\n' literals in quoted strings.
2029
2030 - Added tag_body attribute to the start tag expressions generated by
2031 makeHTMLTags, so that you can avoid using SkipTo to roll your own
2032 tag body expression:
2033
2034 a, aEnd = pp.makeHTMLTags('a')
2035 link = a + a.tag_body("displayed_text") + aEnd
2036 for t in s.searchString(html_page):
2037 print(t.displayed_text, '->', t.startA.href)
2038
2039 - indentedBlock failure handling was improved; PR submitted by TMiguelT,
2040 thanks!
2041
2042 - Address Py2 incompatibility in simpleUnitTests, plus explain() and
2043 Forward str() cleanup; PRs graciously provided by eswald.
2044
2045 - Fixed docstring with embedded '\w', which creates SyntaxWarnings in
2046 Py3.8, issue #80.
2047
2048 - Examples:
2049
2050 - Added example parser for rosettacode.org tutorial compiler.
2051
2052 - Added example to show how an HTML table can be parsed into a
2053 collection of Python lists or dicts, one per row.
2054
2055 - Updated SimpleSQL.py example to handle nested selects, reworked
2056 'where' expression to use infixNotation.
2057
2058 - Added include_preprocessor.py, similar to macroExpander.py.
2059
2060 - Examples using makeHTMLTags use new tag_body expression when
2061 retrieving a tag's body text.
2062
2063 - Updated examples that are runnable as unit tests:
2064
2065 python setup.py test -s examples.antlr_grammar_tests
2066 python setup.py test -s examples.test_bibparse
2067
2068
2069 Version 2.3.1 - January, 2019
2070 -----------------------------
2071 - POSSIBLE API CHANGE: this release fixes a bug when results names were
2072 attached to a MatchFirst or Or object containing an And object.
2073 Previously, a results name on an And object within an enclosing MatchFirst
2074 or Or could return just the first token in the And. Now, all the tokens
2075 matched by the And are correctly returned. This may result in subtle
2076 changes in the tokens returned if you have this condition in your pyparsing
2077 scripts.
2078
2079 - New staticmethod ParseException.explain() to help diagnose parse exceptions
2080 by showing the failing input line and the trace of ParserElements in
2081 the parser leading up to the exception. explain() returns a multiline
2082 string listing each element by name. (This is still an experimental
2083 method, and the method signature and format of the returned string may
2084 evolve over the next few releases.)
2085
2086 Example:
2087 # define a parser to parse an integer followed by an
2088 # alphabetic word
2089 expr = pp.Word(pp.nums).setName("int")
2090 + pp.Word(pp.alphas).setName("word")
2091 try:
2092 # parse a string with a numeric second value instead of alpha
2093 expr.parseString("123 355")
2094 except pp.ParseException as pe:
2095 print(pp.ParseException.explain(pe))
2096
2097 Prints:
2098 123 355
2099 ^
2100 ParseException: Expected word (at char 4), (line:1, col:5)
2101 __main__.ExplainExceptionTest
2102 pyparsing.And - {int word}
2103 pyparsing.Word - word
2104
2105 explain() will accept any exception type and will list the function
2106 names and parse expressions in the stack trace. This is especially
2107 useful when an exception is raised in a parse action.
2108
2109 Note: explain() is only supported under Python 3.
2110
2111 - Fix bug in dictOf which could match an empty sequence, making it
2112 infinitely loop if wrapped in a OneOrMore.
2113
2114 - Added unicode sets to pyparsing_unicode for Latin-A and Latin-B ranges.
2115
2116 - Added ability to define custom unicode sets as combinations of other sets
2117 using multiple inheritance.
2118
2119 class Turkish_set(pp.pyparsing_unicode.Latin1, pp.pyparsing_unicode.LatinA):
2120 pass
2121
2122 turkish_word = pp.Word(Turkish_set.alphas)
2123
2124 - Updated state machine import examples, with state machine demos for:
2125 . traffic light
2126 . library book checkin/checkout
2127 . document review/approval
2128
2129 In the traffic light example, you can use the custom 'statemachine' keyword
2130 to define the states for a traffic light, and have the state classes
2131 auto-generated for you:
2132
2133 statemachine TrafficLightState:
2134 Red -> Green
2135 Green -> Yellow
2136 Yellow -> Red
2137
2138 Similar for state machines with named transitions, like the library book
2139 state example:
2140
2141 statemachine LibraryBookState:
2142 New -(shelve)-> Available
2143 Available -(reserve)-> OnHold
2144 OnHold -(release)-> Available
2145 Available -(checkout)-> CheckedOut
2146 CheckedOut -(checkin)-> Available
2147
2148 Once the classes are defined, then additional Python code can reference those
2149 classes to add class attributes, instance methods, etc.
2150
2151 See the examples in examples/statemachine
2152
2153 - Added an example parser for the decaf language. This language is used in
2154 CS compiler classes in many colleges and universities.
2155
2156 - Fixup of docstrings to Sphinx format, inclusion of test files in the source
2157 package, and convert markdown to rst throughout the distribution, great job
2158 by Matěj Cepl!
2159
2160 - Expanded the whitespace characters recognized by the White class to include
2161 all unicode defined spaces. Suggested in Issue #51 by rtkjbillo.
2162
2163 - Added optional postParse argument to ParserElement.runTests() to add a
2164 custom callback to be called for test strings that parse successfully. Useful
2165 for running tests that do additional validation or processing on the parsed
2166 results. See updated chemicalFormulas.py example.
2167
2168 - Removed distutils fallback in setup.py. If installing the package fails,
2169 please update to the latest version of setuptools. Plus overall project code
2170 cleanup (CRLFs, whitespace, imports, etc.), thanks Jon Dufresne!
2171
2172 - Fix bug in CaselessKeyword, to make its behavior consistent with
2173 Keyword(caseless=True). Fixes Issue #65 reported by telesphore.
2174
2175
2176 Version 2.3.0 - October, 2018
2177 -----------------------------
2178 - NEW SUPPORT FOR UNICODE CHARACTER RANGES
2179 This release introduces the pyparsing_unicode namespace class, defining
2180 a series of language character sets to simplify the definition of alphas,
2181 nums, alphanums, and printables in the following language sets:
2182 . Arabic
2183 . Chinese
2184 . Cyrillic
2185 . Devanagari
2186 . Greek
2187 . Hebrew
2188 . Japanese (including Kanji, Katakana, and Hirigana subsets)
2189 . Korean
2190 . Latin1 (includes 7 and 8-bit Latin characters)
2191 . Thai
2192 . CJK (combination of Chinese, Japanese, and Korean sets)
2193
2194 For example, your code can define words using:
2195
2196 korean_word = Word(pyparsing_unicode.Korean.alphas)
2197
2198 See their use in the updated examples greetingInGreek.py and
2199 greetingInKorean.py.
2200
2201 This namespace class also offers access to these sets using their
2202 unicode identifiers.
2203
2204 - POSSIBLE API CHANGE: Fixed bug where a parse action that explicitly
2205 returned the input ParseResults could add another nesting level in
2206 the results if the current expression had a results name.
2207
2208 vals = pp.OneOrMore(pp.pyparsing_common.integer)("int_values")
2209
2210 def add_total(tokens):
2211 tokens['total'] = sum(tokens)
2212 return tokens # this line can be removed
2213
2214 vals.addParseAction(add_total)
2215 print(vals.parseString("244 23 13 2343").dump())
2216
2217 Before the fix, this code would print (note the extra nesting level):
2218
2219 [244, 23, 13, 2343]
2220 - int_values: [244, 23, 13, 2343]
2221 - int_values: [244, 23, 13, 2343]
2222 - total: 2623
2223 - total: 2623
2224
2225 With the fix, this code now prints:
2226
2227 [244, 23, 13, 2343]
2228 - int_values: [244, 23, 13, 2343]
2229 - total: 2623
2230
2231 This fix will change the structure of ParseResults returned if a
2232 program defines a parse action that returns the tokens that were
2233 sent in. This is not necessary, and statements like "return tokens"
2234 in the example above can be safely deleted prior to upgrading to
2235 this release, in order to avoid the bug and get the new behavior.
2236
2237 Reported by seron in Issue #22, nice catch!
2238
2239 - POSSIBLE API CHANGE: Fixed a related bug where a results name
2240 erroneously created a second level of hierarchy in the returned
2241 ParseResults. The intent for accumulating results names into ParseResults
2242 is that, in the absence of Group'ing, all names get merged into a
2243 common namespace. This allows us to write:
2244
2245 key_value_expr = (Word(alphas)("key") + '=' + Word(nums)("value"))
2246 result = key_value_expr.parseString("a = 100")
2247
2248 and have result structured as {"key": "a", "value": "100"}
2249 instead of [{"key": "a"}, {"value": "100"}].
2250
2251 However, if a named expression is used in a higher-level non-Group
2252 expression that *also* has a name, a false sub-level would be created
2253 in the namespace:
2254
2255 num = pp.Word(pp.nums)
2256 num_pair = ("[" + (num("A") + num("B"))("values") + "]")
2257 U = num_pair.parseString("[ 10 20 ]")
2258 print(U.dump())
2259
2260 Since there is no grouping, "A", "B", and "values" should all appear
2261 at the same level in the results, as:
2262
2263 ['[', '10', '20', ']']
2264 - A: '10'
2265 - B: '20'
2266 - values: ['10', '20']
2267
2268 Instead, an extra level of "A" and "B" show up under "values":
2269
2270 ['[', '10', '20', ']']
2271 - A: '10'
2272 - B: '20'
2273 - values: ['10', '20']
2274 - A: '10'
2275 - B: '20'
2276
2277 This bug has been fixed. Now, if this hierarchy is desired, then a
2278 Group should be added:
2279
2280 num_pair = ("[" + pp.Group(num("A") + num("B"))("values") + "]")
2281
2282 Giving:
2283
2284 ['[', ['10', '20'], ']']
2285 - values: ['10', '20']
2286 - A: '10'
2287 - B: '20'
2288
2289 But in no case should "A" and "B" appear in multiple levels. This bug-fix
2290 fixes that.
2291
2292 If you have current code which relies on this behavior, then add or remove
2293 Groups as necessary to get your intended results structure.
2294
2295 Reported by Athanasios Anastasiou.
2296
2297 - IndexError's raised in parse actions will get explicitly reraised
2298 as ParseExceptions that wrap the original IndexError. Since
2299 IndexError sometimes occurs as part of pyparsing's normal parsing
2300 logic, IndexErrors that are raised during a parse action may have
2301 gotten silently reinterpreted as parsing errors. To retain the
2302 information from the IndexError, these exceptions will now be
2303 raised as ParseExceptions that reference the original IndexError.
2304 This wrapping will only be visible when run under Python3, since it
2305 emulates "raise ... from ..." syntax.
2306
2307 Addresses Issue #4, reported by guswns0528.
2308
2309 - Added Char class to simplify defining expressions of a single
2310 character. (Char("abc") is equivalent to Word("abc", exact=1))
2311
2312 - Added class PrecededBy to perform lookbehind tests. PrecededBy is
2313 used in the same way as FollowedBy, passing in an expression that
2314 must occur just prior to the current parse location.
2315
2316 For fixed-length expressions like a Literal, Keyword, Char, or a
2317 Word with an `exact` or `maxLen` length given, `PrecededBy(expr)`
2318 is sufficient. For varying length expressions like a Word with no
2319 given maximum length, `PrecededBy` must be constructed with an
2320 integer `retreat` argument, as in
2321 `PrecededBy(Word(alphas, nums), retreat=10)`, to specify the maximum
2322 number of characters pyparsing must look backward to make a match.
2323 pyparsing will check all the values from 1 up to retreat characters
2324 back from the current parse location.
2325
2326 When stepping backwards through the input string, PrecededBy does
2327 *not* skip over whitespace.
2328
2329 PrecededBy can be created with a results name so that, even though
2330 it always returns an empty parse result, the result *can* include
2331 named results.
2332
2333 Idea first suggested in Issue #30 by Freakwill.
2334
2335 - Updated FollowedBy to accept expressions that contain named results,
2336 so that results names defined in the lookahead expression will be
2337 returned, even though FollowedBy always returns an empty list.
2338 Inspired by the same feature implemented in PrecededBy.
2339
2340
2341 Version 2.2.2 - September, 2018
2342 -------------------------------
2343 - Fixed bug in SkipTo, if a SkipTo expression that was skipping to
2344 an expression that returned a list (such as an And), and the
2345 SkipTo was saved as a named result, the named result could be
2346 saved as a ParseResults - should always be saved as a string.
2347 Issue #28, reported by seron.
2348
2349 - Added simple_unit_tests.py, as a collection of easy-to-follow unit
2350 tests for various classes and features of the pyparsing library.
2351 Primary intent is more to be instructional than actually rigorous
2352 testing. Complex tests can still be added in the unitTests.py file.
2353
2354 - New features added to the `Regex` class:
2355 - optional asGroupList parameter, returns all the capture groups as
2356 a list
2357 - optional asMatch parameter, returns the raw re.match result
2358 - new sub(repl) method, which adds a parse action calling
2359 re.sub(pattern, repl, parsed_result). Simplifies creating
2360 `Regex` expressions to be used with transformString. Like re.sub,
2361 repl may be an ordinary string (similar to using pyparsing's
2362 replaceWith), or may contain references to capture groups by group
2363 number, or may be a callable that takes an re match group and
2364 returns a string.
2365
2366 For instance:
2367 expr = pp.Regex(r"([Hh]\d):\s*(.*)").sub(r"<\1>\2</\1>")
2368 expr.transformString("h1: This is the title")
2369
2370 will return
2371 <h1>This is the title</h1>
2372
2373 - Fixed omission of LICENSE file in source tarball, also added
2374 CODE_OF_CONDUCT.md per GitHub community standards.
2375
2376
2377 Version 2.2.1 - September, 2018
2378 -------------------------------
2379 - Applied changes necessary to migrate hosting of pyparsing source
2380 over to GitHub. Many thanks for help and contributions from hugovk,
2381 jdufresne, and cngkaygusuz among others through this transition,
2382 sorry it took me so long!
2383
2384 - Fixed import of collections.abc to address DeprecationWarnings
2385 in Python 3.7.
2386
2387 - Updated oc.py example to support function calls in arithmetic
2388 expressions; fixed regex for '==' operator; and added packrat
2389 parsing. Raised on the pyparsing wiki by Boris Marin, thanks!
2390
2391 - Fixed bug in select_parser.py example, group_by_terms was not
2392 reported. Reported on SF bugs by Adam Groszer, thanks Adam!
2393
2394 - Added "Getting Started" section to the module docstring, to
2395 guide new users to the most common starting points in pyparsing's
2396 API.
2397
2398 - Fixed bug in Literal and Keyword classes, which erroneously
2399 raised IndexError instead of ParseException.
2400
2401
2402 Version 2.2.0 - March, 2017
2403 ---------------------------
2404 - Bumped minor version number to reflect compatibility issues with
2405 OneOrMore and ZeroOrMore bugfixes in 2.1.10. (2.1.10 fixed a bug
2406 that was introduced in 2.1.4, but the fix could break code
2407 written against 2.1.4 - 2.1.9.)
2408
2409 - Updated setup.py to address recursive import problems now
2410 that pyparsing is part of 'packaging' (used by setuptools).
2411 Patch submitted by Joshua Root, much thanks!
2412
2413 - Fixed KeyError issue reported by Yann Bizeul when using packrat
2414 parsing in the Graphite time series database, thanks Yann!
2415
2416 - Fixed incorrect usages of '\' in literals, as described in
2417 https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior
2418 Patch submitted by Ville Skyttä - thanks!
2419
2420 - Minor internal change when using '-' operator, to be compatible
2421 with ParserElement.streamline() method.
2422
2423 - Expanded infixNotation to accept a list or tuple of parse actions
2424 to attach to an operation.
2425
2426 - New unit test added for dill support for storing pyparsing parsers.
2427 Ordinary Python pickle can be used to pickle pyparsing parsers as
2428 long as they do not use any parse actions. The 'dill' module is an
2429 extension to pickle which *does* support pickling of attached
2430 parse actions.
2431
2432
2433 Version 2.1.10 - October, 2016
2434 -------------------------------
2435 - Fixed bug in reporting named parse results for ZeroOrMore
2436 expressions, thanks Ethan Nash for reporting this!
2437
2438 - Fixed behavior of LineStart to be much more predictable.
2439 LineStart can now be used to detect if the next parse position
2440 is col 1, factoring in potential leading whitespace (which would
2441 cause LineStart to fail). Also fixed a bug in col, which is
2442 used in LineStart, where '\n's were erroneously considered to
2443 be column 1.
2444
2445 - Added support for multiline test strings in runTests.
2446
2447 - Fixed bug in ParseResults.dump when keys were not strings.
2448 Also changed display of string values to show them in quotes,
2449 to help distinguish parsed numeric strings from parsed integers
2450 that have been converted to Python ints.
2451
2452
2453 Version 2.1.9 - September, 2016
2454 -------------------------------
2455 - Added class CloseMatch, a variation on Literal which matches
2456 "close" matches, that is, strings with at most 'n' mismatching
2457 characters.
2458
2459 - Fixed bug in Keyword.setDefaultKeywordChars(), reported by Kobayashi
2460 Shinji - nice catch, thanks!
2461
2462 - Minor API change in pyparsing_common. Renamed some of the common
2463 expressions to PEP8 format (to be consistent with the other
2464 pyparsing_common expressions):
2465 . signedInteger -> signed_integer
2466 . sciReal -> sci_real
2467
2468 Also, in trying to stem the API bloat of pyparsing, I've copied
2469 some of the global expressions and helper parse actions into
2470 pyparsing_common, with the originals to be deprecated and removed
2471 in a future release:
2472 . commaSeparatedList -> pyparsing_common.comma_separated_list
2473 . upcaseTokens -> pyparsing_common.upcaseTokens
2474 . downcaseTokens -> pyparsing_common.downcaseTokens
2475
2476 (I don't expect any other expressions, like the comment expressions,
2477 quotedString, or the Word-helping strings like alphas, nums, etc.
2478 to migrate to pyparsing_common - they are just too pervasive. As for
2479 the PEP8 vs camelCase naming, all the expressions are PEP8, while
2480 the parse actions in pyparsing_common are still camelCase. It's a
2481 small step - when pyparsing 3.0 comes around, everything will change
2482 to PEP8 snake case.)
2483
2484 - Fixed Python3 compatibility bug when using dict keys() and values()
2485 in ParseResults.getName().
2486
2487 - After some prodding, I've reworked the unitTests.py file for
2488 pyparsing over the past few releases. It uses some variations on
2489 unittest to handle my testing style. The test now:
2490 . auto-discovers its test classes (while maintining their order
2491 of definition)
2492 . suppresses voluminous 'print' output for tests that pass
2493
2494
2495 Version 2.1.8 - August, 2016
2496 ----------------------------
2497 - Fixed issue in the optimization to _trim_arity, when the full
2498 stacktrace is retrieved to determine if a TypeError is raised in
2499 pyparsing or in the caller's parse action. Code was traversing
2500 the full stacktrace, and potentially encountering UnicodeDecodeError.
2501
2502 - Fixed bug in ParserElement.inlineLiteralsUsing, causing infinite
2503 loop with Suppress.
2504
2505 - Fixed bug in Each, when merging named results from multiple
2506 expressions in a ZeroOrMore or OneOrMore. Also fixed bug when
2507 ZeroOrMore expressions were erroneously treated as required
2508 expressions in an Each expression.
2509
2510 - Added a few more inline doc examples.
2511
2512 - Improved use of runTests in several example scripts.
2513
2514
2515 Version 2.1.7 - August, 2016
2516 ----------------------------
2517 - Fixed regression reported by Andrea Censi (surfaced in PyContracts
2518 tests) when using ParseSyntaxExceptions (raised when using operator '-')
2519 with packrat parsing.
2520
2521 - Minor fix to oneOf, to accept all iterables, not just space-delimited
2522 strings and lists. (If you have a list or set of strings, it is
2523 not necessary to concat them using ' '.join to pass them to oneOf,
2524 oneOf will accept the list or set or generator directly.)
2525
2526
2527 Version 2.1.6 - August, 2016
2528 ----------------------------
2529 - *Major packrat upgrade*, inspired by patch provided by Tal Einat -
2530 many, many, thanks to Tal for working on this! Tal's tests show
2531 faster parsing performance (2X in some tests), *and* memory reduction
2532 from 3GB down to ~100MB! Requires no changes to existing code using
2533 packratting. (Uses OrderedDict, available in Python 2.7 and later.
2534 For Python 2.6 users, will attempt to import from ordereddict
2535 backport. If not present, will implement pure-Python Fifo dict.)
2536
2537 - Minor API change - to better distinguish between the flexible
2538 numeric types defined in pyparsing_common, I've changed "numeric"
2539 (which parsed numbers of different types and returned int for ints,
2540 float for floats, etc.) and "number" (which parsed numbers of int
2541 or float type, and returned all floats) to "number" and "fnumber"
2542 respectively. I hope the "f" prefix of "fnumber" will be a better
2543 indicator of its internal conversion of parsed values to floats,
2544 while the generic "number" is similar to the flexible number syntax
2545 in other languages. Also fixed a bug in pyparsing_common.numeric
2546 (now renamed to pyparsing_common.number), integers were parsed and
2547 returned as floats instead of being retained as ints.
2548
2549 - Fixed bug in upcaseTokens and downcaseTokens introduced in 2.1.5,
2550 when the parse action was used in conjunction with results names.
2551 Reported by Steven Arcangeli from the dql project, thanks for your
2552 patience, Steven!
2553
2554 - Major change to docs! After seeing some comments on reddit about
2555 general issue with docs of Python modules, and thinking that I'm a
2556 little overdue in doing some doc tuneup on pyparsing, I decided to
2557 following the suggestions of the redditor and add more inline examples
2558 to the pyparsing reference documentation. I hope this addition
2559 will clarify some of the more common questions people have, especially
2560 when first starting with pyparsing/Python.
2561
2562 - Deprecated ParseResults.asXML. I've never been too happy with this
2563 method, and it usually forces some unnatural code in the parsers in
2564 order to get decent tag names. The amount of guesswork that asXML
2565 has to do to try to match names with values should have been a red
2566 flag from day one. If you are using asXML, you will need to implement
2567 your own ParseResults->XML serialization. Or consider migrating to
2568 a more current format such as JSON (which is very easy to do:
2569 results_as_json = json.dumps(parse_result.asDict()) Hopefully, when
2570 I remove this code in a future version, I'll also be able to simplify
2571 some of the craziness in ParseResults, which IIRC was only there to try
2572 to make asXML work.
2573
2574 - Updated traceParseAction parse action decorator to show the repr
2575 of the input and output tokens, instead of the str format, since
2576 str has been simplified to just show the token list content.
2577
2578 (The change to ParseResults.__str__ occurred in pyparsing 2.0.4, but
2579 it seems that didn't make it into the release notes - sorry! Too
2580 many users, especially beginners, were confused by the
2581 "([token_list], {names_dict})" str format for ParseResults, thinking
2582 they were getting a tuple containing a list and a dict. The full form
2583 can be seen if using repr().)
2584
2585 For tracing tokens in and out of parse actions, the more complete
2586 repr form provides important information when debugging parse actions.
2587
2588
2589 Version 2.1.5 - June, 2016
2590 ------------------------------
2591 - Added ParserElement.split() generator method, similar to re.split().
2592 Includes optional arguments maxsplit (to limit the number of splits),
2593 and includeSeparators (to include the separating matched text in the
2594 returned output, default=False).
2595
2596 - Added a new parse action construction helper tokenMap, which will
2597 apply a function and optional arguments to each element in a
2598 ParseResults. So this parse action:
2599
2600 def lowercase_all(tokens):
2601 return [str(t).lower() for t in tokens]
2602 OneOrMore(Word(alphas)).setParseAction(lowercase_all)
2603
2604 can now be written:
2605
2606 OneOrMore(Word(alphas)).setParseAction(tokenMap(str.lower))
2607
2608 Also simplifies writing conversion parse actions like:
2609
2610 integer = Word(nums).setParseAction(lambda t: int(t[0]))
2611
2612 to just:
2613
2614 integer = Word(nums).setParseAction(tokenMap(int))
2615
2616 If additional arguments are necessary, they can be included in the
2617 call to tokenMap, as in:
2618
2619 hex_integer = Word(hexnums).setParseAction(tokenMap(int, 16))
2620
2621 - Added more expressions to pyparsing_common:
2622 . IPv4 and IPv6 addresses (including long, short, and mixed forms
2623 of IPv6)
2624 . MAC address
2625 . ISO8601 date and date time strings (with named fields for year, month, etc.)
2626 . UUID (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
2627 . hex integer (returned as int)
2628 . fraction (integer '/' integer, returned as float)
2629 . mixed integer (integer '-' fraction, or just fraction, returned as float)
2630 . stripHTMLTags (parse action to remove tags from HTML source)
2631 . parse action helpers convertToDate and convertToDatetime to do custom parse
2632 time conversions of parsed ISO8601 strings
2633
2634 - runTests now returns a two-tuple: success if all tests succeed,
2635 and an output list of each test and its output lines.
2636
2637 - Added failureTests argument (default=False) to runTests, so that
2638 tests can be run that are expected failures, and runTests' success
2639 value will return True only if all tests *fail* as expected. Also,
2640 parseAll now defaults to True.
2641
2642 - New example numerics.py, shows samples of parsing integer and real
2643 numbers using locale-dependent formats:
2644
2645 4.294.967.295,000
2646 4 294 967 295,000
2647 4,294,967,295.000
2648
2649
2650 Version 2.1.4 - May, 2016
2651 ------------------------------
2652 - Split out the '==' behavior in ParserElement, now implemented
2653 as the ParserElement.matches() method. Using '==' for string test
2654 purposes will be removed in a future release.
2655
2656 - Expanded capabilities of runTests(). Will now accept embedded
2657 comments (default is Python style, leading '#' character, but
2658 customizable). Comments will be emitted along with the tests and
2659 test output. Useful during test development, to create a test string
2660 consisting only of test case description comments separated by
2661 blank lines, and then fill in the test cases. Will also highlight
2662 ParseFatalExceptions with "(FATAL)".
2663
2664 - Added a 'pyparsing_common' class containing common/helpful little
2665 expressions such as integer, float, identifier, etc. I used this
2666 class as a sort of embedded namespace, to contain these helpers
2667 without further adding to pyparsing's namespace bloat.
2668
2669 - Minor enhancement to traceParseAction decorator, to retain the
2670 parse action's name for the trace output.
2671
2672 - Added optional 'fatal' keyword arg to addCondition, to indicate that
2673 a condition failure should halt parsing immediately.
2674
2675
2676 Version 2.1.3 - May, 2016
2677 ------------------------------
2678 - _trim_arity fix in 2.1.2 was very version-dependent on Py 3.5.0.
2679 Now works for Python 2.x, 3.3, 3.4, 3.5.0, and 3.5.1 (and hopefully
2680 beyond).
2681
2682
2683 Version 2.1.2 - May, 2016
2684 ------------------------------
2685 - Fixed bug in _trim_arity when pyparsing code is included in a
2686 PyInstaller, reported by maluwa.
2687
2688 - Fixed catastrophic regex backtracking in implementation of the
2689 quoted string expressions (dblQuotedString, sglQuotedString, and
2690 quotedString). Reported on the pyparsing wiki by webpentest,
2691 good catch! (Also tuned up some other expressions susceptible to the
2692 same backtracking problem, such as cStyleComment, cppStyleComment,
2693 etc.)
2694
2695
2696 Version 2.1.1 - March, 2016
2697 ---------------------------
2698 - Added support for assigning to ParseResults using slices.
2699
2700 - Fixed bug in ParseResults.toDict(), in which dict values were always
2701 converted to dicts, even if they were just unkeyed lists of tokens.
2702 Reported on SO by Gerald Thibault, thanks Gerald!
2703
2704 - Fixed bug in SkipTo when using failOn, reported by robyschek, thanks!
2705
2706 - Fixed bug in Each introduced in 2.1.0, reported by AND patch and
2707 unit test submitted by robyschek, well done!
2708
2709 - Removed use of functools.partial in replaceWith, as this creates
2710 an ambiguous signature for the generated parse action, which fails in
2711 PyPy. Reported by Evan Hubinger, thanks Evan!
2712
2713 - Added default behavior to QuotedString to convert embedded '\t', '\n',
2714 etc. characters to their whitespace counterparts. Found during Q&A
2715 exchange on SO with Maxim.
2716
2717
2718 Version 2.1.0 - February, 2016
2719 ------------------------------
2720 - Modified the internal _trim_arity method to distinguish between
2721 TypeError's raised while trying to determine parse action arity and
2722 those raised within the parse action itself. This will clear up those
2723 confusing "<lambda>() takes exactly 1 argument (0 given)" error
2724 messages when there is an actual TypeError in the body of the parse
2725 action. Thanks to all who have raised this issue in the past, and
2726 most recently to Michael Cohen, who sent in a proposed patch, and got
2727 me to finally tackle this problem.
2728
2729 - Added compatibility for pickle protocols 2-4 when pickling ParseResults.
2730 In Python 2.x, protocol 0 was the default, and protocol 2 did not work.
2731 In Python 3.x, protocol 3 is the default, so explicitly naming
2732 protocol 0 or 1 was required to pickle ParseResults. With this release,
2733 all protocols 0-4 are supported. Thanks for reporting this on StackOverflow,
2734 Arne Wolframm, and for providing a nice simple test case!
2735
2736 - Added optional 'stopOn' argument to ZeroOrMore and OneOrMore, to
2737 simplify breaking on stop tokens that would match the repetition
2738 expression.
2739
2740 It is a common problem to fail to look ahead when matching repetitive
2741 tokens if the sentinel at the end also matches the repetition
2742 expression, as when parsing "BEGIN aaa bbb ccc END" with:
2743
2744 "BEGIN" + OneOrMore(Word(alphas)) + "END"
2745
2746 Since "END" matches the repetition expression "Word(alphas)", it will
2747 never get parsed as the terminating sentinel. Up until now, this has
2748 to be resolved by the user inserting their own negative lookahead:
2749
2750 "BEGIN" + OneOrMore(~Literal("END") + Word(alphas)) + "END"
2751
2752 Using stopOn, they can more easily write:
2753
2754 "BEGIN" + OneOrMore(Word(alphas), stopOn="END") + "END"
2755
2756 The stopOn argument can be a literal string or a pyparsing expression.
2757 Inspired by a question by Lamakaha on StackOverflow (and many previous
2758 questions with the same negative-lookahead resolution).
2759
2760 - Added expression names for many internal and builtin expressions, to
2761 reduce name and error message overhead during parsing.
2762
2763 - Converted helper lambdas to functions to refactor and add docstring
2764 support.
2765
2766 - Fixed ParseResults.asDict() to correctly convert nested ParseResults
2767 values to dicts.
2768
2769 - Cleaned up some examples, fixed typo in fourFn.py identified by
2770 aristotle2600 on reddit.
2771
2772 - Removed keepOriginalText helper method, which was deprecated ages ago.
2773 Superceded by originalTextFor.
2774
2775 - Same for the Upcase class, which was long ago deprecated and replaced
2776 with the upcaseTokens method.
2777
2778
2779
2780 Version 2.0.7 - December, 2015
2781 ------------------------------
2782 - Simplified string representation of Forward class, to avoid memory
2783 and performance errors while building ParseException messages. Thanks,
2784 Will McGugan, Andrea Censi, and Martijn Vermaat for the bug reports and
2785 test code.
2786
2787 - Cleaned up additional issues from enhancing the error messages for
2788 Or and MatchFirst, handling Unicode values in expressions. Fixes Unicode
2789 encoding issues in Python 2, thanks to Evan Hubinger for the bug report.
2790
2791 - Fixed implementation of dir() for ParseResults - was leaving out all the
2792 defined methods and just adding the custom results names.
2793
2794 - Fixed bug in ignore() that was introduced in pyparsing 1.5.3, that would
2795 not accept a string literal as the ignore expression.
2796
2797 - Added new example parseTabularData.py to illustrate parsing of data
2798 formatted in columns, with detection of empty cells.
2799
2800 - Updated a number of examples to more current Python and pyparsing
2801 forms.
2802
2803
2804 Version 2.0.6 - November, 2015
2805 ------------------------------
2806 - Fixed a bug in Each when multiple Optional elements are present.
2807 Thanks for reporting this, whereswalden on SO.
2808
2809 - Fixed another bug in Each, when Optional elements have results names
2810 or parse actions, reported by Max Rothman - thank you, Max!
2811
2812 - Added optional parseAll argument to runTests, whether tests should
2813 require the entire input string to be parsed or not (similar to
2814 parseAll argument to parseString). Plus a little neaten-up of the
2815 output on Python 2 (no stray ()'s).
2816
2817 - Modified exception messages from MatchFirst and Or expressions. These
2818 were formerly misleading as they would only give the first or longest
2819 exception mismatch error message. Now the error message includes all
2820 the alternatives that were possible matches. Originally proposed by
2821 a pyparsing user, but I've lost the email thread - finally figured out
2822 a fairly clean way to do this.
2823
2824 - Fixed a bug in Or, when a parse action on an alternative raises an
2825 exception, other potentially matching alternatives were not always tried.
2826 Reported by TheVeryOmni on the pyparsing wiki, thanks!
2827
2828 - Fixed a bug to dump() introduced in 2.0.4, where list values were shown
2829 in duplicate.
2830
2831
2832 Version 2.0.5 - October, 2015
2833 -----------------------------
2834 - (&$(@#&$(@!!!! Some "print" statements snuck into pyparsing v2.0.4,
2835 breaking Python 3 compatibility! Fixed. Reported by jenshn, thanks!
2836
2837
2838 Version 2.0.4 - October, 2015
2839 -----------------------------
2840 - Added ParserElement.addCondition, to simplify adding parse actions
2841 that act primarily as filters. If the given condition evaluates False,
2842 pyparsing will raise a ParseException. The condition should be a method
2843 with the same method signature as a parse action, but should return a
2844 boolean. Suggested by Victor Porton, nice idea Victor, thanks!
2845
2846 - Slight mod to srange to accept unicode literals for the input string,
2847 such as "[а-яА-Я]" instead of "[\u0430-\u044f\u0410-\u042f]". Thanks
2848 to Alexandr Suchkov for the patch!
2849
2850 - Enhanced implementation of replaceWith.
2851
2852 - Fixed enhanced ParseResults.dump() method when the results consists
2853 only of an unnamed array of sub-structure results. Reported by Robin
2854 Siebler, thanks for your patience and persistence, Robin!
2855
2856 - Fixed bug in fourFn.py example code, where pi and e were defined using
2857 CaselessLiteral instead of CaselessKeyword. This was not a problem until
2858 adding a new function 'exp', and the leading 'e' of 'exp' was accidentally
2859 parsed as the mathematical constant 'e'. Nice catch, Tom Grydeland - thanks!
2860
2861 - Adopt new-fangled Python features, like decorators and ternary expressions,
2862 per suggestions from Williamzjc - thanks William! (Oh yeah, I'm not
2863 supporting Python 2.3 with this code any more...) Plus, some additional
2864 code fixes/cleanup - thanks again!
2865
2866 - Added ParserElement.runTests, a little test bench for quickly running
2867 an expression against a list of sample input strings. Basically, I got
2868 tired of writing the same test code over and over, and finally added it
2869 as a test point method on ParserElement.
2870
2871 - Added withClass helper method, a simplified version of withAttribute for
2872 the common but annoying case when defining a filter on a div's class -
2873 made difficult because 'class' is a Python reserved word.
2874
2875
2876 Version 2.0.3 - October, 2014
2877 -----------------------------
2878 - Fixed escaping behavior in QuotedString. Formerly, only quotation
2879 marks (or characters designated as quotation marks in the QuotedString
2880 constructor) would be escaped. Now all escaped characters will be
2881 escaped, and the escaping backslashes will be removed.
2882
2883 - Fixed regression in ParseResults.pop() - pop() was pretty much
2884 broken after I added *improvements* in 2.0.2. Reported by Iain
2885 Shelvington, thanks Iain!
2886
2887 - Fixed bug in And class when initializing using a generator.
2888
2889 - Enhanced ParseResults.dump() method to list out nested ParseResults that
2890 are unnamed arrays of sub-structures.
2891
2892 - Fixed UnboundLocalError under Python 3.4 in oneOf method, reported
2893 on Sourceforge by aldanor, thanks!
2894
2895 - Fixed bug in ParseResults __init__ method, when returning non-ParseResults
2896 types from parse actions that implement __eq__. Raised during discussion
2897 on the pyparsing wiki with cyrfer.
2898
2899
2900 Version 2.0.2 - April, 2014
2901 ---------------------------
2902 - Extended "expr(name)" shortcut (same as "expr.setResultsName(name)")
2903 to accept "expr()" as a shortcut for "expr.copy()".
2904
2905 - Added "locatedExpr(expr)" helper, to decorate any returned tokens
2906 with their location within the input string. Adds the results names
2907 locn_start and locn_end to the output parse results.
2908
2909 - Added "pprint()" method to ParseResults, to simplify troubleshooting
2910 and prettified output. Now instead of importing the pprint module
2911 and then writing "pprint.pprint(result)", you can just write
2912 "result.pprint()". This method also accepts additional positional and
2913 keyword arguments (such as indent, width, etc.), which get passed
2914 through directly to the pprint method
2915 (see https://docs.python.org/2/library/pprint.html#pprint.pprint).
2916
2917 - Removed deprecation warnings when using '<<' for Forward expression
2918 assignment. '<<=' is still preferred, but '<<' will be retained
2919 for cases where '<<=' operator is not suitable (such as in defining
2920 lambda expressions).
2921
2922 - Expanded argument compatibility for classes and functions that
2923 take list arguments, to now accept generators as well.
2924
2925 - Extended list-like behavior of ParseResults, adding support for
2926 append and extend. NOTE: if you have existing applications using
2927 these names as results names, you will have to access them using
2928 dict-style syntax: res["append"] and res["extend"]
2929
2930 - ParseResults emulates the change in list vs. iterator semantics for
2931 methods like keys(), values(), and items(). Under Python 2.x, these
2932 methods will return lists, under Python 3.x, these methods will
2933 return iterators.
2934
2935 - ParseResults now has a method haskeys() which returns True or False
2936 depending on whether any results names have been defined. This simplifies
2937 testing for the existence of results names under Python 3.x, which
2938 returns keys() as an iterator, not a list.
2939
2940 - ParseResults now supports both list and dict semantics for pop().
2941 If passed no argument or an integer argument, it will use list semantics
2942 and pop tokens from the list of parsed tokens. If passed a non-integer
2943 argument (most likely a string), it will use dict semantics and
2944 pop the corresponding value from any defined results names. A
2945 second default return value argument is supported, just as in
2946 dict.pop().
2947
2948 - Fixed bug in markInputline, thanks for reporting this, Matt Grant!
2949
2950 - Cleaned up my unit test environment, now runs with Python 2.6 and
2951 3.3.
2952
2953
2954 Version 2.0.1 - July, 2013
2955 --------------------------
2956 - Removed use of "nonlocal" that prevented using this version of
2957 pyparsing with Python 2.6 and 2.7. This will make it easier to
2958 install for packages that depend on pyparsing, under Python
2959 versions 2.6 and later. Those using older versions of Python
2960 will have to manually install pyparsing 1.5.7.
2961
2962 - Fixed implementation of <<= operator to return self; reported by
2963 Luc J. Bourhis, with patch fix by Mathias Mamsch - thanks, Luc
2964 and Mathias!
2965
2966
2967 Version 2.0.0 - November, 2012
2968 ------------------------------
2969 - Rather than release another combined Python 2.x/3.x release
2970 I've decided to start a new major version that is only
2971 compatible with Python 3.x (and consequently Python 2.7 as
2972 well due to backporting of key features). This version will
2973 be the main development path from now on, with little follow-on
2974 development on the 1.5.x path.
2975
2976 - Operator '<<' is now deprecated, in favor of operator '<<=' for
2977 attaching parsing expressions to Forward() expressions. This is
2978 being done to address precedence of operations problems with '<<'.
2979 Operator '<<' will be removed in a future version of pyparsing.
2980
2981
2982 Version 1.5.7 - November, 2012
2983 -----------------------------
2984 - NOTE: This is the last release of pyparsing that will try to
2985 maintain compatibility with Python versions < 2.6. The next
2986 release of pyparsing will be version 2.0.0, using new Python
2987 syntax that will not be compatible for Python version 2.5 or
2988 older.
2989
2990 - An awesome new example is included in this release, submitted
2991 by Luca DellOlio, for parsing ANTLR grammar definitions, nice
2992 work Luca!
2993
2994 - Fixed implementation of ParseResults.__str__ to use Pythonic
2995 ''.join() instead of repeated string concatenation. This
2996 purportedly has been a performance issue under PyPy.
2997
2998 - Fixed bug in ParseResults.__dir__ under Python 3, reported by
2999 Thomas Kluyver, thank you Thomas!
3000
3001 - Added ParserElement.inlineLiteralsUsing static method, to
3002 override pyparsing's default behavior of converting string
3003 literals to Literal instances, to use other classes (such
3004 as Suppress or CaselessLiteral).
3005
3006 - Added new operator '<<=', which will eventually replace '<<' for
3007 storing the contents of a Forward(). '<<=' does not have the same
3008 operator precedence problems that '<<' does.
3009
3010 - 'operatorPrecedence' is being renamed 'infixNotation' as a better
3011 description of what this helper function creates. 'operatorPrecedence'
3012 is deprecated, and will be dropped entirely in a future release.
3013
3014 - Added optional arguments lpar and rpar to operatorPrecedence, so that
3015 expressions that use it can override the default suppression of the
3016 grouping characters.
3017
3018 - Added support for using single argument builtin functions as parse
3019 actions. Now you can write 'expr.setParseAction(len)' and get back
3020 the length of the list of matched tokens. Supported builtins are:
3021 sum, len, sorted, reversed, list, tuple, set, any, all, min, and max.
3022 A script demonstrating this feature is included in the examples
3023 directory.
3024
3025 - Improved linking in generated docs, proposed on the pyparsing wiki
3026 by techtonik, thanks!
3027
3028 - Fixed a bug in the definition of 'alphas', which was based on the
3029 string.uppercase and string.lowercase "constants", which in fact
3030 *aren't* constant, but vary with locale settings. This could make
3031 parsers locale-sensitive in a subtle way. Thanks to Kef Schecter for
3032 his diligence in following through on reporting and monitoring
3033 this bugfix!
3034
3035 - Fixed a bug in the Py3 version of pyparsing, during exception
3036 handling with packrat parsing enabled, reported by Catherine
3037 Devlin - thanks Catherine!
3038
3039 - Fixed typo in ParseBaseException.__dir__, reported anonymously on
3040 the SourceForge bug tracker, thank you Pyparsing User With No Name.
3041
3042 - Fixed bug in srange when using '\x###' hex character codes.
3043
3044 - Added optional 'intExpr' argument to countedArray, so that you
3045 can define your own expression that will evaluate to an integer,
3046 to be used as the count for the following elements. Allows you
3047 to define a countedArray with the count given in hex, for example,
3048 by defining intExpr as "Word(hexnums).setParseAction(int(t[0],16))".
3049
3050
3051 Version 1.5.6 - June, 2011
3052 ----------------------------
3053 - Cleanup of parse action normalizing code, to be more version-tolerant,
3054 and robust in the face of future Python versions - much thanks to
3055 Raymond Hettinger for this rewrite!
3056
3057 - Removal of exception cacheing, addressing a memory leak condition
3058 in Python 3. Thanks to Michael Droettboom and the Cape Town PUG for
3059 their analysis and work on this problem!
3060
3061 - Fixed bug when using packrat parsing, where a previously parsed
3062 expression would duplicate subsequent tokens - reported by Frankie
3063 Ribery on stackoverflow, thanks!
3064
3065 - Added 'ungroup' helper method, to address token grouping done
3066 implicitly by And expressions, even if only one expression in the
3067 And actually returns any text - also inspired by stackoverflow
3068 discussion with Frankie Ribery!
3069
3070 - Fixed bug in srange, which accepted escaped hex characters of the
3071 form '\0x##', but should be '\x##'. Both forms will be supported
3072 for backwards compatibility.
3073
3074 - Enhancement to countedArray, accepting an optional expression to be
3075 used for matching the leading integer count - proposed by Mathias on
3076 the pyparsing mailing list, good idea!
3077
3078 - Added the Verilog parser to the provided set of examples, under the
3079 MIT license. While this frees up this parser for any use, if you find
3080 yourself using it in a commercial purpose, please consider making a
3081 charitable donation as described in the parser's header.
3082
3083 - Added the excludeChars argument to the Word class, to simplify defining
3084 a word composed of all characters in a large range except for one or
3085 two. Suggested by JesterEE on the pyparsing wiki.
3086
3087 - Added optional overlap parameter to scanString, to return overlapping
3088 matches found in the source text.
3089
3090 - Updated oneOf internal regular expression generation, with improved
3091 parse time performance.
3092
3093 - Slight performance improvement in transformString, removing empty
3094 strings from the list of string fragments built while scanning the
3095 source text, before calling ''.join. Especially useful when using
3096 transformString to strip out selected text.
3097
3098 - Enhanced form of using the "expr('name')" style of results naming,
3099 in lieu of calling setResultsName. If name ends with an '*', then
3100 this is equivalent to expr.setResultsName('name',listAllMatches=True).
3101
3102 - Fixed up internal list flattener to use iteration instead of recursion,
3103 to avoid stack overflow when transforming large files.
3104
3105 - Added other new examples:
3106 . protobuf parser - parses Google's protobuf language
3107 . btpyparse - a BibTex parser contributed by Matthew Brett,
3108 with test suite test_bibparse.py (thanks, Matthew!)
3109 . groupUsingListAllMatches.py - demo using trailing '*' for results
3110 names
3111
3112
3113 Version 1.5.5 - August, 2010
3114 ----------------------------
3115
3116 - Typo in Python3 version of pyparsing, "builtin" should be "builtins".
3117 (sigh)
3118
3119
3120 Version 1.5.4 - August, 2010
3121 ----------------------------
3122
3123 - Fixed __builtins__ and file references in Python 3 code, thanks to
3124 Greg Watson, saulspatz, sminos, and Mark Summerfield for reporting
3125 their Python 3 experiences.
3126
3127 - Added new example, apicheck.py, as a sample of scanning a Tcl-like
3128 language for functions with incorrect number of arguments (difficult
3129 to track down in Tcl languages). This example uses some interesting
3130 methods for capturing exceptions while scanning through source
3131 code.
3132
3133 - Added new example deltaTime.py, that takes everyday time references
3134 like "an hour from now", "2 days ago", "next Sunday at 2pm".
3135
3136
3137 Version 1.5.3 - June, 2010
3138 --------------------------
3139
3140 - ======= NOTE: API CHANGE!!!!!!! ===============
3141 With this release, and henceforward, the pyparsing module is
3142 imported as "pyparsing" on both Python 2.x and Python 3.x versions.
3143
3144 - Fixed up setup.py to auto-detect Python version and install the
3145 correct version of pyparsing - suggested by Alex Martelli,
3146 thanks, Alex! (and my apologies to all those who struggled with
3147 those spurious installation errors caused by my earlier
3148 fumblings!)
3149
3150 - Fixed bug on Python3 when using parseFile, getting bytes instead of
3151 a str from the input file.
3152
3153 - Fixed subtle bug in originalTextFor, if followed by
3154 significant whitespace (like a newline) - discovered by
3155 Francis Vidal, thanks!
3156
3157 - Fixed very sneaky bug in Each, in which Optional elements were
3158 not completely recognized as optional - found by Tal Weiss, thanks
3159 for your patience.
3160
3161 - Fixed off-by-1 bug in line() method when the first line of the
3162 input text was an empty line. Thanks to John Krukoff for submitting
3163 a patch!
3164
3165 - Fixed bug in transformString if grammar contains Group expressions,
3166 thanks to patch submitted by barnabas79, nice work!
3167
3168 - Fixed bug in originalTextFor in which trailing comments or otherwised
3169 ignored text got slurped in with the matched expression. Thanks to
3170 michael_ramirez44 on the pyparsing wiki for reporting this just in
3171 time to get into this release!
3172
3173 - Added better support for summing ParseResults, see the new example,
3174 parseResultsSumExample.py.
3175
3176 - Added support for composing a `Regex` using a compiled RE object;
3177 thanks to my new colleague, Mike Thornton!
3178
3179 - In version 1.5.2, I changed the way exceptions are raised in order
3180 to simplify the stacktraces reported during parsing. An anonymous
3181 user posted a bug report on SF that this behavior makes it difficult
3182 to debug some complex parsers, or parsers nested within parsers. In
3183 this release I've added a class attribute ParserElement.verbose_stacktrace,
3184 with a default value of False. If you set this to True, pyparsing will
3185 report stacktraces using the pre-1.5.2 behavior.
3186
3187 - New examples:
3188
3189 . pymicko.py, a MicroC compiler submitted by Zarko Zivanov.
3190 (Note: this example is separately licensed under the GPLv3,
3191 and requires Python 2.6 or higher.) Thank you, Zarko!
3192
3193 . oc.py, a subset C parser, using the BNF from the 1996 Obfuscated C
3194 Contest.
3195
3196 . stateMachine2.py, a modified version of stateMachine.py submitted
3197 by Matt Anderson, that is compatible with Python versions 2.7 and
3198 above - thanks so much, Matt!
3199
3200 . select_parser.py, a parser for reading SQLite SELECT statements,
3201 as specified at https://www.sqlite.org/lang_select.html this goes
3202 into much more detail than the simple SQL parser included in pyparsing's
3203 source code
3204
3205 . excelExpr.py, a *simplistic* first-cut at a parser for Excel
3206 expressions, which I originally posted on comp.lang.python in January,
3207 2010; beware, this parser omits many common Excel cases (addition of
3208 numbers represented as strings, references to named ranges)
3209
3210 . cpp_enum_parser.py, a nice little parser posted my Mark Tolonen on
3211 comp.lang.python in August, 2009 (redistributed here with Mark's
3212 permission). Thanks a bunch, Mark!
3213
3214 . partial_gene_match.py, a sample I posted to Stackoverflow.com,
3215 implementing a special variation on Literal that does "close" matching,
3216 up to a given number of allowed mismatches. The application was to
3217 find matching gene sequences, with allowance for one or two mismatches.
3218
3219 . tagCapture.py, a sample showing how to use a Forward placeholder to
3220 enforce matching of text parsed in a previous expression.
3221
3222 . matchPreviousDemo.py, simple demo showing how the matchPreviousLiteral
3223 helper method is used to match a previously parsed token.
3224
3225
3226 Version 1.5.2 - April, 2009
3227 ------------------------------
3228 - Added pyparsing_py3.py module, so that Python 3 users can use
3229 pyparsing by changing their pyparsing import statement to:
3230
3231 import pyparsing_py3
3232
3233 Thanks for help from Patrick Laban and his friend Geremy
3234 Condra on the pyparsing wiki.
3235
3236 - Removed __slots__ declaration on ParseBaseException, for
3237 compatibility with IronPython 2.0.1. Raised by David
3238 Lawler on the pyparsing wiki, thanks David!
3239
3240 - Fixed bug in SkipTo/failOn handling - caught by eagle eye
3241 cpennington on the pyparsing wiki!
3242
3243 - Fixed second bug in SkipTo when using the ignore constructor
3244 argument, reported by Catherine Devlin, thanks!
3245
3246 - Fixed obscure bug reported by Eike Welk when using a class
3247 as a ParseAction with an errant __getitem__ method.
3248
3249 - Simplified exception stack traces when reporting parse
3250 exceptions back to caller of parseString or parseFile - thanks
3251 to a tip from Peter Otten on comp.lang.python.
3252
3253 - Changed behavior of scanString to avoid infinitely looping on
3254 expressions that match zero-length strings. Prompted by a
3255 question posted by ellisonbg on the wiki.
3256
3257 - Enhanced classes that take a list of expressions (And, Or,
3258 MatchFirst, and Each) to accept generator expressions also.
3259 This can be useful when generating lists of alternative
3260 expressions, as in this case, where the user wanted to match
3261 any repetitions of '+', '*', '#', or '.', but not mixtures
3262 of them (that is, match '+++', but not '+-+'):
3263
3264 codes = "+*#."
3265 format = MatchFirst(Word(c) for c in codes)
3266
3267 Based on a problem posed by Denis Spir on the Python tutor
3268 list.
3269
3270 - Added new example eval_arith.py, which extends the example
3271 simpleArith.py to actually evaluate the parsed expressions.
3272
3273
3274 Version 1.5.1 - October, 2008
3275 -------------------------------
3276 - Added new helper method originalTextFor, to replace the use of
3277 the current keepOriginalText parse action. Now instead of
3278 using the parse action, as in:
3279
3280 fullName = Word(alphas) + Word(alphas)
3281 fullName.setParseAction(keepOriginalText)
3282
3283 (in this example, we used keepOriginalText to restore any white
3284 space that may have been skipped between the first and last
3285 names)
3286 You can now write:
3287
3288 fullName = originalTextFor(Word(alphas) + Word(alphas))
3289
3290 The implementation of originalTextFor is simpler and faster than
3291 keepOriginalText, and does not depend on using the inspect or
3292 imp modules.
3293
3294 - Added optional parseAll argument to parseFile, to be consistent
3295 with parseAll argument to parseString. Posted by pboucher on the
3296 pyparsing wiki, thanks!
3297
3298 - Added failOn argument to SkipTo, so that grammars can define
3299 literal strings or pyparsing expressions which, if found in the
3300 skipped text, will cause SkipTo to fail. Useful to prevent
3301 SkipTo from reading past terminating expression. Instigated by
3302 question posed by Aki Niimura on the pyparsing wiki.
3303
3304 - Fixed bug in nestedExpr if multi-character expressions are given
3305 for nesting delimiters. Patch provided by new pyparsing user,
3306 Hans-Martin Gaudecker - thanks, H-M!
3307
3308 - Removed dependency on xml.sax.saxutils.escape, and included
3309 internal implementation instead - proposed by Mike Droettboom on
3310 the pyparsing mailing list, thanks Mike! Also fixed erroneous
3311 mapping in replaceHTMLEntity of &quot; to ', now correctly maps
3312 to ". (Also added support for mapping &apos; to '.)
3313
3314 - Fixed typo in ParseResults.insert, found by Alejandro Dubrovsky,
3315 good catch!
3316
3317 - Added __dir__() methods to ParseBaseException and ParseResults,
3318 to support new dir() behavior in Py2.6 and Py3.0. If dir() is
3319 called on a ParseResults object, the returned list will include
3320 the base set of attribute names, plus any results names that are
3321 defined.
3322
3323 - Fixed bug in ParseResults.asXML(), in which the first named
3324 item within a ParseResults gets reported with an <ITEM> tag
3325 instead of with the correct results name.
3326
3327 - Fixed bug in '-' error stop, when '-' operator is used inside a
3328 Combine expression.
3329
3330 - Reverted generator expression to use list comprehension, for
3331 better compatibility with old versions of Python. Reported by
3332 jester/artixdesign on the SourceForge pyparsing discussion list.
3333
3334 - Fixed bug in parseString(parseAll=True), when the input string
3335 ends with a comment or whitespace.
3336
3337 - Fixed bug in LineStart and LineEnd that did not recognize any
3338 special whitespace chars defined using ParserElement.setDefault-
3339 WhitespaceChars, found while debugging an issue for Marek Kubica,
3340 thanks for the new test case, Marek!
3341
3342 - Made Forward class more tolerant of subclassing.
3343
3344
3345 Version 1.5.0 - June, 2008
3346 --------------------------
3347 This version of pyparsing includes work on two long-standing
3348 FAQ's: support for forcing parsing of the complete input string
3349 (without having to explicitly append StringEnd() to the grammar),
3350 and a method to improve the mechanism of detecting where syntax
3351 errors occur in an input string with various optional and
3352 alternative paths. This release also includes a helper method
3353 to simplify definition of indentation-based grammars. With
3354 these changes (and the past few minor updates), I thought it was
3355 finally time to bump the minor rev number on pyparsing - so
3356 1.5.0 is now available! Read on...
3357
3358 - AT LAST!!! You can now call parseString and have it raise
3359 an exception if the expression does not parse the entire
3360 input string. This has been an FAQ for a LONG time.
3361
3362 The parseString method now includes an optional parseAll
3363 argument (default=False). If parseAll is set to True, then
3364 the given parse expression must parse the entire input
3365 string. (This is equivalent to adding StringEnd() to the
3366 end of the expression.) The default value is False to
3367 retain backward compatibility.
3368
3369 Inspired by MANY requests over the years, most recently by
3370 ecir-hana on the pyparsing wiki!
3371
3372 - Added new operator '-' for composing grammar sequences. '-'
3373 behaves just like '+' in creating And expressions, but '-'
3374 is used to mark grammar structures that should stop parsing
3375 immediately and report a syntax error, rather than just
3376 backtracking to the last successful parse and trying another
3377 alternative. For instance, running the following code:
3378
3379 port_definition = Keyword("port") + '=' + Word(nums)
3380 entity_definition = Keyword("entity") + "{" +
3381 Optional(port_definition) + "}"
3382
3383 entity_definition.parseString("entity { port 100 }")
3384
3385 pyparsing fails to detect the missing '=' in the port definition.
3386 But, since this expression is optional, pyparsing then proceeds
3387 to try to match the closing '}' of the entity_definition. Not
3388 finding it, pyparsing reports that there was no '}' after the '{'
3389 character. Instead, we would like pyparsing to parse the 'port'
3390 keyword, and if not followed by an equals sign and an integer,
3391 to signal this as a syntax error.
3392
3393 This can now be done simply by changing the port_definition to:
3394
3395 port_definition = Keyword("port") - '=' + Word(nums)
3396
3397 Now after successfully parsing 'port', pyparsing must also find
3398 an equals sign and an integer, or it will raise a fatal syntax
3399 exception.
3400
3401 By judicious insertion of '-' operators, a pyparsing developer
3402 can have their grammar report much more informative syntax error
3403 messages.
3404
3405 Patches and suggestions proposed by several contributors on
3406 the pyparsing mailing list and wiki - special thanks to
3407 Eike Welk and Thomas/Poldy on the pyparsing wiki!
3408
3409 - Added indentedBlock helper method, to encapsulate the parse
3410 actions and indentation stack management needed to keep track of
3411 indentation levels. Use indentedBlock to define grammars for
3412 indentation-based grouping grammars, like Python's.
3413
3414 indentedBlock takes up to 3 parameters:
3415 - blockStatementExpr - expression defining syntax of statement
3416 that is repeated within the indented block
3417 - indentStack - list created by caller to manage indentation
3418 stack (multiple indentedBlock expressions
3419 within a single grammar should share a common indentStack)
3420 - indent - boolean indicating whether block must be indented
3421 beyond the current level; set to False for block of
3422 left-most statements (default=True)
3423
3424 A valid block must contain at least one indented statement.
3425
3426 - Fixed bug in nestedExpr in which ignored expressions needed
3427 to be set off with whitespace. Reported by Stefaan Himpe,
3428 nice catch!
3429
3430 - Expanded multiplication of an expression by a tuple, to
3431 accept tuple values of None:
3432 . expr*(n,None) or expr*(n,) is equivalent
3433 to expr*n + ZeroOrMore(expr)
3434 (read as "at least n instances of expr")
3435 . expr*(None,n) is equivalent to expr*(0,n)
3436 (read as "0 to n instances of expr")
3437 . expr*(None,None) is equivalent to ZeroOrMore(expr)
3438 . expr*(1,None) is equivalent to OneOrMore(expr)
3439
3440 Note that expr*(None,n) does not raise an exception if
3441 more than n exprs exist in the input stream; that is,
3442 expr*(None,n) does not enforce a maximum number of expr
3443 occurrences. If this behavior is desired, then write
3444 expr*(None,n) + ~expr
3445
3446 - Added None as a possible operator for operatorPrecedence.
3447 None signifies "no operator", as in multiplying m times x
3448 in "y=mx+b".
3449
3450 - Fixed bug in Each, reported by Michael Ramirez, in which the
3451 order of terms in the Each affected the parsing of the results.
3452 Problem was due to premature grouping of the expressions in
3453 the overall Each during grammar construction, before the
3454 complete Each was defined. Thanks, Michael!
3455
3456 - Also fixed bug in Each in which Optional's with default values
3457 were not getting the defaults added to the results of the
3458 overall Each expression.
3459
3460 - Fixed a bug in Optional in which results names were not
3461 assigned if a default value was supplied.
3462
3463 - Cleaned up Py3K compatibility statements, including exception
3464 construction statements, and better equivalence between _ustr
3465 and basestring, and __nonzero__ and __bool__.
3466
3467
3468 Version 1.4.11 - February, 2008
3469 -------------------------------
3470 - With help from Robert A. Clark, this version of pyparsing
3471 is compatible with Python 3.0a3. Thanks for the help,
3472 Robert!
3473
3474 - Added WordStart and WordEnd positional classes, to support
3475 expressions that must occur at the start or end of a word.
3476 Proposed by piranha on the pyparsing wiki, good idea!
3477
3478 - Added matchOnlyAtCol helper parser action, to simplify
3479 parsing log or data files that have optional fields that are
3480 column dependent. Inspired by a discussion thread with
3481 hubritic on comp.lang.python.
3482
3483 - Added withAttribute.ANY_VALUE as a match-all value when using
3484 withAttribute. Used to ensure that an attribute is present,
3485 without having to match on the actual attribute value.
3486
3487 - Added get() method to ParseResults, similar to dict.get().
3488 Suggested by new pyparsing user, Alejandro Dubrovksy, thanks!
3489
3490 - Added '==' short-cut to see if a given string matches a
3491 pyparsing expression. For instance, you can now write:
3492
3493 integer = Word(nums)
3494 if "123" == integer:
3495 # do something
3496
3497 print [ x for x in "123 234 asld".split() if x==integer ]
3498 # prints ['123', '234']
3499
3500 - Simplified the use of nestedExpr when using an expression for
3501 the opening or closing delimiters. Now the content expression
3502 will not have to explicitly negate closing delimiters. Found
3503 while working with dfinnie on GHOP Task #277, thanks!
3504
3505 - Fixed bug when defining ignorable expressions that are
3506 later enclosed in a wrapper expression (such as ZeroOrMore,
3507 OneOrMore, etc.) - found while working with Prabhu
3508 Gurumurthy, thanks Prahbu!
3509
3510 - Fixed bug in withAttribute in which keys were automatically
3511 converted to lowercase, making it impossible to match XML
3512 attributes with uppercase characters in them. Using with-
3513 Attribute requires that you reference attributes in all
3514 lowercase if parsing HTML, and in correct case when parsing
3515 XML.
3516
3517 - Changed '<<' operator on Forward to return None, since this
3518 is really used as a pseudo-assignment operator, not as a
3519 left-shift operator. By returning None, it is easier to
3520 catch faulty statements such as a << b | c, where precedence
3521 of operations causes the '|' operation to be performed
3522 *after* inserting b into a, so no alternation is actually
3523 implemented. The correct form is a << (b | c). With this
3524 change, an error will be reported instead of silently
3525 clipping the alternative term. (Note: this may break some
3526 existing code, but if it does, the code had a silent bug in
3527 it anyway.) Proposed by wcbarksdale on the pyparsing wiki,
3528 thanks!
3529
3530 - Several unit tests were added to pyparsing's regression
3531 suite, courtesy of the Google Highly-Open Participation
3532 Contest. Thanks to all who administered and took part in
3533 this event!
3534
3535
3536 Version 1.4.10 - December 9, 2007
3537 ---------------------------------
3538 - Fixed bug introduced in v1.4.8, parse actions were called for
3539 intermediate operator levels, not just the deepest matching
3540 operation level. Again, big thanks to Torsten Marek for
3541 helping isolate this problem!
3542
3543
3544 Version 1.4.9 - December 8, 2007
3545 --------------------------------
3546 - Added '*' multiplication operator support when creating
3547 grammars, accepting either an integer, or a two-integer
3548 tuple multiplier, as in:
3549 ipAddress = Word(nums) + ('.'+Word(nums))*3
3550 usPhoneNumber = Word(nums) + ('-'+Word(nums))*(1,2)
3551 If multiplying by a tuple, the two integer values represent
3552 min and max multiples. Suggested by Vincent of eToy.com,
3553 great idea, Vincent!
3554
3555 - Fixed bug in nestedExpr, original version was overly greedy!
3556 Thanks to Michael Ramirez for raising this issue.
3557
3558 - Fixed internal bug in ParseResults - when an item was deleted,
3559 the key indices were not updated. Thanks to Tim Mitchell for
3560 posting a bugfix patch to the SF bug tracking system!
3561
3562 - Fixed internal bug in operatorPrecedence - when the results of
3563 a right-associative term were sent to a parse action, the wrong
3564 tokens were sent. Reported by Torsten Marek, nice job!
3565
3566 - Added pop() method to ParseResults. If pop is called with an
3567 integer or with no arguments, it will use list semantics and
3568 update the ParseResults' list of tokens. If pop is called with
3569 a non-integer (a string, for instance), then it will use dict
3570 semantics and update the ParseResults' internal dict.
3571 Suggested by Donn Ingle, thanks Donn!
3572
3573 - Fixed quoted string built-ins to accept '\xHH' hex characters
3574 within the string.
3575
3576
3577 Version 1.4.8 - October, 2007
3578 -----------------------------
3579 - Added new helper method nestedExpr to easily create expressions
3580 that parse lists of data in nested parentheses, braces, brackets,
3581 etc.
3582
3583 - Added withAttribute parse action helper, to simplify creating
3584 filtering parse actions to attach to expressions returned by
3585 makeHTMLTags and makeXMLTags. Use withAttribute to qualify a
3586 starting tag with one or more required attribute values, to avoid
3587 false matches on common tags such as <TD> or <DIV>.
3588
3589 - Added new examples nested.py and withAttribute.py to demonstrate
3590 the new features.
3591
3592 - Added performance speedup to grammars using operatorPrecedence,
3593 instigated by Stefan Reichör - thanks for the feedback, Stefan!
3594
3595 - Fixed bug/typo when deleting an element from a ParseResults by
3596 using the element's results name.
3597
3598 - Fixed whitespace-skipping bug in wrapper classes (such as Group,
3599 Suppress, Combine, etc.) and when using setDebug(), reported by
3600 new pyparsing user dazzawazza on SourceForge, nice job!
3601
3602 - Added restriction to prevent defining Word or CharsNotIn expressions
3603 with minimum length of 0 (should use Optional if this is desired),
3604 and enhanced docstrings to reflect this limitation. Issue was
3605 raised by Joey Tallieu, who submitted a patch with a slightly
3606 different solution. Thanks for taking the initiative, Joey, and
3607 please keep submitting your ideas!
3608
3609 - Fixed bug in makeHTMLTags that did not detect HTML tag attributes
3610 with no '= value' portion (such as "<td nowrap>"), reported by
3611 hamidh on the pyparsing wiki - thanks!
3612
3613 - Fixed minor bug in makeHTMLTags and makeXMLTags, which did not
3614 accept whitespace in closing tags.
3615
3616
3617 Version 1.4.7 - July, 2007
3618 --------------------------
3619 - NEW NOTATION SHORTCUT: ParserElement now accepts results names using
3620 a notational shortcut, following the expression with the results name
3621 in parentheses. So this:
3622
3623 stats = "AVE:" + realNum.setResultsName("average") + \
3624 "MIN:" + realNum.setResultsName("min") + \
3625 "MAX:" + realNum.setResultsName("max")
3626
3627 can now be written as this:
3628
3629 stats = "AVE:" + realNum("average") + \
3630 "MIN:" + realNum("min") + \
3631 "MAX:" + realNum("max")
3632
3633 The intent behind this change is to make it simpler to define results
3634 names for significant fields within the expression, while keeping
3635 the grammar syntax clean and uncluttered.
3636
3637 - Fixed bug when packrat parsing is enabled, with cached ParseResults
3638 being updated by subsequent parsing. Reported on the pyparsing
3639 wiki by Kambiz, thanks!
3640
3641 - Fixed bug in operatorPrecedence for unary operators with left
3642 associativity, if multiple operators were given for the same term.
3643
3644 - Fixed bug in example simpleBool.py, corrected precedence of "and" vs.
3645 "or" operations.
3646
3647 - Fixed bug in Dict class, in which keys were converted to strings
3648 whether they needed to be or not. Have narrowed this logic to
3649 convert keys to strings only if the keys are ints (which would
3650 confuse __getitem__ behavior for list indexing vs. key lookup).
3651
3652 - Added ParserElement method setBreak(), which will invoke the pdb
3653 module's set_trace() function when this expression is about to be
3654 parsed.
3655
3656 - Fixed bug in StringEnd in which reading off the end of the input
3657 string raises an exception - should match. Resolved while
3658 answering a question for Shawn on the pyparsing wiki.
3659
3660
3661 Version 1.4.6 - April, 2007
3662 ---------------------------
3663 - Simplified constructor for ParseFatalException, to support common
3664 exception construction idiom:
3665 raise ParseFatalException, "unexpected text: 'Spanish Inquisition'"
3666
3667 - Added method getTokensEndLoc(), to be called from within a parse action,
3668 for those parse actions that need both the starting *and* ending
3669 location of the parsed tokens within the input text.
3670
3671 - Enhanced behavior of keepOriginalText so that named parse fields are
3672 preserved, even though tokens are replaced with the original input
3673 text matched by the current expression. Also, cleaned up the stack
3674 traversal to be more robust. Suggested by Tim Arnold - thanks, Tim!
3675
3676 - Fixed subtle bug in which countedArray (and similar dynamic
3677 expressions configured in parse actions) failed to match within Or,
3678 Each, FollowedBy, or NotAny. Reported by Ralf Vosseler, thanks for
3679 your patience, Ralf!
3680
3681 - Fixed Unicode bug in upcaseTokens and downcaseTokens parse actions,
3682 scanString, and default debugging actions; reported (and patch submitted)
3683 by Nikolai Zamkovoi, spasibo!
3684
3685 - Fixed bug when saving a tuple as a named result. The returned
3686 token list gave the proper tuple value, but accessing the result by
3687 name only gave the first element of the tuple. Reported by
3688 Poromenos, nice catch!
3689
3690 - Fixed bug in makeHTMLTags/makeXMLTags, which failed to match tag
3691 attributes with namespaces.
3692
3693 - Fixed bug in SkipTo when setting include=True, to have the skipped-to
3694 tokens correctly included in the returned data. Reported by gunars on
3695 the pyparsing wiki, thanks!
3696
3697 - Fixed typobug in OnceOnly.reset method, omitted self argument.
3698 Submitted by eike welk, thanks for the lint-picking!
3699
3700 - Added performance enhancement to Forward class, suggested by
3701 akkartik on the pyparsing Wiki discussion, nice work!
3702
3703 - Added optional asKeyword to Word constructor, to indicate that the
3704 given word pattern should be matched only as a keyword, that is, it
3705 should only match if it is within word boundaries.
3706
3707 - Added S-expression parser to examples directory.
3708
3709 - Added macro substitution example to examples directory.
3710
3711 - Added holaMundo.py example, excerpted from Marco Alfonso's blog -
3712 muchas gracias, Marco!
3713
3714 - Modified internal cyclic references in ParseResults to use weakrefs;
3715 this should help reduce the memory footprint of large parsing
3716 programs, at some cost to performance (3-5%). Suggested by bca48150 on
3717 the pyparsing wiki, thanks!
3718
3719 - Enhanced the documentation describing the vagaries and idiosyncrasies
3720 of parsing strings with embedded tabs, and the impact on:
3721 . parse actions
3722 . scanString
3723 . col and line helper functions
3724 (Suggested by eike welk in response to some unexplained inconsistencies
3725 between parsed location and offsets in the input string.)
3726
3727 - Cleaned up internal decorators to preserve function names,
3728 docstrings, etc.
3729
3730
3731 Version 1.4.5 - December, 2006
3732 ------------------------------
3733 - Removed debugging print statement from QuotedString class. Sorry
3734 for not stripping this out before the 1.4.4 release!
3735
3736 - A significant performance improvement, the first one in a while!
3737 For my Verilog parser, this version of pyparsing is about double the
3738 speed - YMMV.
3739
3740 - Added support for pickling of ParseResults objects. (Reported by
3741 Jeff Poole, thanks Jeff!)
3742
3743 - Fixed minor bug in makeHTMLTags that did not recognize tag attributes
3744 with embedded '-' or '_' characters. Also, added support for
3745 passing expressions to makeHTMLTags and makeXMLTags, and used this
3746 feature to define the globals anyOpenTag and anyCloseTag.
3747
3748 - Fixed error in alphas8bit, I had omitted the y-with-umlaut character.
3749
3750 - Added punc8bit string to complement alphas8bit - it contains all the
3751 non-alphabetic, non-blank 8-bit characters.
3752
3753 - Added commonHTMLEntity expression, to match common HTML "ampersand"
3754 codes, such as "&lt;", "&gt;", "&amp;", "&nbsp;", and "&quot;". This
3755 expression also defines a results name 'entity', which can be used
3756 to extract the entity field (that is, "lt", "gt", etc.). Also added
3757 built-in parse action replaceHTMLEntity, which can be attached to
3758 commonHTMLEntity to translate "&lt;", "&gt;", "&amp;", "&nbsp;", and
3759 "&quot;" to "<", ">", "&", " ", and "'".
3760
3761 - Added example, htmlStripper.py, that strips HTML tags and scripts
3762 from HTML pages. It also translates common HTML entities to their
3763 respective characters.
3764
3765
3766 Version 1.4.4 - October, 2006
3767 -------------------------------
3768 - Fixed traceParseAction decorator to also trap and record exception
3769 returns from parse actions, and to handle parse actions with 0,
3770 1, 2, or 3 arguments.
3771
3772 - Enhanced parse action normalization to support using classes as
3773 parse actions; that is, the class constructor is called at parse
3774 time and the __init__ function is called with 0, 1, 2, or 3
3775 arguments. If passing a class as a parse action, the __init__
3776 method must use one of the valid parse action parameter list
3777 formats. (This technique is useful when using pyparsing to compile
3778 parsed text into a series of application objects - see the new
3779 example simpleBool.py.)
3780
3781 - Fixed bug in ParseResults when setting an item using an integer
3782 index. (Reported by Christopher Lambacher, thanks!)
3783
3784 - Fixed whitespace-skipping bug, patch submitted by Paolo Losi -
3785 grazie, Paolo!
3786
3787 - Fixed bug when a Combine contained an embedded Forward expression,
3788 reported by cie on the pyparsing wiki - good catch!
3789
3790 - Fixed listAllMatches bug, when a listAllMatches result was
3791 nested within another result. (Reported by don pasquale on
3792 comp.lang.python, well done!)
3793
3794 - Fixed bug in ParseResults items() method, when returning an item
3795 marked as listAllMatches=True
3796
3797 - Fixed bug in definition of cppStyleComment (and javaStyleComment)
3798 in which '//' line comments were not continued to the next line
3799 if the line ends with a '\'. (Reported by eagle-eyed Ralph
3800 Corderoy!)
3801
3802 - Optimized re's for cppStyleComment and quotedString for better
3803 re performance - also provided by Ralph Corderoy, thanks!
3804
3805 - Added new example, indentedGrammarExample.py, showing how to
3806 define a grammar using indentation to show grouping (as Python
3807 does for defining statement nesting). Instigated by an e-mail
3808 discussion with Andrew Dalke, thanks Andrew!
3809
3810 - Added new helper operatorPrecedence (based on e-mail list discussion
3811 with Ralph Corderoy and Paolo Losi), to facilitate definition of
3812 grammars for expressions with unary and binary operators. For
3813 instance, this grammar defines a 6-function arithmetic expression
3814 grammar, with unary plus and minus, proper operator precedence,and
3815 right- and left-associativity:
3816
3817 expr = operatorPrecedence( operand,
3818 [("!", 1, opAssoc.LEFT),
3819 ("^", 2, opAssoc.RIGHT),
3820 (oneOf("+ -"), 1, opAssoc.RIGHT),
3821 (oneOf("* /"), 2, opAssoc.LEFT),
3822 (oneOf("+ -"), 2, opAssoc.LEFT),]
3823 )
3824
3825 Also added example simpleArith.py and simpleBool.py to provide
3826 more detailed code samples using this new helper method.
3827
3828 - Added new helpers matchPreviousLiteral and matchPreviousExpr, for
3829 creating adaptive parsing expressions that match the same content
3830 as was parsed in a previous parse expression. For instance:
3831
3832 first = Word(nums)
3833 matchExpr = first + ":" + matchPreviousLiteral(first)
3834
3835 will match "1:1", but not "1:2". Since this matches at the literal
3836 level, this will also match the leading "1:1" in "1:10".
3837
3838 In contrast:
3839
3840 first = Word(nums)
3841 matchExpr = first + ":" + matchPreviousExpr(first)
3842
3843 will *not* match the leading "1:1" in "1:10"; the expressions are
3844 evaluated first, and then compared, so "1" is compared with "10".
3845
3846 - Added keepOriginalText parse action. Sometimes pyparsing's
3847 whitespace-skipping leaves out too much whitespace. Adding this
3848 parse action will restore any internal whitespace for a parse
3849 expression. This is especially useful when defining expressions
3850 for scanString or transformString applications.
3851
3852 - Added __add__ method for ParseResults class, to better support
3853 using Python sum built-in for summing ParseResults objects returned
3854 from scanString.
3855
3856 - Added reset method for the new OnlyOnce class wrapper for parse
3857 actions (to allow a grammar to be used multiple times).
3858
3859 - Added optional maxMatches argument to scanString and searchString,
3860 to short-circuit scanning after 'n' expression matches are found.
3861
3862
3863 Version 1.4.3 - July, 2006
3864 ------------------------------
3865 - Fixed implementation of multiple parse actions for an expression
3866 (added in 1.4.2).
3867 . setParseAction() reverts to its previous behavior, setting
3868 one (or more) actions for an expression, overwriting any
3869 action or actions previously defined
3870 . new method addParseAction() appends one or more parse actions
3871 to the list of parse actions attached to an expression
3872 Now it is harder to accidentally append parse actions to an
3873 expression, when what you wanted to do was overwrite whatever had
3874 been defined before. (Thanks, Jean-Paul Calderone!)
3875
3876 - Simplified interface to parse actions that do not require all 3
3877 parse action arguments. Very rarely do parse actions require more
3878 than just the parsed tokens, yet parse actions still require all
3879 3 arguments including the string being parsed and the location
3880 within the string where the parse expression was matched. With this
3881 release, parse actions may now be defined to be called as:
3882 . fn(string,locn,tokens) (the current form)
3883 . fn(locn,tokens)
3884 . fn(tokens)
3885 . fn()
3886 The setParseAction and addParseAction methods will internally decorate
3887 the provided parse actions with compatible wrappers to conform to
3888 the full (string,locn,tokens) argument sequence.
3889
3890 - REMOVED SUPPORT FOR RETURNING PARSE LOCATION FROM A PARSE ACTION.
3891 I announced this in March, 2004, and gave a final warning in the last
3892 release. Now you can return a tuple from a parse action, and it will
3893 be treated like any other return value (i.e., the tuple will be
3894 substituted for the incoming tokens passed to the parse action,
3895 which is useful when trying to parse strings into tuples).
3896
3897 - Added setFailAction method, taking a callable function fn that
3898 takes the arguments fn(s,loc,expr,err) where:
3899 . s - string being parsed
3900 . loc - location where expression match was attempted and failed
3901 . expr - the parse expression that failed
3902 . err - the exception thrown
3903 The function returns no values. It may throw ParseFatalException
3904 if it is desired to stop parsing immediately.
3905 (Suggested by peter21081944 on wikispaces.com)
3906
3907 - Added class OnlyOnce as helper wrapper for parse actions. OnlyOnce
3908 only permits a parse action to be called one time, after which
3909 all subsequent calls throw a ParseException.
3910
3911 - Added traceParseAction decorator to help debug parse actions.
3912 Simply insert "@traceParseAction" ahead of the definition of your
3913 parse action, and each invocation will be displayed, along with
3914 incoming arguments, and returned value.
3915
3916 - Fixed bug when copying ParserElements using copy() or
3917 setResultsName(). (Reported by Dan Thill, great catch!)
3918
3919 - Fixed bug in asXML() where token text contains <, >, and &
3920 characters - generated XML now escapes these as &lt;, &gt; and
3921 &amp;. (Reported by Jacek Sieka, thanks!)
3922
3923 - Fixed bug in SkipTo() when searching for a StringEnd(). (Reported
3924 by Pete McEvoy, thanks Pete!)
3925
3926 - Fixed "except Exception" statements, the most critical added as part
3927 of the packrat parsing enhancement. (Thanks, Erick Tryzelaar!)
3928
3929 - Fixed end-of-string infinite looping on LineEnd and StringEnd
3930 expressions. (Thanks again to Erick Tryzelaar.)
3931
3932 - Modified setWhitespaceChars to return self, to be consistent with
3933 other ParserElement modifiers. (Suggested by Erick Tryzelaar.)
3934
3935 - Fixed bug/typo in new ParseResults.dump() method.
3936
3937 - Fixed bug in searchString() method, in which only the first token of
3938 an expression was returned. searchString() now returns a
3939 ParseResults collection of all search matches.
3940
3941 - Added example program removeLineBreaks.py, a string transformer that
3942 converts text files with hard line-breaks into one with line breaks
3943 only between paragraphs.
3944
3945 - Added example program listAllMatches.py, to illustrate using the
3946 listAllMatches option when specifying results names (also shows new
3947 support for passing lists to oneOf).
3948
3949 - Added example program linenoExample.py, to illustrate using the
3950 helper methods lineno, line, and col, and returning objects from a
3951 parse action.
3952
3953 - Added example program parseListString.py, to which can parse the
3954 string representation of a Python list back into a true list. Taken
3955 mostly from my PyCon presentation examples, but now with support
3956 for tuple elements, too!
3957
3958
3959
3960 Version 1.4.2 - April 1, 2006 (No foolin'!)
3961 -------------------------------------------
3962 - Significant speedup from memoizing nested expressions (a technique
3963 known as "packrat parsing"), thanks to Chris Lesniewski-Laas! Your
3964 mileage may vary, but my Verilog parser almost doubled in speed to
3965 over 600 lines/sec!
3966
3967 This speedup may break existing programs that use parse actions that
3968 have side-effects. For this reason, packrat parsing is disabled when
3969 you first import pyparsing. To activate the packrat feature, your
3970 program must call the class method ParserElement.enablePackrat(). If
3971 your program uses psyco to "compile as you go", you must call
3972 enablePackrat before calling psyco.full(). If you do not do this,
3973 Python will crash. For best results, call enablePackrat() immediately
3974 after importing pyparsing.
3975
3976 - Added new helper method countedArray(expr), for defining patterns that
3977 start with a leading integer to indicate the number of array elements,
3978 followed by that many elements, matching the given expr parse
3979 expression. For instance, this two-liner:
3980 wordArray = countedArray(Word(alphas))
3981 print wordArray.parseString("3 Practicality beats purity")[0]
3982 returns the parsed array of words:
3983 ['Practicality', 'beats', 'purity']
3984 The leading token '3' is suppressed, although it is easily obtained
3985 from the length of the returned array.
3986 (Inspired by e-mail discussion with Ralf Vosseler.)
3987
3988 - Added support for attaching multiple parse actions to a single
3989 ParserElement. (Suggested by Dan "Dang" Griffith - nice idea, Dan!)
3990
3991 - Added support for asymmetric quoting characters in the recently-added
3992 QuotedString class. Now you can define your own quoted string syntax
3993 like "<<This is a string in double angle brackets.>>". To define
3994 this custom form of QuotedString, your code would define:
3995 dblAngleQuotedString = QuotedString('<<',endQuoteChar='>>')
3996 QuotedString also supports escaped quotes, escape character other
3997 than '\', and multiline.
3998
3999 - Changed the default value returned internally by Optional, so that
4000 None can be used as a default value. (Suggested by Steven Bethard -
4001 I finally saw the light!)
4002
4003 - Added dump() method to ParseResults, to make it easier to list out
4004 and diagnose values returned from calling parseString.
4005
4006 - A new example, a search query string parser, submitted by Steven
4007 Mooij and Rudolph Froger - a very interesting application, thanks!
4008
4009 - Added an example that parses the BNF in Python's Grammar file, in
4010 support of generating Python grammar documentation. (Suggested by
4011 J H Stovall.)
4012
4013 - A new example, submitted by Tim Cera, of a flexible parser module,
4014 using a simple config variable to adjust parsing for input formats
4015 that have slight variations - thanks, Tim!
4016
4017 - Added an example for parsing Roman numerals, showing the capability
4018 of parse actions to "compile" Roman numerals into their integer
4019 values during parsing.
4020
4021 - Added a new docs directory, for additional documentation or help.
4022 Currently, this includes the text and examples from my recent
4023 presentation at PyCon.
4024
4025 - Fixed another typo in CaselessKeyword, thanks Stefan Behnel.
4026
4027 - Expanded oneOf to also accept tuples, not just lists. This really
4028 should be sufficient...
4029
4030 - Added deprecation warnings when tuple is returned from a parse action.
4031 Looking back, I see that I originally deprecated this feature in March,
4032 2004, so I'm guessing people really shouldn't have been using this
4033 feature - I'll drop it altogether in the next release, which will
4034 allow users to return a tuple from a parse action (which is really
4035 handy when trying to reconstuct tuples from a tuple string
4036 representation!).
4037
4038
4039 Version 1.4.1 - February, 2006
4040 ------------------------------
4041 - Converted generator expression in QuotedString class to list
4042 comprehension, to retain compatibility with Python 2.3. (Thanks, Titus
4043 Brown for the heads-up!)
4044
4045 - Added searchString() method to ParserElement, as an alternative to
4046 using "scanString(instring).next()[0][0]" to search through a string
4047 looking for a substring matching a given parse expression. (Inspired by
4048 e-mail conversation with Dave Feustel.)
4049
4050 - Modified oneOf to accept lists of strings as well as a single string
4051 of space-delimited literals. (Suggested by Jacek Sieka - thanks!)
4052
4053 - Removed deprecated use of Upcase in pyparsing test code. (Also caught by
4054 Titus Brown.)
4055
4056 - Removed lstrip() call from Literal - too aggressive in stripping
4057 whitespace which may be valid for some grammars. (Point raised by Jacek
4058 Sieka). Also, made Literal more robust in the event of passing an empty
4059 string.
4060
4061 - Fixed bug in replaceWith when returning None.
4062
4063 - Added cautionary documentation for Forward class when assigning a
4064 MatchFirst expression, as in:
4065 fwdExpr << a | b | c
4066 Precedence of operators causes this to be evaluated as:
4067 (fwdExpr << a) | b | c
4068 thereby leaving b and c out as parseable alternatives. Users must
4069 explicitly group the values inserted into the Forward:
4070 fwdExpr << (a | b | c)
4071 (Suggested by Scot Wilcoxon - thanks, Scot!)
4072
4073
4074 Version 1.4 - January 18, 2006
4075 ------------------------------
4076 - Added `Regex` class, to permit definition of complex embedded expressions
4077 using regular expressions. (Enhancement provided by John Beisley, great
4078 job!)
4079
4080 - Converted implementations of Word, oneOf, quoted string, and comment
4081 helpers to utilize regular expression matching. Performance improvements
4082 in the 20-40% range.
4083
4084 - Added QuotedString class, to support definition of non-standard quoted
4085 strings (Suggested by Guillaume Proulx, thanks!)
4086
4087 - Added CaselessKeyword class, to streamline grammars with, well, caseless
4088 keywords (Proposed by Stefan Behnel, thanks!)
4089
4090 - Fixed bug in SkipTo, when using an ignoreable expression. (Patch provided
4091 by Anonymous, thanks, whoever-you-are!)
4092
4093 - Fixed typo in NoMatch class. (Good catch, Stefan Behnel!)
4094
4095 - Fixed minor bug in _makeTags(), using string.printables instead of
4096 pyparsing.printables.
4097
4098 - Cleaned up some of the expressions created by makeXXXTags helpers, to
4099 suppress extraneous <> characters.
4100
4101 - Added some grammar definition-time checking to verify that a grammar is
4102 being built using proper ParserElements.
4103
4104 - Added examples:
4105 . LAparser.py - linear algebra C preprocessor (submitted by Mike Ellis,
4106 thanks Mike!)
4107 . wordsToNum.py - converts word description of a number back to
4108 the original number (such as 'one hundred and twenty three' -> 123)
4109 . updated fourFn.py to support unary minus, added BNF comments
4110
4111
4112 Version 1.3.3 - September 12, 2005
4113 ----------------------------------
4114 - Improved support for Unicode strings that would be returned using
4115 srange. Added greetingInKorean.py example, for a Korean version of
4116 "Hello, World!" using Unicode. (Thanks, June Kim!)
4117
4118 - Added 'hexnums' string constant (nums+"ABCDEFabcdef") for defining
4119 hexadecimal value expressions.
4120
4121 - NOTE: ===THIS CHANGE MAY BREAK EXISTING CODE===
4122 Modified tag and results definitions returned by makeHTMLTags(),
4123 to better support the looseness of HTML parsing. Tags to be
4124 parsed are now caseless, and keys generated for tag attributes are
4125 now converted to lower case.
4126
4127 Formerly, makeXMLTags("XYZ") would return a tag with results
4128 name of "startXYZ", this has been changed to "startXyz". If this
4129 tag is matched against '<XYZ Abc="1" DEF="2" ghi="3">', the
4130 matched keys formerly would be "Abc", "DEF", and "ghi"; keys are
4131 now converted to lower case, giving keys of "abc", "def", and
4132 "ghi". These changes were made to try to address the lax
4133 case sensitivity agreement between start and end tags in many
4134 HTML pages.
4135
4136 No changes were made to makeXMLTags(), which assumes more rigorous
4137 parsing rules.
4138
4139 Also, cleaned up case-sensitivity bugs in closing tags, and
4140 switched to using Keyword instead of Literal class for tags.
4141 (Thanks, Steve Young, for getting me to look at these in more
4142 detail!)
4143
4144 - Added two helper parse actions, upcaseTokens and downcaseTokens,
4145 which will convert matched text to all uppercase or lowercase,
4146 respectively.
4147
4148 - Deprecated Upcase class, to be replaced by upcaseTokens parse
4149 action.
4150
4151 - Converted messages sent to stderr to use warnings module, such as
4152 when constructing a Literal with an empty string, one should use
4153 the Empty() class or the empty helper instead.
4154
4155 - Added ' ' (space) as an escapable character within a quoted
4156 string.
4157
4158 - Added helper expressions for common comment types, in addition
4159 to the existing cStyleComment (/*...*/) and htmlStyleComment
4160 (<!-- ... -->)
4161 . dblSlashComment = // ... (to end of line)
4162 . cppStyleComment = cStyleComment or dblSlashComment
4163 . javaStyleComment = cppStyleComment
4164 . pythonStyleComment = # ... (to end of line)
4165
4166
4167
4168 Version 1.3.2 - July 24, 2005
4169 -----------------------------
4170 - Added Each class as an enhanced version of And. 'Each' requires
4171 that all given expressions be present, but may occur in any order.
4172 Special handling is provided to group ZeroOrMore and OneOrMore
4173 elements that occur out-of-order in the input string. You can also
4174 construct 'Each' objects by joining expressions with the '&'
4175 operator. When using the Each class, results names are strongly
4176 recommended for accessing the matched tokens. (Suggested by Pradam
4177 Amini - thanks, Pradam!)
4178
4179 - Stricter interpretation of 'max' qualifier on Word elements. If the
4180 'max' attribute is specified, matching will fail if an input field
4181 contains more than 'max' consecutive body characters. For example,
4182 previously, Word(nums,max=3) would match the first three characters
4183 of '0123456', returning '012' and continuing parsing at '3'. Now,
4184 when constructed using the max attribute, Word will raise an
4185 exception with this string.
4186
4187 - Cleaner handling of nested dictionaries returned by Dict. No
4188 longer necessary to dereference sub-dictionaries as element [0] of
4189 their parents.
4190 === NOTE: THIS CHANGE MAY BREAK SOME EXISTING CODE, BUT ONLY IF
4191 PARSING NESTED DICTIONARIES USING THE LITTLE-USED DICT CLASS ===
4192 (Prompted by discussion thread on the Python Tutor list, with
4193 contributions from Danny Yoo, Kent Johnson, and original post by
4194 Liam Clarke - thanks all!)
4195
4196
4197
4198 Version 1.3.1 - June, 2005
4199 ----------------------------------
4200 - Added markInputline() method to ParseException, to display the input
4201 text line location of the parsing exception. (Thanks, Stefan Behnel!)
4202
4203 - Added setDefaultKeywordChars(), so that Keyword definitions using a
4204 custom keyword character set do not all need to add the keywordChars
4205 constructor argument (similar to setDefaultWhitespaceChars()).
4206 (suggested by rzhanka on the SourceForge pyparsing forum.)
4207
4208 - Simplified passing debug actions to setDebugAction(). You can now
4209 pass 'None' for a debug action if you want to take the default
4210 debug behavior. To suppress a particular debug action, you can pass
4211 the pyparsing method nullDebugAction.
4212
4213 - Refactored parse exception classes, moved all behavior to
4214 ParseBaseException, and the former ParseException is now a subclass of
4215 ParseBaseException. Added a second subclass, ParseFatalException, as
4216 a subclass of ParseBaseException. User-defined parse actions can raise
4217 ParseFatalException if a data inconsistency is detected (such as a
4218 begin-tag/end-tag mismatch), and this will stop all parsing immediately.
4219 (Inspired by e-mail thread with Michele Petrazzo - thanks, Michelle!)
4220
4221 - Added helper methods makeXMLTags and makeHTMLTags, that simplify the
4222 definition of XML or HTML tag parse expressions for a given tagname.
4223 Both functions return a pair of parse expressions, one for the opening
4224 tag (that is, '<tagname>') and one for the closing tag ('</tagname>').
4225 The opening tagame also recognizes any attribute definitions that have
4226 been included in the opening tag, as well as an empty tag (one with a
4227 trailing '/', as in '<BODY/>' which is equivalent to '<BODY></BODY>').
4228 makeXMLTags uses stricter XML syntax for attributes, requiring that they
4229 be enclosed in double quote characters - makeHTMLTags is more lenient,
4230 and accepts single-quoted strings or any contiguous string of characters
4231 up to the next whitespace character or '>' character. Attributes can
4232 be retrieved as dictionary or attribute values of the returned results
4233 from the opening tag.
4234
4235 - Added example minimath2.py, a refinement on fourFn.py that adds
4236 an interactive session and support for variables. (Thanks, Steven Siew!)
4237
4238 - Added performance improvement, up to 20% reduction! (Found while working
4239 with Wolfgang Borgert on performance tuning of his TTCN3 parser.)
4240
4241 - And another performance improvement, up to 25%, when using scanString!
4242 (Found while working with Henrik Westlund on his C header file scanner.)
4243
4244 - Updated UML diagrams to reflect latest class/method changes.
4245
4246
4247 Version 1.3 - March, 2005
4248 ----------------------------------
4249 - Added new Keyword class, as a special form of Literal. Keywords
4250 must be followed by whitespace or other non-keyword characters, to
4251 distinguish them from variables or other identifiers that just
4252 happen to start with the same characters as a keyword. For instance,
4253 the input string containing "ifOnlyIfOnly" will match a Literal("if")
4254 at the beginning and in the middle, but will fail to match a
4255 Keyword("if"). Keyword("if") will match only strings such as "if only"
4256 or "if(only)". (Proposed by Wolfgang Borgert, and Berteun Damman
4257 separately requested this on comp.lang.python - great idea!)
4258
4259 - Added setWhitespaceChars() method to override the characters to be
4260 skipped as whitespace before matching a particular ParseElement. Also
4261 added the class-level method setDefaultWhitespaceChars(), to allow
4262 users to override the default set of whitespace characters (space,
4263 tab, newline, and return) for all subsequently defined ParseElements.
4264 (Inspired by Klaas Hofstra's inquiry on the Sourceforge pyparsing
4265 forum.)
4266
4267 - Added helper parse actions to support some very common parse
4268 action use cases:
4269 . replaceWith(replStr) - replaces the matching tokens with the
4270 provided replStr replacement string; especially useful with
4271 transformString()
4272 . removeQuotes - removes first and last character from string enclosed
4273 in quotes (note - NOT the same as the string strip() method, as only
4274 a single character is removed at each end)
4275
4276 - Added copy() method to ParseElement, to make it easier to define
4277 different parse actions for the same basic parse expression. (Note, copy
4278 is implicitly called when using setResultsName().)
4279
4280
4281 (The following changes were posted to CVS as Version 1.2.3 -
4282 October-December, 2004)
4283
4284 - Added support for Unicode strings in creating grammar definitions.
4285 (Big thanks to Gavin Panella!)
4286
4287 - Added constant alphas8bit to include the following 8-bit characters:
4288 ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ
4289
4290 - Added srange() function to simplify definition of Word elements, using
4291 regexp-like '[A-Za-z0-9]' syntax. This also simplifies referencing
4292 common 8-bit characters.
4293
4294 - Fixed bug in Dict when a single element Dict was embedded within another
4295 Dict. (Thanks Andy Yates for catching this one!)
4296
4297 - Added 'formatted' argument to ParseResults.asXML(). If set to False,
4298 suppresses insertion of whitespace for pretty-print formatting. Default
4299 equals True for backward compatibility.
4300
4301 - Added setDebugActions() function to ParserElement, to allow user-defined
4302 debugging actions.
4303
4304 - Added support for escaped quotes (either in \', \", or doubled quote
4305 form) to the predefined expressions for quoted strings. (Thanks, Ero
4306 Carrera!)
4307
4308 - Minor performance improvement (~5%) converting "char in string" tests
4309 to "char in dict". (Suggested by Gavin Panella, cool idea!)
4310
4311
4312 Version 1.2.2 - September 27, 2004
4313 ----------------------------------
4314 - Modified delimitedList to accept an expression as the delimiter, instead
4315 of only accepting strings.
4316
4317 - Modified ParseResults, to convert integer field keys to strings (to
4318 avoid confusion with list access).
4319
4320 - Modified Combine, to convert all embedded tokens to strings before
4321 combining.
4322
4323 - Fixed bug in MatchFirst in which parse actions would be called for
4324 expressions that only partially match. (Thanks, John Hunter!)
4325
4326 - Fixed bug in fourFn.py example that fixes right-associativity of ^
4327 operator. (Thanks, Andrea Griffini!)
4328
4329 - Added class FollowedBy(expression), to look ahead in the input string
4330 without consuming tokens.
4331
4332 - Added class NoMatch that never matches any input. Can be useful in
4333 debugging, and in very specialized grammars.
4334
4335 - Added example pgn.py, for parsing chess game files stored in Portable
4336 Game Notation. (Thanks, Alberto Santini!)
4337
4338
4339 Version 1.2.1 - August 19, 2004
4340 -------------------------------
4341 - Added SkipTo(expression) token type, simplifying grammars that only
4342 want to specify delimiting expressions, and want to match any characters
4343 between them.
4344
4345 - Added helper method dictOf(key,value), making it easier to work with
4346 the Dict class. (Inspired by Pavel Volkovitskiy, thanks!).
4347
4348 - Added optional argument listAllMatches (default=False) to
4349 setResultsName(). Setting listAllMatches to True overrides the default
4350 modal setting of tokens to results names; instead, the results name
4351 acts as an accumulator for all matching tokens within the local
4352 repetition group. (Suggested by Amaury Le Leyzour - thanks!)
4353
4354 - Fixed bug in ParseResults, throwing exception when trying to extract
4355 slice, or make a copy using [:]. (Thanks, Wilson Fowlie!)
4356
4357 - Fixed bug in transformString() when the input string contains <TAB>'s
4358 (Thanks, Rick Walia!).
4359
4360 - Fixed bug in returning tokens from un-Grouped And's, Or's and
4361 MatchFirst's, where too many tokens would be included in the results,
4362 confounding parse actions and returned results.
4363
4364 - Fixed bug in naming ParseResults returned by And's, Or's, and Match
4365 First's.
4366
4367 - Fixed bug in LineEnd() - matching this token now correctly consumes
4368 and returns the end of line "\n".
4369
4370 - Added a beautiful example for parsing Mozilla calendar files (Thanks,
4371 Petri Savolainen!).
4372
4373 - Added support for dynamically modifying Forward expressions during
4374 parsing.
4375
4376
4377 Version 1.2 - 20 June 2004
4378 --------------------------
4379 - Added definition for htmlComment to help support HTML scanning and
4380 parsing.
4381
4382 - Fixed bug in generating XML for Dict classes, in which trailing item was
4383 duplicated in the output XML.
4384
4385 - Fixed release bug in which scanExamples.py was omitted from release
4386 files.
4387
4388 - Fixed bug in transformString() when parse actions are not defined on the
4389 outermost parser element.
4390
4391 - Added example urlExtractor.py, as another example of using scanString
4392 and parse actions.
4393
4394
4395 Version 1.2beta3 - 4 June 2004
4396 ------------------------------
4397 - Added White() token type, analogous to Word, to match on whitespace
4398 characters. Use White in parsers with significant whitespace (such as
4399 configuration file parsers that use indentation to indicate grouping).
4400 Construct White with a string containing the whitespace characters to be
4401 matched. Similar to Word, White also takes optional min, max, and exact
4402 parameters.
4403
4404 - As part of supporting whitespace-signficant parsing, added parseWithTabs()
4405 method to ParserElement, to override the default behavior in parseString
4406 of automatically expanding tabs to spaces. To retain tabs during
4407 parsing, call parseWithTabs() before calling parseString(), parseFile() or
4408 scanString(). (Thanks, Jean-Guillaume Paradis for catching this, and for
4409 your suggestions on whitespace-significant parsing.)
4410
4411 - Added transformString() method to ParseElement, as a complement to
4412 scanString(). To use transformString, define a grammar and attach a parse
4413 action to the overall grammar that modifies the returned token list.
4414 Invoking transformString() on a target string will then scan for matches,
4415 and replace the matched text patterns according to the logic in the parse
4416 action. transformString() returns the resulting transformed string.
4417 (Note: transformString() does *not* automatically expand tabs to spaces.)
4418 Also added scanExamples.py to the examples directory to show sample uses of
4419 scanString() and transformString().
4420
4421 - Removed group() method that was introduced in beta2. This turns out NOT to
4422 be equivalent to nesting within a Group() object, and I'd prefer not to sow
4423 more seeds of confusion.
4424
4425 - Fixed behavior of asXML() where tags for groups were incorrectly duplicated.
4426 (Thanks, Brad Clements!)
4427
4428 - Changed beta version message to display to stderr instead of stdout, to
4429 make asXML() easier to use. (Thanks again, Brad.)
4430
4431
4432 Version 1.2beta2 - 19 May 2004
4433 ------------------------------
4434 - *** SIMPLIFIED API *** - Parse actions that do not modify the list of tokens
4435 no longer need to return a value. This simplifies those parse actions that
4436 use the list of tokens to update a counter or record or display some of the
4437 token content; these parse actions can simply end without having to specify
4438 'return toks'.
4439
4440 - *** POSSIBLE API INCOMPATIBILITY *** - Fixed CaselessLiteral bug, where the
4441 returned token text was not the original string (as stated in the docs),
4442 but the original string converted to upper case. (Thanks, Dang Griffith!)
4443 **NOTE: this may break some code that relied on this erroneous behavior.
4444 Users should scan their code for uses of CaselessLiteral.**
4445
4446 - *** POSSIBLE CODE INCOMPATIBILITY *** - I have renamed the internal
4447 attributes on ParseResults from 'dict' and 'list' to '__tokdict' and
4448 '__toklist', to avoid collisions with user-defined data fields named 'dict'
4449 and 'list'. Any client code that accesses these attributes directly will
4450 need to be modified. Hopefully the implementation of methods such as keys(),
4451 items(), len(), etc. on ParseResults will make such direct attribute
4452 accessess unnecessary.
4453
4454 - Added asXML() method to ParseResults. This greatly simplifies the process
4455 of parsing an input data file and generating XML-structured data.
4456
4457 - Added getName() method to ParseResults. This method is helpful when
4458 a grammar specifies ZeroOrMore or OneOrMore of a MatchFirst or Or
4459 expression, and the parsing code needs to know which expression matched.
4460 (Thanks, Eric van der Vlist, for this idea!)
4461
4462 - Added items() and values() methods to ParseResults, to better support using
4463 ParseResults as a Dictionary.
4464
4465 - Added parseFile() as a convenience function to parse the contents of an
4466 entire text file. Accepts either a file name or a file object. (Thanks
4467 again, Dang!)
4468
4469 - Added group() method to And, Or, and MatchFirst, as a short-cut alternative
4470 to enclosing a construct inside a Group object.
4471
4472 - Extended fourFn.py to support exponentiation, and simple built-in functions.
4473
4474 - Added EBNF parser to examples, including a demo where it parses its own
4475 EBNF! (Thanks to Seo Sanghyeon!)
4476
4477 - Added Delphi Form parser to examples, dfmparse.py, plus a couple of
4478 sample Delphi forms as tests. (Well done, Dang!)
4479
4480 - Another performance speedup, 5-10%, inspired by Dang! Plus about a 20%
4481 speedup, by pre-constructing and cacheing exception objects instead of
4482 constructing them on the fly.
4483
4484 - Fixed minor bug when specifying oneOf() with 'caseless=True'.
4485
4486 - Cleaned up and added a few more docstrings, to improve the generated docs.
4487
4488
4489 Version 1.1.2 - 21 Mar 2004
4490 ---------------------------
4491 - Fixed minor bug in scanString(), so that start location is at the start of
4492 the matched tokens, not at the start of the whitespace before the matched
4493 tokens.
4494
4495 - Inclusion of HTML documentation, generated using Epydoc. Reformatted some
4496 doc strings to better generate readable docs. (Beautiful work, Ed Loper,
4497 thanks for Epydoc!)
4498
4499 - Minor performance speedup, 5-15%
4500
4501 - And on a process note, I've used the unittest module to define a series of
4502 unit tests, to help avoid the embarrassment of the version 1.1 snafu.
4503
4504
4505 Version 1.1.1 - 6 Mar 2004
4506 --------------------------
4507 - Fixed critical bug introduced in 1.1, which broke MatchFirst(!) token
4508 matching.
4509 **THANK YOU, SEO SANGHYEON!!!**
4510
4511 - Added "from future import __generators__" to permit running under
4512 pre-Python 2.3.
4513
4514 - Added example getNTPservers.py, showing how to use pyparsing to extract
4515 a text pattern from the HTML of a web page.
4516
4517
4518 Version 1.1 - 3 Mar 2004
4519 -------------------------
4520 - ***Changed API*** - While testing out parse actions, I found that the value
4521 of loc passed in was not the starting location of the matched tokens, but
4522 the location of the next token in the list. With this version, the location
4523 passed to the parse action is now the starting location of the tokens that
4524 matched.
4525
4526 A second part of this change is that the return value of parse actions no
4527 longer needs to return a tuple containing both the location and the parsed
4528 tokens (which may optionally be modified); parse actions only need to return
4529 the list of tokens. Parse actions that return a tuple are deprecated; they
4530 will still work properly for conversion/compatibility, but this behavior will
4531 be removed in a future version.
4532
4533 - Added validate() method, to help diagnose infinite recursion in a grammar tree.
4534 validate() is not 100% fool-proof, but it can help track down nasty infinite
4535 looping due to recursively referencing the same grammar construct without some
4536 intervening characters.
4537
4538 - Cleaned up default listing of some parse element types, to more closely match
4539 ordinary BNF. Instead of the form <classname>:[contents-list], some changes
4540 are:
4541 . And(token1,token2,token3) is "{ token1 token2 token3 }"
4542 . Or(token1,token2,token3) is "{ token1 ^ token2 ^ token3 }"
4543 . MatchFirst(token1,token2,token3) is "{ token1 | token2 | token3 }"
4544 . Optional(token) is "[ token ]"
4545 . OneOrMore(token) is "{ token }..."
4546 . ZeroOrMore(token) is "[ token ]..."
4547
4548 - Fixed an infinite loop in oneOf if the input string contains a duplicated
4549 option. (Thanks Brad Clements)
4550
4551 - Fixed a bug when specifying a results name on an Optional token. (Thanks
4552 again, Brad Clements)
4553
4554 - Fixed a bug introduced in 1.0.6 when I converted quotedString to use
4555 CharsNotIn; I accidentally permitted quoted strings to span newlines. I have
4556 fixed this in this version to go back to the original behavior, in which
4557 quoted strings do *not* span newlines.
4558
4559 - Fixed minor bug in HTTP server log parser. (Thanks Jim Richardson)
4560
4561
4562 Version 1.0.6 - 13 Feb 2004
4563 ----------------------------
4564 - Added CharsNotIn class (Thanks, Lee SangYeong). This is the opposite of
4565 Word, in that it is constructed with a set of characters *not* to be matched.
4566 (This enhancement also allowed me to clean up and simplify some of the
4567 definitions for quoted strings, cStyleComment, and restOfLine.)
4568
4569 - **MINOR API CHANGE** - Added joinString argument to the __init__ method of
4570 Combine (Thanks, Thomas Kalka). joinString defaults to "", but some
4571 applications might choose some other string to use instead, such as a blank
4572 or newline. joinString was inserted as the second argument to __init__,
4573 so if you have code that specifies an adjacent value, without using
4574 'adjacent=', this code will break.
4575
4576 - Modified LineStart to recognize the start of an empty line.
4577
4578 - Added optional caseless flag to oneOf(), to create a list of CaselessLiteral
4579 tokens instead of Literal tokens.
4580
4581 - Added some enhancements to the SQL example:
4582 . Oracle-style comments (Thanks to Harald Armin Massa)
4583 . simple WHERE clause
4584
4585 - Minor performance speedup - 5-15%
4586
4587
4588 Version 1.0.5 - 19 Jan 2004
4589 ----------------------------
4590 - Added scanString() generator method to ParseElement, to support regex-like
4591 pattern-searching
4592
4593 - Added items() list to ParseResults, to return named results as a
4594 list of (key,value) pairs
4595
4596 - Fixed memory overflow in asList() for deeply nested ParseResults (Thanks,
4597 Sverrir Valgeirsson)
4598
4599 - Minor performance speedup - 10-15%
4600
4601
4602 Version 1.0.4 - 8 Jan 2004
4603 ---------------------------
4604 - Added positional tokens StringStart, StringEnd, LineStart, and LineEnd
4605
4606 - Added commaSeparatedList to pre-defined global token definitions; also added
4607 commasep.py to the examples directory, to demonstrate the differences between
4608 parsing comma-separated data and simple line-splitting at commas
4609
4610 - Minor API change: delimitedList does not automatically enclose the
4611 list elements in a Group, but makes this the responsibility of the caller;
4612 also, if invoked using 'combine=True', the list delimiters are also included
4613 in the returned text (good for scoped variables, such as a.b.c or a::b::c, or
4614 for directory paths such as a/b/c)
4615
4616 - Performance speed-up again, 30-40%
4617
4618 - Added httpServerLogParser.py to examples directory, as this is
4619 a common parsing task
4620
4621
4622 Version 1.0.3 - 23 Dec 2003
4623 ---------------------------
4624 - Performance speed-up again, 20-40%
4625
4626 - Added Python distutils installation setup.py, etc. (thanks, Dave Kuhlman)
4627
4628
4629 Version 1.0.2 - 18 Dec 2003
4630 ---------------------------
4631 - **NOTE: Changed API again!!!** (for the last time, I hope)
4632
4633 + Renamed module from parsing to pyparsing, to better reflect Python
4634 linkage.
4635
4636 - Also added dictExample.py to examples directory, to illustrate
4637 usage of the Dict class.
4638
4639
4640 Version 1.0.1 - 17 Dec 2003
4641 ---------------------------
4642 - **NOTE: Changed API!**
4643
4644 + Renamed 'len' argument on Word.__init__() to 'exact'
4645
4646 - Performance speed-up, 10-30%
4647
4648
4649 Version 1.0.0 - 15 Dec 2003
4650 ---------------------------
4651 - Initial public release
4652
4653 Version 0.1.1 thru 0.1.17 - October-November, 2003
4654 --------------------------------------------------
4655 - initial development iterations:
4656 - added Dict, Group
4657 - added helper methods oneOf, delimitedList
4658 - added helpers quotedString (and double and single), restOfLine, cStyleComment
4659 - added MatchFirst as an alternative to the slower Or
4660 - added UML class diagram
4661 - fixed various logic bugs