Cython 3.2.0__cp39-abi3-win32.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 (333) hide show
  1. Cython/Build/BuildExecutable.py +169 -0
  2. Cython/Build/Cache.py +199 -0
  3. Cython/Build/Cythonize.py +350 -0
  4. Cython/Build/Dependencies.py +1314 -0
  5. Cython/Build/Distutils.py +1 -0
  6. Cython/Build/Inline.py +463 -0
  7. Cython/Build/IpythonMagic.py +560 -0
  8. Cython/Build/SharedModule.py +94 -0
  9. Cython/Build/Tests/TestCyCache.py +194 -0
  10. Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
  11. Cython/Build/Tests/TestDependencies.py +133 -0
  12. Cython/Build/Tests/TestInline.py +177 -0
  13. Cython/Build/Tests/TestIpythonMagic.py +287 -0
  14. Cython/Build/Tests/TestRecythonize.py +212 -0
  15. Cython/Build/Tests/TestStripLiterals.py +155 -0
  16. Cython/Build/Tests/__init__.py +1 -0
  17. Cython/Build/__init__.py +11 -0
  18. Cython/CodeWriter.py +815 -0
  19. Cython/Compiler/AnalysedTreeTransforms.py +97 -0
  20. Cython/Compiler/Annotate.py +328 -0
  21. Cython/Compiler/AutoDocTransforms.py +320 -0
  22. Cython/Compiler/Buffer.py +680 -0
  23. Cython/Compiler/Builtin.py +984 -0
  24. Cython/Compiler/CmdLine.py +263 -0
  25. Cython/Compiler/Code.pxd +149 -0
  26. Cython/Compiler/Code.py +3746 -0
  27. Cython/Compiler/Code.pyd +0 -0
  28. Cython/Compiler/CodeGeneration.py +33 -0
  29. Cython/Compiler/CythonScope.py +191 -0
  30. Cython/Compiler/Dataclass.py +864 -0
  31. Cython/Compiler/DebugFlags.py +24 -0
  32. Cython/Compiler/Errors.py +297 -0
  33. Cython/Compiler/ExprNodes.py +15562 -0
  34. Cython/Compiler/FlowControl.pxd +97 -0
  35. Cython/Compiler/FlowControl.py +1451 -0
  36. Cython/Compiler/FlowControl.pyd +0 -0
  37. Cython/Compiler/FusedNode.py +971 -0
  38. Cython/Compiler/FusedNode.pyd +0 -0
  39. Cython/Compiler/Future.py +16 -0
  40. Cython/Compiler/Interpreter.py +57 -0
  41. Cython/Compiler/Lexicon.py +421 -0
  42. Cython/Compiler/LineTable.py +114 -0
  43. Cython/Compiler/LineTable.pyd +0 -0
  44. Cython/Compiler/Main.py +857 -0
  45. Cython/Compiler/MatchCaseNodes.py +259 -0
  46. Cython/Compiler/MemoryView.py +905 -0
  47. Cython/Compiler/ModuleNode.py +4235 -0
  48. Cython/Compiler/Naming.py +363 -0
  49. Cython/Compiler/Nodes.py +10831 -0
  50. Cython/Compiler/Optimize.py +5288 -0
  51. Cython/Compiler/Options.py +843 -0
  52. Cython/Compiler/ParseTreeTransforms.pxd +78 -0
  53. Cython/Compiler/ParseTreeTransforms.py +4638 -0
  54. Cython/Compiler/Parsing.pxd +9 -0
  55. Cython/Compiler/Parsing.py +4775 -0
  56. Cython/Compiler/Parsing.pyd +0 -0
  57. Cython/Compiler/Pipeline.py +439 -0
  58. Cython/Compiler/PyrexTypes.py +5870 -0
  59. Cython/Compiler/Pythran.py +232 -0
  60. Cython/Compiler/Scanning.pxd +48 -0
  61. Cython/Compiler/Scanning.py +701 -0
  62. Cython/Compiler/Scanning.pyd +0 -0
  63. Cython/Compiler/StringEncoding.py +298 -0
  64. Cython/Compiler/Symtab.py +3073 -0
  65. Cython/Compiler/Tests/TestBuffer.py +105 -0
  66. Cython/Compiler/Tests/TestBuiltin.py +72 -0
  67. Cython/Compiler/Tests/TestCmdLine.py +586 -0
  68. Cython/Compiler/Tests/TestCode.py +144 -0
  69. Cython/Compiler/Tests/TestFlowControl.py +65 -0
  70. Cython/Compiler/Tests/TestGrammar.py +202 -0
  71. Cython/Compiler/Tests/TestMemView.py +71 -0
  72. Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
  73. Cython/Compiler/Tests/TestScanning.py +134 -0
  74. Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
  75. Cython/Compiler/Tests/TestStringEncoding.py +21 -0
  76. Cython/Compiler/Tests/TestTreeFragment.py +63 -0
  77. Cython/Compiler/Tests/TestTreePath.py +103 -0
  78. Cython/Compiler/Tests/TestTypes.py +75 -0
  79. Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
  80. Cython/Compiler/Tests/TestVisitor.py +61 -0
  81. Cython/Compiler/Tests/Utils.py +36 -0
  82. Cython/Compiler/Tests/__init__.py +1 -0
  83. Cython/Compiler/TreeFragment.py +278 -0
  84. Cython/Compiler/TreePath.py +303 -0
  85. Cython/Compiler/TypeInference.py +591 -0
  86. Cython/Compiler/TypeSlots.py +1174 -0
  87. Cython/Compiler/UFuncs.py +311 -0
  88. Cython/Compiler/UtilNodes.py +389 -0
  89. Cython/Compiler/UtilityCode.py +344 -0
  90. Cython/Compiler/Version.py +8 -0
  91. Cython/Compiler/Visitor.pxd +53 -0
  92. Cython/Compiler/Visitor.py +861 -0
  93. Cython/Compiler/Visitor.pyd +0 -0
  94. Cython/Compiler/__init__.py +1 -0
  95. Cython/Coverage.py +448 -0
  96. Cython/Debugger/Cygdb.py +177 -0
  97. Cython/Debugger/DebugWriter.py +82 -0
  98. Cython/Debugger/Tests/TestLibCython.py +275 -0
  99. Cython/Debugger/Tests/__init__.py +1 -0
  100. Cython/Debugger/Tests/cfuncs.c +8 -0
  101. Cython/Debugger/Tests/codefile +49 -0
  102. Cython/Debugger/Tests/test_libcython_in_gdb.py +578 -0
  103. Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
  104. Cython/Debugger/__init__.py +1 -0
  105. Cython/Debugger/libcython.py +1548 -0
  106. Cython/Debugger/libpython.py +2821 -0
  107. Cython/Debugging.py +20 -0
  108. Cython/Distutils/__init__.py +2 -0
  109. Cython/Distutils/build_ext.py +139 -0
  110. Cython/Distutils/extension.py +96 -0
  111. Cython/Distutils/old_build_ext.py +351 -0
  112. Cython/Includes/cpython/__init__.pxd +173 -0
  113. Cython/Includes/cpython/array.pxd +178 -0
  114. Cython/Includes/cpython/bool.pxd +37 -0
  115. Cython/Includes/cpython/buffer.pxd +112 -0
  116. Cython/Includes/cpython/bytearray.pxd +33 -0
  117. Cython/Includes/cpython/bytes.pxd +200 -0
  118. Cython/Includes/cpython/cellobject.pxd +35 -0
  119. Cython/Includes/cpython/ceval.pxd +8 -0
  120. Cython/Includes/cpython/codecs.pxd +121 -0
  121. Cython/Includes/cpython/complex.pxd +60 -0
  122. Cython/Includes/cpython/contextvars.pxd +145 -0
  123. Cython/Includes/cpython/conversion.pxd +36 -0
  124. Cython/Includes/cpython/datetime.pxd +395 -0
  125. Cython/Includes/cpython/descr.pxd +26 -0
  126. Cython/Includes/cpython/dict.pxd +187 -0
  127. Cython/Includes/cpython/exc.pxd +263 -0
  128. Cython/Includes/cpython/fileobject.pxd +57 -0
  129. Cython/Includes/cpython/float.pxd +47 -0
  130. Cython/Includes/cpython/function.pxd +65 -0
  131. Cython/Includes/cpython/genobject.pxd +25 -0
  132. Cython/Includes/cpython/getargs.pxd +12 -0
  133. Cython/Includes/cpython/instance.pxd +25 -0
  134. Cython/Includes/cpython/iterator.pxd +36 -0
  135. Cython/Includes/cpython/iterobject.pxd +24 -0
  136. Cython/Includes/cpython/list.pxd +92 -0
  137. Cython/Includes/cpython/long.pxd +149 -0
  138. Cython/Includes/cpython/longintrepr.pxd +14 -0
  139. Cython/Includes/cpython/mapping.pxd +63 -0
  140. Cython/Includes/cpython/marshal.pxd +66 -0
  141. Cython/Includes/cpython/mem.pxd +120 -0
  142. Cython/Includes/cpython/memoryview.pxd +50 -0
  143. Cython/Includes/cpython/method.pxd +49 -0
  144. Cython/Includes/cpython/module.pxd +208 -0
  145. Cython/Includes/cpython/number.pxd +258 -0
  146. Cython/Includes/cpython/object.pxd +433 -0
  147. Cython/Includes/cpython/pycapsule.pxd +143 -0
  148. Cython/Includes/cpython/pylifecycle.pxd +68 -0
  149. Cython/Includes/cpython/pyport.pxd +8 -0
  150. Cython/Includes/cpython/pystate.pxd +95 -0
  151. Cython/Includes/cpython/pythread.pxd +53 -0
  152. Cython/Includes/cpython/ref.pxd +141 -0
  153. Cython/Includes/cpython/sequence.pxd +134 -0
  154. Cython/Includes/cpython/set.pxd +119 -0
  155. Cython/Includes/cpython/slice.pxd +70 -0
  156. Cython/Includes/cpython/time.pxd +129 -0
  157. Cython/Includes/cpython/tuple.pxd +72 -0
  158. Cython/Includes/cpython/type.pxd +53 -0
  159. Cython/Includes/cpython/unicode.pxd +639 -0
  160. Cython/Includes/cpython/version.pxd +32 -0
  161. Cython/Includes/cpython/weakref.pxd +78 -0
  162. Cython/Includes/libc/__init__.pxd +1 -0
  163. Cython/Includes/libc/complex.pxd +35 -0
  164. Cython/Includes/libc/errno.pxd +127 -0
  165. Cython/Includes/libc/float.pxd +43 -0
  166. Cython/Includes/libc/limits.pxd +28 -0
  167. Cython/Includes/libc/locale.pxd +46 -0
  168. Cython/Includes/libc/math.pxd +209 -0
  169. Cython/Includes/libc/setjmp.pxd +10 -0
  170. Cython/Includes/libc/signal.pxd +64 -0
  171. Cython/Includes/libc/stddef.pxd +9 -0
  172. Cython/Includes/libc/stdint.pxd +105 -0
  173. Cython/Includes/libc/stdio.pxd +80 -0
  174. Cython/Includes/libc/stdlib.pxd +72 -0
  175. Cython/Includes/libc/string.pxd +50 -0
  176. Cython/Includes/libc/threads.pxd +234 -0
  177. Cython/Includes/libc/time.pxd +52 -0
  178. Cython/Includes/libcpp/__init__.pxd +4 -0
  179. Cython/Includes/libcpp/algorithm.pxd +320 -0
  180. Cython/Includes/libcpp/any.pxd +16 -0
  181. Cython/Includes/libcpp/atomic.pxd +59 -0
  182. Cython/Includes/libcpp/barrier.pxd +22 -0
  183. Cython/Includes/libcpp/bit.pxd +29 -0
  184. Cython/Includes/libcpp/cast.pxd +12 -0
  185. Cython/Includes/libcpp/cmath.pxd +518 -0
  186. Cython/Includes/libcpp/complex.pxd +106 -0
  187. Cython/Includes/libcpp/condition_variable.pxd +322 -0
  188. Cython/Includes/libcpp/deque.pxd +165 -0
  189. Cython/Includes/libcpp/exception.pxd +86 -0
  190. Cython/Includes/libcpp/execution.pxd +15 -0
  191. Cython/Includes/libcpp/forward_list.pxd +63 -0
  192. Cython/Includes/libcpp/functional.pxd +26 -0
  193. Cython/Includes/libcpp/future.pxd +103 -0
  194. Cython/Includes/libcpp/iterator.pxd +34 -0
  195. Cython/Includes/libcpp/latch.pxd +17 -0
  196. Cython/Includes/libcpp/limits.pxd +61 -0
  197. Cython/Includes/libcpp/list.pxd +117 -0
  198. Cython/Includes/libcpp/map.pxd +252 -0
  199. Cython/Includes/libcpp/memory.pxd +115 -0
  200. Cython/Includes/libcpp/mutex.pxd +387 -0
  201. Cython/Includes/libcpp/numbers.pxd +15 -0
  202. Cython/Includes/libcpp/numeric.pxd +131 -0
  203. Cython/Includes/libcpp/optional.pxd +34 -0
  204. Cython/Includes/libcpp/pair.pxd +1 -0
  205. Cython/Includes/libcpp/queue.pxd +25 -0
  206. Cython/Includes/libcpp/random.pxd +166 -0
  207. Cython/Includes/libcpp/semaphore.pxd +43 -0
  208. Cython/Includes/libcpp/set.pxd +228 -0
  209. Cython/Includes/libcpp/shared_mutex.pxd +96 -0
  210. Cython/Includes/libcpp/span.pxd +87 -0
  211. Cython/Includes/libcpp/stack.pxd +11 -0
  212. Cython/Includes/libcpp/stop_token.pxd +117 -0
  213. Cython/Includes/libcpp/string.pxd +355 -0
  214. Cython/Includes/libcpp/string_view.pxd +183 -0
  215. Cython/Includes/libcpp/typeindex.pxd +15 -0
  216. Cython/Includes/libcpp/typeinfo.pxd +10 -0
  217. Cython/Includes/libcpp/unordered_map.pxd +193 -0
  218. Cython/Includes/libcpp/unordered_set.pxd +152 -0
  219. Cython/Includes/libcpp/utility.pxd +30 -0
  220. Cython/Includes/libcpp/vector.pxd +186 -0
  221. Cython/Includes/numpy/math.pxd +150 -0
  222. Cython/Includes/openmp.pxd +50 -0
  223. Cython/Includes/posix/__init__.pxd +1 -0
  224. Cython/Includes/posix/dlfcn.pxd +14 -0
  225. Cython/Includes/posix/fcntl.pxd +86 -0
  226. Cython/Includes/posix/ioctl.pxd +4 -0
  227. Cython/Includes/posix/mman.pxd +101 -0
  228. Cython/Includes/posix/resource.pxd +57 -0
  229. Cython/Includes/posix/select.pxd +21 -0
  230. Cython/Includes/posix/signal.pxd +73 -0
  231. Cython/Includes/posix/stat.pxd +98 -0
  232. Cython/Includes/posix/stdio.pxd +37 -0
  233. Cython/Includes/posix/stdlib.pxd +29 -0
  234. Cython/Includes/posix/strings.pxd +9 -0
  235. Cython/Includes/posix/time.pxd +71 -0
  236. Cython/Includes/posix/types.pxd +30 -0
  237. Cython/Includes/posix/uio.pxd +26 -0
  238. Cython/Includes/posix/unistd.pxd +271 -0
  239. Cython/Includes/posix/wait.pxd +38 -0
  240. Cython/Plex/Actions.pxd +24 -0
  241. Cython/Plex/Actions.py +119 -0
  242. Cython/Plex/Actions.pyd +0 -0
  243. Cython/Plex/DFA.pxd +14 -0
  244. Cython/Plex/DFA.py +164 -0
  245. Cython/Plex/DFA.pyd +0 -0
  246. Cython/Plex/Errors.py +48 -0
  247. Cython/Plex/Lexicons.py +178 -0
  248. Cython/Plex/Machines.pxd +36 -0
  249. Cython/Plex/Machines.py +238 -0
  250. Cython/Plex/Machines.pyd +0 -0
  251. Cython/Plex/Regexps.py +535 -0
  252. Cython/Plex/Scanners.pxd +45 -0
  253. Cython/Plex/Scanners.py +328 -0
  254. Cython/Plex/Scanners.pyd +0 -0
  255. Cython/Plex/Transitions.pxd +14 -0
  256. Cython/Plex/Transitions.py +239 -0
  257. Cython/Plex/Transitions.pyd +0 -0
  258. Cython/Plex/__init__.py +34 -0
  259. Cython/Runtime/__init__.py +1 -0
  260. Cython/Runtime/refnanny.pyd +0 -0
  261. Cython/Runtime/refnanny.pyx +237 -0
  262. Cython/Shadow.py +690 -0
  263. Cython/Shadow.pyi +521 -0
  264. Cython/StringIOTree.py +170 -0
  265. Cython/StringIOTree.pyd +0 -0
  266. Cython/Tempita/__init__.py +4 -0
  267. Cython/Tempita/_looper.py +154 -0
  268. Cython/Tempita/_tempita.py +1091 -0
  269. Cython/Tempita/_tempita.pyd +0 -0
  270. Cython/TestUtils.py +422 -0
  271. Cython/Tests/TestCodeWriter.py +128 -0
  272. Cython/Tests/TestCythonUtils.py +202 -0
  273. Cython/Tests/TestJediTyper.py +223 -0
  274. Cython/Tests/TestShadow.py +114 -0
  275. Cython/Tests/TestStringIOTree.py +67 -0
  276. Cython/Tests/TestTestUtils.py +90 -0
  277. Cython/Tests/__init__.py +1 -0
  278. Cython/Tests/xmlrunner.py +390 -0
  279. Cython/Utility/AsyncGen.c +1031 -0
  280. Cython/Utility/Buffer.c +865 -0
  281. Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
  282. Cython/Utility/Builtins.c +810 -0
  283. Cython/Utility/CConvert.pyx +134 -0
  284. Cython/Utility/CMath.c +104 -0
  285. Cython/Utility/CommonStructures.c +226 -0
  286. Cython/Utility/Complex.c +378 -0
  287. Cython/Utility/Coroutine.c +2300 -0
  288. Cython/Utility/CpdefEnums.pyx +103 -0
  289. Cython/Utility/CppConvert.pyx +282 -0
  290. Cython/Utility/CppSupport.cpp +151 -0
  291. Cython/Utility/CythonFunction.c +1832 -0
  292. Cython/Utility/Dataclasses.c +101 -0
  293. Cython/Utility/Embed.c +121 -0
  294. Cython/Utility/Exceptions.c +1016 -0
  295. Cython/Utility/ExtensionTypes.c +996 -0
  296. Cython/Utility/FunctionArguments.c +1043 -0
  297. Cython/Utility/FusedFunction.pyx +44 -0
  298. Cython/Utility/ImportExport.c +907 -0
  299. Cython/Utility/MemoryView.pxd +188 -0
  300. Cython/Utility/MemoryView.pyx +1482 -0
  301. Cython/Utility/MemoryView_C.c +927 -0
  302. Cython/Utility/ModuleSetupCode.c +3203 -0
  303. Cython/Utility/NumpyImportArray.c +46 -0
  304. Cython/Utility/ObjectHandling.c +3273 -0
  305. Cython/Utility/Optimize.c +1603 -0
  306. Cython/Utility/Overflow.c +384 -0
  307. Cython/Utility/Printing.c +86 -0
  308. Cython/Utility/Profile.c +732 -0
  309. Cython/Utility/StringTools.c +1379 -0
  310. Cython/Utility/Synchronization.c +399 -0
  311. Cython/Utility/TString.c +356 -0
  312. Cython/Utility/TestCyUtilityLoader.pyx +8 -0
  313. Cython/Utility/TestCythonScope.pyx +75 -0
  314. Cython/Utility/TestUtilityLoader.c +12 -0
  315. Cython/Utility/TypeConversion.c +1385 -0
  316. Cython/Utility/UFuncs.pyx +50 -0
  317. Cython/Utility/UFuncs_C.c +89 -0
  318. Cython/Utility/__init__.py +28 -0
  319. Cython/Utility/arrayarray.h +167 -0
  320. Cython/Utils.py +687 -0
  321. Cython/Utils.pyd +0 -0
  322. Cython/__init__.py +10 -0
  323. Cython/__init__.pyi +7 -0
  324. Cython/py.typed +0 -0
  325. cython-3.2.0.dist-info/METADATA +85 -0
  326. cython-3.2.0.dist-info/RECORD +333 -0
  327. cython-3.2.0.dist-info/WHEEL +5 -0
  328. cython-3.2.0.dist-info/entry_points.txt +4 -0
  329. cython-3.2.0.dist-info/top_level.txt +3 -0
  330. cython.py +29 -0
  331. pyximport/__init__.py +4 -0
  332. pyximport/pyxbuild.py +160 -0
  333. pyximport/pyximport.py +482 -0
