matplotlib-rs 0.0.8__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. docs/releases/0.0.1.md +268 -0
  2. docs/releases/0.0.2.md +69 -0
  3. docs/releases/0.0.3.md +80 -0
  4. docs/releases/0.0.4.md +73 -0
  5. docs/releases/0.0.5.md +24 -0
  6. docs/releases/0.0.6.md +24 -0
  7. docs/releases/0.0.7.md +24 -0
  8. docs/releases/0.0.8.md +16 -0
  9. licenses/LICENSE_CONTOURPY +29 -0
  10. licenses/LICENSE_CYCLER +27 -0
  11. licenses/LICENSE_DATEUTIL +54 -0
  12. licenses/LICENSE_KIWISOLVER +71 -0
  13. licenses/LICENSE_LIBWEBP +56 -0
  14. licenses/LICENSE_MATPLOTLIB +1253 -0
  15. licenses/LICENSE_PYPARSING +20 -0
  16. licenses/LICENSE_QHULL +39 -0
  17. licenses/LICENSE_SIX +18 -0
  18. matplotlib_rs/__init__.py +1683 -0
  19. matplotlib_rs/__main__.py +27 -0
  20. matplotlib_rs/_afm.py +500 -0
  21. matplotlib_rs/_animation_data.py +263 -0
  22. matplotlib_rs/_api/__init__.py +495 -0
  23. matplotlib_rs/_api/deprecation.py +534 -0
  24. matplotlib_rs/_axis_py.py +2991 -0
  25. matplotlib_rs/_blocking_input.py +31 -0
  26. matplotlib_rs/_cm.py +1500 -0
  27. matplotlib_rs/_cm_bivar.py +1289 -0
  28. matplotlib_rs/_cm_listed.py +2848 -0
  29. matplotlib_rs/_cm_multivar.py +167 -0
  30. matplotlib_rs/_color_data.py +1142 -0
  31. matplotlib_rs/_colormap.py +132 -0
  32. matplotlib_rs/_constrained_layout.py +825 -0
  33. matplotlib_rs/_contour.py +108 -0
  34. matplotlib_rs/_doc_cache.py +12214 -0
  35. matplotlib_rs/_docstring.py +142 -0
  36. matplotlib_rs/_enums.py +178 -0
  37. matplotlib_rs/_figure_rs.py +294 -0
  38. matplotlib_rs/_fontconfig_pattern.py +129 -0
  39. matplotlib_rs/_foreign.py +220 -0
  40. matplotlib_rs/_hook.py +94 -0
  41. matplotlib_rs/_image.py +160 -0
  42. matplotlib_rs/_imageio.py +229 -0
  43. matplotlib_rs/_internal_utils.py +65 -0
  44. matplotlib_rs/_kiwi.py +484 -0
  45. matplotlib_rs/_layoutgrid.py +549 -0
  46. matplotlib_rs/_live.py +192 -0
  47. matplotlib_rs/_mathtext.py +3103 -0
  48. matplotlib_rs/_mathtext_data.py +1811 -0
  49. matplotlib_rs/_mplrs.cp313-win_amd64.pyd +0 -0
  50. matplotlib_rs/_path.py +25 -0
  51. matplotlib_rs/_png.py +162 -0
  52. matplotlib_rs/_pylab_helpers.py +137 -0
  53. matplotlib_rs/_qhull.py +66 -0
  54. matplotlib_rs/_rcpush.py +84 -0
  55. matplotlib_rs/_spines_rs.py +108 -0
  56. matplotlib_rs/_style_helpers.py +52 -0
  57. matplotlib_rs/_text_helpers.py +51 -0
  58. matplotlib_rs/_tight_bbox.py +85 -0
  59. matplotlib_rs/_tight_layout.py +302 -0
  60. matplotlib_rs/_tri.py +140 -0
  61. matplotlib_rs/_type1font.py +1228 -0
  62. matplotlib_rs/_vendor/__init__.py +8 -0
  63. matplotlib_rs/_vendor/cycler.py +574 -0
  64. matplotlib_rs/_vendor/dateutil/__init__.py +27 -0
  65. matplotlib_rs/_vendor/dateutil/_common.py +44 -0
  66. matplotlib_rs/_vendor/dateutil/_tzdata_impl.py +148 -0
  67. matplotlib_rs/_vendor/dateutil/_version.py +5 -0
  68. matplotlib_rs/_vendor/dateutil/easter.py +90 -0
  69. matplotlib_rs/_vendor/dateutil/parser/__init__.py +62 -0
  70. matplotlib_rs/_vendor/dateutil/parser/_parser.py +1614 -0
  71. matplotlib_rs/_vendor/dateutil/parser/isoparser.py +417 -0
  72. matplotlib_rs/_vendor/dateutil/relativedelta.py +597 -0
  73. matplotlib_rs/_vendor/dateutil/rrule.py +1765 -0
  74. matplotlib_rs/_vendor/dateutil/tz/__init__.py +61 -0
  75. matplotlib_rs/_vendor/dateutil/tz/_common.py +420 -0
  76. matplotlib_rs/_vendor/dateutil/tz/_factories.py +81 -0
  77. matplotlib_rs/_vendor/dateutil/tz/_tzfile.py +1429 -0
  78. matplotlib_rs/_vendor/dateutil/tz/_tzpath.py +105 -0
  79. matplotlib_rs/_vendor/dateutil/tz/tz.py +1473 -0
  80. matplotlib_rs/_vendor/dateutil/tz/win.py +371 -0
  81. matplotlib_rs/_vendor/dateutil/tzwin.py +3 -0
  82. matplotlib_rs/_vendor/dateutil/utils.py +72 -0
  83. matplotlib_rs/_vendor/dateutil/zoneinfo/__init__.py +234 -0
  84. matplotlib_rs/_vendor/pyparsing/__init__.py +414 -0
  85. matplotlib_rs/_vendor/pyparsing/actions.py +265 -0
  86. matplotlib_rs/_vendor/pyparsing/common.py +571 -0
  87. matplotlib_rs/_vendor/pyparsing/core.py +6973 -0
  88. matplotlib_rs/_vendor/pyparsing/exceptions.py +354 -0
  89. matplotlib_rs/_vendor/pyparsing/helpers.py +1770 -0
  90. matplotlib_rs/_vendor/pyparsing/results.py +929 -0
  91. matplotlib_rs/_vendor/pyparsing/testing.py +399 -0
  92. matplotlib_rs/_vendor/pyparsing/unicode.py +357 -0
  93. matplotlib_rs/_vendor/pyparsing/util.py +515 -0
  94. matplotlib_rs/_vendor/pyparsing/warnings.py +11 -0
  95. matplotlib_rs/_vendor/six.py +1004 -0
  96. matplotlib_rs/animation.py +1843 -0
  97. matplotlib_rs/artist.py +2302 -0
  98. matplotlib_rs/axes/__init__.py +19 -0
  99. matplotlib_rs/axes/_axes.py +9402 -0
  100. matplotlib_rs/axes/_bar.py +185 -0
  101. matplotlib_rs/axes/_base.py +5236 -0
  102. matplotlib_rs/axes/_base_rs.py +727 -0
  103. matplotlib_rs/axes/_boxplot.py +391 -0
  104. matplotlib_rs/axes/_hist.py +99 -0
  105. matplotlib_rs/axes/_secondary_axes.py +357 -0
  106. matplotlib_rs/axis.py +1963 -0
  107. matplotlib_rs/backend_bases.py +3760 -0
  108. matplotlib_rs/backend_managers.py +388 -0
  109. matplotlib_rs/backend_tools.py +1002 -0
  110. matplotlib_rs/backends/__init__.py +6 -0
  111. matplotlib_rs/backends/_backend_pdf_ps.py +451 -0
  112. matplotlib_rs/backends/backend_agg.py +552 -0
  113. matplotlib_rs/backends/backend_mixed.py +123 -0
  114. matplotlib_rs/backends/backend_pdf.py +2711 -0
  115. matplotlib_rs/backends/backend_pgf.py +1031 -0
  116. matplotlib_rs/backends/backend_ps.py +1491 -0
  117. matplotlib_rs/backends/backend_svg.py +1395 -0
  118. matplotlib_rs/backends/backend_template.py +214 -0
  119. matplotlib_rs/backends/registry.py +423 -0
  120. matplotlib_rs/bezier.py +691 -0
  121. matplotlib_rs/category.py +236 -0
  122. matplotlib_rs/cbook.py +2762 -0
  123. matplotlib_rs/cm.py +251 -0
  124. matplotlib_rs/collections.py +2711 -0
  125. matplotlib_rs/colorbar.py +1586 -0
  126. matplotlib_rs/colorizer.py +909 -0
  127. matplotlib_rs/colors.py +4278 -0
  128. matplotlib_rs/container.py +256 -0
  129. matplotlib_rs/contour.py +1756 -0
  130. matplotlib_rs/dates.py +1847 -0
  131. matplotlib_rs/dviread.py +1386 -0
  132. matplotlib_rs/figure.py +3815 -0
  133. matplotlib_rs/font_manager.py +1855 -0
  134. matplotlib_rs/ft2font.py +515 -0
  135. matplotlib_rs/gridspec.py +808 -0
  136. matplotlib_rs/hatch.py +244 -0
  137. matplotlib_rs/image.py +1863 -0
  138. matplotlib_rs/inset.py +291 -0
  139. matplotlib_rs/layout_engine.py +310 -0
  140. matplotlib_rs/legend.py +1480 -0
  141. matplotlib_rs/legend_handler.py +812 -0
  142. matplotlib_rs/lines.py +1886 -0
  143. matplotlib_rs/markers.py +908 -0
  144. matplotlib_rs/mathtext.py +141 -0
  145. matplotlib_rs/mlab.py +959 -0
  146. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Bold.ttf +0 -0
  147. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf +0 -0
  148. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf +0 -0
  149. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans.ttf +0 -0
  150. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf +0 -0
  151. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Bold.ttf +0 -0
  152. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-BoldOblique.ttf +0 -0
  153. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf +0 -0
  154. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono.ttf +0 -0
  155. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Bold.ttf +0 -0
  156. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-BoldItalic.ttf +0 -0
  157. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Italic.ttf +0 -0
  158. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif.ttf +0 -0
  159. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerifDisplay.ttf +0 -0
  160. matplotlib_rs/mpl-data/fonts/ttf/LICENSE_DEJAVU +99 -0
  161. matplotlib_rs/mpl-data/fonts/ttf/LICENSE_STIX +124 -0
  162. matplotlib_rs/mpl-data/fonts/ttf/LastResortHE-Regular.ttf +0 -0
  163. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneral.ttf +0 -0
  164. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBol.ttf +0 -0
  165. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf +0 -0
  166. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralItalic.ttf +0 -0
  167. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUni.ttf +0 -0
  168. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBol.ttf +0 -0
  169. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf +0 -0
  170. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniIta.ttf +0 -0
  171. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFiveSymReg.ttf +0 -0
  172. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymBol.ttf +0 -0
  173. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymReg.ttf +0 -0
  174. matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymBol.ttf +0 -0
  175. matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymReg.ttf +0 -0
  176. matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymBol.ttf +0 -0
  177. matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymReg.ttf +0 -0
  178. matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymBol.ttf +0 -0
  179. matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymReg.ttf +0 -0
  180. matplotlib_rs/mpl-data/fonts/ttf/cmb10.ttf +0 -0
  181. matplotlib_rs/mpl-data/fonts/ttf/cmex10.ttf +0 -0
  182. matplotlib_rs/mpl-data/fonts/ttf/cmmi10.ttf +0 -0
  183. matplotlib_rs/mpl-data/fonts/ttf/cmr10.ttf +0 -0
  184. matplotlib_rs/mpl-data/fonts/ttf/cmss10.ttf +0 -0
  185. matplotlib_rs/mpl-data/fonts/ttf/cmsy10.ttf +0 -0
  186. matplotlib_rs/mpl-data/fonts/ttf/cmti10.ttf +0 -0
  187. matplotlib_rs/mpl-data/fonts/ttf/cmtt10.ttf +0 -0
  188. matplotlib_rs/mpl-data/images/back-symbolic.svg +46 -0
  189. matplotlib_rs/mpl-data/images/back.pdf +0 -0
  190. matplotlib_rs/mpl-data/images/back.png +0 -0
  191. matplotlib_rs/mpl-data/images/back.svg +46 -0
  192. matplotlib_rs/mpl-data/images/back_large.png +0 -0
  193. matplotlib_rs/mpl-data/images/filesave-symbolic.svg +68 -0
  194. matplotlib_rs/mpl-data/images/filesave.pdf +72 -0
  195. matplotlib_rs/mpl-data/images/filesave.png +0 -0
  196. matplotlib_rs/mpl-data/images/filesave.svg +68 -0
  197. matplotlib_rs/mpl-data/images/filesave_large.png +0 -0
  198. matplotlib_rs/mpl-data/images/forward-symbolic.svg +46 -0
  199. matplotlib_rs/mpl-data/images/forward.pdf +0 -0
  200. matplotlib_rs/mpl-data/images/forward.png +0 -0
  201. matplotlib_rs/mpl-data/images/forward.svg +46 -0
  202. matplotlib_rs/mpl-data/images/forward_large.png +0 -0
  203. matplotlib_rs/mpl-data/images/hand.pdf +0 -0
  204. matplotlib_rs/mpl-data/images/hand.png +0 -0
  205. matplotlib_rs/mpl-data/images/hand.svg +130 -0
  206. matplotlib_rs/mpl-data/images/help-symbolic.svg +52 -0
  207. matplotlib_rs/mpl-data/images/help.pdf +71 -0
  208. matplotlib_rs/mpl-data/images/help.png +0 -0
  209. matplotlib_rs/mpl-data/images/help.svg +52 -0
  210. matplotlib_rs/mpl-data/images/help_large.png +0 -0
  211. matplotlib_rs/mpl-data/images/home-symbolic.svg +59 -0
  212. matplotlib_rs/mpl-data/images/home.pdf +0 -0
  213. matplotlib_rs/mpl-data/images/home.png +0 -0
  214. matplotlib_rs/mpl-data/images/home.svg +59 -0
  215. matplotlib_rs/mpl-data/images/home_large.png +0 -0
  216. matplotlib_rs/mpl-data/images/matplotlib.pdf +0 -0
  217. matplotlib_rs/mpl-data/images/matplotlib.png +0 -0
  218. matplotlib_rs/mpl-data/images/matplotlib.svg +3171 -0
  219. matplotlib_rs/mpl-data/images/matplotlib_large.png +0 -0
  220. matplotlib_rs/mpl-data/images/move-symbolic.svg +73 -0
  221. matplotlib_rs/mpl-data/images/move.pdf +0 -0
  222. matplotlib_rs/mpl-data/images/move.png +0 -0
  223. matplotlib_rs/mpl-data/images/move.svg +73 -0
  224. matplotlib_rs/mpl-data/images/move_large.png +0 -0
  225. matplotlib_rs/mpl-data/images/qt4_editor_options.pdf +0 -0
  226. matplotlib_rs/mpl-data/images/qt4_editor_options.png +0 -0
  227. matplotlib_rs/mpl-data/images/qt4_editor_options.svg +48 -0
  228. matplotlib_rs/mpl-data/images/qt4_editor_options_large.png +0 -0
  229. matplotlib_rs/mpl-data/images/subplots-symbolic.svg +81 -0
  230. matplotlib_rs/mpl-data/images/subplots.pdf +0 -0
  231. matplotlib_rs/mpl-data/images/subplots.png +0 -0
  232. matplotlib_rs/mpl-data/images/subplots.svg +81 -0
  233. matplotlib_rs/mpl-data/images/subplots_large.png +0 -0
  234. matplotlib_rs/mpl-data/images/zoom_to_rect-symbolic.svg +40 -0
  235. matplotlib_rs/mpl-data/images/zoom_to_rect.pdf +69 -0
  236. matplotlib_rs/mpl-data/images/zoom_to_rect.png +0 -0
  237. matplotlib_rs/mpl-data/images/zoom_to_rect.svg +40 -0
  238. matplotlib_rs/mpl-data/images/zoom_to_rect_large.png +0 -0
  239. matplotlib_rs/mpl-data/kpsewhich.lua +4 -0
  240. matplotlib_rs/mpl-data/matplotlibrc +849 -0
  241. matplotlib_rs/mpl-data/plot_directive/plot_directive.css +16 -0
  242. matplotlib_rs/mpl-data/sample_data/Minduka_Present_Blue_Pack.png +0 -0
  243. matplotlib_rs/mpl-data/sample_data/README.txt +2 -0
  244. matplotlib_rs/mpl-data/sample_data/Stocks.csv +526 -0
  245. matplotlib_rs/mpl-data/sample_data/axes_grid/bivariate_normal.npy +0 -0
  246. matplotlib_rs/mpl-data/sample_data/data_x_x2_x3.csv +11 -0
  247. matplotlib_rs/mpl-data/sample_data/eeg.dat +0 -0
  248. matplotlib_rs/mpl-data/sample_data/embedding_in_wx3.xrc +65 -0
  249. matplotlib_rs/mpl-data/sample_data/goog.npz +0 -0
  250. matplotlib_rs/mpl-data/sample_data/grace_hopper.jpg +0 -0
  251. matplotlib_rs/mpl-data/sample_data/jacksboro_fault_dem.npz +0 -0
  252. matplotlib_rs/mpl-data/sample_data/logo2.png +0 -0
  253. matplotlib_rs/mpl-data/sample_data/membrane.dat +0 -0
  254. matplotlib_rs/mpl-data/sample_data/msft.csv +66 -0
  255. matplotlib_rs/mpl-data/sample_data/s1045.ima.gz +0 -0
  256. matplotlib_rs/mpl-data/sample_data/topobathy.npz +0 -0
  257. matplotlib_rs/mpl-data/stylelib/Solarize_Light2.mplstyle +53 -0
  258. matplotlib_rs/mpl-data/stylelib/_classic_test_patch.mplstyle +8 -0
  259. matplotlib_rs/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle +19 -0
  260. matplotlib_rs/mpl-data/stylelib/_mpl-gallery.mplstyle +19 -0
  261. matplotlib_rs/mpl-data/stylelib/bmh.mplstyle +27 -0
  262. matplotlib_rs/mpl-data/stylelib/classic.mplstyle +491 -0
  263. matplotlib_rs/mpl-data/stylelib/dark_background.mplstyle +26 -0
  264. matplotlib_rs/mpl-data/stylelib/fast.mplstyle +11 -0
  265. matplotlib_rs/mpl-data/stylelib/fivethirtyeight.mplstyle +37 -0
  266. matplotlib_rs/mpl-data/stylelib/ggplot.mplstyle +39 -0
  267. matplotlib_rs/mpl-data/stylelib/grayscale.mplstyle +29 -0
  268. matplotlib_rs/mpl-data/stylelib/petroff10.mplstyle +5 -0
  269. matplotlib_rs/mpl-data/stylelib/petroff6.mplstyle +5 -0
  270. matplotlib_rs/mpl-data/stylelib/petroff8.mplstyle +5 -0
  271. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-bright.mplstyle +3 -0
  272. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-colorblind.mplstyle +3 -0
  273. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark-palette.mplstyle +3 -0
  274. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark.mplstyle +30 -0
  275. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-darkgrid.mplstyle +30 -0
  276. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-deep.mplstyle +3 -0
  277. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-muted.mplstyle +3 -0
  278. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-notebook.mplstyle +21 -0
  279. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-paper.mplstyle +21 -0
  280. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-pastel.mplstyle +3 -0
  281. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-poster.mplstyle +21 -0
  282. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-talk.mplstyle +21 -0
  283. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-ticks.mplstyle +30 -0
  284. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-white.mplstyle +30 -0
  285. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-whitegrid.mplstyle +30 -0
  286. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8.mplstyle +57 -0
  287. matplotlib_rs/mpl-data/stylelib/tableau-colorblind10.mplstyle +3 -0
  288. matplotlib_rs/mpl_toolkits/__init__.py +3 -0
  289. matplotlib_rs/mpl_toolkits/axes_grid1/__init__.py +11 -0
  290. matplotlib_rs/mpl_toolkits/axes_grid1/anchored_artists.py +415 -0
  291. matplotlib_rs/mpl_toolkits/axes_grid1/axes_divider.py +619 -0
  292. matplotlib_rs/mpl_toolkits/axes_grid1/axes_grid.py +565 -0
  293. matplotlib_rs/mpl_toolkits/axes_grid1/axes_rgb.py +158 -0
  294. matplotlib_rs/mpl_toolkits/axes_grid1/axes_size.py +272 -0
  295. matplotlib_rs/mpl_toolkits/axes_grid1/inset_locator.py +525 -0
  296. matplotlib_rs/mpl_toolkits/axes_grid1/mpl_axes.py +129 -0
  297. matplotlib_rs/mpl_toolkits/axes_grid1/parasite_axes.py +261 -0
  298. matplotlib_rs/mpl_toolkits/axisartist/__init__.py +15 -0
  299. matplotlib_rs/mpl_toolkits/axisartist/angle_helper.py +396 -0
  300. matplotlib_rs/mpl_toolkits/axisartist/axes_divider.py +3 -0
  301. matplotlib_rs/mpl_toolkits/axisartist/axis_artist.py +1148 -0
  302. matplotlib_rs/mpl_toolkits/axisartist/axisline_style.py +193 -0
  303. matplotlib_rs/mpl_toolkits/axisartist/axislines.py +475 -0
  304. matplotlib_rs/mpl_toolkits/axisartist/floating_axes.py +265 -0
  305. matplotlib_rs/mpl_toolkits/axisartist/grid_finder.py +329 -0
  306. matplotlib_rs/mpl_toolkits/axisartist/grid_helper_curvelinear.py +353 -0
  307. matplotlib_rs/mpl_toolkits/axisartist/parasite_axes.py +8 -0
  308. matplotlib_rs/mpl_toolkits/mplot3d/__init__.py +4 -0
  309. matplotlib_rs/mpl_toolkits/mplot3d/art3d.py +1758 -0
  310. matplotlib_rs/mpl_toolkits/mplot3d/axes3d.py +4462 -0
  311. matplotlib_rs/mpl_toolkits/mplot3d/axis3d.py +807 -0
  312. matplotlib_rs/mpl_toolkits/mplot3d/proj3d.py +270 -0
  313. matplotlib_rs/offsetbox.py +1726 -0
  314. matplotlib_rs/patches.py +5049 -0
  315. matplotlib_rs/path.py +1147 -0
  316. matplotlib_rs/patheffects.py +512 -0
  317. matplotlib_rs/projections/__init__.py +126 -0
  318. matplotlib_rs/projections/geo.py +512 -0
  319. matplotlib_rs/projections/polar.py +1518 -0
  320. matplotlib_rs/pylab.py +68 -0
  321. matplotlib_rs/pyplot.py +4834 -0
  322. matplotlib_rs/quiver.py +1236 -0
  323. matplotlib_rs/rcsetup.py +3435 -0
  324. matplotlib_rs/sankey.py +815 -0
  325. matplotlib_rs/scale.py +1002 -0
  326. matplotlib_rs/spines.py +618 -0
  327. matplotlib_rs/stackplot.py +144 -0
  328. matplotlib_rs/streamplot.py +768 -0
  329. matplotlib_rs/style/__init__.py +269 -0
  330. matplotlib_rs/style/core.py +28 -0
  331. matplotlib_rs/table.py +860 -0
  332. matplotlib_rs/texmanager.py +375 -0
  333. matplotlib_rs/text.py +2412 -0
  334. matplotlib_rs/textpath.py +377 -0
  335. matplotlib_rs/ticker.py +3111 -0
  336. matplotlib_rs/transforms.py +3069 -0
  337. matplotlib_rs/tri/__init__.py +24 -0
  338. matplotlib_rs/tri/_triangulation.py +248 -0
  339. matplotlib_rs/tri/_tricontour.py +271 -0
  340. matplotlib_rs/tri/_trifinder.py +97 -0
  341. matplotlib_rs/tri/_triinterpolate.py +1575 -0
  342. matplotlib_rs/tri/_tripcolor.py +170 -0
  343. matplotlib_rs/tri/_triplot.py +87 -0
  344. matplotlib_rs/tri/_trirefine.py +308 -0
  345. matplotlib_rs/tri/_tritools.py +264 -0
  346. matplotlib_rs/typing.py +597 -0
  347. matplotlib_rs/units.py +196 -0
  348. matplotlib_rs/widgets.py +4455 -0
  349. matplotlib_rs-0.0.8.dist-info/METADATA +392 -0
  350. matplotlib_rs-0.0.8.dist-info/RECORD +352 -0
  351. matplotlib_rs-0.0.8.dist-info/WHEEL +4 -0
  352. matplotlib_rs-0.0.8.dist-info/sboms/matplotlib-rs.cyclonedx.json +4390 -0
