CHANGES 124 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049
  1. ==========
  2. Change Log
  3. ==========
  4. Version 2.4.7 - March, 2020
  5. ---------------------------
  6. - Backport of selected fixes from 3.0.0 work:
  7. . Each bug with Regex expressions
  8. . And expressions not properly constructing with generator
  9. . Traceback abbreviation
  10. . Bug in delta_time example
  11. . Fix regexen in pyparsing_common.real and .sci_real
  12. . Avoid FutureWarning on Python 3.7 or later
  13. . Cleanup output in runTests if comments are embedded in test string
  14. Version 2.4.6 - December, 2019
  15. ------------------------------
  16. - Fixed typos in White mapping of whitespace characters, to use
  17. correct "\u" prefix instead of "u\".
  18. - Fix bug in left-associative ternary operators defined using
  19. infixNotation. First reported on StackOverflow by user Jeronimo.
  20. - Backport of pyparsing_test namespace from 3.0.0, including
  21. TestParseResultsAsserts mixin class defining unittest-helper
  22. methods:
  23. . def assertParseResultsEquals(
  24. self, result, expected_list=None, expected_dict=None, msg=None)
  25. . def assertParseAndCheckList(
  26. self, expr, test_string, expected_list, msg=None, verbose=True)
  27. . def assertParseAndCheckDict(
  28. self, expr, test_string, expected_dict, msg=None, verbose=True)
  29. . def assertRunTestResults(
  30. self, run_tests_report, expected_parse_results=None, msg=None)
  31. . def assertRaisesParseException(self, exc_type=ParseException, msg=None)
  32. To use the methods in this mixin class, declare your unittest classes as:
  33. from pyparsing import pyparsing_test as ppt
  34. class MyParserTest(ppt.TestParseResultsAsserts, unittest.TestCase):
  35. ...
  36. Version 2.4.5 - November, 2019
  37. ------------------------------
  38. - Fixed encoding when setup.py reads README.rst to include the
  39. project long description when uploading to PyPI. A stray
  40. unicode space in README.rst prevented the source install on
  41. systems whose default encoding is not 'utf-8'.
  42. Version 2.4.4 - November, 2019
  43. --------------------------------
  44. - Unresolved symbol reference in 2.4.3 release was masked by stdout
  45. buffering in unit tests, thanks for the prompt heads-up, Ned
  46. Batchelder!
  47. Version 2.4.3 - November, 2019
  48. ------------------------------
  49. - Fixed a bug in ParserElement.__eq__ that would for some parsers
  50. create a recursion error at parser definition time. Thanks to
  51. Michael Clerx for the assist. (Addresses issue #123)
  52. - Fixed bug in indentedBlock where a block that ended at the end
  53. of the input string could cause pyaprsing to loop forever. Raised
  54. as part of discussion on StackOverflow with geckos.
  55. - Backports from pyparsing 3.0.0:
  56. . __diag__.enable_all_warnings()
  57. . Fixed bug in PrecededBy which caused infinite recursion, issue #127
  58. . support for using regex-compiled RE to construct Regex expressions
  59. Version 2.4.2 - July, 2019
  60. --------------------------
  61. - Updated the shorthand notation that has been added for repetition
  62. expressions: expr[min, max], with '...' valid as a min or max value:
  63. - expr[...] and expr[0, ...] are equivalent to ZeroOrMore(expr)
  64. - expr[1, ...] is equivalent to OneOrMore(expr)
  65. - expr[n, ...] or expr[n,] is equivalent
  66. to expr*n + ZeroOrMore(expr)
  67. (read as "n or more instances of expr")
  68. - expr[..., n] is equivalent to expr*(0, n)
  69. - expr[m, n] is equivalent to expr*(m, n)
  70. Note that expr[..., n] and expr[m, n] do not raise an exception
  71. if more than n exprs exist in the input stream. If this
  72. behavior is desired, then write expr[..., n] + ~expr.
  73. Better interpretation of [...] as ZeroOrMore raised by crowsonkb,
  74. thanks for keeping me in line!
  75. If upgrading from 2.4.1 or 2.4.1.1 and you have used `expr[...]`
  76. for `OneOrMore(expr)`, it must be updated to `expr[1, ...]`.
  77. - The defaults on all the `__diag__` switches have been set to False,
  78. to avoid getting alarming warnings. To use these diagnostics, set
  79. them to True after importing pyparsing.
  80. Example:
  81. import pyparsing as pp
  82. pp.__diag__.warn_multiple_tokens_in_named_alternation = True
  83. - Fixed bug introduced by the use of __getitem__ for repetition,
  84. overlooking Python's legacy implementation of iteration
  85. by sequentially calling __getitem__ with increasing numbers until
  86. getting an IndexError. Found during investigation of problem
  87. reported by murlock, merci!
  88. Version 2.4.2a1 - July, 2019
  89. ----------------------------
  90. It turns out I got the meaning of `[...]` absolutely backwards,
  91. so I've deleted 2.4.1 and am repushing this release as 2.4.2a1
  92. for people to give it a try before I can call it ready to go.
  93. The `expr[...]` notation was pushed out to be synonymous with
  94. `OneOrMore(expr)`, but this is really counter to most Python
  95. notations (and even other internal pyparsing notations as well).
  96. It should have been defined to be equivalent to ZeroOrMore(expr).
  97. - Changed [...] to emit ZeroOrMore instead of OneOrMore.
  98. - Removed code that treats ParserElements like iterables.
  99. - Change all __diag__ switches to False.
  100. Version 2.4.1.1 - July 24, 2019
  101. -------------------------------
  102. This is a re-release of version 2.4.1 to restore the release history
  103. in PyPI, since the 2.4.1 release was deleted.
  104. There are 3 known issues in this release, which are fixed in
  105. the upcoming 2.4.2:
  106. - API change adding support for `expr[...]` - the original
  107. code in 2.4.1 incorrectly implemented this as OneOrMore.
  108. Code using this feature under this relase should explicitly
  109. use `expr[0, ...]` for ZeroOrMore and `expr[1, ...]` for
  110. OneOrMore. In 2.4.2 you will be able to write `expr[...]`
  111. equivalent to `ZeroOrMore(expr)`.
  112. - Bug if composing And, Or, MatchFirst, or Each expressions
  113. using an expression. This only affects code which uses
  114. explicit expression construction using the And, Or, etc.
  115. classes instead of using overloaded operators '+', '^', and
  116. so on. If constructing an And using a single expression,
  117. you may get an error that "cannot multiply ParserElement by
  118. 0 or (0, 0)" or a Python `IndexError`. Change code like
  119. cmd = Or(Word(alphas))
  120. to
  121. cmd = Or([Word(alphas)])
  122. (Note that this is not the recommended style for constructing
  123. Or expressions.)
  124. - Some newly-added `__diag__` switches are enabled by default,
  125. which may give rise to noisy user warnings for existing parsers.
  126. You can disable them using:
  127. import pyparsing as pp
  128. pp.__diag__.warn_multiple_tokens_in_named_alternation = False
  129. pp.__diag__.warn_ungrouped_named_tokens_in_collection = False
  130. pp.__diag__.warn_name_set_on_empty_Forward = False
  131. pp.__diag__.warn_on_multiple_string_args_to_oneof = False
  132. pp.__diag__.enable_debug_on_named_expressions = False
  133. In 2.4.2 these will all be set to False by default.
  134. Version 2.4.1 - July, 2019
  135. --------------------------
  136. - NOTE: Deprecated functions and features that will be dropped
  137. in pyparsing 2.5.0 (planned next release):
  138. . support for Python 2 - ongoing users running with
  139. Python 2 can continue to use pyparsing 2.4.1
  140. . ParseResults.asXML() - if used for debugging, switch
  141. to using ParseResults.dump(); if used for data transfer,
  142. use ParseResults.asDict() to convert to a nested Python
  143. dict, which can then be converted to XML or JSON or
  144. other transfer format
  145. . operatorPrecedence synonym for infixNotation -
  146. convert to calling infixNotation
  147. . commaSeparatedList - convert to using
  148. pyparsing_common.comma_separated_list
  149. . upcaseTokens and downcaseTokens - convert to using
  150. pyparsing_common.upcaseTokens and downcaseTokens
  151. . __compat__.collect_all_And_tokens will not be settable to
  152. False to revert to pre-2.3.1 results name behavior -
  153. review use of names for MatchFirst and Or expressions
  154. containing And expressions, as they will return the
  155. complete list of parsed tokens, not just the first one.
  156. Use __diag__.warn_multiple_tokens_in_named_alternation
  157. (described below) to help identify those expressions
  158. in your parsers that will have changed as a result.
  159. - A new shorthand notation has been added for repetition
  160. expressions: expr[min, max], with '...' valid as a min
  161. or max value:
  162. - expr[...] is equivalent to OneOrMore(expr)
  163. - expr[0, ...] is equivalent to ZeroOrMore(expr)
  164. - expr[1, ...] is equivalent to OneOrMore(expr)
  165. - expr[n, ...] or expr[n,] is equivalent
  166. to expr*n + ZeroOrMore(expr)
  167. (read as "n or more instances of expr")
  168. - expr[..., n] is equivalent to expr*(0, n)
  169. - expr[m, n] is equivalent to expr*(m, n)
  170. Note that expr[..., n] and expr[m, n] do not raise an exception
  171. if more than n exprs exist in the input stream. If this
  172. behavior is desired, then write expr[..., n] + ~expr.
  173. - '...' can also be used as short hand for SkipTo when used
  174. in adding parse expressions to compose an And expression.
  175. Literal('start') + ... + Literal('end')
  176. And(['start', ..., 'end'])
  177. are both equivalent to:
  178. Literal('start') + SkipTo('end')("_skipped*") + Literal('end')
  179. The '...' form has the added benefit of not requiring repeating
  180. the skip target expression. Note that the skipped text is
  181. returned with '_skipped' as a results name, and that the contents of
  182. `_skipped` will contain a list of text from all `...`s in the expression.
  183. - '...' can also be used as a "skip forward in case of error" expression:
  184. expr = "start" + (Word(nums).setName("int") | ...) + "end"
  185. expr.parseString("start 456 end")
  186. ['start', '456', 'end']
  187. expr.parseString("start 456 foo 789 end")
  188. ['start', '456', 'foo 789 ', 'end']
  189. - _skipped: ['foo 789 ']
  190. expr.parseString("start foo end")
  191. ['start', 'foo ', 'end']
  192. - _skipped: ['foo ']
  193. expr.parseString("start end")
  194. ['start', '', 'end']
  195. - _skipped: ['missing <int>']
  196. Note that in all the error cases, the '_skipped' results name is
  197. present, showing a list of the extra or missing items.
  198. This form is only valid when used with the '|' operator.
  199. - Improved exception messages to show what was actually found, not
  200. just what was expected.
  201. word = pp.Word(pp.alphas)
  202. pp.OneOrMore(word).parseString("aaa bbb 123", parseAll=True)
  203. Former exception message:
  204. pyparsing.ParseException: Expected end of text (at char 8), (line:1, col:9)
  205. New exception message:
  206. pyparsing.ParseException: Expected end of text, found '1' (at char 8), (line:1, col:9)
  207. - Added diagnostic switches to help detect and warn about common
  208. parser construction mistakes, or enable additional parse
  209. debugging. Switches are attached to the pyparsing.__diag__
  210. namespace object:
  211. - warn_multiple_tokens_in_named_alternation - flag to enable warnings when a results
  212. name is defined on a MatchFirst or Or expression with one or more And subexpressions
  213. (default=True)
  214. - warn_ungrouped_named_tokens_in_collection - flag to enable warnings when a results
  215. name is defined on a containing expression with ungrouped subexpressions that also
  216. have results names (default=True)
  217. - warn_name_set_on_empty_Forward - flag to enable warnings whan a Forward is defined
  218. with a results name, but has no contents defined (default=False)
  219. - warn_on_multiple_string_args_to_oneof - flag to enable warnings whan oneOf is
  220. incorrectly called with multiple str arguments (default=True)
  221. - enable_debug_on_named_expressions - flag to auto-enable debug on all subsequent
  222. calls to ParserElement.setName() (default=False)
  223. warn_multiple_tokens_in_named_alternation is intended to help
  224. those who currently have set __compat__.collect_all_And_tokens to
  225. False as a workaround for using the pre-2.3.1 code with named
  226. MatchFirst or Or expressions containing an And expression.
  227. - Added ParseResults.from_dict classmethod, to simplify creation
  228. of a ParseResults with results names using a dict, which may be nested.
  229. This makes it easy to add a sub-level of named items to the parsed
  230. tokens in a parse action.
  231. - Added asKeyword argument (default=False) to oneOf, to force
  232. keyword-style matching on the generated expressions.
  233. - ParserElement.runTests now accepts an optional 'file' argument to
  234. redirect test output to a file-like object (such as a StringIO,
  235. or opened file). Default is to write to sys.stdout.
  236. - conditionAsParseAction is a helper method for constructing a
  237. parse action method from a predicate function that simply
  238. returns a boolean result. Useful for those places where a
  239. predicate cannot be added using addCondition, but must be
  240. converted to a parse action (such as in infixNotation). May be
  241. used as a decorator if default message and exception types
  242. can be used. See ParserElement.addCondition for more details
  243. about the expected signature and behavior for predicate condition
  244. methods.
  245. - While investigating issue #93, I found that Or and
  246. addCondition could interact to select an alternative that
  247. is not the longest match. This is because Or first checks
  248. all alternatives for matches without running attached
  249. parse actions or conditions, orders by longest match, and
  250. then rechecks for matches with conditions and parse actions.
  251. Some expressions, when checking with conditions, may end
  252. up matching on a shorter token list than originally matched,
  253. but would be selected because of its original priority.
  254. This matching code has been expanded to do more extensive
  255. searching for matches when a second-pass check matches a
  256. smaller list than in the first pass.
  257. - Fixed issue #87, a regression in indented block.
  258. Reported by Renz Bagaporo, who submitted a very nice repro
  259. example, which makes the bug-fixing process a lot easier,
  260. thanks!
  261. - Fixed MemoryError issue #85 and #91 with str generation for
  262. Forwards. Thanks decalage2 and Harmon758 for your patience.
  263. - Modified setParseAction to accept None as an argument,
  264. indicating that all previously-defined parse actions for the
  265. expression should be cleared.
  266. - Modified pyparsing_common.real and sci_real to parse reals
  267. without leading integer digits before the decimal point,
  268. consistent with Python real number formats. Original PR #98
  269. submitted by ansobolev.
  270. - Modified runTests to call postParse function before dumping out
  271. the parsed results - allows for postParse to add further results,
  272. such as indications of additional validation success/failure.
  273. - Updated statemachine example: refactored state transitions to use
  274. overridden classmethods; added <statename>Mixin class to simplify
  275. definition of application classes that "own" the state object and
  276. delegate to it to model state-specific properties and behavior.
  277. - Added example nested_markup.py, showing a simple wiki markup with
  278. nested markup directives, and illustrating the use of '...' for
  279. skipping over input to match the next expression. (This example
  280. uses syntax that is not valid under Python 2.)
  281. - Rewrote delta_time.py example (renamed from deltaTime.py) to
  282. fix some omitted formats and upgrade to latest pyparsing idioms,
  283. beginning with writing an actual BNF.
  284. - With the help and encouragement from several contributors, including
  285. Matěj Cepl and Cengiz Kaygusuz, I've started cleaning up the internal
  286. coding styles in core pyparsing, bringing it up to modern coding
  287. practices from pyparsing's early development days dating back to
  288. 2003. Whitespace has been largely standardized along PEP8 guidelines,
  289. removing extra spaces around parentheses, and adding them around
  290. arithmetic operators and after colons and commas. I was going to hold
  291. off on doing this work until after 2.4.1, but after cleaning up a
  292. few trial classes, the difference was so significant that I continued
  293. on to the rest of the core code base. This should facilitate future
  294. work and submitted PRs, allowing them to focus on substantive code
  295. changes, and not get sidetracked by whitespace issues.
  296. Version 2.4.0 - April, 2019
  297. ---------------------------
  298. - Well, it looks like the API change that was introduced in 2.3.1 was more
  299. drastic than expected, so for a friendlier forward upgrade path, this
  300. release:
  301. . Bumps the current version number to 2.4.0, to reflect this
  302. incompatible change.
  303. . Adds a pyparsing.__compat__ object for specifying compatibility with
  304. future breaking changes.
  305. . Conditionalizes the API-breaking behavior, based on the value
  306. pyparsing.__compat__.collect_all_And_tokens. By default, this value
  307. will be set to True, reflecting the new bugfixed behavior. To set this
  308. value to False, add to your code:
  309. import pyparsing
  310. pyparsing.__compat__.collect_all_And_tokens = False
  311. . User code that is dependent on the pre-bugfix behavior can restore
  312. it by setting this value to False.
  313. In 2.5 and later versions, the conditional code will be removed and
  314. setting the flag to True or False in these later versions will have no
  315. effect.
  316. - Updated unitTests.py and simple_unit_tests.py to be compatible with
  317. "python setup.py test". To run tests using setup, do:
  318. python setup.py test
  319. python setup.py test -s unitTests.suite
  320. python setup.py test -s simple_unit_tests.suite
  321. Prompted by issue #83 and PR submitted by bdragon28, thanks.
  322. - Fixed bug in runTests handling '\n' literals in quoted strings.
  323. - Added tag_body attribute to the start tag expressions generated by
  324. makeHTMLTags, so that you can avoid using SkipTo to roll your own
  325. tag body expression:
  326. a, aEnd = pp.makeHTMLTags('a')
  327. link = a + a.tag_body("displayed_text") + aEnd
  328. for t in s.searchString(html_page):
  329. print(t.displayed_text, '->', t.startA.href)
  330. - indentedBlock failure handling was improved; PR submitted by TMiguelT,
  331. thanks!
  332. - Address Py2 incompatibility in simpleUnitTests, plus explain() and
  333. Forward str() cleanup; PRs graciously provided by eswald.
  334. - Fixed docstring with embedded '\w', which creates SyntaxWarnings in
  335. Py3.8, issue #80.
  336. - Examples:
  337. - Added example parser for rosettacode.org tutorial compiler.
  338. - Added example to show how an HTML table can be parsed into a
  339. collection of Python lists or dicts, one per row.
  340. - Updated SimpleSQL.py example to handle nested selects, reworked
  341. 'where' expression to use infixNotation.
  342. - Added include_preprocessor.py, similar to macroExpander.py.
  343. - Examples using makeHTMLTags use new tag_body expression when
  344. retrieving a tag's body text.
  345. - Updated examples that are runnable as unit tests:
  346. python setup.py test -s examples.antlr_grammar_tests
  347. python setup.py test -s examples.test_bibparse
  348. Version 2.3.1 - January, 2019
  349. -----------------------------
  350. - POSSIBLE API CHANGE: this release fixes a bug when results names were
  351. attached to a MatchFirst or Or object containing an And object.
  352. Previously, a results name on an And object within an enclosing MatchFirst
  353. or Or could return just the first token in the And. Now, all the tokens
  354. matched by the And are correctly returned. This may result in subtle
  355. changes in the tokens returned if you have this condition in your pyparsing
  356. scripts.
  357. - New staticmethod ParseException.explain() to help diagnose parse exceptions
  358. by showing the failing input line and the trace of ParserElements in
  359. the parser leading up to the exception. explain() returns a multiline
  360. string listing each element by name. (This is still an experimental
  361. method, and the method signature and format of the returned string may
  362. evolve over the next few releases.)
  363. Example:
  364. # define a parser to parse an integer followed by an
  365. # alphabetic word
  366. expr = pp.Word(pp.nums).setName("int")
  367. + pp.Word(pp.alphas).setName("word")
  368. try:
  369. # parse a string with a numeric second value instead of alpha
  370. expr.parseString("123 355")
  371. except pp.ParseException as pe:
  372. print(pp.ParseException.explain(pe))
  373. Prints:
  374. 123 355
  375. ^
  376. ParseException: Expected word (at char 4), (line:1, col:5)
  377. __main__.ExplainExceptionTest
  378. pyparsing.And - {int word}
  379. pyparsing.Word - word
  380. explain() will accept any exception type and will list the function
  381. names and parse expressions in the stack trace. This is especially
  382. useful when an exception is raised in a parse action.
  383. Note: explain() is only supported under Python 3.
  384. - Fix bug in dictOf which could match an empty sequence, making it
  385. infinitely loop if wrapped in a OneOrMore.
  386. - Added unicode sets to pyparsing_unicode for Latin-A and Latin-B ranges.
  387. - Added ability to define custom unicode sets as combinations of other sets
  388. using multiple inheritance.
  389. class Turkish_set(pp.pyparsing_unicode.Latin1, pp.pyparsing_unicode.LatinA):
  390. pass
  391. turkish_word = pp.Word(Turkish_set.alphas)
  392. - Updated state machine import examples, with state machine demos for:
  393. . traffic light
  394. . library book checkin/checkout
  395. . document review/approval
  396. In the traffic light example, you can use the custom 'statemachine' keyword
  397. to define the states for a traffic light, and have the state classes
  398. auto-generated for you:
  399. statemachine TrafficLightState:
  400. Red -> Green
  401. Green -> Yellow
  402. Yellow -> Red
  403. Similar for state machines with named transitions, like the library book
  404. state example:
  405. statemachine LibraryBookState:
  406. New -(shelve)-> Available
  407. Available -(reserve)-> OnHold
  408. OnHold -(release)-> Available
  409. Available -(checkout)-> CheckedOut
  410. CheckedOut -(checkin)-> Available
  411. Once the classes are defined, then additional Python code can reference those
  412. classes to add class attributes, instance methods, etc.
  413. See the examples in examples/statemachine
  414. - Added an example parser for the decaf language. This language is used in
  415. CS compiler classes in many colleges and universities.
  416. - Fixup of docstrings to Sphinx format, inclusion of test files in the source
  417. package, and convert markdown to rst throughout the distribution, great job
  418. by Matěj Cepl!
  419. - Expanded the whitespace characters recognized by the White class to include
  420. all unicode defined spaces. Suggested in Issue #51 by rtkjbillo.
  421. - Added optional postParse argument to ParserElement.runTests() to add a
  422. custom callback to be called for test strings that parse successfully. Useful
  423. for running tests that do additional validation or processing on the parsed
  424. results. See updated chemicalFormulas.py example.
  425. - Removed distutils fallback in setup.py. If installing the package fails,
  426. please update to the latest version of setuptools. Plus overall project code
  427. cleanup (CRLFs, whitespace, imports, etc.), thanks Jon Dufresne!
  428. - Fix bug in CaselessKeyword, to make its behavior consistent with
  429. Keyword(caseless=True). Fixes Issue #65 reported by telesphore.
  430. Version 2.3.0 - October, 2018
  431. -----------------------------
  432. - NEW SUPPORT FOR UNICODE CHARACTER RANGES
  433. This release introduces the pyparsing_unicode namespace class, defining
  434. a series of language character sets to simplify the definition of alphas,
  435. nums, alphanums, and printables in the following language sets:
  436. . Arabic
  437. . Chinese
  438. . Cyrillic
  439. . Devanagari
  440. . Greek
  441. . Hebrew
  442. . Japanese (including Kanji, Katakana, and Hirigana subsets)
  443. . Korean
  444. . Latin1 (includes 7 and 8-bit Latin characters)
  445. . Thai
  446. . CJK (combination of Chinese, Japanese, and Korean sets)
  447. For example, your code can define words using:
  448. korean_word = Word(pyparsing_unicode.Korean.alphas)
  449. See their use in the updated examples greetingInGreek.py and
  450. greetingInKorean.py.
  451. This namespace class also offers access to these sets using their
  452. unicode identifiers.
  453. - POSSIBLE API CHANGE: Fixed bug where a parse action that explicitly
  454. returned the input ParseResults could add another nesting level in
  455. the results if the current expression had a results name.
  456. vals = pp.OneOrMore(pp.pyparsing_common.integer)("int_values")
  457. def add_total(tokens):
  458. tokens['total'] = sum(tokens)
  459. return tokens # this line can be removed
  460. vals.addParseAction(add_total)
  461. print(vals.parseString("244 23 13 2343").dump())
  462. Before the fix, this code would print (note the extra nesting level):
  463. [244, 23, 13, 2343]
  464. - int_values: [244, 23, 13, 2343]
  465. - int_values: [244, 23, 13, 2343]
  466. - total: 2623
  467. - total: 2623
  468. With the fix, this code now prints:
  469. [244, 23, 13, 2343]
  470. - int_values: [244, 23, 13, 2343]
  471. - total: 2623
  472. This fix will change the structure of ParseResults returned if a
  473. program defines a parse action that returns the tokens that were
  474. sent in. This is not necessary, and statements like "return tokens"
  475. in the example above can be safely deleted prior to upgrading to
  476. this release, in order to avoid the bug and get the new behavior.
  477. Reported by seron in Issue #22, nice catch!
  478. - POSSIBLE API CHANGE: Fixed a related bug where a results name
  479. erroneously created a second level of hierarchy in the returned
  480. ParseResults. The intent for accumulating results names into ParseResults
  481. is that, in the absence of Group'ing, all names get merged into a
  482. common namespace. This allows us to write:
  483. key_value_expr = (Word(alphas)("key") + '=' + Word(nums)("value"))
  484. result = key_value_expr.parseString("a = 100")
  485. and have result structured as {"key": "a", "value": "100"}
  486. instead of [{"key": "a"}, {"value": "100"}].
  487. However, if a named expression is used in a higher-level non-Group
  488. expression that *also* has a name, a false sub-level would be created
  489. in the namespace:
  490. num = pp.Word(pp.nums)
  491. num_pair = ("[" + (num("A") + num("B"))("values") + "]")
  492. U = num_pair.parseString("[ 10 20 ]")
  493. print(U.dump())
  494. Since there is no grouping, "A", "B", and "values" should all appear
  495. at the same level in the results, as:
  496. ['[', '10', '20', ']']
  497. - A: '10'
  498. - B: '20'
  499. - values: ['10', '20']
  500. Instead, an extra level of "A" and "B" show up under "values":
  501. ['[', '10', '20', ']']
  502. - A: '10'
  503. - B: '20'
  504. - values: ['10', '20']
  505. - A: '10'
  506. - B: '20'
  507. This bug has been fixed. Now, if this hierarchy is desired, then a
  508. Group should be added:
  509. num_pair = ("[" + pp.Group(num("A") + num("B"))("values") + "]")
  510. Giving:
  511. ['[', ['10', '20'], ']']
  512. - values: ['10', '20']
  513. - A: '10'
  514. - B: '20'
  515. But in no case should "A" and "B" appear in multiple levels. This bug-fix
  516. fixes that.
  517. If you have current code which relies on this behavior, then add or remove
  518. Groups as necessary to get your intended results structure.
  519. Reported by Athanasios Anastasiou.
  520. - IndexError's raised in parse actions will get explicitly reraised
  521. as ParseExceptions that wrap the original IndexError. Since
  522. IndexError sometimes occurs as part of pyparsing's normal parsing
  523. logic, IndexErrors that are raised during a parse action may have
  524. gotten silently reinterpreted as parsing errors. To retain the
  525. information from the IndexError, these exceptions will now be
  526. raised as ParseExceptions that reference the original IndexError.
  527. This wrapping will only be visible when run under Python3, since it
  528. emulates "raise ... from ..." syntax.
  529. Addresses Issue #4, reported by guswns0528.
  530. - Added Char class to simplify defining expressions of a single
  531. character. (Char("abc") is equivalent to Word("abc", exact=1))
  532. - Added class PrecededBy to perform lookbehind tests. PrecededBy is
  533. used in the same way as FollowedBy, passing in an expression that
  534. must occur just prior to the current parse location.
  535. For fixed-length expressions like a Literal, Keyword, Char, or a
  536. Word with an `exact` or `maxLen` length given, `PrecededBy(expr)`
  537. is sufficient. For varying length expressions like a Word with no
  538. given maximum length, `PrecededBy` must be constructed with an
  539. integer `retreat` argument, as in
  540. `PrecededBy(Word(alphas, nums), retreat=10)`, to specify the maximum
  541. number of characters pyparsing must look backward to make a match.
  542. pyparsing will check all the values from 1 up to retreat characters
  543. back from the current parse location.
  544. When stepping backwards through the input string, PrecededBy does
  545. *not* skip over whitespace.
  546. PrecededBy can be created with a results name so that, even though
  547. it always returns an empty parse result, the result *can* include
  548. named results.
  549. Idea first suggested in Issue #30 by Freakwill.
  550. - Updated FollowedBy to accept expressions that contain named results,
  551. so that results names defined in the lookahead expression will be
  552. returned, even though FollowedBy always returns an empty list.
  553. Inspired by the same feature implemented in PrecededBy.
  554. Version 2.2.2 - September, 2018
  555. -------------------------------
  556. - Fixed bug in SkipTo, if a SkipTo expression that was skipping to
  557. an expression that returned a list (such as an And), and the
  558. SkipTo was saved as a named result, the named result could be
  559. saved as a ParseResults - should always be saved as a string.
  560. Issue #28, reported by seron.
  561. - Added simple_unit_tests.py, as a collection of easy-to-follow unit
  562. tests for various classes and features of the pyparsing library.
  563. Primary intent is more to be instructional than actually rigorous
  564. testing. Complex tests can still be added in the unitTests.py file.
  565. - New features added to the Regex class:
  566. - optional asGroupList parameter, returns all the capture groups as
  567. a list
  568. - optional asMatch parameter, returns the raw re.match result
  569. - new sub(repl) method, which adds a parse action calling
  570. re.sub(pattern, repl, parsed_result). Simplifies creating
  571. Regex expressions to be used with transformString. Like re.sub,
  572. repl may be an ordinary string (similar to using pyparsing's
  573. replaceWith), or may contain references to capture groups by group
  574. number, or may be a callable that takes an re match group and
  575. returns a string.
  576. For instance:
  577. expr = pp.Regex(r"([Hh]\d):\s*(.*)").sub(r"<\1>\2</\1>")
  578. expr.transformString("h1: This is the title")
  579. will return
  580. <h1>This is the title</h1>
  581. - Fixed omission of LICENSE file in source tarball, also added
  582. CODE_OF_CONDUCT.md per GitHub community standards.
  583. Version 2.2.1 - September, 2018
  584. -------------------------------
  585. - Applied changes necessary to migrate hosting of pyparsing source
  586. over to GitHub. Many thanks for help and contributions from hugovk,
  587. jdufresne, and cngkaygusuz among others through this transition,
  588. sorry it took me so long!
  589. - Fixed import of collections.abc to address DeprecationWarnings
  590. in Python 3.7.
  591. - Updated oc.py example to support function calls in arithmetic
  592. expressions; fixed regex for '==' operator; and added packrat
  593. parsing. Raised on the pyparsing wiki by Boris Marin, thanks!
  594. - Fixed bug in select_parser.py example, group_by_terms was not
  595. reported. Reported on SF bugs by Adam Groszer, thanks Adam!
  596. - Added "Getting Started" section to the module docstring, to
  597. guide new users to the most common starting points in pyparsing's
  598. API.
  599. - Fixed bug in Literal and Keyword classes, which erroneously
  600. raised IndexError instead of ParseException.
  601. Version 2.2.0 - March, 2017
  602. ---------------------------
  603. - Bumped minor version number to reflect compatibility issues with
  604. OneOrMore and ZeroOrMore bugfixes in 2.1.10. (2.1.10 fixed a bug
  605. that was introduced in 2.1.4, but the fix could break code
  606. written against 2.1.4 - 2.1.9.)
  607. - Updated setup.py to address recursive import problems now
  608. that pyparsing is part of 'packaging' (used by setuptools).
  609. Patch submitted by Joshua Root, much thanks!
  610. - Fixed KeyError issue reported by Yann Bizeul when using packrat
  611. parsing in the Graphite time series database, thanks Yann!
  612. - Fixed incorrect usages of '\' in literals, as described in
  613. https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior
  614. Patch submitted by Ville Skyttä - thanks!
  615. - Minor internal change when using '-' operator, to be compatible
  616. with ParserElement.streamline() method.
  617. - Expanded infixNotation to accept a list or tuple of parse actions
  618. to attach to an operation.
  619. - New unit test added for dill support for storing pyparsing parsers.
  620. Ordinary Python pickle can be used to pickle pyparsing parsers as
  621. long as they do not use any parse actions. The 'dill' module is an
  622. extension to pickle which *does* support pickling of attached
  623. parse actions.
  624. Version 2.1.10 - October, 2016
  625. -------------------------------
  626. - Fixed bug in reporting named parse results for ZeroOrMore
  627. expressions, thanks Ethan Nash for reporting this!
  628. - Fixed behavior of LineStart to be much more predictable.
  629. LineStart can now be used to detect if the next parse position
  630. is col 1, factoring in potential leading whitespace (which would
  631. cause LineStart to fail). Also fixed a bug in col, which is
  632. used in LineStart, where '\n's were erroneously considered to
  633. be column 1.
  634. - Added support for multiline test strings in runTests.
  635. - Fixed bug in ParseResults.dump when keys were not strings.
  636. Also changed display of string values to show them in quotes,
  637. to help distinguish parsed numeric strings from parsed integers
  638. that have been converted to Python ints.
  639. Version 2.1.9 - September, 2016
  640. -------------------------------
  641. - Added class CloseMatch, a variation on Literal which matches
  642. "close" matches, that is, strings with at most 'n' mismatching
  643. characters.
  644. - Fixed bug in Keyword.setDefaultKeywordChars(), reported by Kobayashi
  645. Shinji - nice catch, thanks!
  646. - Minor API change in pyparsing_common. Renamed some of the common
  647. expressions to PEP8 format (to be consistent with the other
  648. pyparsing_common expressions):
  649. . signedInteger -> signed_integer
  650. . sciReal -> sci_real
  651. Also, in trying to stem the API bloat of pyparsing, I've copied
  652. some of the global expressions and helper parse actions into
  653. pyparsing_common, with the originals to be deprecated and removed
  654. in a future release:
  655. . commaSeparatedList -> pyparsing_common.comma_separated_list
  656. . upcaseTokens -> pyparsing_common.upcaseTokens
  657. . downcaseTokens -> pyparsing_common.downcaseTokens
  658. (I don't expect any other expressions, like the comment expressions,
  659. quotedString, or the Word-helping strings like alphas, nums, etc.
  660. to migrate to pyparsing_common - they are just too pervasive. As for
  661. the PEP8 vs camelCase naming, all the expressions are PEP8, while
  662. the parse actions in pyparsing_common are still camelCase. It's a
  663. small step - when pyparsing 3.0 comes around, everything will change
  664. to PEP8 snake case.)
  665. - Fixed Python3 compatibility bug when using dict keys() and values()
  666. in ParseResults.getName().
  667. - After some prodding, I've reworked the unitTests.py file for
  668. pyparsing over the past few releases. It uses some variations on
  669. unittest to handle my testing style. The test now:
  670. . auto-discovers its test classes (while maintining their order
  671. of definition)
  672. . suppresses voluminous 'print' output for tests that pass
  673. Version 2.1.8 - August, 2016
  674. ----------------------------
  675. - Fixed issue in the optimization to _trim_arity, when the full
  676. stacktrace is retrieved to determine if a TypeError is raised in
  677. pyparsing or in the caller's parse action. Code was traversing
  678. the full stacktrace, and potentially encountering UnicodeDecodeError.
  679. - Fixed bug in ParserElement.inlineLiteralsUsing, causing infinite
  680. loop with Suppress.
  681. - Fixed bug in Each, when merging named results from multiple
  682. expressions in a ZeroOrMore or OneOrMore. Also fixed bug when
  683. ZeroOrMore expressions were erroneously treated as required
  684. expressions in an Each expression.
  685. - Added a few more inline doc examples.
  686. - Improved use of runTests in several example scripts.
  687. Version 2.1.7 - August, 2016
  688. ----------------------------
  689. - Fixed regression reported by Andrea Censi (surfaced in PyContracts
  690. tests) when using ParseSyntaxExceptions (raised when using operator '-')
  691. with packrat parsing.
  692. - Minor fix to oneOf, to accept all iterables, not just space-delimited
  693. strings and lists. (If you have a list or set of strings, it is
  694. not necessary to concat them using ' '.join to pass them to oneOf,
  695. oneOf will accept the list or set or generator directly.)
  696. Version 2.1.6 - August, 2016
  697. ----------------------------
  698. - *Major packrat upgrade*, inspired by patch provided by Tal Einat -
  699. many, many, thanks to Tal for working on this! Tal's tests show
  700. faster parsing performance (2X in some tests), *and* memory reduction
  701. from 3GB down to ~100MB! Requires no changes to existing code using
  702. packratting. (Uses OrderedDict, available in Python 2.7 and later.
  703. For Python 2.6 users, will attempt to import from ordereddict
  704. backport. If not present, will implement pure-Python Fifo dict.)
  705. - Minor API change - to better distinguish between the flexible
  706. numeric types defined in pyparsing_common, I've changed "numeric"
  707. (which parsed numbers of different types and returned int for ints,
  708. float for floats, etc.) and "number" (which parsed numbers of int
  709. or float type, and returned all floats) to "number" and "fnumber"
  710. respectively. I hope the "f" prefix of "fnumber" will be a better
  711. indicator of its internal conversion of parsed values to floats,
  712. while the generic "number" is similar to the flexible number syntax
  713. in other languages. Also fixed a bug in pyparsing_common.numeric
  714. (now renamed to pyparsing_common.number), integers were parsed and
  715. returned as floats instead of being retained as ints.
  716. - Fixed bug in upcaseTokens and downcaseTokens introduced in 2.1.5,
  717. when the parse action was used in conjunction with results names.
  718. Reported by Steven Arcangeli from the dql project, thanks for your
  719. patience, Steven!
  720. - Major change to docs! After seeing some comments on reddit about
  721. general issue with docs of Python modules, and thinking that I'm a
  722. little overdue in doing some doc tuneup on pyparsing, I decided to
  723. following the suggestions of the redditor and add more inline examples
  724. to the pyparsing reference documentation. I hope this addition
  725. will clarify some of the more common questions people have, especially
  726. when first starting with pyparsing/Python.
  727. - Deprecated ParseResults.asXML. I've never been too happy with this
  728. method, and it usually forces some unnatural code in the parsers in
  729. order to get decent tag names. The amount of guesswork that asXML
  730. has to do to try to match names with values should have been a red
  731. flag from day one. If you are using asXML, you will need to implement
  732. your own ParseResults->XML serialization. Or consider migrating to
  733. a more current format such as JSON (which is very easy to do:
  734. results_as_json = json.dumps(parse_result.asDict()) Hopefully, when
  735. I remove this code in a future version, I'll also be able to simplify
  736. some of the craziness in ParseResults, which IIRC was only there to try
  737. to make asXML work.
  738. - Updated traceParseAction parse action decorator to show the repr
  739. of the input and output tokens, instead of the str format, since
  740. str has been simplified to just show the token list content.
  741. (The change to ParseResults.__str__ occurred in pyparsing 2.0.4, but
  742. it seems that didn't make it into the release notes - sorry! Too
  743. many users, especially beginners, were confused by the
  744. "([token_list], {names_dict})" str format for ParseResults, thinking
  745. they were getting a tuple containing a list and a dict. The full form
  746. can be seen if using repr().)
  747. For tracing tokens in and out of parse actions, the more complete
  748. repr form provides important information when debugging parse actions.
  749. Verison 2.1.5 - June, 2016
  750. ------------------------------
  751. - Added ParserElement.split() generator method, similar to re.split().
  752. Includes optional arguments maxsplit (to limit the number of splits),
  753. and includeSeparators (to include the separating matched text in the
  754. returned output, default=False).
  755. - Added a new parse action construction helper tokenMap, which will
  756. apply a function and optional arguments to each element in a
  757. ParseResults. So this parse action:
  758. def lowercase_all(tokens):
  759. return [str(t).lower() for t in tokens]
  760. OneOrMore(Word(alphas)).setParseAction(lowercase_all)
  761. can now be written:
  762. OneOrMore(Word(alphas)).setParseAction(tokenMap(str.lower))
  763. Also simplifies writing conversion parse actions like:
  764. integer = Word(nums).setParseAction(lambda t: int(t[0]))
  765. to just:
  766. integer = Word(nums).setParseAction(tokenMap(int))
  767. If additional arguments are necessary, they can be included in the
  768. call to tokenMap, as in:
  769. hex_integer = Word(hexnums).setParseAction(tokenMap(int, 16))
  770. - Added more expressions to pyparsing_common:
  771. . IPv4 and IPv6 addresses (including long, short, and mixed forms
  772. of IPv6)
  773. . MAC address
  774. . ISO8601 date and date time strings (with named fields for year, month, etc.)
  775. . UUID (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
  776. . hex integer (returned as int)
  777. . fraction (integer '/' integer, returned as float)
  778. . mixed integer (integer '-' fraction, or just fraction, returned as float)
  779. . stripHTMLTags (parse action to remove tags from HTML source)
  780. . parse action helpers convertToDate and convertToDatetime to do custom parse
  781. time conversions of parsed ISO8601 strings
  782. - runTests now returns a two-tuple: success if all tests succeed,
  783. and an output list of each test and its output lines.
  784. - Added failureTests argument (default=False) to runTests, so that
  785. tests can be run that are expected failures, and runTests' success
  786. value will return True only if all tests *fail* as expected. Also,
  787. parseAll now defaults to True.
  788. - New example numerics.py, shows samples of parsing integer and real
  789. numbers using locale-dependent formats:
  790. 4.294.967.295,000
  791. 4 294 967 295,000
  792. 4,294,967,295.000
  793. Version 2.1.4 - May, 2016
  794. ------------------------------
  795. - Split out the '==' behavior in ParserElement, now implemented
  796. as the ParserElement.matches() method. Using '==' for string test
  797. purposes will be removed in a future release.
  798. - Expanded capabilities of runTests(). Will now accept embedded
  799. comments (default is Python style, leading '#' character, but
  800. customizable). Comments will be emitted along with the tests and
  801. test output. Useful during test development, to create a test string
  802. consisting only of test case description comments separated by
  803. blank lines, and then fill in the test cases. Will also highlight
  804. ParseFatalExceptions with "(FATAL)".
  805. - Added a 'pyparsing_common' class containing common/helpful little
  806. expressions such as integer, float, identifier, etc. I used this
  807. class as a sort of embedded namespace, to contain these helpers
  808. without further adding to pyparsing's namespace bloat.
  809. - Minor enhancement to traceParseAction decorator, to retain the
  810. parse action's name for the trace output.
  811. - Added optional 'fatal' keyword arg to addCondition, to indicate that
  812. a condition failure should halt parsing immediately.
  813. Version 2.1.3 - May, 2016
  814. ------------------------------
  815. - _trim_arity fix in 2.1.2 was very version-dependent on Py 3.5.0.
  816. Now works for Python 2.x, 3.3, 3.4, 3.5.0, and 3.5.1 (and hopefully
  817. beyond).
  818. Version 2.1.2 - May, 2016
  819. ------------------------------
  820. - Fixed bug in _trim_arity when pyparsing code is included in a
  821. PyInstaller, reported by maluwa.
  822. - Fixed catastrophic regex backtracking in implementation of the
  823. quoted string expressions (dblQuotedString, sglQuotedString, and
  824. quotedString). Reported on the pyparsing wiki by webpentest,
  825. good catch! (Also tuned up some other expressions susceptible to the
  826. same backtracking problem, such as cStyleComment, cppStyleComment,
  827. etc.)
  828. Version 2.1.1 - March, 2016
  829. ---------------------------
  830. - Added support for assigning to ParseResults using slices.
  831. - Fixed bug in ParseResults.toDict(), in which dict values were always
  832. converted to dicts, even if they were just unkeyed lists of tokens.
  833. Reported on SO by Gerald Thibault, thanks Gerald!
  834. - Fixed bug in SkipTo when using failOn, reported by robyschek, thanks!
  835. - Fixed bug in Each introduced in 2.1.0, reported by AND patch and
  836. unit test submitted by robyschek, well done!
  837. - Removed use of functools.partial in replaceWith, as this creates
  838. an ambiguous signature for the generated parse action, which fails in
  839. PyPy. Reported by Evan Hubinger, thanks Evan!
  840. - Added default behavior to QuotedString to convert embedded '\t', '\n',
  841. etc. characters to their whitespace counterparts. Found during Q&A
  842. exchange on SO with Maxim.
  843. Version 2.1.0 - February, 2016
  844. ------------------------------
  845. - Modified the internal _trim_arity method to distinguish between
  846. TypeError's raised while trying to determine parse action arity and
  847. those raised within the parse action itself. This will clear up those
  848. confusing "<lambda>() takes exactly 1 argument (0 given)" error
  849. messages when there is an actual TypeError in the body of the parse
  850. action. Thanks to all who have raised this issue in the past, and
  851. most recently to Michael Cohen, who sent in a proposed patch, and got
  852. me to finally tackle this problem.
  853. - Added compatibility for pickle protocols 2-4 when pickling ParseResults.
  854. In Python 2.x, protocol 0 was the default, and protocol 2 did not work.
  855. In Python 3.x, protocol 3 is the default, so explicitly naming
  856. protocol 0 or 1 was required to pickle ParseResults. With this release,
  857. all protocols 0-4 are supported. Thanks for reporting this on StackOverflow,
  858. Arne Wolframm, and for providing a nice simple test case!
  859. - Added optional 'stopOn' argument to ZeroOrMore and OneOrMore, to
  860. simplify breaking on stop tokens that would match the repetition
  861. expression.
  862. It is a common problem to fail to look ahead when matching repetitive
  863. tokens if the sentinel at the end also matches the repetition
  864. expression, as when parsing "BEGIN aaa bbb ccc END" with:
  865. "BEGIN" + OneOrMore(Word(alphas)) + "END"
  866. Since "END" matches the repetition expression "Word(alphas)", it will
  867. never get parsed as the terminating sentinel. Up until now, this has
  868. to be resolved by the user inserting their own negative lookahead:
  869. "BEGIN" + OneOrMore(~Literal("END") + Word(alphas)) + "END"
  870. Using stopOn, they can more easily write:
  871. "BEGIN" + OneOrMore(Word(alphas), stopOn="END") + "END"
  872. The stopOn argument can be a literal string or a pyparsing expression.
  873. Inspired by a question by Lamakaha on StackOverflow (and many previous
  874. questions with the same negative-lookahead resolution).
  875. - Added expression names for many internal and builtin expressions, to
  876. reduce name and error message overhead during parsing.
  877. - Converted helper lambdas to functions to refactor and add docstring
  878. support.
  879. - Fixed ParseResults.asDict() to correctly convert nested ParseResults
  880. values to dicts.
  881. - Cleaned up some examples, fixed typo in fourFn.py identified by
  882. aristotle2600 on reddit.
  883. - Removed keepOriginalText helper method, which was deprecated ages ago.
  884. Superceded by originalTextFor.
  885. - Same for the Upcase class, which was long ago deprecated and replaced
  886. with the upcaseTokens method.
  887. Version 2.0.7 - December, 2015
  888. ------------------------------
  889. - Simplified string representation of Forward class, to avoid memory
  890. and performance errors while building ParseException messages. Thanks,
  891. Will McGugan, Andrea Censi, and Martijn Vermaat for the bug reports and
  892. test code.
  893. - Cleaned up additional issues from enhancing the error messages for
  894. Or and MatchFirst, handling Unicode values in expressions. Fixes Unicode
  895. encoding issues in Python 2, thanks to Evan Hubinger for the bug report.
  896. - Fixed implementation of dir() for ParseResults - was leaving out all the
  897. defined methods and just adding the custom results names.
  898. - Fixed bug in ignore() that was introduced in pyparsing 1.5.3, that would
  899. not accept a string literal as the ignore expression.
  900. - Added new example parseTabularData.py to illustrate parsing of data
  901. formatted in columns, with detection of empty cells.
  902. - Updated a number of examples to more current Python and pyparsing
  903. forms.
  904. Version 2.0.6 - November, 2015
  905. ------------------------------
  906. - Fixed a bug in Each when multiple Optional elements are present.
  907. Thanks for reporting this, whereswalden on SO.
  908. - Fixed another bug in Each, when Optional elements have results names
  909. or parse actions, reported by Max Rothman - thank you, Max!
  910. - Added optional parseAll argument to runTests, whether tests should
  911. require the entire input string to be parsed or not (similar to
  912. parseAll argument to parseString). Plus a little neaten-up of the
  913. output on Python 2 (no stray ()'s).
  914. - Modified exception messages from MatchFirst and Or expressions. These
  915. were formerly misleading as they would only give the first or longest
  916. exception mismatch error message. Now the error message includes all
  917. the alternatives that were possible matches. Originally proposed by
  918. a pyparsing user, but I've lost the email thread - finally figured out
  919. a fairly clean way to do this.
  920. - Fixed a bug in Or, when a parse action on an alternative raises an
  921. exception, other potentially matching alternatives were not always tried.
  922. Reported by TheVeryOmni on the pyparsing wiki, thanks!
  923. - Fixed a bug to dump() introduced in 2.0.4, where list values were shown
  924. in duplicate.
  925. Version 2.0.5 - October, 2015
  926. -----------------------------
  927. - (&$(@#&$(@!!!! Some "print" statements snuck into pyparsing v2.0.4,
  928. breaking Python 3 compatibility! Fixed. Reported by jenshn, thanks!
  929. Version 2.0.4 - October, 2015
  930. -----------------------------
  931. - Added ParserElement.addCondition, to simplify adding parse actions
  932. that act primarily as filters. If the given condition evaluates False,
  933. pyparsing will raise a ParseException. The condition should be a method
  934. with the same method signature as a parse action, but should return a
  935. boolean. Suggested by Victor Porton, nice idea Victor, thanks!
  936. - Slight mod to srange to accept unicode literals for the input string,
  937. such as "[а-яА-Я]" instead of "[\u0430-\u044f\u0410-\u042f]". Thanks
  938. to Alexandr Suchkov for the patch!
  939. - Enhanced implementation of replaceWith.
  940. - Fixed enhanced ParseResults.dump() method when the results consists
  941. only of an unnamed array of sub-structure results. Reported by Robin
  942. Siebler, thanks for your patience and persistence, Robin!
  943. - Fixed bug in fourFn.py example code, where pi and e were defined using
  944. CaselessLiteral instead of CaselessKeyword. This was not a problem until
  945. adding a new function 'exp', and the leading 'e' of 'exp' was accidentally
  946. parsed as the mathematical constant 'e'. Nice catch, Tom Grydeland - thanks!
  947. - Adopt new-fangled Python features, like decorators and ternary expressions,
  948. per suggestions from Williamzjc - thanks William! (Oh yeah, I'm not
  949. supporting Python 2.3 with this code any more...) Plus, some additional
  950. code fixes/cleanup - thanks again!
  951. - Added ParserElement.runTests, a little test bench for quickly running
  952. an expression against a list of sample input strings. Basically, I got
  953. tired of writing the same test code over and over, and finally added it
  954. as a test point method on ParserElement.
  955. - Added withClass helper method, a simplified version of withAttribute for
  956. the common but annoying case when defining a filter on a div's class -
  957. made difficult because 'class' is a Python reserved word.
  958. Version 2.0.3 - October, 2014
  959. -----------------------------
  960. - Fixed escaping behavior in QuotedString. Formerly, only quotation
  961. marks (or characters designated as quotation marks in the QuotedString
  962. constructor) would be escaped. Now all escaped characters will be
  963. escaped, and the escaping backslashes will be removed.
  964. - Fixed regression in ParseResults.pop() - pop() was pretty much
  965. broken after I added *improvements* in 2.0.2. Reported by Iain
  966. Shelvington, thanks Iain!
  967. - Fixed bug in And class when initializing using a generator.
  968. - Enhanced ParseResults.dump() method to list out nested ParseResults that
  969. are unnamed arrays of sub-structures.
  970. - Fixed UnboundLocalError under Python 3.4 in oneOf method, reported
  971. on Sourceforge by aldanor, thanks!
  972. - Fixed bug in ParseResults __init__ method, when returning non-ParseResults
  973. types from parse actions that implement __eq__. Raised during discussion
  974. on the pyparsing wiki with cyrfer.
  975. Version 2.0.2 - April, 2014
  976. ---------------------------
  977. - Extended "expr(name)" shortcut (same as "expr.setResultsName(name)")
  978. to accept "expr()" as a shortcut for "expr.copy()".
  979. - Added "locatedExpr(expr)" helper, to decorate any returned tokens
  980. with their location within the input string. Adds the results names
  981. locn_start and locn_end to the output parse results.
  982. - Added "pprint()" method to ParseResults, to simplify troubleshooting
  983. and prettified output. Now instead of importing the pprint module
  984. and then writing "pprint.pprint(result)", you can just write
  985. "result.pprint()". This method also accepts addtional positional and
  986. keyword arguments (such as indent, width, etc.), which get passed
  987. through directly to the pprint method
  988. (see https://docs.python.org/2/library/pprint.html#pprint.pprint).
  989. - Removed deprecation warnings when using '<<' for Forward expression
  990. assignment. '<<=' is still preferred, but '<<' will be retained
  991. for cases where '<<=' operator is not suitable (such as in defining
  992. lambda expressions).
  993. - Expanded argument compatibility for classes and functions that
  994. take list arguments, to now accept generators as well.
  995. - Extended list-like behavior of ParseResults, adding support for
  996. append and extend. NOTE: if you have existing applications using
  997. these names as results names, you will have to access them using
  998. dict-style syntax: res["append"] and res["extend"]
  999. - ParseResults emulates the change in list vs. iterator semantics for
  1000. methods like keys(), values(), and items(). Under Python 2.x, these
  1001. methods will return lists, under Python 3.x, these methods will
  1002. return iterators.
  1003. - ParseResults now has a method haskeys() which returns True or False
  1004. depending on whether any results names have been defined. This simplifies
  1005. testing for the existence of results names under Python 3.x, which
  1006. returns keys() as an iterator, not a list.
  1007. - ParseResults now supports both list and dict semantics for pop().
  1008. If passed no argument or an integer argument, it will use list semantics
  1009. and pop tokens from the list of parsed tokens. If passed a non-integer
  1010. argument (most likely a string), it will use dict semantics and
  1011. pop the corresponding value from any defined results names. A
  1012. second default return value argument is supported, just as in
  1013. dict.pop().
  1014. - Fixed bug in markInputline, thanks for reporting this, Matt Grant!
  1015. - Cleaned up my unit test environment, now runs with Python 2.6 and
  1016. 3.3.
  1017. Version 2.0.1 - July, 2013
  1018. --------------------------
  1019. - Removed use of "nonlocal" that prevented using this version of
  1020. pyparsing with Python 2.6 and 2.7. This will make it easier to
  1021. install for packages that depend on pyparsing, under Python
  1022. versions 2.6 and later. Those using older versions of Python
  1023. will have to manually install pyparsing 1.5.7.
  1024. - Fixed implementation of <<= operator to return self; reported by
  1025. Luc J. Bourhis, with patch fix by Mathias Mamsch - thanks, Luc
  1026. and Mathias!
  1027. Version 2.0.0 - November, 2012
  1028. ------------------------------
  1029. - Rather than release another combined Python 2.x/3.x release
  1030. I've decided to start a new major version that is only
  1031. compatible with Python 3.x (and consequently Python 2.7 as
  1032. well due to backporting of key features). This version will
  1033. be the main development path from now on, with little follow-on
  1034. development on the 1.5.x path.
  1035. - Operator '<<' is now deprecated, in favor of operator '<<=' for
  1036. attaching parsing expressions to Forward() expressions. This is
  1037. being done to address precedence of operations problems with '<<'.
  1038. Operator '<<' will be removed in a future version of pyparsing.
  1039. Version 1.5.7 - November, 2012
  1040. -----------------------------
  1041. - NOTE: This is the last release of pyparsing that will try to
  1042. maintain compatibility with Python versions < 2.6. The next
  1043. release of pyparsing will be version 2.0.0, using new Python
  1044. syntax that will not be compatible for Python version 2.5 or
  1045. older.
  1046. - An awesome new example is included in this release, submitted
  1047. by Luca DellOlio, for parsing ANTLR grammar definitions, nice
  1048. work Luca!
  1049. - Fixed implementation of ParseResults.__str__ to use Pythonic
  1050. ''.join() instead of repeated string concatenation. This
  1051. purportedly has been a performance issue under PyPy.
  1052. - Fixed bug in ParseResults.__dir__ under Python 3, reported by
  1053. Thomas Kluyver, thank you Thomas!
  1054. - Added ParserElement.inlineLiteralsUsing static method, to
  1055. override pyparsing's default behavior of converting string
  1056. literals to Literal instances, to use other classes (such
  1057. as Suppress or CaselessLiteral).
  1058. - Added new operator '<<=', which will eventually replace '<<' for
  1059. storing the contents of a Forward(). '<<=' does not have the same
  1060. operator precedence problems that '<<' does.
  1061. - 'operatorPrecedence' is being renamed 'infixNotation' as a better
  1062. description of what this helper function creates. 'operatorPrecedence'
  1063. is deprecated, and will be dropped entirely in a future release.
  1064. - Added optional arguments lpar and rpar to operatorPrecedence, so that
  1065. expressions that use it can override the default suppression of the
  1066. grouping characters.
  1067. - Added support for using single argument builtin functions as parse
  1068. actions. Now you can write 'expr.setParseAction(len)' and get back
  1069. the length of the list of matched tokens. Supported builtins are:
  1070. sum, len, sorted, reversed, list, tuple, set, any, all, min, and max.
  1071. A script demonstrating this feature is included in the examples
  1072. directory.
  1073. - Improved linking in generated docs, proposed on the pyparsing wiki
  1074. by techtonik, thanks!
  1075. - Fixed a bug in the definition of 'alphas', which was based on the
  1076. string.uppercase and string.lowercase "constants", which in fact
  1077. *aren't* constant, but vary with locale settings. This could make
  1078. parsers locale-sensitive in a subtle way. Thanks to Kef Schecter for
  1079. his diligence in following through on reporting and monitoring
  1080. this bugfix!
  1081. - Fixed a bug in the Py3 version of pyparsing, during exception
  1082. handling with packrat parsing enabled, reported by Catherine
  1083. Devlin - thanks Catherine!
  1084. - Fixed typo in ParseBaseException.__dir__, reported anonymously on
  1085. the SourceForge bug tracker, thank you Pyparsing User With No Name.
  1086. - Fixed bug in srange when using '\x###' hex character codes.
  1087. - Addeed optional 'intExpr' argument to countedArray, so that you
  1088. can define your own expression that will evaluate to an integer,
  1089. to be used as the count for the following elements. Allows you
  1090. to define a countedArray with the count given in hex, for example,
  1091. by defining intExpr as "Word(hexnums).setParseAction(int(t[0],16))".
  1092. Version 1.5.6 - June, 2011
  1093. ----------------------------
  1094. - Cleanup of parse action normalizing code, to be more version-tolerant,
  1095. and robust in the face of future Python versions - much thanks to
  1096. Raymond Hettinger for this rewrite!
  1097. - Removal of exception cacheing, addressing a memory leak condition
  1098. in Python 3. Thanks to Michael Droettboom and the Cape Town PUG for
  1099. their analysis and work on this problem!
  1100. - Fixed bug when using packrat parsing, where a previously parsed
  1101. expression would duplicate subsequent tokens - reported by Frankie
  1102. Ribery on stackoverflow, thanks!
  1103. - Added 'ungroup' helper method, to address token grouping done
  1104. implicitly by And expressions, even if only one expression in the
  1105. And actually returns any text - also inspired by stackoverflow
  1106. discussion with Frankie Ribery!
  1107. - Fixed bug in srange, which accepted escaped hex characters of the
  1108. form '\0x##', but should be '\x##'. Both forms will be supported
  1109. for backwards compatibility.
  1110. - Enhancement to countedArray, accepting an optional expression to be
  1111. used for matching the leading integer count - proposed by Mathias on
  1112. the pyparsing mailing list, good idea!
  1113. - Added the Verilog parser to the provided set of examples, under the
  1114. MIT license. While this frees up this parser for any use, if you find
  1115. yourself using it in a commercial purpose, please consider making a
  1116. charitable donation as described in the parser's header.
  1117. - Added the excludeChars argument to the Word class, to simplify defining
  1118. a word composed of all characters in a large range except for one or
  1119. two. Suggested by JesterEE on the pyparsing wiki.
  1120. - Added optional overlap parameter to scanString, to return overlapping
  1121. matches found in the source text.
  1122. - Updated oneOf internal regular expression generation, with improved
  1123. parse time performance.
  1124. - Slight performance improvement in transformString, removing empty
  1125. strings from the list of string fragments built while scanning the
  1126. source text, before calling ''.join. Especially useful when using
  1127. transformString to strip out selected text.
  1128. - Enhanced form of using the "expr('name')" style of results naming,
  1129. in lieu of calling setResultsName. If name ends with an '*', then
  1130. this is equivalent to expr.setResultsName('name',listAllMatches=True).
  1131. - Fixed up internal list flattener to use iteration instead of recursion,
  1132. to avoid stack overflow when transforming large files.
  1133. - Added other new examples:
  1134. . protobuf parser - parses Google's protobuf language
  1135. . btpyparse - a BibTex parser contributed by Matthew Brett,
  1136. with test suite test_bibparse.py (thanks, Matthew!)
  1137. . groupUsingListAllMatches.py - demo using trailing '*' for results
  1138. names
  1139. Version 1.5.5 - August, 2010
  1140. ----------------------------
  1141. - Typo in Python3 version of pyparsing, "builtin" should be "builtins".
  1142. (sigh)
  1143. Version 1.5.4 - August, 2010
  1144. ----------------------------
  1145. - Fixed __builtins__ and file references in Python 3 code, thanks to
  1146. Greg Watson, saulspatz, sminos, and Mark Summerfield for reporting
  1147. their Python 3 experiences.
  1148. - Added new example, apicheck.py, as a sample of scanning a Tcl-like
  1149. language for functions with incorrect number of arguments (difficult
  1150. to track down in Tcl languages). This example uses some interesting
  1151. methods for capturing exceptions while scanning through source
  1152. code.
  1153. - Added new example deltaTime.py, that takes everyday time references
  1154. like "an hour from now", "2 days ago", "next Sunday at 2pm".
  1155. Version 1.5.3 - June, 2010
  1156. --------------------------
  1157. - ======= NOTE: API CHANGE!!!!!!! ===============
  1158. With this release, and henceforward, the pyparsing module is
  1159. imported as "pyparsing" on both Python 2.x and Python 3.x versions.
  1160. - Fixed up setup.py to auto-detect Python version and install the
  1161. correct version of pyparsing - suggested by Alex Martelli,
  1162. thanks, Alex! (and my apologies to all those who struggled with
  1163. those spurious installation errors caused by my earlier
  1164. fumblings!)
  1165. - Fixed bug on Python3 when using parseFile, getting bytes instead of
  1166. a str from the input file.
  1167. - Fixed subtle bug in originalTextFor, if followed by
  1168. significant whitespace (like a newline) - discovered by
  1169. Francis Vidal, thanks!
  1170. - Fixed very sneaky bug in Each, in which Optional elements were
  1171. not completely recognized as optional - found by Tal Weiss, thanks
  1172. for your patience.
  1173. - Fixed off-by-1 bug in line() method when the first line of the
  1174. input text was an empty line. Thanks to John Krukoff for submitting
  1175. a patch!
  1176. - Fixed bug in transformString if grammar contains Group expressions,
  1177. thanks to patch submitted by barnabas79, nice work!
  1178. - Fixed bug in originalTextFor in which trailing comments or otherwised
  1179. ignored text got slurped in with the matched expression. Thanks to
  1180. michael_ramirez44 on the pyparsing wiki for reporting this just in
  1181. time to get into this release!
  1182. - Added better support for summing ParseResults, see the new example,
  1183. parseResultsSumExample.py.
  1184. - Added support for composing a Regex using a compiled RE object;
  1185. thanks to my new colleague, Mike Thornton!
  1186. - In version 1.5.2, I changed the way exceptions are raised in order
  1187. to simplify the stacktraces reported during parsing. An anonymous
  1188. user posted a bug report on SF that this behavior makes it difficult
  1189. to debug some complex parsers, or parsers nested within parsers. In
  1190. this release I've added a class attribute ParserElement.verbose_stacktrace,
  1191. with a default value of False. If you set this to True, pyparsing will
  1192. report stacktraces using the pre-1.5.2 behavior.
  1193. - New examples:
  1194. . pymicko.py, a MicroC compiler submitted by Zarko Zivanov.
  1195. (Note: this example is separately licensed under the GPLv3,
  1196. and requires Python 2.6 or higher.) Thank you, Zarko!
  1197. . oc.py, a subset C parser, using the BNF from the 1996 Obfuscated C
  1198. Contest.
  1199. . stateMachine2.py, a modified version of stateMachine.py submitted
  1200. by Matt Anderson, that is compatible with Python versions 2.7 and
  1201. above - thanks so much, Matt!
  1202. . select_parser.py, a parser for reading SQLite SELECT statements,
  1203. as specified at https://www.sqlite.org/lang_select.html this goes
  1204. into much more detail than the simple SQL parser included in pyparsing's
  1205. source code
  1206. . excelExpr.py, a *simplistic* first-cut at a parser for Excel
  1207. expressions, which I originally posted on comp.lang.python in January,
  1208. 2010; beware, this parser omits many common Excel cases (addition of
  1209. numbers represented as strings, references to named ranges)
  1210. . cpp_enum_parser.py, a nice little parser posted my Mark Tolonen on
  1211. comp.lang.python in August, 2009 (redistributed here with Mark's
  1212. permission). Thanks a bunch, Mark!
  1213. . partial_gene_match.py, a sample I posted to Stackoverflow.com,
  1214. implementing a special variation on Literal that does "close" matching,
  1215. up to a given number of allowed mismatches. The application was to
  1216. find matching gene sequences, with allowance for one or two mismatches.
  1217. . tagCapture.py, a sample showing how to use a Forward placeholder to
  1218. enforce matching of text parsed in a previous expression.
  1219. . matchPreviousDemo.py, simple demo showing how the matchPreviousLiteral
  1220. helper method is used to match a previously parsed token.
  1221. Version 1.5.2 - April, 2009
  1222. ------------------------------
  1223. - Added pyparsing_py3.py module, so that Python 3 users can use
  1224. pyparsing by changing their pyparsing import statement to:
  1225. import pyparsing_py3
  1226. Thanks for help from Patrick Laban and his friend Geremy
  1227. Condra on the pyparsing wiki.
  1228. - Removed __slots__ declaration on ParseBaseException, for
  1229. compatibility with IronPython 2.0.1. Raised by David
  1230. Lawler on the pyparsing wiki, thanks David!
  1231. - Fixed bug in SkipTo/failOn handling - caught by eagle eye
  1232. cpennington on the pyparsing wiki!
  1233. - Fixed second bug in SkipTo when using the ignore constructor
  1234. argument, reported by Catherine Devlin, thanks!
  1235. - Fixed obscure bug reported by Eike Welk when using a class
  1236. as a ParseAction with an errant __getitem__ method.
  1237. - Simplified exception stack traces when reporting parse
  1238. exceptions back to caller of parseString or parseFile - thanks
  1239. to a tip from Peter Otten on comp.lang.python.
  1240. - Changed behavior of scanString to avoid infinitely looping on
  1241. expressions that match zero-length strings. Prompted by a
  1242. question posted by ellisonbg on the wiki.
  1243. - Enhanced classes that take a list of expressions (And, Or,
  1244. MatchFirst, and Each) to accept generator expressions also.
  1245. This can be useful when generating lists of alternative
  1246. expressions, as in this case, where the user wanted to match
  1247. any repetitions of '+', '*', '#', or '.', but not mixtures
  1248. of them (that is, match '+++', but not '+-+'):
  1249. codes = "+*#."
  1250. format = MatchFirst(Word(c) for c in codes)
  1251. Based on a problem posed by Denis Spir on the Python tutor
  1252. list.
  1253. - Added new example eval_arith.py, which extends the example
  1254. simpleArith.py to actually evaluate the parsed expressions.
  1255. Version 1.5.1 - October, 2008
  1256. -------------------------------
  1257. - Added new helper method originalTextFor, to replace the use of
  1258. the current keepOriginalText parse action. Now instead of
  1259. using the parse action, as in:
  1260. fullName = Word(alphas) + Word(alphas)
  1261. fullName.setParseAction(keepOriginalText)
  1262. (in this example, we used keepOriginalText to restore any white
  1263. space that may have been skipped between the first and last
  1264. names)
  1265. You can now write:
  1266. fullName = originalTextFor(Word(alphas) + Word(alphas))
  1267. The implementation of originalTextFor is simpler and faster than
  1268. keepOriginalText, and does not depend on using the inspect or
  1269. imp modules.
  1270. - Added optional parseAll argument to parseFile, to be consistent
  1271. with parseAll argument to parseString. Posted by pboucher on the
  1272. pyparsing wiki, thanks!
  1273. - Added failOn argument to SkipTo, so that grammars can define
  1274. literal strings or pyparsing expressions which, if found in the
  1275. skipped text, will cause SkipTo to fail. Useful to prevent
  1276. SkipTo from reading past terminating expression. Instigated by
  1277. question posed by Aki Niimura on the pyparsing wiki.
  1278. - Fixed bug in nestedExpr if multi-character expressions are given
  1279. for nesting delimiters. Patch provided by new pyparsing user,
  1280. Hans-Martin Gaudecker - thanks, H-M!
  1281. - Removed dependency on xml.sax.saxutils.escape, and included
  1282. internal implementation instead - proposed by Mike Droettboom on
  1283. the pyparsing mailing list, thanks Mike! Also fixed erroneous
  1284. mapping in replaceHTMLEntity of &quot; to ', now correctly maps
  1285. to ". (Also added support for mapping &apos; to '.)
  1286. - Fixed typo in ParseResults.insert, found by Alejandro Dubrovsky,
  1287. good catch!
  1288. - Added __dir__() methods to ParseBaseException and ParseResults,
  1289. to support new dir() behavior in Py2.6 and Py3.0. If dir() is
  1290. called on a ParseResults object, the returned list will include
  1291. the base set of attribute names, plus any results names that are
  1292. defined.
  1293. - Fixed bug in ParseResults.asXML(), in which the first named
  1294. item within a ParseResults gets reported with an <ITEM> tag
  1295. instead of with the correct results name.
  1296. - Fixed bug in '-' error stop, when '-' operator is used inside a
  1297. Combine expression.
  1298. - Reverted generator expression to use list comprehension, for
  1299. better compatibility with old versions of Python. Reported by
  1300. jester/artixdesign on the SourceForge pyparsing discussion list.
  1301. - Fixed bug in parseString(parseAll=True), when the input string
  1302. ends with a comment or whitespace.
  1303. - Fixed bug in LineStart and LineEnd that did not recognize any
  1304. special whitespace chars defined using ParserElement.setDefault-
  1305. WhitespaceChars, found while debugging an issue for Marek Kubica,
  1306. thanks for the new test case, Marek!
  1307. - Made Forward class more tolerant of subclassing.
  1308. Version 1.5.0 - June, 2008
  1309. --------------------------
  1310. This version of pyparsing includes work on two long-standing
  1311. FAQ's: support for forcing parsing of the complete input string
  1312. (without having to explicitly append StringEnd() to the grammar),
  1313. and a method to improve the mechanism of detecting where syntax
  1314. errors occur in an input string with various optional and
  1315. alternative paths. This release also includes a helper method
  1316. to simplify definition of indentation-based grammars. With
  1317. these changes (and the past few minor updates), I thought it was
  1318. finally time to bump the minor rev number on pyparsing - so
  1319. 1.5.0 is now available! Read on...
  1320. - AT LAST!!! You can now call parseString and have it raise
  1321. an exception if the expression does not parse the entire
  1322. input string. This has been an FAQ for a LONG time.
  1323. The parseString method now includes an optional parseAll
  1324. argument (default=False). If parseAll is set to True, then
  1325. the given parse expression must parse the entire input
  1326. string. (This is equivalent to adding StringEnd() to the
  1327. end of the expression.) The default value is False to
  1328. retain backward compatibility.
  1329. Inspired by MANY requests over the years, most recently by
  1330. ecir-hana on the pyparsing wiki!
  1331. - Added new operator '-' for composing grammar sequences. '-'
  1332. behaves just like '+' in creating And expressions, but '-'
  1333. is used to mark grammar structures that should stop parsing
  1334. immediately and report a syntax error, rather than just
  1335. backtracking to the last successful parse and trying another
  1336. alternative. For instance, running the following code:
  1337. port_definition = Keyword("port") + '=' + Word(nums)
  1338. entity_definition = Keyword("entity") + "{" +
  1339. Optional(port_definition) + "}"
  1340. entity_definition.parseString("entity { port 100 }")
  1341. pyparsing fails to detect the missing '=' in the port definition.
  1342. But, since this expression is optional, pyparsing then proceeds
  1343. to try to match the closing '}' of the entity_definition. Not
  1344. finding it, pyparsing reports that there was no '}' after the '{'
  1345. character. Instead, we would like pyparsing to parse the 'port'
  1346. keyword, and if not followed by an equals sign and an integer,
  1347. to signal this as a syntax error.
  1348. This can now be done simply by changing the port_definition to:
  1349. port_definition = Keyword("port") - '=' + Word(nums)
  1350. Now after successfully parsing 'port', pyparsing must also find
  1351. an equals sign and an integer, or it will raise a fatal syntax
  1352. exception.
  1353. By judicious insertion of '-' operators, a pyparsing developer
  1354. can have their grammar report much more informative syntax error
  1355. messages.
  1356. Patches and suggestions proposed by several contributors on
  1357. the pyparsing mailing list and wiki - special thanks to
  1358. Eike Welk and Thomas/Poldy on the pyparsing wiki!
  1359. - Added indentedBlock helper method, to encapsulate the parse
  1360. actions and indentation stack management needed to keep track of
  1361. indentation levels. Use indentedBlock to define grammars for
  1362. indentation-based grouping grammars, like Python's.
  1363. indentedBlock takes up to 3 parameters:
  1364. - blockStatementExpr - expression defining syntax of statement
  1365. that is repeated within the indented block
  1366. - indentStack - list created by caller to manage indentation
  1367. stack (multiple indentedBlock expressions
  1368. within a single grammar should share a common indentStack)
  1369. - indent - boolean indicating whether block must be indented
  1370. beyond the current level; set to False for block of
  1371. left-most statements (default=True)
  1372. A valid block must contain at least one indented statement.
  1373. - Fixed bug in nestedExpr in which ignored expressions needed
  1374. to be set off with whitespace. Reported by Stefaan Himpe,
  1375. nice catch!
  1376. - Expanded multiplication of an expression by a tuple, to
  1377. accept tuple values of None:
  1378. . expr*(n,None) or expr*(n,) is equivalent
  1379. to expr*n + ZeroOrMore(expr)
  1380. (read as "at least n instances of expr")
  1381. . expr*(None,n) is equivalent to expr*(0,n)
  1382. (read as "0 to n instances of expr")
  1383. . expr*(None,None) is equivalent to ZeroOrMore(expr)
  1384. . expr*(1,None) is equivalent to OneOrMore(expr)
  1385. Note that expr*(None,n) does not raise an exception if
  1386. more than n exprs exist in the input stream; that is,
  1387. expr*(None,n) does not enforce a maximum number of expr
  1388. occurrences. If this behavior is desired, then write
  1389. expr*(None,n) + ~expr
  1390. - Added None as a possible operator for operatorPrecedence.
  1391. None signifies "no operator", as in multiplying m times x
  1392. in "y=mx+b".
  1393. - Fixed bug in Each, reported by Michael Ramirez, in which the
  1394. order of terms in the Each affected the parsing of the results.
  1395. Problem was due to premature grouping of the expressions in
  1396. the overall Each during grammar construction, before the
  1397. complete Each was defined. Thanks, Michael!
  1398. - Also fixed bug in Each in which Optional's with default values
  1399. were not getting the defaults added to the results of the
  1400. overall Each expression.
  1401. - Fixed a bug in Optional in which results names were not
  1402. assigned if a default value was supplied.
  1403. - Cleaned up Py3K compatibility statements, including exception
  1404. construction statements, and better equivalence between _ustr
  1405. and basestring, and __nonzero__ and __bool__.
  1406. Version 1.4.11 - February, 2008
  1407. -------------------------------
  1408. - With help from Robert A. Clark, this version of pyparsing
  1409. is compatible with Python 3.0a3. Thanks for the help,
  1410. Robert!
  1411. - Added WordStart and WordEnd positional classes, to support
  1412. expressions that must occur at the start or end of a word.
  1413. Proposed by piranha on the pyparsing wiki, good idea!
  1414. - Added matchOnlyAtCol helper parser action, to simplify
  1415. parsing log or data files that have optional fields that are
  1416. column dependent. Inspired by a discussion thread with
  1417. hubritic on comp.lang.python.
  1418. - Added withAttribute.ANY_VALUE as a match-all value when using
  1419. withAttribute. Used to ensure that an attribute is present,
  1420. without having to match on the actual attribute value.
  1421. - Added get() method to ParseResults, similar to dict.get().
  1422. Suggested by new pyparsing user, Alejandro Dubrovksy, thanks!
  1423. - Added '==' short-cut to see if a given string matches a
  1424. pyparsing expression. For instance, you can now write:
  1425. integer = Word(nums)
  1426. if "123" == integer:
  1427. # do something
  1428. print [ x for x in "123 234 asld".split() if x==integer ]
  1429. # prints ['123', '234']
  1430. - Simplified the use of nestedExpr when using an expression for
  1431. the opening or closing delimiters. Now the content expression
  1432. will not have to explicitly negate closing delimiters. Found
  1433. while working with dfinnie on GHOP Task #277, thanks!
  1434. - Fixed bug when defining ignorable expressions that are
  1435. later enclosed in a wrapper expression (such as ZeroOrMore,
  1436. OneOrMore, etc.) - found while working with Prabhu
  1437. Gurumurthy, thanks Prahbu!
  1438. - Fixed bug in withAttribute in which keys were automatically
  1439. converted to lowercase, making it impossible to match XML
  1440. attributes with uppercase characters in them. Using with-
  1441. Attribute requires that you reference attributes in all
  1442. lowercase if parsing HTML, and in correct case when parsing
  1443. XML.
  1444. - Changed '<<' operator on Forward to return None, since this
  1445. is really used as a pseudo-assignment operator, not as a
  1446. left-shift operator. By returning None, it is easier to
  1447. catch faulty statements such as a << b | c, where precedence
  1448. of operations causes the '|' operation to be performed
  1449. *after* inserting b into a, so no alternation is actually
  1450. implemented. The correct form is a << (b | c). With this
  1451. change, an error will be reported instead of silently
  1452. clipping the alternative term. (Note: this may break some
  1453. existing code, but if it does, the code had a silent bug in
  1454. it anyway.) Proposed by wcbarksdale on the pyparsing wiki,
  1455. thanks!
  1456. - Several unit tests were added to pyparsing's regression
  1457. suite, courtesy of the Google Highly-Open Participation
  1458. Contest. Thanks to all who administered and took part in
  1459. this event!
  1460. Version 1.4.10 - December 9, 2007
  1461. ---------------------------------
  1462. - Fixed bug introduced in v1.4.8, parse actions were called for
  1463. intermediate operator levels, not just the deepest matching
  1464. operation level. Again, big thanks to Torsten Marek for
  1465. helping isolate this problem!
  1466. Version 1.4.9 - December 8, 2007
  1467. --------------------------------
  1468. - Added '*' multiplication operator support when creating
  1469. grammars, accepting either an integer, or a two-integer
  1470. tuple multiplier, as in:
  1471. ipAddress = Word(nums) + ('.'+Word(nums))*3
  1472. usPhoneNumber = Word(nums) + ('-'+Word(nums))*(1,2)
  1473. If multiplying by a tuple, the two integer values represent
  1474. min and max multiples. Suggested by Vincent of eToy.com,
  1475. great idea, Vincent!
  1476. - Fixed bug in nestedExpr, original version was overly greedy!
  1477. Thanks to Michael Ramirez for raising this issue.
  1478. - Fixed internal bug in ParseResults - when an item was deleted,
  1479. the key indices were not updated. Thanks to Tim Mitchell for
  1480. posting a bugfix patch to the SF bug tracking system!
  1481. - Fixed internal bug in operatorPrecedence - when the results of
  1482. a right-associative term were sent to a parse action, the wrong
  1483. tokens were sent. Reported by Torsten Marek, nice job!
  1484. - Added pop() method to ParseResults. If pop is called with an
  1485. integer or with no arguments, it will use list semantics and
  1486. update the ParseResults' list of tokens. If pop is called with
  1487. a non-integer (a string, for instance), then it will use dict
  1488. semantics and update the ParseResults' internal dict.
  1489. Suggested by Donn Ingle, thanks Donn!
  1490. - Fixed quoted string built-ins to accept '\xHH' hex characters
  1491. within the string.
  1492. Version 1.4.8 - October, 2007
  1493. -----------------------------
  1494. - Added new helper method nestedExpr to easily create expressions
  1495. that parse lists of data in nested parentheses, braces, brackets,
  1496. etc.
  1497. - Added withAttribute parse action helper, to simplify creating
  1498. filtering parse actions to attach to expressions returned by
  1499. makeHTMLTags and makeXMLTags. Use withAttribute to qualify a
  1500. starting tag with one or more required attribute values, to avoid
  1501. false matches on common tags such as <TD> or <DIV>.
  1502. - Added new examples nested.py and withAttribute.py to demonstrate
  1503. the new features.
  1504. - Added performance speedup to grammars using operatorPrecedence,
  1505. instigated by Stefan Reichör - thanks for the feedback, Stefan!
  1506. - Fixed bug/typo when deleting an element from a ParseResults by
  1507. using the element's results name.
  1508. - Fixed whitespace-skipping bug in wrapper classes (such as Group,
  1509. Suppress, Combine, etc.) and when using setDebug(), reported by
  1510. new pyparsing user dazzawazza on SourceForge, nice job!
  1511. - Added restriction to prevent defining Word or CharsNotIn expressions
  1512. with minimum length of 0 (should use Optional if this is desired),
  1513. and enhanced docstrings to reflect this limitation. Issue was
  1514. raised by Joey Tallieu, who submitted a patch with a slightly
  1515. different solution. Thanks for taking the initiative, Joey, and
  1516. please keep submitting your ideas!
  1517. - Fixed bug in makeHTMLTags that did not detect HTML tag attributes
  1518. with no '= value' portion (such as "<td nowrap>"), reported by
  1519. hamidh on the pyparsing wiki - thanks!
  1520. - Fixed minor bug in makeHTMLTags and makeXMLTags, which did not
  1521. accept whitespace in closing tags.
  1522. Version 1.4.7 - July, 2007
  1523. --------------------------
  1524. - NEW NOTATION SHORTCUT: ParserElement now accepts results names using
  1525. a notational shortcut, following the expression with the results name
  1526. in parentheses. So this:
  1527. stats = "AVE:" + realNum.setResultsName("average") + \
  1528. "MIN:" + realNum.setResultsName("min") + \
  1529. "MAX:" + realNum.setResultsName("max")
  1530. can now be written as this:
  1531. stats = "AVE:" + realNum("average") + \
  1532. "MIN:" + realNum("min") + \
  1533. "MAX:" + realNum("max")
  1534. The intent behind this change is to make it simpler to define results
  1535. names for significant fields within the expression, while keeping
  1536. the grammar syntax clean and uncluttered.
  1537. - Fixed bug when packrat parsing is enabled, with cached ParseResults
  1538. being updated by subsequent parsing. Reported on the pyparsing
  1539. wiki by Kambiz, thanks!
  1540. - Fixed bug in operatorPrecedence for unary operators with left
  1541. associativity, if multiple operators were given for the same term.
  1542. - Fixed bug in example simpleBool.py, corrected precedence of "and" vs.
  1543. "or" operations.
  1544. - Fixed bug in Dict class, in which keys were converted to strings
  1545. whether they needed to be or not. Have narrowed this logic to
  1546. convert keys to strings only if the keys are ints (which would
  1547. confuse __getitem__ behavior for list indexing vs. key lookup).
  1548. - Added ParserElement method setBreak(), which will invoke the pdb
  1549. module's set_trace() function when this expression is about to be
  1550. parsed.
  1551. - Fixed bug in StringEnd in which reading off the end of the input
  1552. string raises an exception - should match. Resolved while
  1553. answering a question for Shawn on the pyparsing wiki.
  1554. Version 1.4.6 - April, 2007
  1555. ---------------------------
  1556. - Simplified constructor for ParseFatalException, to support common
  1557. exception construction idiom:
  1558. raise ParseFatalException, "unexpected text: 'Spanish Inquisition'"
  1559. - Added method getTokensEndLoc(), to be called from within a parse action,
  1560. for those parse actions that need both the starting *and* ending
  1561. location of the parsed tokens within the input text.
  1562. - Enhanced behavior of keepOriginalText so that named parse fields are
  1563. preserved, even though tokens are replaced with the original input
  1564. text matched by the current expression. Also, cleaned up the stack
  1565. traversal to be more robust. Suggested by Tim Arnold - thanks, Tim!
  1566. - Fixed subtle bug in which countedArray (and similar dynamic
  1567. expressions configured in parse actions) failed to match within Or,
  1568. Each, FollowedBy, or NotAny. Reported by Ralf Vosseler, thanks for
  1569. your patience, Ralf!
  1570. - Fixed Unicode bug in upcaseTokens and downcaseTokens parse actions,
  1571. scanString, and default debugging actions; reported (and patch submitted)
  1572. by Nikolai Zamkovoi, spasibo!
  1573. - Fixed bug when saving a tuple as a named result. The returned
  1574. token list gave the proper tuple value, but accessing the result by
  1575. name only gave the first element of the tuple. Reported by
  1576. Poromenos, nice catch!
  1577. - Fixed bug in makeHTMLTags/makeXMLTags, which failed to match tag
  1578. attributes with namespaces.
  1579. - Fixed bug in SkipTo when setting include=True, to have the skipped-to
  1580. tokens correctly included in the returned data. Reported by gunars on
  1581. the pyparsing wiki, thanks!
  1582. - Fixed typobug in OnceOnly.reset method, omitted self argument.
  1583. Submitted by eike welk, thanks for the lint-picking!
  1584. - Added performance enhancement to Forward class, suggested by
  1585. akkartik on the pyparsing Wiki discussion, nice work!
  1586. - Added optional asKeyword to Word constructor, to indicate that the
  1587. given word pattern should be matched only as a keyword, that is, it
  1588. should only match if it is within word boundaries.
  1589. - Added S-expression parser to examples directory.
  1590. - Added macro substitution example to examples directory.
  1591. - Added holaMundo.py example, excerpted from Marco Alfonso's blog -
  1592. muchas gracias, Marco!
  1593. - Modified internal cyclic references in ParseResults to use weakrefs;
  1594. this should help reduce the memory footprint of large parsing
  1595. programs, at some cost to performance (3-5%). Suggested by bca48150 on
  1596. the pyparsing wiki, thanks!
  1597. - Enhanced the documentation describing the vagaries and idiosyncracies
  1598. of parsing strings with embedded tabs, and the impact on:
  1599. . parse actions
  1600. . scanString
  1601. . col and line helper functions
  1602. (Suggested by eike welk in response to some unexplained inconsistencies
  1603. between parsed location and offsets in the input string.)
  1604. - Cleaned up internal decorators to preserve function names,
  1605. docstrings, etc.
  1606. Version 1.4.5 - December, 2006
  1607. ------------------------------
  1608. - Removed debugging print statement from QuotedString class. Sorry
  1609. for not stripping this out before the 1.4.4 release!
  1610. - A significant performance improvement, the first one in a while!
  1611. For my Verilog parser, this version of pyparsing is about double the
  1612. speed - YMMV.
  1613. - Added support for pickling of ParseResults objects. (Reported by
  1614. Jeff Poole, thanks Jeff!)
  1615. - Fixed minor bug in makeHTMLTags that did not recognize tag attributes
  1616. with embedded '-' or '_' characters. Also, added support for
  1617. passing expressions to makeHTMLTags and makeXMLTags, and used this
  1618. feature to define the globals anyOpenTag and anyCloseTag.
  1619. - Fixed error in alphas8bit, I had omitted the y-with-umlaut character.
  1620. - Added punc8bit string to complement alphas8bit - it contains all the
  1621. non-alphabetic, non-blank 8-bit characters.
  1622. - Added commonHTMLEntity expression, to match common HTML "ampersand"
  1623. codes, such as "&lt;", "&gt;", "&amp;", "&nbsp;", and "&quot;". This
  1624. expression also defines a results name 'entity', which can be used
  1625. to extract the entity field (that is, "lt", "gt", etc.). Also added
  1626. built-in parse action replaceHTMLEntity, which can be attached to
  1627. commonHTMLEntity to translate "&lt;", "&gt;", "&amp;", "&nbsp;", and
  1628. "&quot;" to "<", ">", "&", " ", and "'".
  1629. - Added example, htmlStripper.py, that strips HTML tags and scripts
  1630. from HTML pages. It also translates common HTML entities to their
  1631. respective characters.
  1632. Version 1.4.4 - October, 2006
  1633. -------------------------------
  1634. - Fixed traceParseAction decorator to also trap and record exception
  1635. returns from parse actions, and to handle parse actions with 0,
  1636. 1, 2, or 3 arguments.
  1637. - Enhanced parse action normalization to support using classes as
  1638. parse actions; that is, the class constructor is called at parse
  1639. time and the __init__ function is called with 0, 1, 2, or 3
  1640. arguments. If passing a class as a parse action, the __init__
  1641. method must use one of the valid parse action parameter list
  1642. formats. (This technique is useful when using pyparsing to compile
  1643. parsed text into a series of application objects - see the new
  1644. example simpleBool.py.)
  1645. - Fixed bug in ParseResults when setting an item using an integer
  1646. index. (Reported by Christopher Lambacher, thanks!)
  1647. - Fixed whitespace-skipping bug, patch submitted by Paolo Losi -
  1648. grazie, Paolo!
  1649. - Fixed bug when a Combine contained an embedded Forward expression,
  1650. reported by cie on the pyparsing wiki - good catch!
  1651. - Fixed listAllMatches bug, when a listAllMatches result was
  1652. nested within another result. (Reported by don pasquale on
  1653. comp.lang.python, well done!)
  1654. - Fixed bug in ParseResults items() method, when returning an item
  1655. marked as listAllMatches=True
  1656. - Fixed bug in definition of cppStyleComment (and javaStyleComment)
  1657. in which '//' line comments were not continued to the next line
  1658. if the line ends with a '\'. (Reported by eagle-eyed Ralph
  1659. Corderoy!)
  1660. - Optimized re's for cppStyleComment and quotedString for better
  1661. re performance - also provided by Ralph Corderoy, thanks!
  1662. - Added new example, indentedGrammarExample.py, showing how to
  1663. define a grammar using indentation to show grouping (as Python
  1664. does for defining statement nesting). Instigated by an e-mail
  1665. discussion with Andrew Dalke, thanks Andrew!
  1666. - Added new helper operatorPrecedence (based on e-mail list discussion
  1667. with Ralph Corderoy and Paolo Losi), to facilitate definition of
  1668. grammars for expressions with unary and binary operators. For
  1669. instance, this grammar defines a 6-function arithmetic expression
  1670. grammar, with unary plus and minus, proper operator precedence,and
  1671. right- and left-associativity:
  1672. expr = operatorPrecedence( operand,
  1673. [("!", 1, opAssoc.LEFT),
  1674. ("^", 2, opAssoc.RIGHT),
  1675. (oneOf("+ -"), 1, opAssoc.RIGHT),
  1676. (oneOf("* /"), 2, opAssoc.LEFT),
  1677. (oneOf("+ -"), 2, opAssoc.LEFT),]
  1678. )
  1679. Also added example simpleArith.py and simpleBool.py to provide
  1680. more detailed code samples using this new helper method.
  1681. - Added new helpers matchPreviousLiteral and matchPreviousExpr, for
  1682. creating adaptive parsing expressions that match the same content
  1683. as was parsed in a previous parse expression. For instance:
  1684. first = Word(nums)
  1685. matchExpr = first + ":" + matchPreviousLiteral(first)
  1686. will match "1:1", but not "1:2". Since this matches at the literal
  1687. level, this will also match the leading "1:1" in "1:10".
  1688. In contrast:
  1689. first = Word(nums)
  1690. matchExpr = first + ":" + matchPreviousExpr(first)
  1691. will *not* match the leading "1:1" in "1:10"; the expressions are
  1692. evaluated first, and then compared, so "1" is compared with "10".
  1693. - Added keepOriginalText parse action. Sometimes pyparsing's
  1694. whitespace-skipping leaves out too much whitespace. Adding this
  1695. parse action will restore any internal whitespace for a parse
  1696. expression. This is especially useful when defining expressions
  1697. for scanString or transformString applications.
  1698. - Added __add__ method for ParseResults class, to better support
  1699. using Python sum built-in for summing ParseResults objects returned
  1700. from scanString.
  1701. - Added reset method for the new OnlyOnce class wrapper for parse
  1702. actions (to allow a grammar to be used multiple times).
  1703. - Added optional maxMatches argument to scanString and searchString,
  1704. to short-circuit scanning after 'n' expression matches are found.
  1705. Version 1.4.3 - July, 2006
  1706. ------------------------------
  1707. - Fixed implementation of multiple parse actions for an expression
  1708. (added in 1.4.2).
  1709. . setParseAction() reverts to its previous behavior, setting
  1710. one (or more) actions for an expression, overwriting any
  1711. action or actions previously defined
  1712. . new method addParseAction() appends one or more parse actions
  1713. to the list of parse actions attached to an expression
  1714. Now it is harder to accidentally append parse actions to an
  1715. expression, when what you wanted to do was overwrite whatever had
  1716. been defined before. (Thanks, Jean-Paul Calderone!)
  1717. - Simplified interface to parse actions that do not require all 3
  1718. parse action arguments. Very rarely do parse actions require more
  1719. than just the parsed tokens, yet parse actions still require all
  1720. 3 arguments including the string being parsed and the location
  1721. within the string where the parse expression was matched. With this
  1722. release, parse actions may now be defined to be called as:
  1723. . fn(string,locn,tokens) (the current form)
  1724. . fn(locn,tokens)
  1725. . fn(tokens)
  1726. . fn()
  1727. The setParseAction and addParseAction methods will internally decorate
  1728. the provided parse actions with compatible wrappers to conform to
  1729. the full (string,locn,tokens) argument sequence.
  1730. - REMOVED SUPPORT FOR RETURNING PARSE LOCATION FROM A PARSE ACTION.
  1731. I announced this in March, 2004, and gave a final warning in the last
  1732. release. Now you can return a tuple from a parse action, and it will
  1733. be treated like any other return value (i.e., the tuple will be
  1734. substituted for the incoming tokens passed to the parse action,
  1735. which is useful when trying to parse strings into tuples).
  1736. - Added setFailAction method, taking a callable function fn that
  1737. takes the arguments fn(s,loc,expr,err) where:
  1738. . s - string being parsed
  1739. . loc - location where expression match was attempted and failed
  1740. . expr - the parse expression that failed
  1741. . err - the exception thrown
  1742. The function returns no values. It may throw ParseFatalException
  1743. if it is desired to stop parsing immediately.
  1744. (Suggested by peter21081944 on wikispaces.com)
  1745. - Added class OnlyOnce as helper wrapper for parse actions. OnlyOnce
  1746. only permits a parse action to be called one time, after which
  1747. all subsequent calls throw a ParseException.
  1748. - Added traceParseAction decorator to help debug parse actions.
  1749. Simply insert "@traceParseAction" ahead of the definition of your
  1750. parse action, and each invocation will be displayed, along with
  1751. incoming arguments, and returned value.
  1752. - Fixed bug when copying ParserElements using copy() or
  1753. setResultsName(). (Reported by Dan Thill, great catch!)
  1754. - Fixed bug in asXML() where token text contains <, >, and &
  1755. characters - generated XML now escapes these as &lt;, &gt; and
  1756. &amp;. (Reported by Jacek Sieka, thanks!)
  1757. - Fixed bug in SkipTo() when searching for a StringEnd(). (Reported
  1758. by Pete McEvoy, thanks Pete!)
  1759. - Fixed "except Exception" statements, the most critical added as part
  1760. of the packrat parsing enhancement. (Thanks, Erick Tryzelaar!)
  1761. - Fixed end-of-string infinite looping on LineEnd and StringEnd
  1762. expressions. (Thanks again to Erick Tryzelaar.)
  1763. - Modified setWhitespaceChars to return self, to be consistent with
  1764. other ParserElement modifiers. (Suggested by Erick Tryzelaar.)
  1765. - Fixed bug/typo in new ParseResults.dump() method.
  1766. - Fixed bug in searchString() method, in which only the first token of
  1767. an expression was returned. searchString() now returns a
  1768. ParseResults collection of all search matches.
  1769. - Added example program removeLineBreaks.py, a string transformer that
  1770. converts text files with hard line-breaks into one with line breaks
  1771. only between paragraphs.
  1772. - Added example program listAllMatches.py, to illustrate using the
  1773. listAllMatches option when specifying results names (also shows new
  1774. support for passing lists to oneOf).
  1775. - Added example program linenoExample.py, to illustrate using the
  1776. helper methods lineno, line, and col, and returning objects from a
  1777. parse action.
  1778. - Added example program parseListString.py, to which can parse the
  1779. string representation of a Python list back into a true list. Taken
  1780. mostly from my PyCon presentation examples, but now with support
  1781. for tuple elements, too!
  1782. Version 1.4.2 - April 1, 2006 (No foolin'!)
  1783. -------------------------------------------
  1784. - Significant speedup from memoizing nested expressions (a technique
  1785. known as "packrat parsing"), thanks to Chris Lesniewski-Laas! Your
  1786. mileage may vary, but my Verilog parser almost doubled in speed to
  1787. over 600 lines/sec!
  1788. This speedup may break existing programs that use parse actions that
  1789. have side-effects. For this reason, packrat parsing is disabled when
  1790. you first import pyparsing. To activate the packrat feature, your
  1791. program must call the class method ParserElement.enablePackrat(). If
  1792. your program uses psyco to "compile as you go", you must call
  1793. enablePackrat before calling psyco.full(). If you do not do this,
  1794. Python will crash. For best results, call enablePackrat() immediately
  1795. after importing pyparsing.
  1796. - Added new helper method countedArray(expr), for defining patterns that
  1797. start with a leading integer to indicate the number of array elements,
  1798. followed by that many elements, matching the given expr parse
  1799. expression. For instance, this two-liner:
  1800. wordArray = countedArray(Word(alphas))
  1801. print wordArray.parseString("3 Practicality beats purity")[0]
  1802. returns the parsed array of words:
  1803. ['Practicality', 'beats', 'purity']
  1804. The leading token '3' is suppressed, although it is easily obtained
  1805. from the length of the returned array.
  1806. (Inspired by e-mail discussion with Ralf Vosseler.)
  1807. - Added support for attaching multiple parse actions to a single
  1808. ParserElement. (Suggested by Dan "Dang" Griffith - nice idea, Dan!)
  1809. - Added support for asymmetric quoting characters in the recently-added
  1810. QuotedString class. Now you can define your own quoted string syntax
  1811. like "<<This is a string in double angle brackets.>>". To define
  1812. this custom form of QuotedString, your code would define:
  1813. dblAngleQuotedString = QuotedString('<<',endQuoteChar='>>')
  1814. QuotedString also supports escaped quotes, escape character other
  1815. than '\', and multiline.
  1816. - Changed the default value returned internally by Optional, so that
  1817. None can be used as a default value. (Suggested by Steven Bethard -
  1818. I finally saw the light!)
  1819. - Added dump() method to ParseResults, to make it easier to list out
  1820. and diagnose values returned from calling parseString.
  1821. - A new example, a search query string parser, submitted by Steven
  1822. Mooij and Rudolph Froger - a very interesting application, thanks!
  1823. - Added an example that parses the BNF in Python's Grammar file, in
  1824. support of generating Python grammar documentation. (Suggested by
  1825. J H Stovall.)
  1826. - A new example, submitted by Tim Cera, of a flexible parser module,
  1827. using a simple config variable to adjust parsing for input formats
  1828. that have slight variations - thanks, Tim!
  1829. - Added an example for parsing Roman numerals, showing the capability
  1830. of parse actions to "compile" Roman numerals into their integer
  1831. values during parsing.
  1832. - Added a new docs directory, for additional documentation or help.
  1833. Currently, this includes the text and examples from my recent
  1834. presentation at PyCon.
  1835. - Fixed another typo in CaselessKeyword, thanks Stefan Behnel.
  1836. - Expanded oneOf to also accept tuples, not just lists. This really
  1837. should be sufficient...
  1838. - Added deprecation warnings when tuple is returned from a parse action.
  1839. Looking back, I see that I originally deprecated this feature in March,
  1840. 2004, so I'm guessing people really shouldn't have been using this
  1841. feature - I'll drop it altogether in the next release, which will
  1842. allow users to return a tuple from a parse action (which is really
  1843. handy when trying to reconstuct tuples from a tuple string
  1844. representation!).
  1845. Version 1.4.1 - February, 2006
  1846. ------------------------------
  1847. - Converted generator expression in QuotedString class to list
  1848. comprehension, to retain compatibility with Python 2.3. (Thanks, Titus
  1849. Brown for the heads-up!)
  1850. - Added searchString() method to ParserElement, as an alternative to
  1851. using "scanString(instring).next()[0][0]" to search through a string
  1852. looking for a substring matching a given parse expression. (Inspired by
  1853. e-mail conversation with Dave Feustel.)
  1854. - Modified oneOf to accept lists of strings as well as a single string
  1855. of space-delimited literals. (Suggested by Jacek Sieka - thanks!)
  1856. - Removed deprecated use of Upcase in pyparsing test code. (Also caught by
  1857. Titus Brown.)
  1858. - Removed lstrip() call from Literal - too aggressive in stripping
  1859. whitespace which may be valid for some grammars. (Point raised by Jacek
  1860. Sieka). Also, made Literal more robust in the event of passing an empty
  1861. string.
  1862. - Fixed bug in replaceWith when returning None.
  1863. - Added cautionary documentation for Forward class when assigning a
  1864. MatchFirst expression, as in:
  1865. fwdExpr << a | b | c
  1866. Precedence of operators causes this to be evaluated as:
  1867. (fwdExpr << a) | b | c
  1868. thereby leaving b and c out as parseable alternatives. Users must
  1869. explicitly group the values inserted into the Forward:
  1870. fwdExpr << (a | b | c)
  1871. (Suggested by Scot Wilcoxon - thanks, Scot!)
  1872. Version 1.4 - January 18, 2006
  1873. ------------------------------
  1874. - Added Regex class, to permit definition of complex embedded expressions
  1875. using regular expressions. (Enhancement provided by John Beisley, great
  1876. job!)
  1877. - Converted implementations of Word, oneOf, quoted string, and comment
  1878. helpers to utilize regular expression matching. Performance improvements
  1879. in the 20-40% range.
  1880. - Added QuotedString class, to support definition of non-standard quoted
  1881. strings (Suggested by Guillaume Proulx, thanks!)
  1882. - Added CaselessKeyword class, to streamline grammars with, well, caseless
  1883. keywords (Proposed by Stefan Behnel, thanks!)
  1884. - Fixed bug in SkipTo, when using an ignoreable expression. (Patch provided
  1885. by Anonymous, thanks, whoever-you-are!)
  1886. - Fixed typo in NoMatch class. (Good catch, Stefan Behnel!)
  1887. - Fixed minor bug in _makeTags(), using string.printables instead of
  1888. pyparsing.printables.
  1889. - Cleaned up some of the expressions created by makeXXXTags helpers, to
  1890. suppress extraneous <> characters.
  1891. - Added some grammar definition-time checking to verify that a grammar is
  1892. being built using proper ParserElements.
  1893. - Added examples:
  1894. . LAparser.py - linear algebra C preprocessor (submitted by Mike Ellis,
  1895. thanks Mike!)
  1896. . wordsToNum.py - converts word description of a number back to
  1897. the original number (such as 'one hundred and twenty three' -> 123)
  1898. . updated fourFn.py to support unary minus, added BNF comments
  1899. Version 1.3.3 - September 12, 2005
  1900. ----------------------------------
  1901. - Improved support for Unicode strings that would be returned using
  1902. srange. Added greetingInKorean.py example, for a Korean version of
  1903. "Hello, World!" using Unicode. (Thanks, June Kim!)
  1904. - Added 'hexnums' string constant (nums+"ABCDEFabcdef") for defining
  1905. hexadecimal value expressions.
  1906. - NOTE: ===THIS CHANGE MAY BREAK EXISTING CODE===
  1907. Modified tag and results definitions returned by makeHTMLTags(),
  1908. to better support the looseness of HTML parsing. Tags to be
  1909. parsed are now caseless, and keys generated for tag attributes are
  1910. now converted to lower case.
  1911. Formerly, makeXMLTags("XYZ") would return a tag with results
  1912. name of "startXYZ", this has been changed to "startXyz". If this
  1913. tag is matched against '<XYZ Abc="1" DEF="2" ghi="3">', the
  1914. matched keys formerly would be "Abc", "DEF", and "ghi"; keys are
  1915. now converted to lower case, giving keys of "abc", "def", and
  1916. "ghi". These changes were made to try to address the lax
  1917. case sensitivity agreement between start and end tags in many
  1918. HTML pages.
  1919. No changes were made to makeXMLTags(), which assumes more rigorous
  1920. parsing rules.
  1921. Also, cleaned up case-sensitivity bugs in closing tags, and
  1922. switched to using Keyword instead of Literal class for tags.
  1923. (Thanks, Steve Young, for getting me to look at these in more
  1924. detail!)
  1925. - Added two helper parse actions, upcaseTokens and downcaseTokens,
  1926. which will convert matched text to all uppercase or lowercase,
  1927. respectively.
  1928. - Deprecated Upcase class, to be replaced by upcaseTokens parse
  1929. action.
  1930. - Converted messages sent to stderr to use warnings module, such as
  1931. when constructing a Literal with an empty string, one should use
  1932. the Empty() class or the empty helper instead.
  1933. - Added ' ' (space) as an escapable character within a quoted
  1934. string.
  1935. - Added helper expressions for common comment types, in addition
  1936. to the existing cStyleComment (/*...*/) and htmlStyleComment
  1937. (<!-- ... -->)
  1938. . dblSlashComment = // ... (to end of line)
  1939. . cppStyleComment = cStyleComment or dblSlashComment
  1940. . javaStyleComment = cppStyleComment
  1941. . pythonStyleComment = # ... (to end of line)
  1942. Version 1.3.2 - July 24, 2005
  1943. -----------------------------
  1944. - Added Each class as an enhanced version of And. 'Each' requires
  1945. that all given expressions be present, but may occur in any order.
  1946. Special handling is provided to group ZeroOrMore and OneOrMore
  1947. elements that occur out-of-order in the input string. You can also
  1948. construct 'Each' objects by joining expressions with the '&'
  1949. operator. When using the Each class, results names are strongly
  1950. recommended for accessing the matched tokens. (Suggested by Pradam
  1951. Amini - thanks, Pradam!)
  1952. - Stricter interpretation of 'max' qualifier on Word elements. If the
  1953. 'max' attribute is specified, matching will fail if an input field
  1954. contains more than 'max' consecutive body characters. For example,
  1955. previously, Word(nums,max=3) would match the first three characters
  1956. of '0123456', returning '012' and continuing parsing at '3'. Now,
  1957. when constructed using the max attribute, Word will raise an
  1958. exception with this string.
  1959. - Cleaner handling of nested dictionaries returned by Dict. No
  1960. longer necessary to dereference sub-dictionaries as element [0] of
  1961. their parents.
  1962. === NOTE: THIS CHANGE MAY BREAK SOME EXISTING CODE, BUT ONLY IF
  1963. PARSING NESTED DICTIONARIES USING THE LITTLE-USED DICT CLASS ===
  1964. (Prompted by discussion thread on the Python Tutor list, with
  1965. contributions from Danny Yoo, Kent Johnson, and original post by
  1966. Liam Clarke - thanks all!)
  1967. Version 1.3.1 - June, 2005
  1968. ----------------------------------
  1969. - Added markInputline() method to ParseException, to display the input
  1970. text line location of the parsing exception. (Thanks, Stefan Behnel!)
  1971. - Added setDefaultKeywordChars(), so that Keyword definitions using a
  1972. custom keyword character set do not all need to add the keywordChars
  1973. constructor argument (similar to setDefaultWhitespaceChars()).
  1974. (suggested by rzhanka on the SourceForge pyparsing forum.)
  1975. - Simplified passing debug actions to setDebugAction(). You can now
  1976. pass 'None' for a debug action if you want to take the default
  1977. debug behavior. To suppress a particular debug action, you can pass
  1978. the pyparsing method nullDebugAction.
  1979. - Refactored parse exception classes, moved all behavior to
  1980. ParseBaseException, and the former ParseException is now a subclass of
  1981. ParseBaseException. Added a second subclass, ParseFatalException, as
  1982. a subclass of ParseBaseException. User-defined parse actions can raise
  1983. ParseFatalException if a data inconsistency is detected (such as a
  1984. begin-tag/end-tag mismatch), and this will stop all parsing immediately.
  1985. (Inspired by e-mail thread with Michele Petrazzo - thanks, Michelle!)
  1986. - Added helper methods makeXMLTags and makeHTMLTags, that simplify the
  1987. definition of XML or HTML tag parse expressions for a given tagname.
  1988. Both functions return a pair of parse expressions, one for the opening
  1989. tag (that is, '<tagname>') and one for the closing tag ('</tagname>').
  1990. The opening tagame also recognizes any attribute definitions that have
  1991. been included in the opening tag, as well as an empty tag (one with a
  1992. trailing '/', as in '<BODY/>' which is equivalent to '<BODY></BODY>').
  1993. makeXMLTags uses stricter XML syntax for attributes, requiring that they
  1994. be enclosed in double quote characters - makeHTMLTags is more lenient,
  1995. and accepts single-quoted strings or any contiguous string of characters
  1996. up to the next whitespace character or '>' character. Attributes can
  1997. be retrieved as dictionary or attribute values of the returned results
  1998. from the opening tag.
  1999. - Added example minimath2.py, a refinement on fourFn.py that adds
  2000. an interactive session and support for variables. (Thanks, Steven Siew!)
  2001. - Added performance improvement, up to 20% reduction! (Found while working
  2002. with Wolfgang Borgert on performance tuning of his TTCN3 parser.)
  2003. - And another performance improvement, up to 25%, when using scanString!
  2004. (Found while working with Henrik Westlund on his C header file scanner.)
  2005. - Updated UML diagrams to reflect latest class/method changes.
  2006. Version 1.3 - March, 2005
  2007. ----------------------------------
  2008. - Added new Keyword class, as a special form of Literal. Keywords
  2009. must be followed by whitespace or other non-keyword characters, to
  2010. distinguish them from variables or other identifiers that just
  2011. happen to start with the same characters as a keyword. For instance,
  2012. the input string containing "ifOnlyIfOnly" will match a Literal("if")
  2013. at the beginning and in the middle, but will fail to match a
  2014. Keyword("if"). Keyword("if") will match only strings such as "if only"
  2015. or "if(only)". (Proposed by Wolfgang Borgert, and Berteun Damman
  2016. separately requested this on comp.lang.python - great idea!)
  2017. - Added setWhitespaceChars() method to override the characters to be
  2018. skipped as whitespace before matching a particular ParseElement. Also
  2019. added the class-level method setDefaultWhitespaceChars(), to allow
  2020. users to override the default set of whitespace characters (space,
  2021. tab, newline, and return) for all subsequently defined ParseElements.
  2022. (Inspired by Klaas Hofstra's inquiry on the Sourceforge pyparsing
  2023. forum.)
  2024. - Added helper parse actions to support some very common parse
  2025. action use cases:
  2026. . replaceWith(replStr) - replaces the matching tokens with the
  2027. provided replStr replacement string; especially useful with
  2028. transformString()
  2029. . removeQuotes - removes first and last character from string enclosed
  2030. in quotes (note - NOT the same as the string strip() method, as only
  2031. a single character is removed at each end)
  2032. - Added copy() method to ParseElement, to make it easier to define
  2033. different parse actions for the same basic parse expression. (Note, copy
  2034. is implicitly called when using setResultsName().)
  2035. (The following changes were posted to CVS as Version 1.2.3 -
  2036. October-December, 2004)
  2037. - Added support for Unicode strings in creating grammar definitions.
  2038. (Big thanks to Gavin Panella!)
  2039. - Added constant alphas8bit to include the following 8-bit characters:
  2040. ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ
  2041. - Added srange() function to simplify definition of Word elements, using
  2042. regexp-like '[A-Za-z0-9]' syntax. This also simplifies referencing
  2043. common 8-bit characters.
  2044. - Fixed bug in Dict when a single element Dict was embedded within another
  2045. Dict. (Thanks Andy Yates for catching this one!)
  2046. - Added 'formatted' argument to ParseResults.asXML(). If set to False,
  2047. suppresses insertion of whitespace for pretty-print formatting. Default
  2048. equals True for backward compatibility.
  2049. - Added setDebugActions() function to ParserElement, to allow user-defined
  2050. debugging actions.
  2051. - Added support for escaped quotes (either in \', \", or doubled quote
  2052. form) to the predefined expressions for quoted strings. (Thanks, Ero
  2053. Carrera!)
  2054. - Minor performance improvement (~5%) converting "char in string" tests
  2055. to "char in dict". (Suggested by Gavin Panella, cool idea!)
  2056. Version 1.2.2 - September 27, 2004
  2057. ----------------------------------
  2058. - Modified delimitedList to accept an expression as the delimiter, instead
  2059. of only accepting strings.
  2060. - Modified ParseResults, to convert integer field keys to strings (to
  2061. avoid confusion with list access).
  2062. - Modified Combine, to convert all embedded tokens to strings before
  2063. combining.
  2064. - Fixed bug in MatchFirst in which parse actions would be called for
  2065. expressions that only partially match. (Thanks, John Hunter!)
  2066. - Fixed bug in fourFn.py example that fixes right-associativity of ^
  2067. operator. (Thanks, Andrea Griffini!)
  2068. - Added class FollowedBy(expression), to look ahead in the input string
  2069. without consuming tokens.
  2070. - Added class NoMatch that never matches any input. Can be useful in
  2071. debugging, and in very specialized grammars.
  2072. - Added example pgn.py, for parsing chess game files stored in Portable
  2073. Game Notation. (Thanks, Alberto Santini!)
  2074. Version 1.2.1 - August 19, 2004
  2075. -------------------------------
  2076. - Added SkipTo(expression) token type, simplifying grammars that only
  2077. want to specify delimiting expressions, and want to match any characters
  2078. between them.
  2079. - Added helper method dictOf(key,value), making it easier to work with
  2080. the Dict class. (Inspired by Pavel Volkovitskiy, thanks!).
  2081. - Added optional argument listAllMatches (default=False) to
  2082. setResultsName(). Setting listAllMatches to True overrides the default
  2083. modal setting of tokens to results names; instead, the results name
  2084. acts as an accumulator for all matching tokens within the local
  2085. repetition group. (Suggested by Amaury Le Leyzour - thanks!)
  2086. - Fixed bug in ParseResults, throwing exception when trying to extract
  2087. slice, or make a copy using [:]. (Thanks, Wilson Fowlie!)
  2088. - Fixed bug in transformString() when the input string contains <TAB>'s
  2089. (Thanks, Rick Walia!).
  2090. - Fixed bug in returning tokens from un-Grouped And's, Or's and
  2091. MatchFirst's, where too many tokens would be included in the results,
  2092. confounding parse actions and returned results.
  2093. - Fixed bug in naming ParseResults returned by And's, Or's, and Match
  2094. First's.
  2095. - Fixed bug in LineEnd() - matching this token now correctly consumes
  2096. and returns the end of line "\n".
  2097. - Added a beautiful example for parsing Mozilla calendar files (Thanks,
  2098. Petri Savolainen!).
  2099. - Added support for dynamically modifying Forward expressions during
  2100. parsing.
  2101. Version 1.2 - 20 June 2004
  2102. --------------------------
  2103. - Added definition for htmlComment to help support HTML scanning and
  2104. parsing.
  2105. - Fixed bug in generating XML for Dict classes, in which trailing item was
  2106. duplicated in the output XML.
  2107. - Fixed release bug in which scanExamples.py was omitted from release
  2108. files.
  2109. - Fixed bug in transformString() when parse actions are not defined on the
  2110. outermost parser element.
  2111. - Added example urlExtractor.py, as another example of using scanString
  2112. and parse actions.
  2113. Version 1.2beta3 - 4 June 2004
  2114. ------------------------------
  2115. - Added White() token type, analogous to Word, to match on whitespace
  2116. characters. Use White in parsers with significant whitespace (such as
  2117. configuration file parsers that use indentation to indicate grouping).
  2118. Construct White with a string containing the whitespace characters to be
  2119. matched. Similar to Word, White also takes optional min, max, and exact
  2120. parameters.
  2121. - As part of supporting whitespace-signficant parsing, added parseWithTabs()
  2122. method to ParserElement, to override the default behavior in parseString
  2123. of automatically expanding tabs to spaces. To retain tabs during
  2124. parsing, call parseWithTabs() before calling parseString(), parseFile() or
  2125. scanString(). (Thanks, Jean-Guillaume Paradis for catching this, and for
  2126. your suggestions on whitespace-significant parsing.)
  2127. - Added transformString() method to ParseElement, as a complement to
  2128. scanString(). To use transformString, define a grammar and attach a parse
  2129. action to the overall grammar that modifies the returned token list.
  2130. Invoking transformString() on a target string will then scan for matches,
  2131. and replace the matched text patterns according to the logic in the parse
  2132. action. transformString() returns the resulting transformed string.
  2133. (Note: transformString() does *not* automatically expand tabs to spaces.)
  2134. Also added scanExamples.py to the examples directory to show sample uses of
  2135. scanString() and transformString().
  2136. - Removed group() method that was introduced in beta2. This turns out NOT to
  2137. be equivalent to nesting within a Group() object, and I'd prefer not to sow
  2138. more seeds of confusion.
  2139. - Fixed behavior of asXML() where tags for groups were incorrectly duplicated.
  2140. (Thanks, Brad Clements!)
  2141. - Changed beta version message to display to stderr instead of stdout, to
  2142. make asXML() easier to use. (Thanks again, Brad.)
  2143. Version 1.2beta2 - 19 May 2004
  2144. ------------------------------
  2145. - *** SIMPLIFIED API *** - Parse actions that do not modify the list of tokens
  2146. no longer need to return a value. This simplifies those parse actions that
  2147. use the list of tokens to update a counter or record or display some of the
  2148. token content; these parse actions can simply end without having to specify
  2149. 'return toks'.
  2150. - *** POSSIBLE API INCOMPATIBILITY *** - Fixed CaselessLiteral bug, where the
  2151. returned token text was not the original string (as stated in the docs),
  2152. but the original string converted to upper case. (Thanks, Dang Griffith!)
  2153. **NOTE: this may break some code that relied on this erroneous behavior.
  2154. Users should scan their code for uses of CaselessLiteral.**
  2155. - *** POSSIBLE CODE INCOMPATIBILITY *** - I have renamed the internal
  2156. attributes on ParseResults from 'dict' and 'list' to '__tokdict' and
  2157. '__toklist', to avoid collisions with user-defined data fields named 'dict'
  2158. and 'list'. Any client code that accesses these attributes directly will
  2159. need to be modified. Hopefully the implementation of methods such as keys(),
  2160. items(), len(), etc. on ParseResults will make such direct attribute
  2161. accessess unnecessary.
  2162. - Added asXML() method to ParseResults. This greatly simplifies the process
  2163. of parsing an input data file and generating XML-structured data.
  2164. - Added getName() method to ParseResults. This method is helpful when
  2165. a grammar specifies ZeroOrMore or OneOrMore of a MatchFirst or Or
  2166. expression, and the parsing code needs to know which expression matched.
  2167. (Thanks, Eric van der Vlist, for this idea!)
  2168. - Added items() and values() methods to ParseResults, to better support using
  2169. ParseResults as a Dictionary.
  2170. - Added parseFile() as a convenience function to parse the contents of an
  2171. entire text file. Accepts either a file name or a file object. (Thanks
  2172. again, Dang!)
  2173. - Added group() method to And, Or, and MatchFirst, as a short-cut alternative
  2174. to enclosing a construct inside a Group object.
  2175. - Extended fourFn.py to support exponentiation, and simple built-in functions.
  2176. - Added EBNF parser to examples, including a demo where it parses its own
  2177. EBNF! (Thanks to Seo Sanghyeon!)
  2178. - Added Delphi Form parser to examples, dfmparse.py, plus a couple of
  2179. sample Delphi forms as tests. (Well done, Dang!)
  2180. - Another performance speedup, 5-10%, inspired by Dang! Plus about a 20%
  2181. speedup, by pre-constructing and cacheing exception objects instead of
  2182. constructing them on the fly.
  2183. - Fixed minor bug when specifying oneOf() with 'caseless=True'.
  2184. - Cleaned up and added a few more docstrings, to improve the generated docs.
  2185. Version 1.1.2 - 21 Mar 2004
  2186. ---------------------------
  2187. - Fixed minor bug in scanString(), so that start location is at the start of
  2188. the matched tokens, not at the start of the whitespace before the matched
  2189. tokens.
  2190. - Inclusion of HTML documentation, generated using Epydoc. Reformatted some
  2191. doc strings to better generate readable docs. (Beautiful work, Ed Loper,
  2192. thanks for Epydoc!)
  2193. - Minor performance speedup, 5-15%
  2194. - And on a process note, I've used the unittest module to define a series of
  2195. unit tests, to help avoid the embarrassment of the version 1.1 snafu.
  2196. Version 1.1.1 - 6 Mar 2004
  2197. --------------------------
  2198. - Fixed critical bug introduced in 1.1, which broke MatchFirst(!) token
  2199. matching.
  2200. **THANK YOU, SEO SANGHYEON!!!**
  2201. - Added "from future import __generators__" to permit running under
  2202. pre-Python 2.3.
  2203. - Added example getNTPservers.py, showing how to use pyparsing to extract
  2204. a text pattern from the HTML of a web page.
  2205. Version 1.1 - 3 Mar 2004
  2206. -------------------------
  2207. - ***Changed API*** - While testing out parse actions, I found that the value
  2208. of loc passed in was not the starting location of the matched tokens, but
  2209. the location of the next token in the list. With this version, the location
  2210. passed to the parse action is now the starting location of the tokens that
  2211. matched.
  2212. A second part of this change is that the return value of parse actions no
  2213. longer needs to return a tuple containing both the location and the parsed
  2214. tokens (which may optionally be modified); parse actions only need to return
  2215. the list of tokens. Parse actions that return a tuple are deprecated; they
  2216. will still work properly for conversion/compatibility, but this behavior will
  2217. be removed in a future version.
  2218. - Added validate() method, to help diagnose infinite recursion in a grammar tree.
  2219. validate() is not 100% fool-proof, but it can help track down nasty infinite
  2220. looping due to recursively referencing the same grammar construct without some
  2221. intervening characters.
  2222. - Cleaned up default listing of some parse element types, to more closely match
  2223. ordinary BNF. Instead of the form <classname>:[contents-list], some changes
  2224. are:
  2225. . And(token1,token2,token3) is "{ token1 token2 token3 }"
  2226. . Or(token1,token2,token3) is "{ token1 ^ token2 ^ token3 }"
  2227. . MatchFirst(token1,token2,token3) is "{ token1 | token2 | token3 }"
  2228. . Optional(token) is "[ token ]"
  2229. . OneOrMore(token) is "{ token }..."
  2230. . ZeroOrMore(token) is "[ token ]..."
  2231. - Fixed an infinite loop in oneOf if the input string contains a duplicated
  2232. option. (Thanks Brad Clements)
  2233. - Fixed a bug when specifying a results name on an Optional token. (Thanks
  2234. again, Brad Clements)
  2235. - Fixed a bug introduced in 1.0.6 when I converted quotedString to use
  2236. CharsNotIn; I accidentally permitted quoted strings to span newlines. I have
  2237. fixed this in this version to go back to the original behavior, in which
  2238. quoted strings do *not* span newlines.
  2239. - Fixed minor bug in HTTP server log parser. (Thanks Jim Richardson)
  2240. Version 1.0.6 - 13 Feb 2004
  2241. ----------------------------
  2242. - Added CharsNotIn class (Thanks, Lee SangYeong). This is the opposite of
  2243. Word, in that it is constructed with a set of characters *not* to be matched.
  2244. (This enhancement also allowed me to clean up and simplify some of the
  2245. definitions for quoted strings, cStyleComment, and restOfLine.)
  2246. - **MINOR API CHANGE** - Added joinString argument to the __init__ method of
  2247. Combine (Thanks, Thomas Kalka). joinString defaults to "", but some
  2248. applications might choose some other string to use instead, such as a blank
  2249. or newline. joinString was inserted as the second argument to __init__,
  2250. so if you have code that specifies an adjacent value, without using
  2251. 'adjacent=', this code will break.
  2252. - Modified LineStart to recognize the start of an empty line.
  2253. - Added optional caseless flag to oneOf(), to create a list of CaselessLiteral
  2254. tokens instead of Literal tokens.
  2255. - Added some enhancements to the SQL example:
  2256. . Oracle-style comments (Thanks to Harald Armin Massa)
  2257. . simple WHERE clause
  2258. - Minor performance speedup - 5-15%
  2259. Version 1.0.5 - 19 Jan 2004
  2260. ----------------------------
  2261. - Added scanString() generator method to ParseElement, to support regex-like
  2262. pattern-searching
  2263. - Added items() list to ParseResults, to return named results as a
  2264. list of (key,value) pairs
  2265. - Fixed memory overflow in asList() for deeply nested ParseResults (Thanks,
  2266. Sverrir Valgeirsson)
  2267. - Minor performance speedup - 10-15%
  2268. Version 1.0.4 - 8 Jan 2004
  2269. ---------------------------
  2270. - Added positional tokens StringStart, StringEnd, LineStart, and LineEnd
  2271. - Added commaSeparatedList to pre-defined global token definitions; also added
  2272. commasep.py to the examples directory, to demonstrate the differences between
  2273. parsing comma-separated data and simple line-splitting at commas
  2274. - Minor API change: delimitedList does not automatically enclose the
  2275. list elements in a Group, but makes this the responsibility of the caller;
  2276. also, if invoked using 'combine=True', the list delimiters are also included
  2277. in the returned text (good for scoped variables, such as a.b.c or a::b::c, or
  2278. for directory paths such as a/b/c)
  2279. - Performance speed-up again, 30-40%
  2280. - Added httpServerLogParser.py to examples directory, as this is
  2281. a common parsing task
  2282. Version 1.0.3 - 23 Dec 2003
  2283. ---------------------------
  2284. - Performance speed-up again, 20-40%
  2285. - Added Python distutils installation setup.py, etc. (thanks, Dave Kuhlman)
  2286. Version 1.0.2 - 18 Dec 2003
  2287. ---------------------------
  2288. - **NOTE: Changed API again!!!** (for the last time, I hope)
  2289. + Renamed module from parsing to pyparsing, to better reflect Python
  2290. linkage.
  2291. - Also added dictExample.py to examples directory, to illustrate
  2292. usage of the Dict class.
  2293. Version 1.0.1 - 17 Dec 2003
  2294. ---------------------------
  2295. - **NOTE: Changed API!**
  2296. + Renamed 'len' argument on Word.__init__() to 'exact'
  2297. - Performance speed-up, 10-30%
  2298. Version 1.0.0 - 15 Dec 2003
  2299. ---------------------------
  2300. - Initial public release
  2301. Version 0.1.1 thru 0.1.17 - October-November, 2003
  2302. --------------------------------------------------
  2303. - initial development iterations:
  2304. - added Dict, Group
  2305. - added helper methods oneOf, delimitedList
  2306. - added helpers quotedString (and double and single), restOfLine, cStyleComment
  2307. - added MatchFirst as an alternative to the slower Or
  2308. - added UML class diagram
  2309. - fixed various logic bugs