Binary file
@@ -0,0 +1,16 @@
1
+ def _get_feature(name):
2
+ import __future__
3
+ # fall back to a unique fake object for earlier Python versions or Python 3
4
+ return getattr(__future__, name, object())
5
+
6
+ unicode_literals = _get_feature("unicode_literals")
7
+ with_statement = _get_feature("with_statement") # dummy
8
+ division = _get_feature("division")
9
+ print_function = _get_feature("print_function")
10
+ absolute_import = _get_feature("absolute_import")
11
+ nested_scopes = _get_feature("nested_scopes") # dummy
12
+ generators = _get_feature("generators") # dummy
13
+ generator_stop = _get_feature("generator_stop")
14
+ annotations = _get_feature("annotations")
15
+
16
+ del _get_feature
@@ -0,0 +1,57 @@
1
+ """
2
+ This module deals with interpreting the parse tree as Python
3
+ would have done, in the compiler.
4
+
5
+ For now this only covers parse tree to value conversion of
6
+ compile-time values.
7
+ """
8
+
9
+
10
+ from .ExprNodes import DictNode
11
+ from .Errors import CompileError
12
+
13
+
14
+ class EmptyScope:
15
+ def lookup(self, name):
16
+ return None
17
+
18
+ empty_scope = EmptyScope()
19
+
20
+ def interpret_compiletime_options(optlist, optdict, type_env=None, type_args=()):
21
+ """
22
+ Tries to interpret a list of compile time option nodes.
23
+ The result will be a tuple (optlist, optdict) but where
24
+ all expression nodes have been interpreted. The result is
25
+ in the form of tuples (value, pos).
26
+
27
+ optlist is a list of nodes, while optdict is a DictNode (the
28
+ result optdict is a dict)
29
+
30
+ If type_env is set, all type nodes will be analysed and the resulting
31
+ type set. Otherwise only interpretateable ExprNodes
32
+ are allowed, other nodes raises errors.
33
+
34
+ A CompileError will be raised if there are problems.
35
+ """
36
+
37
+ def interpret(node, ix):
38
+ if ix in type_args:
39
+ if type_env:
40
+ type = node.analyse_as_type(type_env)
41
+ if not type:
42
+ raise CompileError(node.pos, "Invalid type.")
43
+ return (type, node.pos)
44
+ else:
45
+ raise CompileError(node.pos, "Type not allowed here.")
46
+ return (node.compile_time_value(empty_scope), node.pos)
47
+
48
+ if optlist:
49
+ optlist = [interpret(x, ix) for ix, x in enumerate(optlist)]
50
+ if optdict:
51
+ assert isinstance(optdict, DictNode)
52
+ new_optdict = {}
53
+ for item in optdict.key_value_pairs:
54
+ new_key, dummy = interpret(item.key, None)
55
+ new_optdict[new_key] = interpret(item.value, item.key.value)
56
+ optdict = new_optdict
57
+ return (optlist, new_optdict)
@@ -0,0 +1,421 @@
1
+ # cython: py2_import=True
2
+ #
3
+ # Cython Scanner - Lexical Definitions
4
+ #
5
+
6
+
7
+ raw_prefixes = "rR"
8
+ bytes_prefixes = "bB"
9
+ string_prefixes = "uU" + bytes_prefixes
10
+ ft_string_prefixes = "fFtT"
11
+ char_prefixes = "cC"
12
+ any_string_prefix = raw_prefixes + string_prefixes + char_prefixes
13
+ IDENT = 'IDENT'
14
+
15
+
16
+ def make_lexicon():
17
+ from ..Plex import \
18
+ Str, Any, AnyBut, AnyChar, Rep, Rep1, Opt, Bol, Eol, Eof, \
19
+ TEXT, IGNORE, Method, State, Lexicon, Range
20
+
21
+ nonzero_digit = Any("123456789")
22
+ digit = Any("0123456789")
23
+ bindigit = Any("01")
24
+ octdigit = Any("01234567")
25
+ hexdigit = Any("0123456789ABCDEFabcdef")
26
+ indentation = Bol + Rep(Any(" \t"))
27
+
28
+ # The list of valid unicode identifier characters are pretty slow to generate at runtime,
29
+ # and require Python3, so are just included directly here
30
+ # (via the generated code block at the bottom of the file)
31
+ unicode_start_character = (Any(unicode_start_ch_any) | Range(unicode_start_ch_range))
32
+ unicode_continuation_character = (
33
+ unicode_start_character |
34
+ Any(unicode_continuation_ch_any) | Range(unicode_continuation_ch_range))
35
+
36
+ def underscore_digits(d):
37
+ return Rep1(d) + Rep(Str("_") + Rep1(d))
38
+
39
+ def prefixed_digits(prefix, digits):
40
+ return prefix + Opt(Str("_")) + underscore_digits(digits)
41
+
42
+ decimal = underscore_digits(digit)
43
+ dot = Str(".")
44
+ exponent = Any("Ee") + Opt(Any("+-")) + decimal
45
+ decimal_fract = (decimal + dot + Opt(decimal)) | (dot + decimal)
46
+
47
+ #name = letter + Rep(letter | digit)
48
+ name = unicode_start_character + Rep(unicode_continuation_character)
49
+ intconst = (prefixed_digits(nonzero_digit, digit) | # decimal literals with underscores must not start with '0'
50
+ (Str("0") + (prefixed_digits(Any("Xx"), hexdigit) |
51
+ prefixed_digits(Any("Oo"), octdigit) |
52
+ prefixed_digits(Any("Bb"), bindigit) )) |
53
+ underscore_digits(Str('0')) # 0_0_0_0... is allowed as a decimal literal
54
+ | Rep1(digit) # FIXME: remove these Py2 style decimal/octal literals (PY_VERSION_HEX < 3)
55
+ )
56
+ intsuffix = (Opt(Any("Uu")) + Opt(Any("Ll")) + Opt(Any("Ll"))) | (Opt(Any("Ll")) + Opt(Any("Ll")) + Opt(Any("Uu")))
57
+ intliteral = intconst + intsuffix
58
+ fltconst = (decimal_fract + Opt(exponent)) | (decimal + exponent)
59
+ imagconst = (intconst | fltconst) + Any("jJ")
60
+
61
+ # invalid combinations of prefixes are caught in p_string_literal
62
+ beginstring = Opt(Rep(Any(string_prefixes + raw_prefixes)) |
63
+ Any(char_prefixes)
64
+ ) + (Str("'") | Str('"') | Str("'''") | Str('"""'))
65
+ begin_ft_string = (
66
+ ((Any(ft_string_prefixes) + Opt(Any(raw_prefixes))) | (Any(raw_prefixes) + Any(ft_string_prefixes))) +
67
+ (Str("'") | Str('"') | Str("'''") | Str('"""')))
68
+ two_oct = octdigit + octdigit
69
+ three_oct = octdigit + octdigit + octdigit
70
+ two_hex = hexdigit + hexdigit
71
+ four_hex = two_hex + two_hex
72
+ escapeseq = Str("\\") + (octdigit | two_oct | three_oct |
73
+ # Unicode character names are [A-Z \-]
74
+ # https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-4/
75
+ # Although Python itself is case agnostic
76
+ Str('N{') + Rep(Range('azAZ') | Any('- ')) + Str('}') |
77
+ Str('u') + four_hex | Str('x') + two_hex |
78
+ Str('U') + four_hex + four_hex |
79
+ # Invalid escape sequences just produce a slash
80
+ Opt(Any("\n\\'\"abfnrtvNxuU")))
81
+ rawescapeseq = ( # Double \\ isn't actually escaped in raw strings, but
82
+ # we do want to process it so that the end of '\\'
83
+ # doesn't get processed.
84
+ Str("\\\\") |
85
+ Str("\\") + Opt(Any('"\'')))
86
+
87
+ bra = Any("([")
88
+ ket = Any(")]")
89
+ open_brace = Str('{')
90
+ close_brace = Str('}')
91
+ ellipsis = Str("...")
92
+ punct = Any(":,;+-*/|&<>=.%`~^?!@")
93
+ diphthong = Str("==", "<>", "!=", "<=", ">=", "<<", ">>", "**", "//",
94
+ "+=", "-=", "*=", "/=", "%=", "|=", "^=", "&=",
95
+ "<<=", ">>=", "**=", "//=", "->", "@=", "&&", "||", ':=')
96
+ spaces = Rep1(Any(" \t\f"))
97
+ escaped_newline = Str("\\\n")
98
+ lineterm = Eol + Opt(Str("\n"))
99
+
100
+ comment = Str("#") + Rep(AnyBut("\n"))
101
+
102
+ def generate_ft_string_states():
103
+ out = []
104
+
105
+ # In order for self-documenting strings to work, we need to
106
+ # pre-scan the fstring/tstring into a string, and then parse it
107
+ # again as an expression. This allows us to accurately
108
+ # preserve whitespace (at the cost of repeatedly tokenizing
109
+ # for deeply nested fstrings/tstrings).
110
+ # To do this we need to pay attention to brackets, strings,
111
+ # colons, and comments, but can ignore anything else.
112
+ out.append(
113
+ State("FT_STRING_EXPR_PRESCAN", [
114
+ (Rep1(AnyBut('"\'{}()[]:#')), 'CHARS'),
115
+ (comment, IGNORE),
116
+ (Str(':'), Method('colon_action')),
117
+ (open_brace, Method('open_brace_action')),
118
+ (close_brace, Method('close_brace_action')),
119
+ (bra, Method('open_bracket_action')),
120
+ (ket, Method('close_bracket_action')),
121
+ (beginstring, Method('begin_string_action')),
122
+ (begin_ft_string, Method('begin_ft_string_action')),
123
+ (Eof, 'EOF')
124
+ ]))
125
+
126
+ unclosed_string_method = Method('unclosed_string_action')
127
+ open_ft_string_brace_method = Method('open_ft_string_brace_action')
128
+ close_ft_string_brace_method = Method('close_ft_string_brace_action')
129
+ end_ft_string_method = Method('end_ft_string_action')
130
+
131
+ for prefix in ["'", '"', "'''", '"""']:
132
+ quote_type = 'SQ' if "'" in prefix else 'DQ'
133
+ if len(prefix) > 1:
134
+ triple = "T"
135
+ newline_method = "NEWLINE"
136
+ allowed_string_chars = Any("'\"")
137
+ else:
138
+ triple = ""
139
+ newline_method = unclosed_string_method
140
+ allowed_string_chars = Str('"' if quote_type == 'SQ' else "'")
141
+
142
+ for raw in ["", "R"]:
143
+ escapeseq_sy = rawescapeseq if raw else escapeseq
144
+ out.append(
145
+ State(f"{triple}{quote_type}_STRING_FT{raw}", [
146
+ (escapeseq_sy, 'ESCAPE'),
147
+ (Rep1(Str('{')), open_ft_string_brace_method),
148
+ (Rep1(Str('}')), close_ft_string_brace_method),
149
+ (Rep1(AnyBut("'\"\n\\{}")), 'CHARS'),
150
+ (allowed_string_chars, 'CHARS'),
151
+ (Str("\n"), newline_method),
152
+ (Str(prefix), end_ft_string_method),
153
+ (Eof, 'EOF')
154
+ ])
155
+ )
156
+ return out
157
+
158
+ return Lexicon([
159
+ (name, Method('normalize_ident')),
160
+ (intliteral, Method('strip_underscores', symbol='INT')),
161
+ (fltconst, Method('strip_underscores', symbol='FLOAT')),
162
+ (imagconst, Method('strip_underscores', symbol='IMAG')),
163
+ (ellipsis | punct | diphthong, TEXT),
164
+
165
+ (bra, Method('open_bracket_action')),
166
+ (ket, Method('close_bracket_action')),
167
+ (open_brace, Method('open_brace_action')),
168
+ (close_brace, Method('close_brace_action')),
169
+ (lineterm, Method('newline_action')),
170
+
171
+ (beginstring, Method('begin_string_action')),
172
+ (begin_ft_string, Method('begin_ft_string_action')),
173
+
174
+ (comment, IGNORE),
175
+ (spaces, IGNORE),
176
+ (escaped_newline, IGNORE),
177
+
178
+ State('INDENT', [
179
+ (comment + lineterm, Method('commentline')),
180
+ (Opt(spaces) + Opt(comment) + lineterm, IGNORE),
181
+ (indentation, Method('indentation_action')),
182
+ (Eof, Method('eof_action'))
183
+ ]),
184
+
185
+ State('SQ_STRING', [
186
+ (escapeseq, 'ESCAPE'),
187
+ (Rep1(AnyBut("'\"\n\\")), 'CHARS'),
188
+ (Str('"'), 'CHARS'),
189
+ (Str("\n"), Method('unclosed_string_action')),
190
+ (Str("'"), Method('end_string_action')),
191
+ (Eof, 'EOF')
192
+ ]),
193
+
194
+ State('DQ_STRING', [
195
+ (escapeseq, 'ESCAPE'),
196
+ (Rep1(AnyBut('"\n\\')), 'CHARS'),
197
+ (Str("'"), 'CHARS'),
198
+ (Str("\n"), Method('unclosed_string_action')),
199
+ (Str('"'), Method('end_string_action')),
200
+ (Eof, 'EOF')
201
+ ]),
202
+
203
+ State('TSQ_STRING', [
204
+ (escapeseq, 'ESCAPE'),
205
+ (Rep1(AnyBut("'\"\n\\")), 'CHARS'),
206
+ (Any("'\""), 'CHARS'),
207
+ (Str("\n"), 'NEWLINE'),
208
+ (Str("'''"), Method('end_string_action')),
209
+ (Eof, 'EOF')
210
+ ]),
211
+
212
+ State('TDQ_STRING', [
213
+ (escapeseq, 'ESCAPE'),
214
+ (Rep1(AnyBut('"\'\n\\')), 'CHARS'),
215
+ (Any("'\""), 'CHARS'),
216
+ (Str("\n"), 'NEWLINE'),
217
+ (Str('"""'), Method('end_string_action')),
218
+ (Eof, 'EOF')
219
+ ]),
220
+ *generate_ft_string_states(),
221
+
222
+ (Eof, Method('eof_action'))
223
+ ],
224
+
225
+ # FIXME: Plex 1.9 needs different args here from Plex 1.1.4
226
+ #debug_flags = scanner_debug_flags,
227
+ #debug_file = scanner_dump_file
228
+ )
229
+
230
+
231
+ # BEGIN GENERATED CODE
232
+ # Generated with 'cython-generate-lexicon.py' based on Unicode 16.0.0:
233
+ # cpython 3.14.0rc1 free-threading build (main, Jul 25 2025, 19:13:08) [GCC 14.2.1 20250220 [revision 9ffecde121af883b60bbe60d00425036bc873048]]
234
+
235
+ unicode_start_ch_any = (
236
+ "\u005f\u00aa\u00b5\u00ba\u02ec\u02ee\u037f\u0386\u038c\u0559\u06d5"
237
+ "\u06ff\u0710\u07b1\u07fa\u081a\u0824\u0828\u093d\u0950\u09b2\u09bd"
238
+ "\u09ce\u09fc\u0a5e\u0abd\u0ad0\u0af9\u0b3d\u0b71\u0b83\u0b9c\u0bd0"
239
+ "\u0c3d\u0c5d\u0c80\u0cbd\u0d3d\u0d4e\u0dbd\u0e32\u0e84\u0ea5\u0eb2"
240
+ "\u0ebd\u0ec6\u0f00\u103f\u1061\u108e\u10c7\u10cd\u1258\u12c0\u17d7"
241
+ "\u17dc\u18aa\u1aa7\u1cfa\u1f59\u1f5b\u1f5d\u1fbe\u2071\u207f\u2102"
242
+ "\u2107\u2115\u2124\u2126\u2128\u214e\u2d27\u2d2d\u2d6f\ua7d3\ua8fb"
243
+ "\ua9cf\uaa7a\uaab1\uaac0\uaac2\ufb1d\ufb3e\ufe71\ufe73\ufe77\ufe79"
244
+ "\ufe7b\ufe7d\U00010808\U0001083c\U00010a00\U00010f27\U00011075\U00011144\U00011147\U00011176\U000111da"
245
+ "\U000111dc\U00011288\U0001133d\U00011350\U0001138b\U0001138e\U000113b7\U000113d1\U000113d3\U000114c7\U00011644"
246
+ "\U000116b8\U00011909\U0001193f\U00011941\U000119e1\U000119e3\U00011a00\U00011a3a\U00011a50\U00011a9d\U00011c40"
247
+ "\U00011d46\U00011d98\U00011f02\U00011fb0\U00016f50\U00016fe3\U0001b132\U0001b155\U0001d4a2\U0001d4bb\U0001d546"
248
+ "\U0001e14e\U0001e5f0\U0001e94b\U0001ee24\U0001ee27\U0001ee39\U0001ee3b\U0001ee42\U0001ee47\U0001ee49\U0001ee4b"
249
+ "\U0001ee54\U0001ee57\U0001ee59\U0001ee5b\U0001ee5d\U0001ee5f\U0001ee64\U0001ee7e"
250
+ )
251
+ unicode_start_ch_range = (
252
+ "\u0041\u005a\u0061\u007a\u00c0\u00d6\u00d8\u00f6\u00f8\u02c1\u02c6"
253
+ "\u02d1\u02e0\u02e4\u0370\u0374\u0376\u0377\u037b\u037d\u0388\u038a"
254
+ "\u038e\u03a1\u03a3\u03f5\u03f7\u0481\u048a\u052f\u0531\u0556\u0560"
255
+ "\u0588\u05d0\u05ea\u05ef\u05f2\u0620\u064a\u066e\u066f\u0671\u06d3"
256
+ "\u06e5\u06e6\u06ee\u06ef\u06fa\u06fc\u0712\u072f\u074d\u07a5\u07ca"
257
+ "\u07ea\u07f4\u07f5\u0800\u0815\u0840\u0858\u0860\u086a\u0870\u0887"
258
+ "\u0889\u088e\u08a0\u08c9\u0904\u0939\u0958\u0961\u0971\u0980\u0985"
259
+ "\u098c\u098f\u0990\u0993\u09a8\u09aa\u09b0\u09b6\u09b9\u09dc\u09dd"
260
+ "\u09df\u09e1\u09f0\u09f1\u0a05\u0a0a\u0a0f\u0a10\u0a13\u0a28\u0a2a"
261
+ "\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59\u0a5c\u0a72\u0a74"
262
+ "\u0a85\u0a8d\u0a8f\u0a91\u0a93\u0aa8\u0aaa\u0ab0\u0ab2\u0ab3\u0ab5"
263
+ "\u0ab9\u0ae0\u0ae1\u0b05\u0b0c\u0b0f\u0b10\u0b13\u0b28\u0b2a\u0b30"
264
+ "\u0b32\u0b33\u0b35\u0b39\u0b5c\u0b5d\u0b5f\u0b61\u0b85\u0b8a\u0b8e"
265
+ "\u0b90\u0b92\u0b95\u0b99\u0b9a\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8\u0baa"
266
+ "\u0bae\u0bb9\u0c05\u0c0c\u0c0e\u0c10\u0c12\u0c28\u0c2a\u0c39\u0c58"
267
+ "\u0c5a\u0c60\u0c61\u0c85\u0c8c\u0c8e\u0c90\u0c92\u0ca8\u0caa\u0cb3"
268
+ "\u0cb5\u0cb9\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04\u0d0c\u0d0e"
269
+ "\u0d10\u0d12\u0d3a\u0d54\u0d56\u0d5f\u0d61\u0d7a\u0d7f\u0d85\u0d96"
270
+ "\u0d9a\u0db1\u0db3\u0dbb\u0dc0\u0dc6\u0e01\u0e30\u0e40\u0e46\u0e81"
271
+ "\u0e82\u0e86\u0e8a\u0e8c\u0ea3\u0ea7\u0eb0\u0ec0\u0ec4\u0edc\u0edf"
272
+ "\u0f40\u0f47\u0f49\u0f6c\u0f88\u0f8c\u1000\u102a\u1050\u1055\u105a"
273
+ "\u105d\u1065\u1066\u106e\u1070\u1075\u1081\u10a0\u10c5\u10d0\u10fa"
274
+ "\u10fc\u1248\u124a\u124d\u1250\u1256\u125a\u125d\u1260\u1288\u128a"
275
+ "\u128d\u1290\u12b0\u12b2\u12b5\u12b8\u12be\u12c2\u12c5\u12c8\u12d6"
276
+ "\u12d8\u1310\u1312\u1315\u1318\u135a\u1380\u138f\u13a0\u13f5\u13f8"
277
+ "\u13fd\u1401\u166c\u166f\u167f\u1681\u169a\u16a0\u16ea\u16ee\u16f8"
278
+ "\u1700\u1711\u171f\u1731\u1740\u1751\u1760\u176c\u176e\u1770\u1780"
279
+ "\u17b3\u1820\u1878\u1880\u18a8\u18b0\u18f5\u1900\u191e\u1950\u196d"
280
+ "\u1970\u1974\u1980\u19ab\u19b0\u19c9\u1a00\u1a16\u1a20\u1a54\u1b05"
281
+ "\u1b33\u1b45\u1b4c\u1b83\u1ba0\u1bae\u1baf\u1bba\u1be5\u1c00\u1c23"
282
+ "\u1c4d\u1c4f\u1c5a\u1c7d\u1c80\u1c8a\u1c90\u1cba\u1cbd\u1cbf\u1ce9"
283
+ "\u1cec\u1cee\u1cf3\u1cf5\u1cf6\u1d00\u1dbf\u1e00\u1f15\u1f18\u1f1d"
284
+ "\u1f20\u1f45\u1f48\u1f4d\u1f50\u1f57\u1f5f\u1f7d\u1f80\u1fb4\u1fb6"
285
+ "\u1fbc\u1fc2\u1fc4\u1fc6\u1fcc\u1fd0\u1fd3\u1fd6\u1fdb\u1fe0\u1fec"
286
+ "\u1ff2\u1ff4\u1ff6\u1ffc\u2090\u209c\u210a\u2113\u2118\u211d\u212a"
287
+ "\u2139\u213c\u213f\u2145\u2149\u2160\u2188\u2c00\u2ce4\u2ceb\u2cee"
288
+ "\u2cf2\u2cf3\u2d00\u2d25\u2d30\u2d67\u2d80\u2d96\u2da0\u2da6\u2da8"
289
+ "\u2dae\u2db0\u2db6\u2db8\u2dbe\u2dc0\u2dc6\u2dc8\u2dce\u2dd0\u2dd6"
290
+ "\u2dd8\u2dde\u3005\u3007\u3021\u3029\u3031\u3035\u3038\u303c\u3041"
291
+ "\u3096\u309d\u309f\u30a1\u30fa\u30fc\u30ff\u3105\u312f\u3131\u318e"
292
+ "\u31a0\u31bf\u31f0\u31ff\u3400\u4dbf\u4e00\ua48c\ua4d0\ua4fd\ua500"
293
+ "\ua60c\ua610\ua61f\ua62a\ua62b\ua640\ua66e\ua67f\ua69d\ua6a0\ua6ef"
294
+ "\ua717\ua71f\ua722\ua788\ua78b\ua7cd\ua7d0\ua7d1\ua7d5\ua7dc\ua7f2"
295
+ "\ua801\ua803\ua805\ua807\ua80a\ua80c\ua822\ua840\ua873\ua882\ua8b3"
296
+ "\ua8f2\ua8f7\ua8fd\ua8fe\ua90a\ua925\ua930\ua946\ua960\ua97c\ua984"
297
+ "\ua9b2\ua9e0\ua9e4\ua9e6\ua9ef\ua9fa\ua9fe\uaa00\uaa28\uaa40\uaa42"
298
+ "\uaa44\uaa4b\uaa60\uaa76\uaa7e\uaaaf\uaab5\uaab6\uaab9\uaabd\uaadb"
299
+ "\uaadd\uaae0\uaaea\uaaf2\uaaf4\uab01\uab06\uab09\uab0e\uab11\uab16"
300
+ "\uab20\uab26\uab28\uab2e\uab30\uab5a\uab5c\uab69\uab70\uabe2\uac00"
301
+ "\ud7a3\ud7b0\ud7c6\ud7cb\ud7fb\uf900\ufa6d\ufa70\ufad9\ufb00\ufb06"
302
+ "\ufb13\ufb17\ufb1f\ufb28\ufb2a\ufb36\ufb38\ufb3c\ufb40\ufb41\ufb43"
303
+ "\ufb44\ufb46\ufbb1\ufbd3\ufc5d\ufc64\ufd3d\ufd50\ufd8f\ufd92\ufdc7"
304
+ "\ufdf0\ufdf9\ufe7f\ufefc\uff21\uff3a\uff41\uff5a\uff66\uff9d\uffa0"
305
+ "\uffbe\uffc2\uffc7\uffca\uffcf\uffd2\uffd7\uffda\uffdc\U00010000\U0001000b"
306
+ "\U0001000d\U00010026\U00010028\U0001003a\U0001003c\U0001003d\U0001003f\U0001004d\U00010050\U0001005d\U00010080"
307
+ "\U000100fa\U00010140\U00010174\U00010280\U0001029c\U000102a0\U000102d0\U00010300\U0001031f\U0001032d\U0001034a"
308
+ "\U00010350\U00010375\U00010380\U0001039d\U000103a0\U000103c3\U000103c8\U000103cf\U000103d1\U000103d5\U00010400"
309
+ "\U0001049d\U000104b0\U000104d3\U000104d8\U000104fb\U00010500\U00010527\U00010530\U00010563\U00010570\U0001057a"
310
+ "\U0001057c\U0001058a\U0001058c\U00010592\U00010594\U00010595\U00010597\U000105a1\U000105a3\U000105b1\U000105b3"
311
+ "\U000105b9\U000105bb\U000105bc\U000105c0\U000105f3\U00010600\U00010736\U00010740\U00010755\U00010760\U00010767"
312
+ "\U00010780\U00010785\U00010787\U000107b0\U000107b2\U000107ba\U00010800\U00010805\U0001080a\U00010835\U00010837"
313
+ "\U00010838\U0001083f\U00010855\U00010860\U00010876\U00010880\U0001089e\U000108e0\U000108f2\U000108f4\U000108f5"
314
+ "\U00010900\U00010915\U00010920\U00010939\U00010980\U000109b7\U000109be\U000109bf\U00010a10\U00010a13\U00010a15"
315
+ "\U00010a17\U00010a19\U00010a35\U00010a60\U00010a7c\U00010a80\U00010a9c\U00010ac0\U00010ac7\U00010ac9\U00010ae4"
316
+ "\U00010b00\U00010b35\U00010b40\U00010b55\U00010b60\U00010b72\U00010b80\U00010b91\U00010c00\U00010c48\U00010c80"
317
+ "\U00010cb2\U00010cc0\U00010cf2\U00010d00\U00010d23\U00010d4a\U00010d65\U00010d6f\U00010d85\U00010e80\U00010ea9"
318
+ "\U00010eb0\U00010eb1\U00010ec2\U00010ec4\U00010f00\U00010f1c\U00010f30\U00010f45\U00010f70\U00010f81\U00010fb0"
319
+ "\U00010fc4\U00010fe0\U00010ff6\U00011003\U00011037\U00011071\U00011072\U00011083\U000110af\U000110d0\U000110e8"
320
+ "\U00011103\U00011126\U00011150\U00011172\U00011183\U000111b2\U000111c1\U000111c4\U00011200\U00011211\U00011213"
321
+ "\U0001122b\U0001123f\U00011240\U00011280\U00011286\U0001128a\U0001128d\U0001128f\U0001129d\U0001129f\U000112a8"
322
+ "\U000112b0\U000112de\U00011305\U0001130c\U0001130f\U00011310\U00011313\U00011328\U0001132a\U00011330\U00011332"
323
+ "\U00011333\U00011335\U00011339\U0001135d\U00011361\U00011380\U00011389\U00011390\U000113b5\U00011400\U00011434"
324
+ "\U00011447\U0001144a\U0001145f\U00011461\U00011480\U000114af\U000114c4\U000114c5\U00011580\U000115ae\U000115d8"
325
+ "\U000115db\U00011600\U0001162f\U00011680\U000116aa\U00011700\U0001171a\U00011740\U00011746\U00011800\U0001182b"
326
+ "\U000118a0\U000118df\U000118ff\U00011906\U0001190c\U00011913\U00011915\U00011916\U00011918\U0001192f\U000119a0"
327
+ "\U000119a7\U000119aa\U000119d0\U00011a0b\U00011a32\U00011a5c\U00011a89\U00011ab0\U00011af8\U00011bc0\U00011be0"
328
+ "\U00011c00\U00011c08\U00011c0a\U00011c2e\U00011c72\U00011c8f\U00011d00\U00011d06\U00011d08\U00011d09\U00011d0b"
329
+ "\U00011d30\U00011d60\U00011d65\U00011d67\U00011d68\U00011d6a\U00011d89\U00011ee0\U00011ef2\U00011f04\U00011f10"
330
+ "\U00011f12\U00011f33\U00012000\U00012399\U00012400\U0001246e\U00012480\U00012543\U00012f90\U00012ff0\U00013000"
331
+ "\U0001342f\U00013441\U00013446\U00013460\U000143fa\U00014400\U00014646\U00016100\U0001611d\U00016800\U00016a38"
332
+ "\U00016a40\U00016a5e\U00016a70\U00016abe\U00016ad0\U00016aed\U00016b00\U00016b2f\U00016b40\U00016b43\U00016b63"
333
+ "\U00016b77\U00016b7d\U00016b8f\U00016d40\U00016d6c\U00016e40\U00016e7f\U00016f00\U00016f4a\U00016f93\U00016f9f"
334
+ "\U00016fe0\U00016fe1\U00017000\U000187f7\U00018800\U00018cd5\U00018cff\U00018d08\U0001aff0\U0001aff3\U0001aff5"
335
+ "\U0001affb\U0001affd\U0001affe\U0001b000\U0001b122\U0001b150\U0001b152\U0001b164\U0001b167\U0001b170\U0001b2fb"
336
+ "\U0001bc00\U0001bc6a\U0001bc70\U0001bc7c\U0001bc80\U0001bc88\U0001bc90\U0001bc99\U0001d400\U0001d454\U0001d456"
337
+ "\U0001d49c\U0001d49e\U0001d49f\U0001d4a5\U0001d4a6\U0001d4a9\U0001d4ac\U0001d4ae\U0001d4b9\U0001d4bd\U0001d4c3"
338
+ "\U0001d4c5\U0001d505\U0001d507\U0001d50a\U0001d50d\U0001d514\U0001d516\U0001d51c\U0001d51e\U0001d539\U0001d53b"
339
+ "\U0001d53e\U0001d540\U0001d544\U0001d54a\U0001d550\U0001d552\U0001d6a5\U0001d6a8\U0001d6c0\U0001d6c2\U0001d6da"
340
+ "\U0001d6dc\U0001d6fa\U0001d6fc\U0001d714\U0001d716\U0001d734\U0001d736\U0001d74e\U0001d750\U0001d76e\U0001d770"
341
+ "\U0001d788\U0001d78a\U0001d7a8\U0001d7aa\U0001d7c2\U0001d7c4\U0001d7cb\U0001df00\U0001df1e\U0001df25\U0001df2a"
342
+ "\U0001e030\U0001e06d\U0001e100\U0001e12c\U0001e137\U0001e13d\U0001e290\U0001e2ad\U0001e2c0\U0001e2eb\U0001e4d0"
343
+ "\U0001e4eb\U0001e5d0\U0001e5ed\U0001e7e0\U0001e7e6\U0001e7e8\U0001e7eb\U0001e7ed\U0001e7ee\U0001e7f0\U0001e7fe"
344
+ "\U0001e800\U0001e8c4\U0001e900\U0001e943\U0001ee00\U0001ee03\U0001ee05\U0001ee1f\U0001ee21\U0001ee22\U0001ee29"
345
+ "\U0001ee32\U0001ee34\U0001ee37\U0001ee4d\U0001ee4f\U0001ee51\U0001ee52\U0001ee61\U0001ee62\U0001ee67\U0001ee6a"
346
+ "\U0001ee6c\U0001ee72\U0001ee74\U0001ee77\U0001ee79\U0001ee7c\U0001ee80\U0001ee89\U0001ee8b\U0001ee9b\U0001eea1"
347
+ "\U0001eea3\U0001eea5\U0001eea9\U0001eeab\U0001eebb\U00020000\U0002a6df\U0002a700\U0002b739\U0002b740\U0002b81d"
348
+ "\U0002b820\U0002cea1\U0002ceb0\U0002ebe0\U0002ebf0\U0002ee5d\U0002f800\U0002fa1d\U00030000\U0003134a\U00031350"
349
+ "\U000323af"
350
+ )
351
+ unicode_continuation_ch_any = (
352
+ "\u00b7\u0387\u05bf\u05c7\u0670\u0711\u07fd\u09bc\u09d7\u09fe\u0a3c"
353
+ "\u0a51\u0a75\u0abc\u0b3c\u0b82\u0bd7\u0c3c\u0cbc\u0cf3\u0d57\u0dca"
354
+ "\u0dd6\u0e31\u0eb1\u0f35\u0f37\u0f39\u0fc6\u17dd\u18a9\u1ced\u1cf4"
355
+ "\u2054\u20e1\u2d7f\u30fb\ua66f\ua802\ua806\ua80b\ua82c\ua9e5\uaa43"
356
+ "\uaab0\uaac1\ufb1e\uff3f\uff65\U000101fd\U000102e0\U00010a3f\U000110c2\U00011173\U0001123e"
357
+ "\U00011241\U00011357\U000113c2\U000113c5\U000113d2\U0001145e\U00011940\U000119e4\U00011a47\U00011d3a\U00011d47"
358
+ "\U00011f03\U00013440\U00016f4f\U00016fe4\U0001da75\U0001da84\U0001e08f\U0001e2ae"
359
+ )
360
+ unicode_continuation_ch_range = (
361
+ "\u0030\u0039\u0300\u036f\u0483\u0487\u0591\u05bd\u05c1\u05c2\u05c4"
362
+ "\u05c5\u0610\u061a\u064b\u0669\u06d6\u06dc\u06df\u06e4\u06e7\u06e8"
363
+ "\u06ea\u06ed\u06f0\u06f9\u0730\u074a\u07a6\u07b0\u07c0\u07c9\u07eb"
364
+ "\u07f3\u0816\u0819\u081b\u0823\u0825\u0827\u0829\u082d\u0859\u085b"
365
+ "\u0897\u089f\u08ca\u08e1\u08e3\u0903\u093a\u093c\u093e\u094f\u0951"
366
+ "\u0957\u0962\u0963\u0966\u096f\u0981\u0983\u09be\u09c4\u09c7\u09c8"
367
+ "\u09cb\u09cd\u09e2\u09e3\u09e6\u09ef\u0a01\u0a03\u0a3e\u0a42\u0a47"
368
+ "\u0a48\u0a4b\u0a4d\u0a66\u0a71\u0a81\u0a83\u0abe\u0ac5\u0ac7\u0ac9"
369
+ "\u0acb\u0acd\u0ae2\u0ae3\u0ae6\u0aef\u0afa\u0aff\u0b01\u0b03\u0b3e"
370
+ "\u0b44\u0b47\u0b48\u0b4b\u0b4d\u0b55\u0b57\u0b62\u0b63\u0b66\u0b6f"
371
+ "\u0bbe\u0bc2\u0bc6\u0bc8\u0bca\u0bcd\u0be6\u0bef\u0c00\u0c04\u0c3e"
372
+ "\u0c44\u0c46\u0c48\u0c4a\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66\u0c6f"
373
+ "\u0c81\u0c83\u0cbe\u0cc4\u0cc6\u0cc8\u0cca\u0ccd\u0cd5\u0cd6\u0ce2"
374
+ "\u0ce3\u0ce6\u0cef\u0d00\u0d03\u0d3b\u0d3c\u0d3e\u0d44\u0d46\u0d48"
375
+ "\u0d4a\u0d4d\u0d62\u0d63\u0d66\u0d6f\u0d81\u0d83\u0dcf\u0dd4\u0dd8"
376
+ "\u0ddf\u0de6\u0def\u0df2\u0df3\u0e33\u0e3a\u0e47\u0e4e\u0e50\u0e59"
377
+ "\u0eb3\u0ebc\u0ec8\u0ece\u0ed0\u0ed9\u0f18\u0f19\u0f20\u0f29\u0f3e"
378
+ "\u0f3f\u0f71\u0f84\u0f86\u0f87\u0f8d\u0f97\u0f99\u0fbc\u102b\u103e"
379
+ "\u1040\u1049\u1056\u1059\u105e\u1060\u1062\u1064\u1067\u106d\u1071"
380
+ "\u1074\u1082\u108d\u108f\u109d\u135d\u135f\u1369\u1371\u1712\u1715"
381
+ "\u1732\u1734\u1752\u1753\u1772\u1773\u17b4\u17d3\u17e0\u17e9\u180b"
382
+ "\u180d\u180f\u1819\u1920\u192b\u1930\u193b\u1946\u194f\u19d0\u19da"
383
+ "\u1a17\u1a1b\u1a55\u1a5e\u1a60\u1a7c\u1a7f\u1a89\u1a90\u1a99\u1ab0"
384
+ "\u1abd\u1abf\u1ace\u1b00\u1b04\u1b34\u1b44\u1b50\u1b59\u1b6b\u1b73"
385
+ "\u1b80\u1b82\u1ba1\u1bad\u1bb0\u1bb9\u1be6\u1bf3\u1c24\u1c37\u1c40"
386
+ "\u1c49\u1c50\u1c59\u1cd0\u1cd2\u1cd4\u1ce8\u1cf7\u1cf9\u1dc0\u1dff"
387
+ "\u200c\u200d\u203f\u2040\u20d0\u20dc\u20e5\u20f0\u2cef\u2cf1\u2de0"
388
+ "\u2dff\u302a\u302f\u3099\u309a\ua620\ua629\ua674\ua67d\ua69e\ua69f"
389
+ "\ua6f0\ua6f1\ua823\ua827\ua880\ua881\ua8b4\ua8c5\ua8d0\ua8d9\ua8e0"
390
+ "\ua8f1\ua8ff\ua909\ua926\ua92d\ua947\ua953\ua980\ua983\ua9b3\ua9c0"
391
+ "\ua9d0\ua9d9\ua9f0\ua9f9\uaa29\uaa36\uaa4c\uaa4d\uaa50\uaa59\uaa7b"
392
+ "\uaa7d\uaab2\uaab4\uaab7\uaab8\uaabe\uaabf\uaaeb\uaaef\uaaf5\uaaf6"
393
+ "\uabe3\uabea\uabec\uabed\uabf0\uabf9\ufe00\ufe0f\ufe20\ufe2f\ufe33"
394
+ "\ufe34\ufe4d\ufe4f\uff10\uff19\uff9e\uff9f\U00010376\U0001037a\U000104a0\U000104a9"
395
+ "\U00010a01\U00010a03\U00010a05\U00010a06\U00010a0c\U00010a0f\U00010a38\U00010a3a\U00010ae5\U00010ae6\U00010d24"
396
+ "\U00010d27\U00010d30\U00010d39\U00010d40\U00010d49\U00010d69\U00010d6d\U00010eab\U00010eac\U00010efc\U00010eff"
397
+ "\U00010f46\U00010f50\U00010f82\U00010f85\U00011000\U00011002\U00011038\U00011046\U00011066\U00011070\U00011073"
398
+ "\U00011074\U0001107f\U00011082\U000110b0\U000110ba\U000110f0\U000110f9\U00011100\U00011102\U00011127\U00011134"
399
+ "\U00011136\U0001113f\U00011145\U00011146\U00011180\U00011182\U000111b3\U000111c0\U000111c9\U000111cc\U000111ce"
400
+ "\U000111d9\U0001122c\U00011237\U000112df\U000112ea\U000112f0\U000112f9\U00011300\U00011303\U0001133b\U0001133c"
401
+ "\U0001133e\U00011344\U00011347\U00011348\U0001134b\U0001134d\U00011362\U00011363\U00011366\U0001136c\U00011370"
402
+ "\U00011374\U000113b8\U000113c0\U000113c7\U000113ca\U000113cc\U000113d0\U000113e1\U000113e2\U00011435\U00011446"
403
+ "\U00011450\U00011459\U000114b0\U000114c3\U000114d0\U000114d9\U000115af\U000115b5\U000115b8\U000115c0\U000115dc"
404
+ "\U000115dd\U00011630\U00011640\U00011650\U00011659\U000116ab\U000116b7\U000116c0\U000116c9\U000116d0\U000116e3"
405
+ "\U0001171d\U0001172b\U00011730\U00011739\U0001182c\U0001183a\U000118e0\U000118e9\U00011930\U00011935\U00011937"
406
+ "\U00011938\U0001193b\U0001193e\U00011942\U00011943\U00011950\U00011959\U000119d1\U000119d7\U000119da\U000119e0"
407
+ "\U00011a01\U00011a0a\U00011a33\U00011a39\U00011a3b\U00011a3e\U00011a51\U00011a5b\U00011a8a\U00011a99\U00011bf0"
408
+ "\U00011bf9\U00011c2f\U00011c36\U00011c38\U00011c3f\U00011c50\U00011c59\U00011c92\U00011ca7\U00011ca9\U00011cb6"
409
+ "\U00011d31\U00011d36\U00011d3c\U00011d3d\U00011d3f\U00011d45\U00011d50\U00011d59\U00011d8a\U00011d8e\U00011d90"
410
+ "\U00011d91\U00011d93\U00011d97\U00011da0\U00011da9\U00011ef3\U00011ef6\U00011f00\U00011f01\U00011f34\U00011f3a"
411
+ "\U00011f3e\U00011f42\U00011f50\U00011f5a\U00013447\U00013455\U0001611e\U00016139\U00016a60\U00016a69\U00016ac0"
412
+ "\U00016ac9\U00016af0\U00016af4\U00016b30\U00016b36\U00016b50\U00016b59\U00016d70\U00016d79\U00016f51\U00016f87"
413
+ "\U00016f8f\U00016f92\U00016ff0\U00016ff1\U0001bc9d\U0001bc9e\U0001ccf0\U0001ccf9\U0001cf00\U0001cf2d\U0001cf30"
414
+ "\U0001cf46\U0001d165\U0001d169\U0001d16d\U0001d172\U0001d17b\U0001d182\U0001d185\U0001d18b\U0001d1aa\U0001d1ad"
415
+ "\U0001d242\U0001d244\U0001d7ce\U0001d7ff\U0001da00\U0001da36\U0001da3b\U0001da6c\U0001da9b\U0001da9f\U0001daa1"
416
+ "\U0001daaf\U0001e000\U0001e006\U0001e008\U0001e018\U0001e01b\U0001e021\U0001e023\U0001e024\U0001e026\U0001e02a"
417
+ "\U0001e130\U0001e136\U0001e140\U0001e149\U0001e2ec\U0001e2f9\U0001e4ec\U0001e4f9\U0001e5ee\U0001e5ef\U0001e5f1"
418
+ "\U0001e5fa\U0001e8d0\U0001e8d6\U0001e944\U0001e94a\U0001e950\U0001e959\U0001fbf0\U0001fbf9\U000e0100\U000e01ef"
419
+ )
420
+
421
+ # END GENERATED CODE
@@ -0,0 +1,114 @@
1
+ """
2
+ Build a line table for CodeObjects, according to PEP-626 / Python 3.11.
3
+
4
+ See https://github.com/python/cpython/blob/1054a755a3016f95fcd24b3ad20e8ed9048b7939/InternalDocs/locations.md
5
+ See https://github.com/python/cpython/blob/1054a755a3016f95fcd24b3ad20e8ed9048b7939/Python/assemble.c#L192
6
+ """
7
+
8
+ import cython
9
+
10
+
11
+ def build_line_table(positions: list, firstlineno: cython.int):
12
+ # positions is a list of four-tuples (start_lineno, end_lineno, start_col_offset, end_col_offset)
13
+ table_bytes = []
14
+ last_lineno: cython.int = firstlineno
15
+ for position_info in positions:
16
+ last_lineno = encode_single_position(table_bytes, position_info, last_lineno)
17
+ linetable = ''.join(table_bytes)
18
+
19
+ """
20
+ # Hacky debug helper code for the line table generation.
21
+ code_obj = build_line_table.__code__.replace(co_linetable=linetable.encode('latin1'), co_firstlineno=firstlineno)
22
+ print()
23
+ print(repr(linetable))
24
+ print(positions)
25
+ print(list(code_obj.co_positions()))
26
+ """
27
+
28
+ return linetable
29
+
30
+
31
+ @cython.cfunc
32
+ def encode_single_position(table_bytes: list, position_info: tuple, last_lineno: cython.int) -> cython.int:
33
+ start_lineno: cython.int
34
+ end_lineno: cython.int
35
+ start_column: cython.int
36
+ end_column: cython.int
37
+
38
+ start_lineno, end_lineno, start_column, end_column = position_info
39
+ assert start_lineno >= last_lineno, f"{start_lineno} >= {last_lineno}" # positions should be sorted
40
+
41
+ last_lineno_delta: cython.int = start_lineno - last_lineno
42
+
43
+ if end_lineno == start_lineno:
44
+ # All in one line, can try short forms.
45
+ if last_lineno_delta == 0 and start_column < 80 and 0 <= (end_column - start_column) < 16:
46
+ # Short format (code 0-9): still on same line, small column offset
47
+ encode_location_short(table_bytes, start_column, end_column)
48
+ return end_lineno
49
+ elif 0 <= last_lineno_delta < 3 and start_column < 128 and end_column < 128:
50
+ # One line format (code 10-12): small line offsets / larger column offsets
51
+ encode_location_oneline(table_bytes, last_lineno_delta, start_column, end_column)
52
+ return end_lineno
53
+
54
+ # Store in long format (code 14)
55
+ encode_location_start(table_bytes, 14)
56
+ # Since we sort positions, negative line deltas should never occur ==> inline encode_varint_signed()
57
+ encode_varint(table_bytes, last_lineno_delta << 1)
58
+ encode_varint(table_bytes, end_lineno - start_lineno)
59
+ encode_varint(table_bytes, start_column + 1)
60
+ encode_varint(table_bytes, end_column + 1)
61
+ return end_lineno
62
+
63
+
64
+ @cython.exceptval(-1, check=False)
65
+ @cython.cfunc
66
+ def encode_location_start(table_bytes: list, code: cython.int) -> cython.int:
67
+ # "Instruction" size is always 1
68
+ # 128 | (code << 3) | (length - 1)
69
+ table_bytes.append(chr(128 | (code << 3)))
70
+ return 0
71
+
72
+
73
+ @cython.exceptval(-1, check=False)
74
+ @cython.cfunc
75
+ def encode_location_short(table_bytes: list, start_column: cython.int, end_column: cython.int) -> cython.int:
76
+ low_bits: cython.int = start_column & 7
77
+ code: cython.int = start_column >> 3
78
+ # inlined encode_location_start()
79
+ table_bytes.append(f"{128 | (code << 3):c}{(low_bits << 4) | (end_column - start_column):c}")
80
+ return 0
81
+
82
+
83
+ @cython.exceptval(-1, check=False)
84
+ @cython.cfunc
85
+ def encode_location_oneline(table_bytes: list, line_delta: cython.int, start_column: cython.int, end_column: cython.int) -> cython.int:
86
+ code: cython.int = 10 + line_delta
87
+ # inlined encode_location_start()
88
+ table_bytes.append(f"{128 | (code << 3):c}{start_column:c}{end_column:c}")
89
+ return 0
90
+
91
+
92
+ """
93
+ # Since we sort positions, negative line deltas should not occur.
94
+ @cython.cfunc
95
+ def encode_varint_signed(table_bytes: list, value: cython.int) -> cython.int:
96
+ # (unsigned int)(-val) has undefined behavior for INT_MIN
97
+ uval: cython.uint = cython.cast(cython.uint, value) if cython.compiled else value
98
+ if value < 0:
99
+ uval = ((0 - uval) << 1) | 1
100
+ else:
101
+ uval = uval << 1
102
+ encode_varint(table_bytes, uval)
103
+ """
104
+
105
+
106
+ @cython.exceptval(-1, check=False)
107
+ @cython.cfunc
108
+ def encode_varint(table_bytes: list, value: cython.uint) -> cython.int:
109
+ assert value > 0 or value == 0
110
+ while value >= 64:
111
+ table_bytes.append(chr(64 | (value & 63)))
112
+ value >>= 6
113
+ table_bytes.append(chr(value))
114
+ return 0
Binary file