METADATA 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. Metadata-Version: 2.1
  2. Name: parsimonious
  3. Version: 0.10.0
  4. Summary: (Soon to be) the fastest pure-Python PEG parser I could muster
  5. Home-page: https://github.com/erikrose/parsimonious
  6. Author: Erik Rose
  7. Author-email: erikrose@grinchcentral.com
  8. License: MIT
  9. Keywords: parse,parser,parsing,peg,packrat,grammar,language
  10. Classifier: Intended Audience :: Developers
  11. Classifier: Natural Language :: English
  12. Classifier: Development Status :: 3 - Alpha
  13. Classifier: License :: OSI Approved :: MIT License
  14. Classifier: Operating System :: OS Independent
  15. Classifier: Programming Language :: Python :: 3 :: Only
  16. Classifier: Programming Language :: Python :: 3
  17. Classifier: Programming Language :: Python :: 3.7
  18. Classifier: Programming Language :: Python :: 3.8
  19. Classifier: Programming Language :: Python :: 3.9
  20. Classifier: Programming Language :: Python :: 3.10
  21. Classifier: Topic :: Scientific/Engineering :: Information Analysis
  22. Classifier: Topic :: Software Development :: Libraries
  23. Classifier: Topic :: Text Processing :: General
  24. Description-Content-Type: text/x-rst
  25. License-File: LICENSE
  26. Requires-Dist: regex (>=2022.3.15)
  27. ============
  28. Parsimonious
  29. ============
  30. Parsimonious aims to be the fastest arbitrary-lookahead parser written in pure
  31. Python—and the most usable. It's based on parsing expression grammars (PEGs),
  32. which means you feed it a simplified sort of EBNF notation. Parsimonious was
  33. designed to undergird a MediaWiki parser that wouldn't take 5 seconds or a GB
  34. of RAM to do one page, but it's applicable to all sorts of languages.
  35. :Code: https://github.com/erikrose/parsimonious/
  36. :Issues: https://github.com/erikrose/parsimonious/issues
  37. :License: MIT License (MIT)
  38. :Package: https://pypi.org/project/parsimonious/
  39. Goals
  40. =====
  41. * Speed
  42. * Frugal RAM use
  43. * Minimalistic, understandable, idiomatic Python code
  44. * Readable grammars
  45. * Extensible grammars
  46. * Complete test coverage
  47. * Separation of concerns. Some Python parsing kits mix recognition with
  48. instructions about how to turn the resulting tree into some kind of other
  49. representation. This is limiting when you want to do several different things
  50. with a tree: for example, render wiki markup to HTML *or* to text.
  51. * Good error reporting. I want the parser to work *with* me as I develop a
  52. grammar.
  53. Install
  54. =======
  55. To install Parsimonious, run::
  56. $ pip install parsimonious
  57. Example Usage
  58. =============
  59. Here's how to build a simple grammar:
  60. .. code:: python
  61. >>> from parsimonious.grammar import Grammar
  62. >>> grammar = Grammar(
  63. ... """
  64. ... bold_text = bold_open text bold_close
  65. ... text = ~"[A-Z 0-9]*"i
  66. ... bold_open = "(("
  67. ... bold_close = "))"
  68. ... """)
  69. You can have forward references and even right recursion; it's all taken care
  70. of by the grammar compiler. The first rule is taken to be the default start
  71. symbol, but you can override that.
  72. Next, let's parse something and get an abstract syntax tree:
  73. .. code:: python
  74. >>> print(grammar.parse('((bold stuff))'))
  75. <Node called "bold_text" matching "((bold stuff))">
  76. <Node called "bold_open" matching "((">
  77. <RegexNode called "text" matching "bold stuff">
  78. <Node called "bold_close" matching "))">
  79. You'd typically then use a ``nodes.NodeVisitor`` subclass (see below) to walk
  80. the tree and do something useful with it.
  81. Another example would be to implement a parser for ``.ini``-files. Consider the following:
  82. .. code:: python
  83. grammar = Grammar(
  84. r"""
  85. expr = (entry / emptyline)*
  86. entry = section pair*
  87. section = lpar word rpar ws
  88. pair = key equal value ws?
  89. key = word+
  90. value = (word / quoted)+
  91. word = ~r"[-\w]+"
  92. quoted = ~'"[^\"]+"'
  93. equal = ws? "=" ws?
  94. lpar = "["
  95. rpar = "]"
  96. ws = ~"\s*"
  97. emptyline = ws+
  98. """
  99. )
  100. We could now implement a subclass of ``NodeVisitor`` like so:
  101. .. code:: python
  102. class IniVisitor(NodeVisitor):
  103. def visit_expr(self, node, visited_children):
  104. """ Returns the overall output. """
  105. output = {}
  106. for child in visited_children:
  107. output.update(child[0])
  108. return output
  109. def visit_entry(self, node, visited_children):
  110. """ Makes a dict of the section (as key) and the key/value pairs. """
  111. key, values = visited_children
  112. return {key: dict(values)}
  113. def visit_section(self, node, visited_children):
  114. """ Gets the section name. """
  115. _, section, *_ = visited_children
  116. return section.text
  117. def visit_pair(self, node, visited_children):
  118. """ Gets each key/value pair, returns a tuple. """
  119. key, _, value, *_ = node.children
  120. return key.text, value.text
  121. def generic_visit(self, node, visited_children):
  122. """ The generic visit method. """
  123. return visited_children or node
  124. And call it like that:
  125. .. code:: python
  126. from parsimonious.grammar import Grammar
  127. from parsimonious.nodes import NodeVisitor
  128. data = """[section]
  129. somekey = somevalue
  130. someotherkey=someothervalue
  131. [anothersection]
  132. key123 = "what the heck?"
  133. key456="yet another one here"
  134. """
  135. tree = grammar.parse(data)
  136. iv = IniVisitor()
  137. output = iv.visit(tree)
  138. print(output)
  139. This would yield
  140. .. code:: python
  141. {'section': {'somekey': 'somevalue', 'someotherkey': 'someothervalue'}, 'anothersection': {'key123': '"what the heck?"', 'key456': '"yet another one here"'}}
  142. Status
  143. ======
  144. * Everything that exists works. Test coverage is good.
  145. * I don't plan on making any backward-incompatible changes to the rule syntax
  146. in the future, so you can write grammars with confidence.
  147. * It may be slow and use a lot of RAM; I haven't measured either yet. However,
  148. I have yet to begin optimizing in earnest.
  149. * Error reporting is now in place. ``repr`` methods of expressions, grammars,
  150. and nodes are clear and helpful as well. The ``Grammar`` ones are
  151. even round-trippable!
  152. * The grammar extensibility story is underdeveloped at the moment. You should
  153. be able to extend a grammar by simply concatenating more rules onto the
  154. existing ones; later rules of the same name should override previous ones.
  155. However, this is untested and may not be the final story.
  156. * Sphinx docs are coming, but the docstrings are quite useful now.
  157. * Note that there may be API changes until we get to 1.0, so be sure to pin to
  158. the version you're using.
  159. Coming Soon
  160. -----------
  161. * Optimizations to make Parsimonious worthy of its name
  162. * Tighter RAM use
  163. * Better-thought-out grammar extensibility story
  164. * Amazing grammar debugging
  165. A Little About PEG Parsers
  166. ==========================
  167. PEG parsers don't draw a distinction between lexing and parsing; everything is
  168. done at once. As a result, there is no lookahead limit, as there is with, for
  169. instance, Yacc. And, due to both of these properties, PEG grammars are easier
  170. to write: they're basically just a more practical dialect of EBNF. With
  171. caching, they take O(grammar size * text length) memory (though I plan to do
  172. better), but they run in O(text length) time.
  173. More Technically
  174. ----------------
  175. PEGs can describe a superset of *LL(k)* languages, any deterministic *LR(k)*
  176. language, and many others—including some that aren't context-free
  177. (http://www.brynosaurus.com/pub/lang/peg.pdf). They can also deal with what
  178. would be ambiguous languages if described in canonical EBNF. They do this by
  179. trading the ``|`` alternation operator for the ``/`` operator, which works the
  180. same except that it makes priority explicit: ``a / b / c`` first tries matching
  181. ``a``. If that fails, it tries ``b``, and, failing that, moves on to ``c``.
  182. Thus, ambiguity is resolved by always yielding the first successful recognition.
  183. Writing Grammars
  184. ================
  185. Grammars are defined by a series of rules. The syntax should be familiar to
  186. anyone who uses regexes or reads programming language manuals. An example will
  187. serve best:
  188. .. code:: python
  189. my_grammar = Grammar(r"""
  190. styled_text = bold_text / italic_text
  191. bold_text = "((" text "))"
  192. italic_text = "''" text "''"
  193. text = ~"[A-Z 0-9]*"i
  194. """)
  195. You can wrap a rule across multiple lines if you like; the syntax is very
  196. forgiving.
  197. Syntax Reference
  198. ----------------
  199. ==================== ========================================================
  200. ``"some literal"`` Used to quote literals. Backslash escaping and Python
  201. conventions for "raw" and Unicode strings help support
  202. fiddly characters.
  203. ``b"some literal"`` A bytes literal. Using bytes literals and regular
  204. expressions allows your grammar to parse binary files.
  205. Note that all literals and regular expressions must be
  206. of the same type within a grammar. In grammars that
  207. process bytestrings, you should make the grammar string
  208. an ``r"""string"""`` so that byte literals like ``\xff``
  209. work correctly.
  210. [space] Sequences are made out of space- or tab-delimited
  211. things. ``a b c`` matches spots where those 3
  212. terms appear in that order.
  213. ``a / b / c`` Alternatives. The first to succeed of ``a / b / c``
  214. wins.
  215. ``thing?`` An optional expression. This is greedy, always consuming
  216. ``thing`` if it exists.
  217. ``&thing`` A lookahead assertion. Ensures ``thing`` matches at the
  218. current position but does not consume it.
  219. ``!thing`` A negative lookahead assertion. Matches if ``thing``
  220. isn't found here. Doesn't consume any text.
  221. ``things*`` Zero or more things. This is greedy, always consuming as
  222. many repetitions as it can.
  223. ``things+`` One or more things. This is greedy, always consuming as
  224. many repetitions as it can.
  225. ``~r"regex"ilmsuxa`` Regexes have ``~`` in front and are quoted like
  226. literals. Any flags_ (``asilmx``) follow the end quotes
  227. as single chars. Regexes are good for representing
  228. character classes (``[a-z0-9]``) and optimizing for
  229. speed. The downside is that they won't be able to take
  230. advantage of our fancy debugging, once we get that
  231. working. Ultimately, I'd like to deprecate explicit
  232. regexes and instead have Parsimonious dynamically build
  233. them out of simpler primitives. Parsimonious uses the
  234. regex_ library instead of the built-in re module.
  235. ``~br"regex"`` A bytes regex; required if your grammar parses
  236. bytestrings.
  237. ``(things)`` Parentheses are used for grouping, like in every other
  238. language.
  239. ``thing{n}`` Exactly ``n`` repetitions of ``thing``.
  240. ``thing{n,m}`` Between ``n`` and ``m`` repititions (inclusive.)
  241. ``thing{,m}`` At most ``m`` repetitions of ``thing``.
  242. ``thing{n,}`` At least ``n`` repetitions of ``thing``.
  243. ==================== ========================================================
  244. .. _flags: https://docs.python.org/3/howto/regex.html#compilation
  245. .. _regex: https://github.com/mrabarnett/mrab-regex
  246. Optimizing Grammars
  247. ===================
  248. Don't Repeat Expressions
  249. ------------------------
  250. If you need a ``~"[a-z0-9]"i`` at two points in your grammar, don't type it
  251. twice. Make it a rule of its own, and reference it from wherever you need it.
  252. You'll get the most out of the caching this way, since cache lookups are by
  253. expression object identity (for speed).
  254. Even if you have an expression that's very simple, not repeating it will
  255. save RAM, as there can, at worst, be a cached int for every char in the text
  256. you're parsing. In the future, we may identify repeated subexpressions
  257. automatically and factor them up while building the grammar.
  258. How much should you shove into one regex, versus how much should you break them
  259. up to not repeat yourself? That's a fine balance and worthy of benchmarking.
  260. More stuff jammed into a regex will execute faster, because it doesn't have to
  261. run any Python between pieces, but a broken-up one will give better cache
  262. performance if the individual pieces are re-used elsewhere. If the pieces of a
  263. regex aren't used anywhere else, by all means keep the whole thing together.
  264. Quantifiers
  265. -----------
  266. Bring your ``?`` and ``*`` quantifiers up to the highest level you
  267. can. Otherwise, lower-level patterns could succeed but be empty and put a bunch
  268. of useless nodes in your tree that didn't really match anything.
  269. Processing Parse Trees
  270. ======================
  271. A parse tree has a node for each expression matched, even if it matched a
  272. zero-length string, like ``"thing"?`` might.
  273. The ``NodeVisitor`` class provides an inversion-of-control framework for
  274. walking a tree and returning a new construct (tree, string, or whatever) based
  275. on it. For now, have a look at its docstrings for more detail. There's also a
  276. good example in ``grammar.RuleVisitor``. Notice how we take advantage of nodes'
  277. iterability by using tuple unpacks in the formal parameter lists:
  278. .. code:: python
  279. def visit_or_term(self, or_term, (slash, _, term)):
  280. ...
  281. For reference, here is the production the above unpacks::
  282. or_term = "/" _ term
  283. When something goes wrong in your visitor, you get a nice error like this::
  284. [normal traceback here...]
  285. VisitationException: 'Node' object has no attribute 'foo'
  286. Parse tree:
  287. <Node called "rules" matching "number = ~"[0-9]+""> <-- *** We were here. ***
  288. <Node matching "number = ~"[0-9]+"">
  289. <Node called "rule" matching "number = ~"[0-9]+"">
  290. <Node matching "">
  291. <Node called "label" matching "number">
  292. <Node matching " ">
  293. <Node called "_" matching " ">
  294. <Node matching "=">
  295. <Node matching " ">
  296. <Node called "_" matching " ">
  297. <Node called "rhs" matching "~"[0-9]+"">
  298. <Node called "term" matching "~"[0-9]+"">
  299. <Node called "atom" matching "~"[0-9]+"">
  300. <Node called "regex" matching "~"[0-9]+"">
  301. <Node matching "~">
  302. <Node called "literal" matching ""[0-9]+"">
  303. <Node matching "">
  304. <Node matching "">
  305. <Node called "eol" matching "
  306. ">
  307. <Node matching "">
  308. The parse tree is tacked onto the exception, and the node whose visitor method
  309. raised the error is pointed out.
  310. Why No Streaming Tree Processing?
  311. ---------------------------------
  312. Some have asked why we don't process the tree as we go, SAX-style. There are
  313. two main reasons:
  314. 1. It wouldn't work. With a PEG parser, no parsing decision is final until the
  315. whole text is parsed. If we had to change a decision, we'd have to backtrack
  316. and redo the SAX-style interpretation as well, which would involve
  317. reconstituting part of the AST and quite possibly scuttling whatever you
  318. were doing with the streaming output. (Note that some bursty SAX-style
  319. processing may be possible in the future if we use cuts.)
  320. 2. It interferes with the ability to derive multiple representations from the
  321. AST: for example, turning wiki markup into first HTML and then text.
  322. Future Directions
  323. =================
  324. Rule Syntax Changes
  325. -------------------
  326. * Maybe support left-recursive rules like PyMeta, if anybody cares.
  327. * Ultimately, I'd like to get rid of explicit regexes and break them into more
  328. atomic things like character classes. Then we can dynamically compile bits
  329. of the grammar into regexes as necessary to boost speed.
  330. Optimizations
  331. -------------
  332. * Make RAM use almost constant by automatically inserting "cuts", as described
  333. in
  334. http://ialab.cs.tsukuba.ac.jp/~mizusima/publications/paste513-mizushima.pdf.
  335. This would also improve error reporting, as we wouldn't backtrack out of
  336. everything informative before finally failing.
  337. * Find all the distinct subexpressions, and unify duplicates for a better cache
  338. hit ratio.
  339. * Think about having the user (optionally) provide some representative input
  340. along with a grammar. We can then profile against it, see which expressions
  341. are worth caching, and annotate the grammar. Perhaps there will even be
  342. positions at which a given expression is more worth caching. Or we could keep
  343. a count of how many times each cache entry has been used and evict the most
  344. useless ones as RAM use grows.
  345. * We could possibly compile the grammar into VM instructions, like in "A
  346. parsing machine for PEGs" by Medeiros.
  347. * If the recursion gets too deep in practice, use trampolining to dodge it.
  348. Niceties
  349. --------
  350. * Pijnu has a raft of tree manipulators. I don't think I want all of them, but
  351. a judicious subset might be nice. Don't get into mixing formatting with tree
  352. manipulation.
  353. https://github.com/erikrose/pijnu/blob/master/library/node.py#L333. PyPy's
  354. parsing lib exposes a sane subset:
  355. http://doc.pypy.org/en/latest/rlib.html#tree-transformations.
  356. Version History
  357. ===============
  358. (Next release)
  359. * ...
  360. 0.10.0
  361. * Fix infinite recursion in __eq__ in some cases. (FelisNivalis)
  362. * Improve error message in left-recursive rules. (lucaswiman)
  363. * Add support for range ``{min,max}`` repetition expressions (righthandabacus)
  364. * Fix bug in ``*`` and ``+`` for token grammars (lucaswiman)
  365. * Add support for grammars on bytestrings (lucaswiman)
  366. * Fix LazyReference resolution bug #134 (righthandabacus)
  367. * ~15% speedup on benchmarks with a faster node cache (ethframe)
  368. .. warning::
  369. This release makes backward-incompatible changes:
  370. * Fix precedence of string literal modifiers ``u/r/b``.
  371. This will break grammars with no spaces between a
  372. reference and a string literal. (lucaswiman)
  373. 0.9.0
  374. * Add support for Python 3.7, 3.8, 3.9, 3.10 (righthandabacus, Lonnen)
  375. * Drop support for Python 2.x, 3.3, 3.4 (righthandabacus, Lonnen)
  376. * Remove six and go all in on Python 3 idioms (Lonnen)
  377. * Replace re with regex for improved handling of unicode characters
  378. in regexes (Oderjunkie)
  379. * Dropped nose for unittest (swayson)
  380. * `Grammar.__repr__()` now correctly escapes backslashes (ingolemo)
  381. * Custom rules can now be class methods in addition to
  382. functions (James Addison)
  383. * Make the ascii flag available in the regex syntax (Roman Inflianskas)
  384. 0.8.1
  385. * Switch to a function-style ``print`` in the benchmark tests so we work
  386. cleanly as a dependency on Python 3. (Edward Betts)
  387. 0.8.0
  388. * Make Grammar iteration ordered, making the ``__repr__`` more like the
  389. original input. (Lucas Wiman)
  390. * Improve text representation and error messages for anonymous
  391. subexpressions. (Lucas Wiman)
  392. * Expose BadGrammar and VisitationError as top-level imports.
  393. * No longer crash when you try to compare a Node to an instance of a
  394. different class. (Esben Sonne)
  395. * Pin ``six`` at 1.9.0 to ensure we have ``python_2_unicode_compatible``.
  396. (Sam Raker)
  397. * Drop Python 2.6 support.
  398. 0.7.0
  399. * Add experimental token-based parsing, via TokenGrammar class, for those
  400. operating on pre-lexed streams of tokens. This can, for example, help parse
  401. indentation-sensitive languages that use the "off-side rule", like Python.
  402. (Erik Rose)
  403. * Common codebase for Python 2 and 3: no more 2to3 translation step (Mattias
  404. Urlichs, Lucas Wiman)
  405. * Drop Python 3.1 and 3.2 support.
  406. * Fix a bug in ``Grammar.__repr__`` which fails to work on Python 3 since the
  407. string_escape codec is gone in Python 3. (Lucas Wiman)
  408. * Don't lose parentheses when printing representations of expressions.
  409. (Michael Kelly)
  410. * Make Grammar an immutable mapping (until we add automatic recompilation).
  411. (Michael Kelly)
  412. 0.6.2
  413. * Make grammar compilation 100x faster. Thanks to dmoisset for the initial
  414. patch.
  415. 0.6.1
  416. * Fix bug which made the default rule of a grammar invalid when it
  417. contained a forward reference.
  418. 0.6
  419. .. warning::
  420. This release makes backward-incompatible changes:
  421. * The ``default_rule`` arg to Grammar's constructor has been replaced
  422. with a method, ``some_grammar.default('rule_name')``, which returns a
  423. new grammar just like the old except with its default rule changed.
  424. This is to free up the constructor kwargs for custom rules.
  425. * ``UndefinedLabel`` is no longer a subclass of ``VisitationError``. This
  426. matters only in the unlikely case that you were catching
  427. ``VisitationError`` exceptions and expecting to thus also catch
  428. ``UndefinedLabel``.
  429. * Add support for "custom rules" in Grammars. These provide a hook for simple
  430. custom parsing hooks spelled as Python lambdas. For heavy-duty needs,
  431. you can put in Compound Expressions with LazyReferences as subexpressions,
  432. and the Grammar will hook them up for optimal efficiency--no calling
  433. ``__getitem__`` on Grammar at parse time.
  434. * Allow grammars without a default rule (in cases where there are no string
  435. rules), which leads to also allowing empty grammars. Perhaps someone
  436. building up grammars dynamically will find that useful.
  437. * Add ``@rule`` decorator, allowing grammars to be constructed out of
  438. notations on ``NodeVisitor`` methods. This saves looking back and forth
  439. between the visitor and the grammar when there is only one visitor per
  440. grammar.
  441. * Add ``parse()`` and ``match()`` convenience methods to ``NodeVisitor``.
  442. This makes the common case of parsing a string and applying exactly one
  443. visitor to the AST shorter and simpler.
  444. * Improve exception message when you forget to declare a visitor method.
  445. * Add ``unwrapped_exceptions`` attribute to ``NodeVisitor``, letting you
  446. name certain exceptions which propagate out of visitors without being
  447. wrapped by ``VisitationError`` exceptions.
  448. * Expose much more of the library in ``__init__``, making your imports
  449. shorter.
  450. * Drastically simplify reference resolution machinery. (Vladimir Keleshev)
  451. 0.5
  452. .. warning::
  453. This release makes some backward-incompatible changes. See below.
  454. * Add alpha-quality error reporting. Now, rather than returning ``None``,
  455. ``parse()`` and ``match()`` raise ``ParseError`` if they don't succeed.
  456. This makes more sense, since you'd rarely attempt to parse something and
  457. not care if it succeeds. It was too easy before to forget to check for a
  458. ``None`` result. ``ParseError`` gives you a human-readable unicode
  459. representation as well as some attributes that let you construct your own
  460. custom presentation.
  461. * Grammar construction now raises ``ParseError`` rather than ``BadGrammar``
  462. if it can't parse your rules.
  463. * ``parse()`` now takes an optional ``pos`` argument, like ``match()``.
  464. * Make the ``_str__()`` method of ``UndefinedLabel`` return the right type.
  465. * Support splitting rules across multiple lines, interleaving comments,
  466. putting multiple rules on one line (but don't do that) and all sorts of
  467. other horrific behavior.
  468. * Tolerate whitespace after opening parens.
  469. * Add support for single-quoted literals.
  470. 0.4
  471. * Support Python 3.
  472. * Fix ``import *`` for ``parsimonious.expressions``.
  473. * Rewrite grammar compiler so right-recursive rules can be compiled and
  474. parsing no longer fails in some cases with forward rule references.
  475. 0.3
  476. * Support comments, the ``!`` ("not") operator, and parentheses in grammar
  477. definition syntax.
  478. * Change the ``&`` operator to a prefix operator to conform to the original
  479. PEG syntax. The version in Parsing Techniques was infix, and that's what I
  480. used as a reference. However, the unary version is more convenient, as it
  481. lets you spell ``AB & A`` as simply ``A &B``.
  482. * Take the ``print`` statements out of the benchmark tests.
  483. * Give Node an evaluate-able ``__repr__``.
  484. 0.2
  485. * Support matching of prefixes and other not-to-the-end slices of strings by
  486. making ``match()`` public and able to initialize a new cache. Add
  487. ``match()`` callthrough method to ``Grammar``.
  488. * Report a ``BadGrammar`` exception (rather than crashing) when there are
  489. mistakes in a grammar definition.
  490. * Simplify grammar compilation internals: get rid of superfluous visitor
  491. methods and factor up repetitive ones. Simplify rule grammar as well.
  492. * Add ``NodeVisitor.lift_child`` convenience method.
  493. * Rename ``VisitationException`` to ``VisitationError`` for consistency with
  494. the standard Python exception hierarchy.
  495. * Rework ``repr`` and ``str`` values for grammars and expressions. Now they
  496. both look like rule syntax. Grammars are even round-trippable! This fixes a
  497. unicode encoding error when printing nodes that had parsed unicode text.
  498. * Add tox for testing. Stop advertising Python 2.5 support, which never
  499. worked (and won't unless somebody cares a lot, since it makes Python 3
  500. support harder).
  501. * Settle (hopefully) on the term "rule" to mean "the string representation of
  502. a production". Get rid of the vague, mysterious "DSL".
  503. 0.1
  504. * A rough but useable preview release
  505. Thanks to Wiki Loves Monuments Panama for showing their support with a generous
  506. gift.