@@ -0,0 +1,1770 @@
1
+ # Vendored by tools/vendor_deps.py from pyparsing 3.3.3 (see licenses/LICENSE_PYPARSING).
2
+ # helpers.py
3
+ from enum import Enum, auto
4
+ import html.entities
5
+ import operator
6
+ import re
7
+ import sys
8
+ import typing
9
+
10
+ from . import __diag__
11
+ from .core import *
12
+ from .util import (
13
+ _bslash,
14
+ _flatten,
15
+ _escape_regex_range_chars,
16
+ make_compressed_re,
17
+ replaced_by_pep8,
18
+ )
19
+
20
+
21
+ def _suppression(expr: Union[ParserElement, str]) -> ParserElement:
22
+ # internal helper to avoid wrapping Suppress inside another Suppress
23
+ if isinstance(expr, Suppress):
24
+ return expr
25
+ return Suppress(expr)
26
+
27
+
28
+ #
29
+ # global helpers
30
+ #
31
+ def counted_array(
32
+ expr: ParserElement, int_expr: typing.Optional[ParserElement] = None, **kwargs
33
+ ) -> ParserElement:
34
+ """Helper to define a counted list of expressions.
35
+
36
+ This helper defines a pattern of the form::
37
+
38
+ integer expr expr expr...
39
+
40
+ where the leading integer tells how many expr expressions follow.
41
+ The matched tokens returns the array of expr tokens as a list - the
42
+ leading count token is suppressed.
43
+
44
+ If ``int_expr`` is specified, it should be a pyparsing expression
45
+ that produces an integer value.
46
+
47
+ Examples:
48
+
49
+ .. doctest::
50
+
51
+ >>> counted_array(Word(alphas)).parse_string('2 ab cd ef')
52
+ ParseResults(['ab', 'cd'], {})
53
+
54
+ - In this parser, the leading integer value is given in binary,
55
+ '10' indicating that 2 values are in the array:
56
+
57
+ .. doctest::
58
+
59
+ >>> binary_constant = Word('01').set_parse_action(lambda t: int(t[0], 2))
60
+ >>> counted_array(Word(alphas), int_expr=binary_constant
61
+ ... ).parse_string('10 ab cd ef')
62
+ ParseResults(['ab', 'cd'], {})
63
+
64
+ - If other fields must be parsed after the count but before the
65
+ list items, give the fields results names and they will
66
+ be preserved in the returned ParseResults:
67
+
68
+ .. doctest::
69
+
70
+ >>> ppc = pyparsing.common
71
+ >>> count_with_metadata = ppc.integer + Word(alphas)("type")
72
+ >>> typed_array = counted_array(Word(alphanums),
73
+ ... int_expr=count_with_metadata)("items")
74
+ >>> result = typed_array.parse_string("3 bool True True False")
75
+ >>> print(result.dump())
76
+ ['True', 'True', 'False']
77
+ - items: ['True', 'True', 'False']
78
+ - type: 'bool'
79
+ """
80
+ intExpr: typing.Optional[ParserElement] = deprecate_argument(
81
+ kwargs, "intExpr", None
82
+ )
83
+
84
+ intExpr = intExpr or int_expr
85
+ array_expr = Forward()
86
+
87
+ def count_field_parse_action(s, l, t):
88
+ nonlocal array_expr
89
+ n = t[0]
90
+ array_expr <<= (expr * n) if n else Empty()
91
+ # clear list contents, but keep any named results
92
+ del t[:]
93
+
94
+ if intExpr is None:
95
+ intExpr = Word(nums).set_parse_action(lambda t: int(t[0]))
96
+ else:
97
+ intExpr = intExpr.copy()
98
+ intExpr.set_name("arrayLen")
99
+ intExpr.add_parse_action(count_field_parse_action, call_during_try=True)
100
+ return (intExpr + array_expr).set_name(f"(len) {expr}...")
101
+
102
+
103
+ def match_previous_literal(expr: ParserElement) -> ParserElement:
104
+ """Helper to define an expression that is indirectly defined from
105
+ the tokens matched in a previous expression, that is, it looks for
106
+ a 'repeat' of a previous expression. For example::
107
+
108
+ .. testcode::
109
+
110
+ first = Word(nums)
111
+ second = match_previous_literal(first)
112
+ match_expr = first + ":" + second
113
+
114
+ will match ``"1:1"``, but not ``"1:2"``. Because this
115
+ matches a previous literal, will also match the leading
116
+ ``"1:1"`` in ``"1:10"``. If this is not desired, use
117
+ :class:`match_previous_expr`. Do *not* use with packrat parsing
118
+ enabled.
119
+ """
120
+ rep = Forward()
121
+
122
+ def copy_token_to_repeater(s, l, t):
123
+ if not t:
124
+ rep << Empty()
125
+ return
126
+
127
+ if len(t) == 1:
128
+ rep << t[0]
129
+ return
130
+
131
+ # flatten t tokens
132
+ tflat = _flatten(t.as_list())
133
+ rep << And(Literal(tt) for tt in tflat)
134
+
135
+ expr.add_parse_action(copy_token_to_repeater, call_during_try=True)
136
+ rep.set_name(f"(prev) {expr}")
137
+ return rep
138
+
139
+
140
+ def match_previous_expr(expr: ParserElement) -> ParserElement:
141
+ """Helper to define an expression that is indirectly defined from
142
+ the tokens matched in a previous expression, that is, it looks for
143
+ a 'repeat' of a previous expression. For example:
144
+
145
+ .. testcode::
146
+
147
+ first = Word(nums)
148
+ second = match_previous_expr(first)
149
+ match_expr = first + ":" + second
150
+
151
+ will match ``"1:1"``, but not ``"1:2"``. Because this
152
+ matches by expressions, will *not* match the leading ``"1:1"``
153
+ in ``"1:10"``; the expressions are evaluated first, and then
154
+ compared, so ``"1"`` is compared with ``"10"``. Do *not* use
155
+ with packrat parsing enabled.
156
+ """
157
+ rep = Forward()
158
+ e2 = expr.copy()
159
+ rep <<= e2
160
+
161
+ def copy_token_to_repeater(s, l, t):
162
+ matchTokens = _flatten(t.as_list())
163
+
164
+ def must_match_these_tokens(s, l, t):
165
+ theseTokens = _flatten(t.as_list())
166
+ if theseTokens != matchTokens:
167
+ raise ParseException(
168
+ s, l, f"Expected {matchTokens}, found{theseTokens}"
169
+ )
170
+
171
+ rep.set_parse_action(must_match_these_tokens, call_during_try=True)
172
+
173
+ expr.add_parse_action(copy_token_to_repeater, call_during_try=True)
174
+ rep.set_name(f"(prev) {expr}")
175
+ return rep
176
+
177
+
178
+ def one_of(
179
+ strs: Union[typing.Iterable[str], str],
180
+ caseless: bool = False,
181
+ use_regex: bool = True,
182
+ as_keyword: bool = False,
183
+ **kwargs,
184
+ ) -> ParserElement:
185
+ """Helper to quickly define a set of alternative :class:`Literal` s,
186
+ and makes sure to do longest-first testing when there is a conflict,
187
+ regardless of the input order, but returns
188
+ a :class:`MatchFirst` for best performance.
189
+
190
+ :param strs: a string of space-delimited literals, or a collection of
191
+ string literals
192
+ :param caseless: treat all literals as caseless
193
+ :param use_regex: bool - as an optimization, will
194
+ generate a :class:`Regex` object; otherwise, will generate
195
+ a :class:`MatchFirst` object (if ``caseless=True`` or
196
+ ``as_keyword=True``, or if creating a :class:`Regex` raises an exception)
197
+ :param as_keyword: bool - enforce :class:`Keyword`-style matching on the
198
+ generated expressions
199
+
200
+ Parameters ``asKeyword`` and ``useRegex`` are retained for pre-PEP8
201
+ compatibility, but will be removed in a future release.
202
+
203
+ Example:
204
+
205
+ .. testcode::
206
+
207
+ comp_oper = one_of("< = > <= >= !=")
208
+ var = Word(alphas)
209
+ number = Word(nums)
210
+ term = var | number
211
+ comparison_expr = term + comp_oper + term
212
+ print(comparison_expr.search_string("B = 12 AA=23 B<=AA AA>12"))
213
+
214
+ prints:
215
+
216
+ .. testoutput::
217
+
218
+ [['B', '=', '12'], ['AA', '=', '23'], ['B', '<=', 'AA'], ['AA', '>', '12']]
219
+ """
220
+ useRegex: bool = deprecate_argument(kwargs, "useRegex", True)
221
+ asKeyword: bool = deprecate_argument(kwargs, "asKeyword", False)
222
+
223
+ asKeyword = asKeyword or as_keyword
224
+ useRegex = useRegex and use_regex
225
+
226
+ if (
227
+ isinstance(caseless, str_type)
228
+ and __diag__.warn_on_multiple_string_args_to_oneof
229
+ ):
230
+ warnings.warn(
231
+ "warn_on_multiple_string_args_to_oneof:"
232
+ " More than one string argument passed to one_of, pass"
233
+ " choices as a list or space-delimited string",
234
+ PyparsingDiagnosticWarning,
235
+ stacklevel=2,
236
+ )
237
+
238
+ if caseless:
239
+ is_equal = lambda a, b: a.upper() == b.upper()
240
+ masks = lambda a, b: b.upper().startswith(a.upper())
241
+ else:
242
+ is_equal = operator.eq
243
+ masks = lambda a, b: b.startswith(a)
244
+
245
+ symbols: list[str]
246
+ if isinstance(strs, str_type):
247
+ strs = typing.cast(str, strs)
248
+ symbols = strs.split()
249
+ elif isinstance(strs, Iterable):
250
+ symbols = list(strs)
251
+ else:
252
+ raise TypeError("Invalid argument to one_of, expected string or iterable")
253
+ if not symbols:
254
+ return NoMatch()
255
+
256
+ # reorder given symbols to take care to avoid masking longer choices with shorter ones
257
+ # (but only if the given symbols are not just single characters)
258
+ i = 0
259
+ while i < len(symbols) - 1:
260
+ cur = symbols[i]
261
+ for j, other in enumerate(symbols[i + 1 :]):
262
+ if is_equal(other, cur):
263
+ del symbols[i + j + 1]
264
+ break
265
+ if len(other) > len(cur) and masks(cur, other):
266
+ del symbols[i + j + 1]
267
+ symbols.insert(i, other)
268
+ break
269
+ else:
270
+ i += 1
271
+
272
+ if useRegex:
273
+ re_flags: int = re.IGNORECASE if caseless else 0
274
+
275
+ try:
276
+ if all(len(sym) == 1 for sym in symbols):
277
+ # symbols are just single characters, create range regex pattern
278
+ patt = f"[{''.join(_escape_regex_range_chars(sym) for sym in symbols)}]"
279
+ else:
280
+ patt = "|".join(re.escape(sym) for sym in symbols)
281
+
282
+ # wrap with \b word break markers if defining as keywords
283
+ if asKeyword:
284
+ patt = rf"\b(?:{patt})\b"
285
+
286
+ ret = Regex(patt, flags=re_flags)
287
+ ret.set_name(" | ".join(repr(s) for s in symbols))
288
+
289
+ if caseless:
290
+ # add parse action to return symbols as specified, not in random
291
+ # casing as found in input string
292
+ symbol_map = {sym.lower(): sym for sym in symbols}
293
+ ret.add_parse_action(lambda s, l, t: symbol_map[t[0].lower()])
294
+
295
+ return ret
296
+
297
+ except re.error:
298
+ warnings.warn(
299
+ "Exception creating Regex for one_of, building MatchFirst",
300
+ PyparsingDiagnosticWarning,
301
+ stacklevel=2,
302
+ )
303
+
304
+ # last resort, just use MatchFirst of Token class corresponding to caseless
305
+ # and asKeyword settings
306
+ CASELESS = KEYWORD = True
307
+ parse_element_class = {
308
+ (CASELESS, KEYWORD): CaselessKeyword,
309
+ (CASELESS, not KEYWORD): CaselessLiteral,
310
+ (not CASELESS, KEYWORD): Keyword,
311
+ (not CASELESS, not KEYWORD): Literal,
312
+ }[(caseless, asKeyword)]
313
+ return MatchFirst(parse_element_class(sym) for sym in symbols).set_name(
314
+ " | ".join(symbols)
315
+ )
316
+
317
+
318
+ def dict_of(key: ParserElement, value: ParserElement) -> Dict:
319
+ """Helper to easily and clearly define a dictionary by specifying
320
+ the respective patterns for the key and value. Takes care of
321
+ defining the :class:`Dict`, :class:`ZeroOrMore`, and
322
+ :class:`Group` tokens in the proper order. The key pattern
323
+ can include delimiting markers or punctuation, as long as they are
324
+ suppressed, thereby leaving the significant key text. The value
325
+ pattern can include named results, so that the :class:`Dict` results
326
+ can include named token fields.
327
+
328
+ Example:
329
+
330
+ .. doctest::
331
+
332
+ >>> text = "shape: SQUARE posn: upper left color: light blue texture: burlap"
333
+
334
+ >>> data_word = Word(alphas)
335
+ >>> label = data_word + FollowedBy(':')
336
+ >>> attr_expr = (
337
+ ... label
338
+ ... + Suppress(':')
339
+ ... + OneOrMore(data_word, stop_on=label)
340
+ ... .set_parse_action(' '.join))
341
+ >>> print(attr_expr[1, ...].parse_string(text).dump())
342
+ ['shape', 'SQUARE', 'posn', 'upper left', 'color', 'light blue', 'texture', 'burlap']
343
+
344
+ >>> attr_label = label
345
+ >>> attr_value = Suppress(':') + OneOrMore(data_word, stop_on=label
346
+ ... ).set_parse_action(' '.join)
347
+
348
+ # similar to Dict, but simpler call format
349
+ >>> result = dict_of(attr_label, attr_value).parse_string(text)
350
+ >>> print(result.dump())
351
+ [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'light blue'], ['texture', 'burlap']]
352
+ - color: 'light blue'
353
+ - posn: 'upper left'
354
+ - shape: 'SQUARE'
355
+ - texture: 'burlap'
356
+ [0]:
357
+ ['shape', 'SQUARE']
358
+ [1]:
359
+ ['posn', 'upper left']
360
+ [2]:
361
+ ['color', 'light blue']
362
+ [3]:
363
+ ['texture', 'burlap']
364
+
365
+ >>> print(result['shape'])
366
+ SQUARE
367
+ >>> print(result.shape) # object attribute access works too
368
+ SQUARE
369
+ >>> print(result.as_dict())
370
+ {'shape': 'SQUARE', 'posn': 'upper left', 'color': 'light blue', 'texture': 'burlap'}
371
+ """
372
+ return Dict(OneOrMore(Group(key + value)))
373
+
374
+
375
+ def original_text_for(
376
+ expr: ParserElement, as_string: bool = True, **kwargs
377
+ ) -> ParserElement:
378
+ """Helper to return the original, untokenized text for a given
379
+ expression. Useful to restore the parsed fields of an HTML start
380
+ tag into the raw tag text itself, or to revert separate tokens with
381
+ intervening whitespace back to the original matching input text. By
382
+ default, returns a string containing the original parsed text.
383
+
384
+ If the optional ``as_string`` argument is passed as
385
+ ``False``, then the return value is
386
+ a :class:`ParseResults` containing any results names that
387
+ were originally matched, and a single token containing the original
388
+ matched text from the input string. So if the expression passed to
389
+ :class:`original_text_for` contains expressions with defined
390
+ results names, you must set ``as_string`` to ``False`` if you
391
+ want to preserve those results name values.
392
+
393
+ The ``asString`` pre-PEP8 argument is retained for compatibility,
394
+ but will be removed in a future release.
395
+
396
+ Example:
397
+
398
+ .. testcode::
399
+
400
+ src = "this is test <b> bold <i>text</i> </b> normal text "
401
+ for tag in ("b", "i"):
402
+ opener, closer = make_html_tags(tag)
403
+ patt = original_text_for(opener + ... + closer)
404
+ print(patt.search_string(src)[0])
405
+
406
+ prints:
407
+
408
+ .. testoutput::
409
+
410
+ ['<b> bold <i>text</i> </b>']
411
+ ['<i>text</i>']
412
+ """
413
+ asString: bool = deprecate_argument(kwargs, "asString", True)
414
+
415
+ asString = asString and as_string
416
+
417
+ locMarker = Empty().set_parse_action(lambda s, loc, t: loc)
418
+ endlocMarker = locMarker.copy()
419
+ endlocMarker.callPreparse = False
420
+ matchExpr = locMarker("_original_start") + expr + endlocMarker("_original_end")
421
+ if asString:
422
+ extractText = lambda s, l, t: s[t._original_start : t._original_end]
423
+ else:
424
+
425
+ def extractText(s, l, t):
426
+ t[:] = [s[t.pop("_original_start") : t.pop("_original_end")]]
427
+
428
+ matchExpr.set_parse_action(extractText)
429
+ matchExpr.ignoreExprs = expr.ignoreExprs
430
+ matchExpr.suppress_warning(Diagnostics.warn_ungrouped_named_tokens_in_collection)
431
+ return matchExpr
432
+
433
+
434
+ def ungroup(expr: ParserElement) -> ParserElement:
435
+ """Helper to undo pyparsing's default grouping of And expressions,
436
+ even if all but one are non-empty.
437
+ """
438
+ return TokenConverter(expr).add_parse_action(lambda t: t[0])
439
+
440
+
441
+ def locatedExpr(expr: ParserElement) -> ParserElement:
442
+ """
443
+ .. deprecated:: 3.0.0
444
+ Use the :class:`Located` class instead. Note that `Located`
445
+ returns results with one less grouping level.
446
+
447
+ Helper to decorate a returned token with its starting and ending
448
+ locations in the input string.
449
+
450
+ This helper adds the following results names:
451
+
452
+ - ``locn_start`` - location where matched expression begins
453
+ - ``locn_end`` - location where matched expression ends
454
+ - ``value`` - the actual parsed results
455
+
456
+ Be careful if the input text contains ``<TAB>`` characters, you
457
+ may want to call :meth:`ParserElement.parse_with_tabs`
458
+ """
459
+ warnings.warn(
460
+ f"{'locatedExpr'!r} deprecated - use {'Located'!r}",
461
+ PyparsingDeprecationWarning,
462
+ stacklevel=2,
463
+ )
464
+
465
+ locator = Empty().set_parse_action(lambda ss, ll, tt: ll)
466
+ return Group(
467
+ locator("locn_start")
468
+ + expr("value")
469
+ + locator.copy().leave_whitespace()("locn_end")
470
+ )
471
+
472
+
473
+ # define special default value to permit None as a significant value for
474
+ # ignore_expr
475
+ _NO_IGNORE_EXPR_GIVEN = NoMatch()
476
+
477
+
478
+ class _NestedExpr(ParseElementEnhance):
479
+ """Helper method for defining nested lists enclosed in opening and
480
+ closing delimiters (``"("`` and ``")"`` are the default).
481
+
482
+ :param opener: str - opening character for a nested list
483
+ (default= ``"("``); can also be a pyparsing expression
484
+
485
+ :param closer: str - closing character for a nested list
486
+ (default= ``")"``); can also be a pyparsing expression
487
+
488
+ :param content: expression for items within the nested lists
489
+
490
+ :param ignore_expr: expression for ignoring opening and closing delimiters
491
+ (default = :class:`quoted_string`)
492
+
493
+ Parameter ``ignoreExpr`` is retained for compatibility
494
+ but will be removed in a future release.
495
+
496
+ If an expression is not provided for the content argument, the
497
+ nested expression will capture all whitespace-delimited content
498
+ between delimiters as a list of separate values.
499
+
500
+ Use the ``ignore_expr`` argument to define expressions that may
501
+ contain opening or closing characters that should not be treated as
502
+ opening or closing characters for nesting, such as quoted_string or
503
+ a comment expression. Specify multiple expressions using an
504
+ :class:`Or` or :class:`MatchFirst`. The default is
505
+ :class:`quoted_string`, but if no expressions are to be ignored, then
506
+ pass ``None`` for this argument.
507
+
508
+ Example:
509
+
510
+ .. testcode::
511
+
512
+ data_type = one_of("void int short long char float double")
513
+ decl_data_type = Combine(data_type + Opt(Word('*')))
514
+ ident = Word(alphas+'_', alphanums+'_')
515
+ number = pyparsing_common.number
516
+ arg = Group(decl_data_type + ident)
517
+ LPAR, RPAR = map(Suppress, "()")
518
+
519
+ code_body = nested_expr('{', '}', ignore_expr=(quoted_string | c_style_comment))
520
+
521
+ c_function = (decl_data_type("type")
522
+ + ident("name")
523
+ + LPAR + Opt(DelimitedList(arg), [])("args") + RPAR
524
+ + code_body("body"))
525
+ c_function.ignore(c_style_comment)
526
+
527
+ source_code = '''
528
+ int is_odd(int x) {
529
+ return (x%2);
530
+ }
531
+
532
+ int dec_to_hex(char hchar) {
533
+ if (hchar >= '0' && hchar <= '9') {
534
+ return (ord(hchar)-ord('0'));
535
+ } else {
536
+ return (10+ord(hchar)-ord('A'));
537
+ }
538
+ }
539
+ '''
540
+ for func in c_function.search_string(source_code):
541
+ print(f"{func.name} ({func.type}) args: {func.args}")
542
+
543
+
544
+ prints:
545
+
546
+ .. testoutput::
547
+
548
+ is_odd (int) args: [['int', 'x']]
549
+ dec_to_hex (int) args: [['char', 'hchar']]
550
+ """
551
+
552
+ def __init__(
553
+ self,
554
+ opener: Union[str, ParserElement] = "(",
555
+ closer: Union[str, ParserElement] = ")",
556
+ content: typing.Optional[ParserElement] = None,
557
+ ignore_expr: typing.Optional[ParserElement] = _NO_IGNORE_EXPR_GIVEN,
558
+ **kwargs,
559
+ ):
560
+ ignoreExpr = deprecate_argument(kwargs, "ignoreExpr", _NO_IGNORE_EXPR_GIVEN)
561
+ if ignoreExpr != ignore_expr:
562
+ ignoreExpr = (
563
+ ignore_expr if ignoreExpr is _NO_IGNORE_EXPR_GIVEN else ignoreExpr
564
+ )
565
+ if ignoreExpr is _NO_IGNORE_EXPR_GIVEN:
566
+ ignoreExpr = quoted_string()
567
+
568
+ if opener == closer:
569
+ raise ValueError("opening and closing strings cannot be the same")
570
+
571
+ original_content = content
572
+ if content is None:
573
+ if isinstance(opener, str_type) and isinstance(closer, str_type):
574
+ opener_str = str(opener)
575
+ closer_str = str(closer)
576
+ if len(opener_str) == 1 and len(closer_str) == 1:
577
+ if ignoreExpr is not None:
578
+ content = Combine(
579
+ OneOrMore(
580
+ ~ignoreExpr
581
+ + CharsNotIn(
582
+ opener_str
583
+ + closer_str
584
+ + ParserElement.DEFAULT_WHITE_CHARS,
585
+ exact=1,
586
+ )
587
+ )
588
+ )
589
+ else:
590
+ content = Combine(
591
+ Empty()
592
+ + CharsNotIn(
593
+ opener_str
594
+ + closer_str
595
+ + ParserElement.DEFAULT_WHITE_CHARS
596
+ )
597
+ )
598
+ else:
599
+ if ignoreExpr is not None:
600
+ content = Combine(
601
+ OneOrMore(
602
+ ~ignoreExpr
603
+ + ~Literal(opener_str)
604
+ + ~Literal(closer_str)
605
+ + CharsNotIn(ParserElement.DEFAULT_WHITE_CHARS, exact=1)
606
+ )
607
+ )
608
+ else:
609
+ content = Combine(
610
+ OneOrMore(
611
+ ~Literal(opener_str)
612
+ + ~Literal(closer_str)
613
+ + CharsNotIn(ParserElement.DEFAULT_WHITE_CHARS, exact=1)
614
+ )
615
+ )
616
+ else:
617
+ raise ValueError(
618
+ "opening and closing arguments must be strings if no content expression is given"
619
+ )
620
+
621
+ if ParserElement.DEFAULT_WHITE_CHARS:
622
+ content.set_parse_action(
623
+ lambda t: t[0].strip(ParserElement.DEFAULT_WHITE_CHARS)
624
+ )
625
+
626
+ super().__init__(content, savelist=True)
627
+ self.opener = _suppression(opener)
628
+ self.closer = _suppression(closer)
629
+ self.opener_raw = opener
630
+ self.closer_raw = closer
631
+ self.content = content
632
+ self.ignore_expr = ignoreExpr
633
+ self.saveAsList = True
634
+ self.errmsg = None
635
+ self.original_content = original_content
636
+
637
+ def _generateDefaultName(self) -> str:
638
+ if self.original_content is None:
639
+ return f"nested {self.opener_raw}{self.closer_raw} expression"
640
+ else:
641
+ return f"nested {self.opener_raw}{self.original_content}{self.closer_raw} expression"
642
+
643
+ def parseImpl(self, instring, loc, do_actions=True):
644
+ loc, _ = self.opener._parse(instring, loc, do_actions=do_actions)
645
+ stack = [[]]
646
+ while stack:
647
+ # 1. try ignore_expr
648
+ if self.ignore_expr is not None:
649
+ try:
650
+ loc, toks = self.ignore_expr._parse(
651
+ instring, loc, do_actions=do_actions
652
+ )
653
+ stack[-1].extend(toks)
654
+ continue
655
+ except ParseException:
656
+ pass
657
+ # 2. try opener
658
+ try:
659
+ loc, _ = self.opener._parse(instring, loc, do_actions=do_actions)
660
+ stack.append([])
661
+ continue
662
+ except ParseException:
663
+ pass
664
+ # 3. try content
665
+ try:
666
+ next_loc, toks = self.content._parse(
667
+ instring, loc, do_actions=do_actions
668
+ )
669
+ if next_loc > loc:
670
+ loc = next_loc
671
+ stack[-1].extend(toks)
672
+ continue
673
+ except ParseException:
674
+ pass
675
+ # 4. try closer
676
+ try:
677
+ loc, _ = self.closer._parse(instring, loc, do_actions=do_actions)
678
+ top = ParseResults(stack.pop())
679
+ if stack:
680
+ stack[-1].append(top)
681
+ else:
682
+ return loc, ParseResults([top])
683
+ continue
684
+ except ParseException:
685
+ pass
686
+
687
+ raise ParseException(instring, loc, f"Expected {self.closer_raw!r}")
688
+
689
+
690
+ def nested_expr(
691
+ opener: Union[str, ParserElement] = "(",
692
+ closer: Union[str, ParserElement] = ")",
693
+ content: typing.Optional[ParserElement] = None,
694
+ ignore_expr: typing.Optional[ParserElement] = _NO_IGNORE_EXPR_GIVEN,
695
+ **kwargs,
696
+ ) -> ParserElement:
697
+ """Helper method for defining nested lists enclosed in opening and
698
+ closing delimiters (``"("`` and ``")"`` are the default).
699
+
700
+ :param opener: str - opening character for a nested list
701
+ (default= ``"("``); can also be a pyparsing expression
702
+
703
+ :param closer: str - closing character for a nested list
704
+ (default= ``")"``); can also be a pyparsing expression
705
+
706
+ :param content: expression for items within the nested lists
707
+
708
+ :param ignore_expr: expression for ignoring opening and closing delimiters
709
+ (default = :class:`quoted_string`)
710
+
711
+ Parameter ``ignoreExpr`` is retained for compatibility
712
+ but will be removed in a future release.
713
+
714
+ If an expression is not provided for the content argument, the
715
+ nested expression will capture all whitespace-delimited content
716
+ between delimiters as a list of separate values.
717
+
718
+ Use the ``ignore_expr`` argument to define expressions that may
719
+ contain opening or closing characters that should not be treated as
720
+ opening or closing characters for nesting, such as quoted_string or
721
+ a comment expression. Specify multiple expressions using an
722
+ :class:`Or` or :class:`MatchFirst`. The default is
723
+ :class:`quoted_string`, but if no expressions are to be ignored, then
724
+ pass ``None`` for this argument.
725
+
726
+ Example:
727
+
728
+ .. testcode::
729
+
730
+ data_type = one_of("void int short long char float double")
731
+ decl_data_type = Combine(data_type + Opt(Word('*')))
732
+ ident = Word(alphas+'_', alphanums+'_')
733
+ number = pyparsing_common.number
734
+ arg = Group(decl_data_type + ident)
735
+ LPAR, RPAR = map(Suppress, "()")
736
+
737
+ code_body = nested_expr('{', '}', ignore_expr=(quoted_string | c_style_comment))
738
+
739
+ c_function = (decl_data_type("type")
740
+ + ident("name")
741
+ + LPAR + Opt(DelimitedList(arg), [])("args") + RPAR
742
+ + code_body("body"))
743
+ c_function.ignore(c_style_comment)
744
+
745
+ source_code = '''
746
+ int is_odd(int x) {
747
+ return (x%2);
748
+ }
749
+
750
+ int dec_to_hex(char hchar) {
751
+ if (hchar >= '0' && hchar <= '9') {
752
+ return (ord(hchar)-ord('0'));
753
+ } else {
754
+ return (10+ord(hchar)-ord('A'));
755
+ }
756
+ }
757
+ '''
758
+ for func in c_function.search_string(source_code):
759
+ print(f"{func.name} ({func.type}) args: {func.args}")
760
+
761
+
762
+ prints:
763
+
764
+ .. testoutput::
765
+
766
+ is_odd (int) args: [['int', 'x']]
767
+ dec_to_hex (int) args: [['char', 'hchar']]
768
+ """
769
+ return _NestedExpr(
770
+ opener, closer, content=content, ignore_expr=ignore_expr, **kwargs
771
+ )
772
+
773
+
774
+ def _makeTags(tagStr, xml, suppress_LT=Suppress("<"), suppress_GT=Suppress(">")):
775
+ """Internal helper to construct opening and closing tag expressions,
776
+ given a tag name"""
777
+ if isinstance(tagStr, str_type):
778
+ resname = tagStr
779
+ tagStr = Keyword(tagStr, caseless=not xml)
780
+ else:
781
+ resname = tagStr.name
782
+
783
+ tagAttrName = Word(alphas, alphanums + "_-:")
784
+ if xml:
785
+ tagAttrValue = dbl_quoted_string.copy().set_parse_action(remove_quotes)
786
+ openTag = (
787
+ suppress_LT
788
+ + tagStr("tag")
789
+ + Dict(ZeroOrMore(Group(tagAttrName + Suppress("=") + tagAttrValue)))
790
+ + Opt("/", default=[False])("empty").set_parse_action(
791
+ lambda s, l, t: t[0] == "/"
792
+ )
793
+ + suppress_GT
794
+ )
795
+ else:
796
+ tagAttrValue = quoted_string.copy().set_parse_action(remove_quotes) | Word(
797
+ printables, exclude_chars=">"
798
+ )
799
+ openTag = (
800
+ suppress_LT
801
+ + tagStr("tag")
802
+ + Dict(
803
+ ZeroOrMore(
804
+ Group(
805
+ tagAttrName.set_parse_action(lambda t: t[0].lower())
806
+ + Opt(Suppress("=") + tagAttrValue)
807
+ )
808
+ )
809
+ )
810
+ + Opt("/", default=[False])("empty").set_parse_action(
811
+ lambda s, l, t: t[0] == "/"
812
+ )
813
+ + suppress_GT
814
+ )
815
+ closeTag = Combine(Literal("</") + tagStr + ">", adjacent=False)
816
+
817
+ openTag.set_name(f"<{resname}>")
818
+ # add start<tagname> results name in parse action now that ungrouped names are not reported at two levels
819
+ openTag.add_parse_action(
820
+ lambda t: t.__setitem__(
821
+ "start" + "".join(resname.replace(":", " ").title().split()), t.copy()
822
+ )
823
+ )
824
+ closeTag = closeTag(
825
+ "end" + "".join(resname.replace(":", " ").title().split())
826
+ ).set_name(f"</{resname}>")
827
+ openTag.tag = resname
828
+ closeTag.tag = resname
829
+ openTag.tag_body = SkipTo(closeTag())
830
+ return openTag, closeTag
831
+
832
+
833
+ def make_html_tags(
834
+ tag_str: Union[str, ParserElement],
835
+ ) -> tuple[ParserElement, ParserElement]:
836
+ """Helper to construct opening and closing tag expressions for HTML,
837
+ given a tag name. Matches tags in either upper or lower case,
838
+ attributes with namespaces and with quoted or unquoted values.
839
+
840
+ Example:
841
+
842
+ .. testcode::
843
+
844
+ text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>'
845
+ # make_html_tags returns pyparsing expressions for the opening and
846
+ # closing tags as a 2-tuple
847
+ a, a_end = make_html_tags("A")
848
+ link_expr = a + SkipTo(a_end)("link_text") + a_end
849
+
850
+ for link in link_expr.search_string(text):
851
+ # attributes in the <A> tag (like "href" shown here) are
852
+ # also accessible as named results
853
+ print(link.link_text, '->', link.href)
854
+
855
+ prints:
856
+
857
+ .. testoutput::
858
+
859
+ pyparsing -> https://github.com/pyparsing/pyparsing/wiki
860
+ """
861
+ return _makeTags(tag_str, False)
862
+
863
+
864
+ def make_xml_tags(
865
+ tag_str: Union[str, ParserElement],
866
+ ) -> tuple[ParserElement, ParserElement]:
867
+ """Helper to construct opening and closing tag expressions for XML,
868
+ given a tag name. Matches tags only in the given upper/lower case.
869
+
870
+ Example: similar to :class:`make_html_tags`
871
+ """
872
+ return _makeTags(tag_str, True)
873
+
874
+
875
+ any_open_tag: ParserElement
876
+ any_close_tag: ParserElement
877
+ any_open_tag, any_close_tag = make_html_tags(
878
+ Word(alphas, alphanums + "_:").set_name("any tag")
879
+ )
880
+
881
+ _htmlEntityMap = {k.rstrip(";"): v for k, v in html.entities.html5.items()}
882
+ _most_common_entities = "nbsp lt gt amp quot apos cent pound euro copy".replace(
883
+ " ", "|"
884
+ )
885
+ common_html_entity = Regex(
886
+ lambda: f"&(?P<entity>{_most_common_entities}|{make_compressed_re(_htmlEntityMap)});"
887
+ ).set_name("common HTML entity")
888
+
889
+
890
+ def replace_html_entity(s, l, t):
891
+ """Helper parser action to replace common HTML entities with their special characters"""
892
+ return _htmlEntityMap.get(t.entity)
893
+
894
+
895
+ class OpAssoc(Enum):
896
+ """Enumeration of operator associativity
897
+ - used in constructing InfixNotationOperatorSpec for :class:`infix_notation`"""
898
+
899
+ LEFT = 1
900
+ RIGHT = 2
901
+
902
+
903
+ InfixNotationOperatorArgType = Union[
904
+ ParserElement, str, tuple[Union[ParserElement, str], Union[ParserElement, str]]
905
+ ]
906
+ InfixNotationOperatorSpec = Union[
907
+ tuple[
908
+ InfixNotationOperatorArgType,
909
+ int,
910
+ OpAssoc,
911
+ typing.Optional[ParseAction],
912
+ ],
913
+ tuple[
914
+ InfixNotationOperatorArgType,
915
+ int,
916
+ OpAssoc,
917
+ ],
918
+ ]
919
+
920
+
921
+ class _ParserState(Enum):
922
+ EXPECT_OPERAND = auto()
923
+ EXPECT_OPERATOR = auto()
924
+
925
+
926
+ class _OpType(Enum):
927
+ PREFIX = auto()
928
+ POSTFIX = auto()
929
+ INFIX2 = auto()
930
+ INFIX2_RIGHT = auto()
931
+ TERNARY_LEFT_STAGE1 = auto()
932
+ TERNARY_LEFT_STAGE2 = auto()
933
+ TERNARY_RIGHT_STAGE1 = auto()
934
+ TERNARY_RIGHT_STAGE2 = auto()
935
+ LPAR = auto()
936
+
937
+
938
+ class _InfixNotationOperatorSpec(NamedTuple):
939
+ op: InfixNotationOperatorArgType
940
+ arity: int
941
+ op_type: _OpType
942
+ parse_action: typing.Optional[list[Callable]]
943
+
944
+
945
+ class _InfixNotation(ParseElementEnhance):
946
+ """
947
+ An iterative / stack-based implementation of infix_notation (using operator-precedence /
948
+ shunting-yard style evaluation with an explicit stack).
949
+ Prevents Python recursion limits from being exceeded on deeply nested expressions or long chains.
950
+ """
951
+ def __init__(
952
+ self,
953
+ base_expr: ParserElement,
954
+ op_list: list[_InfixNotationOperatorSpec],
955
+ lpar: Union[str, ParserElement] = Suppress("("),
956
+ rpar: Union[str, ParserElement] = Suppress(")"),
957
+ ):
958
+ from .core import _trim_arity
959
+
960
+ while isinstance(base_expr, _InfixNotation):
961
+ op_list[:0] = base_expr.op_list[:] # type: ignore[has-type]
962
+ base_expr = base_expr.base_expr # type: ignore[has-type]
963
+
964
+ super().__init__(base_expr, savelist=True)
965
+ self.base_expr = base_expr
966
+ self.op_list = op_list
967
+ self.lpar = Suppress(lpar) if isinstance(lpar, str) else lpar
968
+ self.rpar = Suppress(rpar) if isinstance(rpar, str) else rpar
969
+ self.keep_parens = not (isinstance(self.lpar, Suppress) and isinstance(self.rpar, Suppress))
970
+ self.errmsg = None
971
+
972
+ # Classify operators by arity and associativity
973
+ # Precedence is defined by order in op_list (higher index in op_list = lower precedence)
974
+ # We assign higher numeric precedence to earlier entries in op_list
975
+ self.prefix_ops: list[_InfixNotationOperatorSpec] = [] # (expr, prec, assoc, pa_list)
976
+ self.postfix_ops: list[_InfixNotationOperatorSpec] = [] # (expr, prec, assoc, pa_list)
977
+ self.infix_ops = [] # type: ignore[var-annotated]
978
+
979
+ total_ops = len(op_list)
980
+ for idx, oper_def in enumerate(op_list):
981
+ op_expr, arity, assoc, *pa_opt = (oper_def + (None,))[:4]
982
+ pa = pa_opt[0] if pa_opt else None
983
+ pa_list = (
984
+ [_trim_arity(f) for f in pa]
985
+ if isinstance(pa, (tuple, list))
986
+ else ([_trim_arity(pa)] if pa is not None else [])
987
+ )
988
+
989
+ if not 1 <= arity <= 3:
990
+ raise ValueError("operator must be unary (1), binary (2), or ternary (3)")
991
+
992
+ if assoc not in (OpAssoc.LEFT, OpAssoc.RIGHT):
993
+ raise ValueError("operator must indicate right or left associativity")
994
+
995
+ # Precedence: top of list has highest precedence
996
+ prec = (total_ops - idx) * 10
997
+
998
+ if arity == 1:
999
+ if isinstance(op_expr, str_type):
1000
+ op_expr = Literal(op_expr)
1001
+ if assoc is OpAssoc.RIGHT:
1002
+ self.prefix_ops.append((op_expr, prec, assoc, pa_list))
1003
+ else:
1004
+ self.postfix_ops.append((op_expr, prec, assoc, pa_list))
1005
+ elif arity == 2:
1006
+ if op_expr is not None and isinstance(op_expr, str_type):
1007
+ op_expr = Literal(op_expr)
1008
+ self.infix_ops.append((op_expr, prec, assoc, pa_list, 2, None))
1009
+ elif arity == 3:
1010
+ if not isinstance(op_expr, (tuple, list)) or len(op_expr) != 2:
1011
+ raise ValueError(
1012
+ "if numterms=3, opExpr must be a tuple or list of two expressions"
1013
+ )
1014
+ op1, op2 = op_expr
1015
+ if isinstance(op1, str_type):
1016
+ op1 = Literal(op1)
1017
+ if isinstance(op2, str_type):
1018
+ op2 = Literal(op2)
1019
+ self.infix_ops.append((op1, prec, assoc, pa_list, 3, op2))
1020
+
1021
+ def _generateDefaultName(self) -> str:
1022
+ return f"{self.base_expr} infix expression"
1023
+
1024
+ def _run_parse_actions(self, pa_list, instring, loc, tokens):
1025
+ ret_tokens = tokens
1026
+ for fn in pa_list:
1027
+ res = fn(instring, loc, ret_tokens)
1028
+ if res is not None and res is not ret_tokens:
1029
+ if isinstance(res, (ParseResults, list, tuple)):
1030
+ ret_tokens = ParseResults(res, aslist=True)
1031
+ else:
1032
+ return res
1033
+ return ret_tokens
1034
+
1035
+ def _apply_operator(self, op_info, operand_stack, instring):
1036
+ op_type = op_info["type"]
1037
+ pa_list = op_info.get("pa", [])
1038
+ start_loc = op_info.get("loc", 0)
1039
+
1040
+ if op_type is _OpType.PREFIX:
1041
+ op_tok = op_info["op"]
1042
+ arg = operand_stack.pop()
1043
+ tokens = []
1044
+ if isinstance(op_tok, (list, ParseResults)):
1045
+ tokens.extend(op_tok)
1046
+ elif op_tok is not None:
1047
+ tokens.append(op_tok)
1048
+ tokens.append(arg)
1049
+ tokens_pr = ParseResults(tokens)
1050
+ if pa_list:
1051
+ res = self._run_parse_actions(pa_list, instring, start_loc, ParseResults([tokens_pr]))
1052
+ else:
1053
+ res = tokens_pr
1054
+ operand_stack.append(res)
1055
+
1056
+ elif op_type is _OpType.POSTFIX:
1057
+ arg = operand_stack.pop()
1058
+ if isinstance(arg, ParseResults):
1059
+ res_pr = arg.copy()
1060
+ elif isinstance(arg, list):
1061
+ res_pr = ParseResults(arg)
1062
+ else:
1063
+ res_pr = ParseResults([arg])
1064
+ for op_tok in op_info["ops"]:
1065
+ if isinstance(op_tok, ParseResults):
1066
+ res_pr += op_tok
1067
+ elif isinstance(op_tok, list):
1068
+ res_pr.extend(op_tok)
1069
+ elif op_tok is not None:
1070
+ res_pr.append(op_tok)
1071
+ if pa_list:
1072
+ res = self._run_parse_actions(pa_list, instring, start_loc, ParseResults([res_pr]))
1073
+ else:
1074
+ res = res_pr
1075
+ operand_stack.append(res)
1076
+
1077
+ elif op_type is _OpType.INFIX2:
1078
+ ops = op_info["ops"]
1079
+ num_ops = len(ops)
1080
+ args = [operand_stack.pop() for _ in range(num_ops + 1)]
1081
+ args.reverse()
1082
+ tokens = [args[0]]
1083
+ for i in range(num_ops):
1084
+ op_tok = ops[i]
1085
+ if isinstance(op_tok, (list, ParseResults)):
1086
+ tokens.extend(op_tok)
1087
+ elif op_tok is not None:
1088
+ tokens.append(op_tok)
1089
+ tokens.append(args[i + 1])
1090
+ tokens_pr = ParseResults(tokens)
1091
+ if pa_list:
1092
+ res = self._run_parse_actions(pa_list, instring, start_loc, ParseResults([tokens_pr]))
1093
+ else:
1094
+ res = tokens_pr
1095
+ operand_stack.append(res)
1096
+
1097
+ elif op_type is _OpType.INFIX2_RIGHT:
1098
+ op_tok = op_info["op"]
1099
+ right = operand_stack.pop()
1100
+ left = operand_stack.pop()
1101
+ tokens = [left]
1102
+ if isinstance(op_tok, (list, ParseResults)):
1103
+ tokens.extend(op_tok)
1104
+ elif op_tok is not None:
1105
+ tokens.append(op_tok)
1106
+ tokens.append(right)
1107
+ tokens_pr = ParseResults(tokens)
1108
+ if pa_list:
1109
+ res = self._run_parse_actions(pa_list, instring, start_loc, ParseResults([tokens_pr]))
1110
+ else:
1111
+ res = tokens_pr
1112
+ operand_stack.append(res)
1113
+
1114
+ elif op_type is _OpType.TERNARY_LEFT_STAGE2:
1115
+ ops_list = op_info["ops"]
1116
+ num_ops = len(ops_list)
1117
+ num_operands = 2 * num_ops + 1
1118
+ args = [operand_stack.pop() for _ in range(num_operands)]
1119
+ args.reverse()
1120
+ tokens = [args[0]]
1121
+ for i in range(num_ops):
1122
+ op1_tok, op2_tok = ops_list[i]
1123
+ if isinstance(op1_tok, (list, ParseResults)):
1124
+ tokens.extend(op1_tok)
1125
+ elif op1_tok is not None:
1126
+ tokens.append(op1_tok)
1127
+ tokens.append(args[2 * i + 1])
1128
+ if isinstance(op2_tok, (list, ParseResults)):
1129
+ tokens.extend(op2_tok)
1130
+ elif op2_tok is not None:
1131
+ tokens.append(op2_tok)
1132
+ tokens.append(args[2 * i + 2])
1133
+ tokens_pr = ParseResults(tokens)
1134
+ if pa_list:
1135
+ res = self._run_parse_actions(pa_list, instring, start_loc, ParseResults([tokens_pr]))
1136
+ else:
1137
+ res = tokens_pr
1138
+ operand_stack.append(res)
1139
+
1140
+ elif op_type is _OpType.TERNARY_RIGHT_STAGE2:
1141
+ op1_tok = op_info["op1"]
1142
+ op2_tok = op_info["op2"]
1143
+ arg3 = operand_stack.pop()
1144
+ arg2 = operand_stack.pop()
1145
+ arg1 = operand_stack.pop()
1146
+ tokens = [arg1]
1147
+ if isinstance(op1_tok, (list, ParseResults)):
1148
+ tokens.extend(op1_tok)
1149
+ elif op1_tok is not None:
1150
+ tokens.append(op1_tok)
1151
+ tokens.append(arg2)
1152
+ if isinstance(op2_tok, (list, ParseResults)):
1153
+ tokens.extend(op2_tok)
1154
+ elif op2_tok is not None:
1155
+ tokens.append(op2_tok)
1156
+ tokens.append(arg3)
1157
+ tokens_pr = ParseResults(tokens)
1158
+ if pa_list:
1159
+ res = self._run_parse_actions(pa_list, instring, start_loc, ParseResults([tokens_pr]))
1160
+ else:
1161
+ res = tokens_pr
1162
+ operand_stack.append(res)
1163
+
1164
+ return bool(pa_list)
1165
+
1166
+ def parseImpl(self, instring, loc, do_actions=True):
1167
+ operand_stack = []
1168
+ operator_stack = []
1169
+ last_pa_applied = [False]
1170
+
1171
+ def reduce_operators(min_prec):
1172
+ while operator_stack:
1173
+ top = operator_stack[-1]
1174
+ if top["type"] in (_OpType.LPAR, _OpType.TERNARY_LEFT_STAGE1, _OpType.TERNARY_RIGHT_STAGE1):
1175
+ break
1176
+ if top["prec"] > min_prec:
1177
+ op_info = operator_stack.pop()
1178
+ last_pa_applied[0] = self._apply_operator(op_info, operand_stack, instring)
1179
+ else:
1180
+ break
1181
+
1182
+ state = _ParserState.EXPECT_OPERAND
1183
+ paren_depth = 0
1184
+
1185
+ while True:
1186
+ try:
1187
+ loc = self.preParse(instring, loc)
1188
+ except ParseException:
1189
+ pass
1190
+
1191
+ if state is _ParserState.EXPECT_OPERAND:
1192
+ # 1. Try prefix operators
1193
+ matched_prefix = False
1194
+ for op_expr, prec, assoc, pa_list in self.prefix_ops:
1195
+ try:
1196
+ next_loc, toks = op_expr._parse(instring, loc, do_actions=do_actions)
1197
+ op_tok = toks.as_list()[0] if len(toks) == 1 else toks.as_list()
1198
+ operator_stack.append({
1199
+ "type": _OpType.PREFIX,
1200
+ "op": op_tok,
1201
+ "prec": prec,
1202
+ "assoc": assoc,
1203
+ "pa": pa_list if do_actions else [],
1204
+ "loc": loc,
1205
+ })
1206
+ loc = next_loc
1207
+ matched_prefix = True
1208
+ break
1209
+ except ParseException:
1210
+ pass
1211
+ if matched_prefix:
1212
+ continue
1213
+
1214
+ # 2. Try base_expr
1215
+ try:
1216
+ next_loc, base_toks = self.base_expr._parse(instring, loc, do_actions=do_actions)
1217
+ if not base_toks and not base_toks._tokdict:
1218
+ loc = next_loc
1219
+ continue
1220
+ operand = base_toks[0] if len(base_toks) == 1 else base_toks
1221
+ operand_stack.append(operand)
1222
+ loc = next_loc
1223
+ state = _ParserState.EXPECT_OPERATOR
1224
+ continue
1225
+ except ParseException:
1226
+ pass
1227
+
1228
+ # 3. Try lpar
1229
+ try:
1230
+ next_loc, lpar_toks = self.lpar._parse(instring, loc, do_actions=do_actions)
1231
+ operator_stack.append({
1232
+ "type": _OpType.LPAR,
1233
+ "paren_toks": lpar_toks.as_list(),
1234
+ "loc": loc,
1235
+ })
1236
+ paren_depth += 1
1237
+ loc = next_loc
1238
+ continue
1239
+ except ParseException:
1240
+ raise ParseException(instring, loc, f"Expected {self.base_expr}")
1241
+
1242
+ elif state is _ParserState.EXPECT_OPERATOR:
1243
+ # 1. Try postfix operators
1244
+ matched_postfix = False
1245
+ for op_expr, prec, assoc, pa_list in self.postfix_ops:
1246
+ try:
1247
+ next_loc, toks = op_expr._parse(instring, loc, do_actions=do_actions)
1248
+ op_tok = toks
1249
+ if (
1250
+ operator_stack
1251
+ and operator_stack[-1]["type"] is _OpType.POSTFIX
1252
+ and operator_stack[-1]["prec"] == prec
1253
+ and operator_stack[-1]["assoc"] is OpAssoc.LEFT
1254
+ ):
1255
+ operator_stack[-1]["ops"].append(op_tok)
1256
+ else:
1257
+ reduce_operators(prec)
1258
+ operator_stack.append({
1259
+ "type": _OpType.POSTFIX,
1260
+ "ops": [op_tok],
1261
+ "prec": prec,
1262
+ "assoc": assoc,
1263
+ "pa": pa_list if do_actions else [],
1264
+ "loc": loc,
1265
+ })
1266
+ loc = next_loc
1267
+ matched_postfix = True
1268
+ break
1269
+ except ParseException:
1270
+ pass
1271
+ if matched_postfix:
1272
+ continue
1273
+
1274
+ # 2. Try rpar if inside parens
1275
+ if paren_depth > 0:
1276
+ try:
1277
+ next_loc, rpar_toks = self.rpar._parse(instring, loc, do_actions=do_actions)
1278
+ reduce_operators(-1) # reduce all operators inside this paren
1279
+ if operator_stack and operator_stack[-1]["type"] is _OpType.LPAR:
1280
+ lpar_info = operator_stack.pop()
1281
+ if self.keep_parens:
1282
+ top_val = operand_stack.pop()
1283
+ operand_stack.append(ParseResults([*lpar_info["paren_toks"], top_val, *rpar_toks.as_list()]))
1284
+ paren_depth -= 1
1285
+ loc = next_loc
1286
+ continue
1287
+ except ParseException:
1288
+ pass
1289
+
1290
+ # 3. Try matching op2 for an open ternary operator (STAGE1)
1291
+ matched_op2 = False
1292
+ for i in range(len(operator_stack) - 1, -1, -1):
1293
+ item = operator_stack[i]
1294
+ if item["type"] is _OpType.LPAR:
1295
+ break
1296
+ if item["type"] in (_OpType.TERNARY_LEFT_STAGE1, _OpType.TERNARY_RIGHT_STAGE1):
1297
+ try:
1298
+ next_loc, toks = item["op2_expr"]._parse(instring, loc, do_actions=do_actions)
1299
+ op2_tok = toks.as_list()[0] if len(toks) == 1 else toks.as_list()
1300
+ while operator_stack and operator_stack[-1] is not item:
1301
+ op_info = operator_stack.pop()
1302
+ self._apply_operator(op_info, operand_stack, instring)
1303
+ if item["type"] is _OpType.TERNARY_LEFT_STAGE1:
1304
+ item["type"] = _OpType.TERNARY_LEFT_STAGE2
1305
+ item["ops"][-1].append(op2_tok)
1306
+ else:
1307
+ item["type"] = _OpType.TERNARY_RIGHT_STAGE2
1308
+ item["op2"] = op2_tok
1309
+ loc = next_loc
1310
+ matched_op2 = True
1311
+ state = _ParserState.EXPECT_OPERAND
1312
+ break
1313
+ except ParseException:
1314
+ pass
1315
+ if matched_op2:
1316
+ continue
1317
+
1318
+ def _check_operand_follows(check_loc):
1319
+ for p_op, _, _, _ in self.prefix_ops:
1320
+ try:
1321
+ p_op._parse(instring, check_loc, do_actions=False)
1322
+ return True
1323
+ except ParseException:
1324
+ pass
1325
+ try:
1326
+ self.base_expr._parse(instring, check_loc, do_actions=False)
1327
+ return True
1328
+ except ParseException:
1329
+ pass
1330
+ try:
1331
+ self.lpar._parse(instring, check_loc, do_actions=False)
1332
+ return True
1333
+ except ParseException:
1334
+ pass
1335
+ return False
1336
+
1337
+ # 4. Try infix binary and ternary operators
1338
+ matched_infix = False
1339
+ for op_expr, prec, assoc, pa_list, arity, op2_expr in self.infix_ops:
1340
+ if arity == 2:
1341
+ if op_expr is None:
1342
+ if not _check_operand_follows(loc):
1343
+ continue
1344
+ next_loc = loc
1345
+ op_tok = None
1346
+ else:
1347
+ try:
1348
+ next_loc, toks = op_expr._parse(instring, loc, do_actions=do_actions)
1349
+ except ParseException:
1350
+ continue
1351
+ if next_loc == loc:
1352
+ if not _check_operand_follows(loc):
1353
+ continue
1354
+ op_tok = (toks.as_list()[0] if len(toks) == 1 else toks.as_list()) if toks else None
1355
+ else:
1356
+ op_tok = toks.as_list()[0] if len(toks) == 1 else toks.as_list()
1357
+
1358
+ if assoc is OpAssoc.LEFT:
1359
+ reduce_operators(prec)
1360
+ if (
1361
+ operator_stack
1362
+ and operator_stack[-1]["type"] is _OpType.INFIX2
1363
+ and operator_stack[-1]["prec"] == prec
1364
+ ):
1365
+ operator_stack[-1]["ops"].append(op_tok)
1366
+ else:
1367
+ operator_stack.append({
1368
+ "type": _OpType.INFIX2,
1369
+ "ops": [op_tok],
1370
+ "prec": prec,
1371
+ "assoc": assoc,
1372
+ "pa": pa_list if do_actions else [],
1373
+ "loc": loc,
1374
+ })
1375
+ else:
1376
+ reduce_operators(prec)
1377
+ operator_stack.append({
1378
+ "type": _OpType.INFIX2_RIGHT,
1379
+ "op": op_tok,
1380
+ "prec": prec,
1381
+ "assoc": assoc,
1382
+ "pa": pa_list if do_actions else [],
1383
+ "loc": loc,
1384
+ })
1385
+ loc = next_loc
1386
+ matched_infix = True
1387
+ state = _ParserState.EXPECT_OPERAND
1388
+ break
1389
+ elif arity == 3:
1390
+ try:
1391
+ next_loc, toks = op_expr._parse(instring, loc, do_actions=do_actions)
1392
+ if next_loc == loc and not _check_operand_follows(loc):
1393
+ continue
1394
+ op_tok = toks.as_list()[0] if len(toks) == 1 else toks.as_list()
1395
+ if assoc is OpAssoc.LEFT:
1396
+ if (
1397
+ operator_stack
1398
+ and operator_stack[-1]["type"] is _OpType.TERNARY_LEFT_STAGE2
1399
+ and operator_stack[-1]["prec"] == prec
1400
+ ):
1401
+ operator_stack[-1]["type"] = _OpType.TERNARY_LEFT_STAGE1
1402
+ operator_stack[-1]["ops"].append([op_tok])
1403
+ else:
1404
+ reduce_operators(prec)
1405
+ operator_stack.append({
1406
+ "type": _OpType.TERNARY_LEFT_STAGE1,
1407
+ "ops": [[op_tok]],
1408
+ "op2_expr": op2_expr,
1409
+ "prec": prec,
1410
+ "assoc": assoc,
1411
+ "pa": pa_list if do_actions else [],
1412
+ "loc": loc,
1413
+ })
1414
+ else:
1415
+ reduce_operators(prec)
1416
+ operator_stack.append({
1417
+ "type": _OpType.TERNARY_RIGHT_STAGE1,
1418
+ "op1": op_tok,
1419
+ "op2_expr": op2_expr,
1420
+ "prec": prec,
1421
+ "assoc": assoc,
1422
+ "pa": pa_list if do_actions else [],
1423
+ "loc": loc,
1424
+ })
1425
+ loc = next_loc
1426
+ matched_infix = True
1427
+ state = _ParserState.EXPECT_OPERAND
1428
+ break
1429
+ except ParseException:
1430
+ pass
1431
+ if matched_infix:
1432
+ continue
1433
+
1434
+ # No more operators can be consumed at this level
1435
+ break
1436
+
1437
+ # Reduce remaining operators
1438
+ reduce_operators(-1)
1439
+
1440
+ if paren_depth != 0 or len(operand_stack) != 1 or operator_stack:
1441
+ raise ParseException(instring, loc, "Unbalanced parentheses or expression syntax error")
1442
+
1443
+ final_result = operand_stack.pop()
1444
+ if last_pa_applied[0] and isinstance(final_result, ParseResults):
1445
+ return loc, final_result
1446
+ else:
1447
+ return loc, ParseResults([final_result])
1448
+
1449
+
1450
+ def infix_notation(base_expr, op_list, lpar="(", rpar=")"):
1451
+ """Helper method for constructing grammars of expressions made up of
1452
+ operators working in a precedence hierarchy. Operators may be unary
1453
+ or binary, left- or right-associative. Parse actions can also be
1454
+ attached to operator expressions. The generated parser will also
1455
+ recognize the use of parentheses to override operator precedences
1456
+ (see example below).
1457
+
1458
+ Note: if you define a deep operator list, you may see performance
1459
+ issues when using infix_notation. See
1460
+ :class:`ParserElement.enable_packrat` for a mechanism to potentially
1461
+ improve your parser performance.
1462
+
1463
+ Parameters:
1464
+
1465
+ :param base_expr: expression representing the most basic operand to
1466
+ be used in the expression
1467
+ :param op_list: list of tuples, one for each operator precedence level
1468
+ in the expression grammar; each tuple is of the form ``(op_expr,
1469
+ num_operands, right_left_assoc, (optional)parse_action)``, where:
1470
+
1471
+ - ``op_expr`` is the pyparsing expression for the operator; may also
1472
+ be a string, which will be converted to a Literal; if ``num_operands``
1473
+ is 3, ``op_expr`` is a tuple of two expressions, for the two
1474
+ operators separating the 3 terms
1475
+ - ``num_operands`` is the number of terms for this operator (must be 1,
1476
+ 2, or 3)
1477
+ - ``right_left_assoc`` is the indicator whether the operator is right
1478
+ or left associative, using the pyparsing-defined constants
1479
+ ``OpAssoc.RIGHT`` and ``OpAssoc.LEFT``.
1480
+ - ``parse_action`` is the parse action to be associated with
1481
+ expressions matching this operator expression (the parse action
1482
+ tuple member may be omitted); if the parse action is passed
1483
+ a tuple or list of functions, this is equivalent to calling
1484
+ ``set_parse_action(*fn)``
1485
+ (:class:`ParserElement.set_parse_action`)
1486
+
1487
+ :param lpar: expression for matching left-parentheses; if passed as a
1488
+ str, then will be parsed as ``Suppress(lpar)``. If lpar is passed as
1489
+ an expression (such as ``Literal('(')``), then it will be kept in
1490
+ the parsed results, and grouped with them. (default= ``Suppress('(')``)
1491
+ :param rpar: expression for matching right-parentheses; if passed as a
1492
+ str, then will be parsed as ``Suppress(rpar)``. If rpar is passed as
1493
+ an expression (such as ``Literal(')')``), then it will be kept in
1494
+ the parsed results, and grouped with them. (default= ``Suppress(')')``)
1495
+
1496
+ Example:
1497
+
1498
+ .. testcode::
1499
+
1500
+ # simple example of four-function arithmetic with ints and
1501
+ # variable names
1502
+ integer = pyparsing_common.signed_integer
1503
+ varname = pyparsing_common.identifier
1504
+
1505
+ arith_expr = infix_notation(integer | varname,
1506
+ [
1507
+ ('-', 1, OpAssoc.RIGHT),
1508
+ (one_of('* /'), 2, OpAssoc.LEFT),
1509
+ (one_of('+ -'), 2, OpAssoc.LEFT),
1510
+ ])
1511
+
1512
+ arith_expr.run_tests('''
1513
+ 5+3*6
1514
+ (5+3)*6
1515
+ (5+x)*y
1516
+ -2--11
1517
+ ''', full_dump=False)
1518
+
1519
+ prints:
1520
+
1521
+ .. testoutput::
1522
+ :options: +NORMALIZE_WHITESPACE
1523
+
1524
+
1525
+ 5+3*6
1526
+ [[5, '+', [3, '*', 6]]]
1527
+
1528
+ (5+3)*6
1529
+ [[[5, '+', 3], '*', 6]]
1530
+
1531
+ (5+x)*y
1532
+ [[[5, '+', 'x'], '*', 'y']]
1533
+
1534
+ -2--11
1535
+ [[['-', 2], '-', ['-', 11]]]
1536
+ """
1537
+ return _InfixNotation(base_expr, op_list, lpar=lpar, rpar=rpar)
1538
+
1539
+
1540
+ def indentedBlock(blockStatementExpr, indentStack, indent=True, backup_stacks=[]):
1541
+ """
1542
+ .. deprecated:: 3.0.0
1543
+ Use the :class:`IndentedBlock` class instead. Note that `IndentedBlock`
1544
+ has a difference method signature.
1545
+
1546
+ Helper method for defining space-delimited indentation blocks,
1547
+ such as those used to define block statements in Python source code.
1548
+
1549
+ :param blockStatementExpr: expression defining syntax of statement that
1550
+ is repeated within the indented block
1551
+
1552
+ :param indentStack: list created by caller to manage indentation stack
1553
+ (multiple ``statementWithIndentedBlock`` expressions within a single
1554
+ grammar should share a common ``indentStack``)
1555
+
1556
+ :param indent: boolean indicating whether block must be indented beyond
1557
+ the current level; set to ``False`` for block of left-most statements
1558
+
1559
+ A valid block must contain at least one ``blockStatement``.
1560
+
1561
+ (Note that indentedBlock uses internal parse actions which make it
1562
+ incompatible with packrat parsing.)
1563
+
1564
+ Example:
1565
+
1566
+ .. testcode::
1567
+
1568
+ data = '''
1569
+ def A(z):
1570
+ A1
1571
+ B = 100
1572
+ G = A2
1573
+ A2
1574
+ A3
1575
+ B
1576
+ def BB(a,b,c):
1577
+ BB1
1578
+ def BBA():
1579
+ bba1
1580
+ bba2
1581
+ bba3
1582
+ C
1583
+ D
1584
+ def spam(x,y):
1585
+ def eggs(z):
1586
+ pass
1587
+ '''
1588
+
1589
+ indentStack = [1]
1590
+ stmt = Forward()
1591
+
1592
+ identifier = Word(alphas, alphanums)
1593
+ funcDecl = ("def" + identifier + Group("(" + Opt(delimitedList(identifier)) + ")") + ":")
1594
+ func_body = indentedBlock(stmt, indentStack)
1595
+ funcDef = Group(funcDecl + func_body)
1596
+
1597
+ rvalue = Forward()
1598
+ funcCall = Group(identifier + "(" + Opt(delimitedList(rvalue)) + ")")
1599
+ rvalue << (funcCall | identifier | Word(nums))
1600
+ assignment = Group(identifier + "=" + rvalue)
1601
+ stmt << (funcDef | assignment | identifier)
1602
+
1603
+ module_body = stmt[1, ...]
1604
+
1605
+ parseTree = module_body.parseString(data)
1606
+ parseTree.pprint()
1607
+
1608
+ prints:
1609
+
1610
+ .. testoutput::
1611
+
1612
+ [['def',
1613
+ 'A',
1614
+ ['(', 'z', ')'],
1615
+ ':',
1616
+ [['A1'], [['B', '=', '100']], [['G', '=', 'A2']], ['A2'], ['A3']]],
1617
+ 'B',
1618
+ ['def',
1619
+ 'BB',
1620
+ ['(', 'a', 'b', 'c', ')'],
1621
+ ':',
1622
+ [['BB1'], [['def', 'BBA', ['(', ')'], ':', [['bba1'], ['bba2'], ['bba3']]]]]],
1623
+ 'C',
1624
+ 'D',
1625
+ ['def',
1626
+ 'spam',
1627
+ ['(', 'x', 'y', ')'],
1628
+ ':',
1629
+ [[['def', 'eggs', ['(', 'z', ')'], ':', [['pass']]]]]]]
1630
+ """
1631
+ warnings.warn(
1632
+ f"{'indentedBlock'!r} deprecated - use {'IndentedBlock'!r}",
1633
+ PyparsingDeprecationWarning,
1634
+ stacklevel=2,
1635
+ )
1636
+
1637
+ backup_stacks.append(indentStack[:])
1638
+
1639
+ def reset_stack():
1640
+ indentStack[:] = backup_stacks[-1]
1641
+
1642
+ def checkPeerIndent(s, l, t):
1643
+ if l >= len(s):
1644
+ return
1645
+ curCol = col(l, s)
1646
+ if curCol != indentStack[-1]:
1647
+ if curCol > indentStack[-1]:
1648
+ raise ParseException(s, l, "illegal nesting")
1649
+ raise ParseException(s, l, "not a peer entry")
1650
+
1651
+ def checkSubIndent(s, l, t):
1652
+ curCol = col(l, s)
1653
+ if curCol > indentStack[-1]:
1654
+ indentStack.append(curCol)
1655
+ else:
1656
+ raise ParseException(s, l, "not a subentry")
1657
+
1658
+ def checkUnindent(s, l, t):
1659
+ if l >= len(s):
1660
+ return
1661
+ curCol = col(l, s)
1662
+ if not (indentStack and curCol in indentStack):
1663
+ raise ParseException(s, l, "not an unindent")
1664
+ if curCol < indentStack[-1]:
1665
+ indentStack.pop()
1666
+
1667
+ NL = OneOrMore(LineEnd().set_whitespace_chars("\t ").suppress())
1668
+ INDENT = (Empty() + Empty().set_parse_action(checkSubIndent)).set_name("INDENT")
1669
+ PEER = Empty().set_parse_action(checkPeerIndent).set_name("")
1670
+ UNDENT = Empty().set_parse_action(checkUnindent).set_name("UNINDENT")
1671
+ if indent:
1672
+ smExpr = Group(
1673
+ Opt(NL)
1674
+ + INDENT
1675
+ + OneOrMore(PEER + Group(blockStatementExpr) + Opt(NL))
1676
+ + UNDENT
1677
+ )
1678
+ else:
1679
+ smExpr = Group(
1680
+ Opt(NL)
1681
+ + OneOrMore(PEER + Group(blockStatementExpr) + Opt(NL))
1682
+ + Opt(UNDENT)
1683
+ )
1684
+
1685
+ # add a parse action to remove backup_stack from list of backups
1686
+ smExpr.add_parse_action(
1687
+ lambda: backup_stacks.pop(-1) and None if backup_stacks else None
1688
+ )
1689
+ smExpr.set_fail_action(lambda a, b, c, d: reset_stack())
1690
+ blockStatementExpr.ignore(_bslash + LineEnd())
1691
+ return smExpr.set_name("indented block")
1692
+
1693
+
1694
+ # it's easy to get these comment structures wrong - they're very common,
1695
+ # so may as well make them available
1696
+ c_style_comment = Regex(r"/\*(?:[^*]|\*(?!/))*\*\/").set_name("C style comment")
1697
+ "Comment of the form ``/* ... */``"
1698
+
1699
+ html_comment = Regex(r"<!--[\s\S]*?-->").set_name("HTML comment")
1700
+ "Comment of the form ``<!-- ... -->``"
1701
+
1702
+ rest_of_line = Regex(r".*").leave_whitespace().set_name("rest of line")
1703
+ dbl_slash_comment = Regex(r"//(?:\\\n|[^\n])*").set_name("// comment")
1704
+ "Comment of the form ``// ... (to end of line)``"
1705
+
1706
+ cpp_style_comment = Regex(
1707
+ r"(?:/\*(?:[^*]|\*(?!/))*\*\/)|(?://(?:\\\n|[^\n])*)"
1708
+ ).set_name("C++ style comment")
1709
+ "Comment of either form :class:`c_style_comment` or :class:`dbl_slash_comment`"
1710
+
1711
+ java_style_comment = cpp_style_comment
1712
+ "Same as :class:`cpp_style_comment`"
1713
+
1714
+ python_style_comment = Regex(r"#.*").set_name("Python style comment")
1715
+ "Comment of the form ``# ... (to end of line)``"
1716
+
1717
+
1718
+ # build list of built-in expressions, for future reference if a global default value
1719
+ # gets updated
1720
+ _builtin_exprs: list[ParserElement] = [
1721
+ v for v in vars().values() if isinstance(v, ParserElement)
1722
+ ]
1723
+
1724
+
1725
+ # compatibility function, superseded by DelimitedList class
1726
+ def delimited_list(
1727
+ expr: Union[str, ParserElement],
1728
+ delim: Union[str, ParserElement] = ",",
1729
+ combine: bool = False,
1730
+ min: typing.Optional[int] = None,
1731
+ max: typing.Optional[int] = None,
1732
+ *,
1733
+ allow_trailing_delim: bool = False,
1734
+ ) -> ParserElement:
1735
+ """
1736
+ .. deprecated:: 3.1.0
1737
+ Use the :class:`DelimitedList` class instead.
1738
+ """
1739
+ return DelimitedList(
1740
+ expr, delim, combine, min, max, allow_trailing_delim=allow_trailing_delim
1741
+ )
1742
+
1743
+
1744
+ # Compatibility synonyms
1745
+ # fmt: off
1746
+ opAssoc = OpAssoc
1747
+ anyOpenTag = any_open_tag
1748
+ anyCloseTag = any_close_tag
1749
+ commonHTMLEntity = common_html_entity
1750
+ cStyleComment = c_style_comment
1751
+ htmlComment = html_comment
1752
+ restOfLine = rest_of_line
1753
+ dblSlashComment = dbl_slash_comment
1754
+ cppStyleComment = cpp_style_comment
1755
+ javaStyleComment = java_style_comment
1756
+ pythonStyleComment = python_style_comment
1757
+ delimitedList = replaced_by_pep8("delimitedList", DelimitedList)
1758
+ delimited_list = replaced_by_pep8("delimited_list", DelimitedList)
1759
+ countedArray = replaced_by_pep8("countedArray", counted_array)
1760
+ matchPreviousLiteral = replaced_by_pep8("matchPreviousLiteral", match_previous_literal)
1761
+ matchPreviousExpr = replaced_by_pep8("matchPreviousExpr", match_previous_expr)
1762
+ oneOf = replaced_by_pep8("oneOf", one_of)
1763
+ dictOf = replaced_by_pep8("dictOf", dict_of)
1764
+ originalTextFor = replaced_by_pep8("originalTextFor", original_text_for)
1765
+ nestedExpr = replaced_by_pep8("nestedExpr", nested_expr)
1766
+ makeHTMLTags = replaced_by_pep8("makeHTMLTags", make_html_tags)
1767
+ makeXMLTags = replaced_by_pep8("makeXMLTags", make_xml_tags)
1768
+ replaceHTMLEntity = replaced_by_pep8("replaceHTMLEntity", replace_html_entity)
1769
+ infixNotation = replaced_by_pep8("infixNotation", infix_notation)
1770
+ # fmt: on