pycparser 2.22__tar.gz → 2.23__tar.gz

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 (198) hide show
  1. {pycparser-2.22/pycparser.egg-info → pycparser-2.23}/PKG-INFO +2 -2
  2. {pycparser-2.22 → pycparser-2.23}/README.rst +2 -2
  3. {pycparser-2.22 → pycparser-2.23}/examples/c_files/funky.c +0 -5
  4. {pycparser-2.22 → pycparser-2.23}/examples/c_files/hash.c +4 -4
  5. {pycparser-2.22 → pycparser-2.23}/examples/c_json.py +0 -1
  6. {pycparser-2.22 → pycparser-2.23}/examples/cdecl.py +0 -1
  7. {pycparser-2.22 → pycparser-2.23}/examples/explore_ast.py +0 -1
  8. {pycparser-2.22 → pycparser-2.23}/examples/using_cpp_libc.py +1 -3
  9. {pycparser-2.22 → pycparser-2.23}/examples/using_gcc_E_libc.py +0 -1
  10. {pycparser-2.22 → pycparser-2.23}/pycparser/__init__.py +1 -1
  11. {pycparser-2.22 → pycparser-2.23}/pycparser/c_generator.py +1 -1
  12. {pycparser-2.22 → pycparser-2.23}/pycparser/c_lexer.py +14 -0
  13. {pycparser-2.22 → pycparser-2.23}/pycparser/c_parser.py +30 -7
  14. pycparser-2.23/pycparser/lextab.py +10 -0
  15. pycparser-2.23/pycparser/yacctab.py +374 -0
  16. {pycparser-2.22 → pycparser-2.23/pycparser.egg-info}/PKG-INFO +2 -2
  17. {pycparser-2.22 → pycparser-2.23}/pycparser.egg-info/SOURCES.txt +0 -2
  18. {pycparser-2.22 → pycparser-2.23}/setup.py +2 -1
  19. {pycparser-2.22 → pycparser-2.23}/tests/test_c_generator.py +7 -0
  20. {pycparser-2.22 → pycparser-2.23}/tests/test_c_lexer.py +5 -1
  21. {pycparser-2.22 → pycparser-2.23}/tests/test_c_parser.py +81 -2
  22. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/_fake_typedefs.h +14 -0
  23. pycparser-2.22/pycparser/lextab.py +0 -10
  24. pycparser-2.22/pycparser/yacctab.py +0 -369
  25. {pycparser-2.22 → pycparser-2.23}/CHANGES +0 -0
  26. {pycparser-2.22 → pycparser-2.23}/LICENSE +0 -0
  27. {pycparser-2.22 → pycparser-2.23}/MANIFEST.in +0 -0
  28. {pycparser-2.22 → pycparser-2.23}/examples/c-to-c.py +0 -0
  29. {pycparser-2.22 → pycparser-2.23}/examples/c_files/basic.c +0 -0
  30. {pycparser-2.22 → pycparser-2.23}/examples/c_files/memmgr.c +0 -0
  31. {pycparser-2.22 → pycparser-2.23}/examples/c_files/memmgr.h +0 -0
  32. {pycparser-2.22 → pycparser-2.23}/examples/c_files/pragmas.c +0 -0
  33. {pycparser-2.22 → pycparser-2.23}/examples/c_files/year.c +0 -0
  34. {pycparser-2.22 → pycparser-2.23}/examples/construct_ast_from_scratch.py +0 -0
  35. {pycparser-2.22 → pycparser-2.23}/examples/dump_ast.py +0 -0
  36. {pycparser-2.22 → pycparser-2.23}/examples/func_calls.py +0 -0
  37. {pycparser-2.22 → pycparser-2.23}/examples/func_defs.py +0 -0
  38. {pycparser-2.22 → pycparser-2.23}/examples/func_defs_add_param.py +0 -0
  39. {pycparser-2.22 → pycparser-2.23}/examples/rewrite_ast.py +0 -0
  40. {pycparser-2.22 → pycparser-2.23}/examples/serialize_ast.py +0 -0
  41. {pycparser-2.22 → pycparser-2.23}/pycparser/_ast_gen.py +0 -0
  42. {pycparser-2.22 → pycparser-2.23}/pycparser/_build_tables.py +0 -0
  43. {pycparser-2.22 → pycparser-2.23}/pycparser/_c_ast.cfg +0 -0
  44. {pycparser-2.22 → pycparser-2.23}/pycparser/ast_transforms.py +0 -0
  45. {pycparser-2.22 → pycparser-2.23}/pycparser/c_ast.py +0 -0
  46. {pycparser-2.22 → pycparser-2.23}/pycparser/ply/__init__.py +0 -0
  47. {pycparser-2.22 → pycparser-2.23}/pycparser/ply/cpp.py +0 -0
  48. {pycparser-2.22 → pycparser-2.23}/pycparser/ply/ctokens.py +0 -0
  49. {pycparser-2.22 → pycparser-2.23}/pycparser/ply/lex.py +0 -0
  50. {pycparser-2.22 → pycparser-2.23}/pycparser/ply/yacc.py +0 -0
  51. {pycparser-2.22 → pycparser-2.23}/pycparser/ply/ygen.py +0 -0
  52. {pycparser-2.22 → pycparser-2.23}/pycparser/plyparser.py +0 -0
  53. {pycparser-2.22 → pycparser-2.23}/pycparser.egg-info/dependency_links.txt +0 -0
  54. {pycparser-2.22 → pycparser-2.23}/pycparser.egg-info/top_level.txt +0 -0
  55. {pycparser-2.22 → pycparser-2.23}/setup.cfg +0 -0
  56. {pycparser-2.22 → pycparser-2.23}/tests/__init__.py +0 -0
  57. {pycparser-2.22 → pycparser-2.23}/tests/c_files/c11.c +0 -0
  58. {pycparser-2.22 → pycparser-2.23}/tests/c_files/cppd_with_stdio_h.c +0 -0
  59. {pycparser-2.22 → pycparser-2.23}/tests/c_files/empty.h +0 -0
  60. {pycparser-2.22 → pycparser-2.23}/tests/c_files/example_c_file.c +0 -0
  61. {pycparser-2.22 → pycparser-2.23}/tests/c_files/hdir/9/inc.h +0 -0
  62. {pycparser-2.22 → pycparser-2.23}/tests/c_files/memmgr.c +0 -0
  63. {pycparser-2.22 → pycparser-2.23}/tests/c_files/memmgr.h +0 -0
  64. {pycparser-2.22 → pycparser-2.23}/tests/c_files/memmgr_with_h.c +0 -0
  65. {pycparser-2.22 → pycparser-2.23}/tests/c_files/simplemain.c +0 -0
  66. {pycparser-2.22 → pycparser-2.23}/tests/c_files/year.c +0 -0
  67. {pycparser-2.22 → pycparser-2.23}/tests/test_c_ast.py +0 -0
  68. {pycparser-2.22 → pycparser-2.23}/tests/test_examples.py +0 -0
  69. {pycparser-2.22 → pycparser-2.23}/tests/test_general.py +0 -0
  70. {pycparser-2.22 → pycparser-2.23}/tests/test_util.py +0 -0
  71. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/X11/Intrinsic.h +0 -0
  72. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/X11/Xlib.h +0 -0
  73. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/X11/_X11_fake_defines.h +0 -0
  74. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/X11/_X11_fake_typedefs.h +0 -0
  75. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/_ansi.h +0 -0
  76. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/_fake_defines.h +0 -0
  77. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/_syslist.h +0 -0
  78. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/aio.h +0 -0
  79. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/alloca.h +0 -0
  80. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/ar.h +0 -0
  81. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/argz.h +0 -0
  82. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/arpa/inet.h +0 -0
  83. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/asm-generic/int-ll64.h +0 -0
  84. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/assert.h +0 -0
  85. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/complex.h +0 -0
  86. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/cpio.h +0 -0
  87. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/ctype.h +0 -0
  88. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/dirent.h +0 -0
  89. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/dlfcn.h +0 -0
  90. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/emmintrin.h +0 -0
  91. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/endian.h +0 -0
  92. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/envz.h +0 -0
  93. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/errno.h +0 -0
  94. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/fastmath.h +0 -0
  95. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/fcntl.h +0 -0
  96. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/features.h +0 -0
  97. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/fenv.h +0 -0
  98. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/float.h +0 -0
  99. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/fmtmsg.h +0 -0
  100. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/fnmatch.h +0 -0
  101. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/ftw.h +0 -0
  102. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/getopt.h +0 -0
  103. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/glob.h +0 -0
  104. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/grp.h +0 -0
  105. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/iconv.h +0 -0
  106. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/ieeefp.h +0 -0
  107. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/immintrin.h +0 -0
  108. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/inttypes.h +0 -0
  109. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/iso646.h +0 -0
  110. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/langinfo.h +0 -0
  111. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/libgen.h +0 -0
  112. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/libintl.h +0 -0
  113. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/limits.h +0 -0
  114. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/linux/socket.h +0 -0
  115. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/linux/version.h +0 -0
  116. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/locale.h +0 -0
  117. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/malloc.h +0 -0
  118. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/math.h +0 -0
  119. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/mir_toolkit/client_types.h +0 -0
  120. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/monetary.h +0 -0
  121. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/mqueue.h +0 -0
  122. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/ndbm.h +0 -0
  123. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/net/if.h +0 -0
  124. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/netdb.h +0 -0
  125. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/netinet/in.h +0 -0
  126. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/netinet/tcp.h +0 -0
  127. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/newlib.h +0 -0
  128. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/nl_types.h +0 -0
  129. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/openssl/err.h +0 -0
  130. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/openssl/evp.h +0 -0
  131. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/openssl/hmac.h +0 -0
  132. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/openssl/ssl.h +0 -0
  133. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/openssl/x509v3.h +0 -0
  134. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/paths.h +0 -0
  135. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/poll.h +0 -0
  136. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/process.h +0 -0
  137. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/pthread.h +0 -0
  138. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/pwd.h +0 -0
  139. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/reent.h +0 -0
  140. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/regdef.h +0 -0
  141. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/regex.h +0 -0
  142. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sched.h +0 -0
  143. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/search.h +0 -0
  144. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/semaphore.h +0 -0
  145. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/setjmp.h +0 -0
  146. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/signal.h +0 -0
  147. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/smmintrin.h +0 -0
  148. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/spawn.h +0 -0
  149. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/stdalign.h +0 -0
  150. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/stdarg.h +0 -0
  151. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/stdatomic.h +0 -0
  152. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/stdbool.h +0 -0
  153. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/stddef.h +0 -0
  154. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/stdint.h +0 -0
  155. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/stdio.h +0 -0
  156. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/stdlib.h +0 -0
  157. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/stdnoreturn.h +0 -0
  158. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/string.h +0 -0
  159. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/strings.h +0 -0
  160. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/stropts.h +0 -0
  161. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/ioctl.h +0 -0
  162. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/ipc.h +0 -0
  163. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/mman.h +0 -0
  164. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/msg.h +0 -0
  165. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/poll.h +0 -0
  166. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/resource.h +0 -0
  167. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/select.h +0 -0
  168. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/sem.h +0 -0
  169. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/shm.h +0 -0
  170. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/socket.h +0 -0
  171. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/stat.h +0 -0
  172. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/statvfs.h +0 -0
  173. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/sysctl.h +0 -0
  174. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/time.h +0 -0
  175. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/times.h +0 -0
  176. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/types.h +0 -0
  177. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/uio.h +0 -0
  178. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/un.h +0 -0
  179. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/utsname.h +0 -0
  180. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/sys/wait.h +0 -0
  181. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/syslog.h +0 -0
  182. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/tar.h +0 -0
  183. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/termios.h +0 -0
  184. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/tgmath.h +0 -0
  185. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/threads.h +0 -0
  186. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/time.h +0 -0
  187. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/trace.h +0 -0
  188. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/ulimit.h +0 -0
  189. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/unctrl.h +0 -0
  190. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/unistd.h +0 -0
  191. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/utime.h +0 -0
  192. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/utmp.h +0 -0
  193. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/utmpx.h +0 -0
  194. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/wchar.h +0 -0
  195. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/wctype.h +0 -0
  196. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/wordexp.h +0 -0
  197. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/xcb/xcb.h +0 -0
  198. {pycparser-2.22 → pycparser-2.23}/utils/fake_libc_include/zlib.h +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycparser
3
- Version: 2.22
3
+ Version: 2.23
4
4
  Summary: C parser in Python
5
5
  Home-page: https://github.com/eliben/pycparser
6
6
  Author: Eli Bendersky
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.9
16
16
  Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
19
20
  Requires-Python: >=3.8
20
21
  License-File: LICENSE
21
22
 
@@ -25,4 +26,3 @@ License-File: LICENSE
25
26
  It parses C code into an AST and can serve as a front-end for
26
27
  C compilers or analysis tools.
27
28
 
28
-
@@ -1,5 +1,5 @@
1
1
  ===============
2
- pycparser v2.22
2
+ pycparser v2.23
3
3
  ===============
4
4
 
5
5
 
@@ -110,7 +110,7 @@ Interaction with the C preprocessor
110
110
  -----------------------------------
111
111
 
112
112
  In order to be compilable, C code must be preprocessed by the C preprocessor -
113
- ``cpp``. ``cpp`` handles preprocessing directives like ``#include`` and
113
+ ``cpp``. A compatible ``cpp`` handles preprocessing directives like ``#include`` and
114
114
  ``#define``, removes comments, and performs other minor tasks that prepare the C
115
115
  code for compilation.
116
116
 
@@ -12,9 +12,4 @@ int maxout_in(int paste, char** matrix)
12
12
  int main()
13
13
  {
14
14
  auto char* multi = "a multi";
15
-
16
-
17
15
  }
18
-
19
-
20
-
@@ -24,7 +24,7 @@ typedef struct tagHash
24
24
  {
25
25
  unsigned int table_size;
26
26
 
27
- Node** heads;
27
+ Node** heads;
28
28
 
29
29
  } Hash;
30
30
 
@@ -137,7 +137,7 @@ ReturnCode HashRemove(Hash* hash, const char* key)
137
137
 
138
138
  return SUCCESS;
139
139
  }
140
-
140
+
141
141
  temp2 = temp1;
142
142
  temp1 = temp1->next;
143
143
  }
@@ -187,10 +187,10 @@ void HashDestroy(Hash* hash)
187
187
  free(temp->entry);
188
188
 
189
189
  temp = temp->next;
190
-
190
+
191
191
  free(temp2);
192
192
  }
193
- }
193
+ }
194
194
 
195
195
  free(hash->heads);
196
196
  hash->heads = NULL;
@@ -40,7 +40,6 @@ import re
40
40
 
41
41
  # This is not required if you've installed pycparser into
42
42
  # your site-packages/ with setup.py
43
- #
44
43
  sys.path.extend(['.', '..'])
45
44
 
46
45
  from pycparser import parse_file, c_ast
@@ -37,7 +37,6 @@ import sys
37
37
 
38
38
  # This is not required if you've installed pycparser into
39
39
  # your site-packages/ with setup.py
40
- #
41
40
  sys.path.extend(['.', '..'])
42
41
 
43
42
  from pycparser import c_parser, c_ast
@@ -16,7 +16,6 @@ import sys
16
16
 
17
17
  # This is not required if you've installed pycparser into
18
18
  # your site-packages/ with setup.py
19
- #
20
19
  sys.path.extend(['.', '..'])
21
20
 
22
21
  from pycparser import c_parser
@@ -1,8 +1,7 @@
1
1
  #-----------------------------------------------------------------
2
2
  # pycparser: using_cpp_libc.py
3
3
  #
4
- # Shows how to use the provided 'cpp' (on Windows, substitute for
5
- # the 'real' cpp if you're on Linux/Unix) and "fake" libc includes
4
+ # Shows how to use 'cpp' (the C pre-processor binary) and "fake" libc includes
6
5
  # to parse a file that includes standard C headers.
7
6
  #
8
7
  # Eli Bendersky [https://eli.thegreenplace.net/]
@@ -12,7 +11,6 @@ import sys
12
11
 
13
12
  # This is not required if you've installed pycparser into
14
13
  # your site-packages/ with setup.py
15
- #
16
14
  sys.path.extend(['.', '..'])
17
15
 
18
16
  from pycparser import parse_file
@@ -12,7 +12,6 @@ import sys
12
12
 
13
13
  # This is not required if you've installed pycparser into
14
14
  # your site-packages/ with setup.py
15
- #
16
15
  sys.path.extend(['.', '..'])
17
16
 
18
17
  from pycparser import parse_file
@@ -8,7 +8,7 @@
8
8
  # License: BSD
9
9
  #-----------------------------------------------------------------
10
10
  __all__ = ['c_lexer', 'c_parser', 'c_ast']
11
- __version__ = '2.22'
11
+ __version__ = '2.23'
12
12
 
13
13
  import io
14
14
  from subprocess import check_output
@@ -133,7 +133,7 @@ class CGenerator(object):
133
133
  def _visit_expr(self, n):
134
134
  if isinstance(n, c_ast.InitList):
135
135
  return '{' + self.visit(n) + '}'
136
- elif isinstance(n, c_ast.ExprList):
136
+ elif isinstance(n, (c_ast.ExprList, c_ast.Compound)):
137
137
  return '(' + self.visit(n) + ')'
138
138
  else:
139
139
  return self.visit(n)
@@ -209,6 +209,10 @@ class CLexer(object):
209
209
 
210
210
  bad_octal_constant = '0[0-7]*[89]'
211
211
 
212
+ # comments are not supported
213
+ unsupported_c_style_comment = r'\/\*'
214
+ unsupported_cxx_style_comment = r'\/\/'
215
+
212
216
  # character constants (K&R2: A.2.5.2)
213
217
  # Note: a-zA-Z and '.-~^_!=&;,' are allowed as escape chars to support #line
214
218
  # directives with Windows paths as filenames (..\..\dir\file)
@@ -475,6 +479,16 @@ class CLexer(object):
475
479
  msg = "Invalid octal constant"
476
480
  self._error(msg, t)
477
481
 
482
+ @TOKEN(unsupported_c_style_comment)
483
+ def t_UNSUPPORTED_C_STYLE_COMMENT(self, t):
484
+ msg = "Comments are not supported, see https://github.com/eliben/pycparser#3using."
485
+ self._error(msg, t)
486
+
487
+ @TOKEN(unsupported_cxx_style_comment)
488
+ def t_UNSUPPORTED_CXX_STYLE_COMMENT(self, t):
489
+ msg = "Comments are not supported, see https://github.com/eliben/pycparser#3using."
490
+ self._error(msg, t)
491
+
478
492
  @TOKEN(octal_constant)
479
493
  def t_INT_CONST_OCT(self, t):
480
494
  return t
@@ -1530,6 +1530,20 @@ class CParser(PLYParser):
1530
1530
  type=c_ast.TypeDecl(None, None, None, None),
1531
1531
  coord=self._token_coord(p, 1))
1532
1532
 
1533
+ def p_direct_abstract_declarator_8(self, p):
1534
+ """ direct_abstract_declarator : LBRACKET STATIC type_qualifier_list_opt assignment_expression RBRACKET
1535
+ | LBRACKET type_qualifier_list STATIC assignment_expression RBRACKET
1536
+ """
1537
+ listed_quals = [item if isinstance(item, list) else [item]
1538
+ for item in [p[2],p[3]]]
1539
+ quals = [qual for sublist in listed_quals for qual in sublist
1540
+ if qual is not None]
1541
+ p[0] = c_ast.ArrayDecl(
1542
+ type=c_ast.TypeDecl(None, None, None, None),
1543
+ dim=p[4],
1544
+ dim_quals=quals,
1545
+ coord=self._token_coord(p, 1))
1546
+
1533
1547
  # declaration is a list, statement isn't. To make it consistent, block_item
1534
1548
  # will always be a list
1535
1549
  #
@@ -1566,6 +1580,18 @@ class CParser(PLYParser):
1566
1580
  """ labeled_statement : DEFAULT COLON pragmacomp_or_statement """
1567
1581
  p[0] = c_ast.Default([p[3]], self._token_coord(p, 1))
1568
1582
 
1583
+ def p_labeled_statement_4(self, p):
1584
+ """ labeled_statement : ID COLON """
1585
+ p[0] = c_ast.Label(p[1], c_ast.EmptyStatement(self._token_coord(p, 1)), self._token_coord(p, 1))
1586
+
1587
+ def p_labeled_statement_5(self, p):
1588
+ """ labeled_statement : CASE constant_expression COLON """
1589
+ p[0] = c_ast.Case(p[2], [c_ast.EmptyStatement(self._token_coord(p, 2))], self._token_coord(p, 1))
1590
+
1591
+ def p_labeled_statement_6(self, p):
1592
+ """ labeled_statement : DEFAULT COLON """
1593
+ p[0] = c_ast.Default([c_ast.EmptyStatement(self._token_coord(p, 1))], self._token_coord(p, 1))
1594
+
1569
1595
  def p_selection_statement_1(self, p):
1570
1596
  """ selection_statement : IF LPAREN expression RPAREN pragmacomp_or_statement """
1571
1597
  p[0] = c_ast.If(p[3], p[5], None, self._token_coord(p, 1))
@@ -1865,15 +1891,12 @@ class CParser(PLYParser):
1865
1891
  """ constant : FLOAT_CONST
1866
1892
  | HEX_FLOAT_CONST
1867
1893
  """
1868
- if 'x' in p[1].lower():
1894
+ if p[1][-1] in ('f', 'F'):
1869
1895
  t = 'float'
1896
+ elif p[1][-1] in ('l', 'L'):
1897
+ t = 'long double'
1870
1898
  else:
1871
- if p[1][-1] in ('f', 'F'):
1872
- t = 'float'
1873
- elif p[1][-1] in ('l', 'L'):
1874
- t = 'long double'
1875
- else:
1876
- t = 'double'
1899
+ t = 'double'
1877
1900
 
1878
1901
  p[0] = c_ast.Constant(
1879
1902
  t, p[1], self._token_coord(p, 1))
@@ -0,0 +1,10 @@
1
+ # lextab.py. This file automatically created by PLY (version 3.10). Don't edit!
2
+ _tabversion = '3.10'
3
+ _lextokens = set(('AND', 'ANDEQUAL', 'ARROW', 'AUTO', 'BREAK', 'CASE', 'CHAR', 'CHAR_CONST', 'COLON', 'COMMA', 'CONDOP', 'CONST', 'CONTINUE', 'DEFAULT', 'DIVEQUAL', 'DIVIDE', 'DO', 'DOUBLE', 'ELLIPSIS', 'ELSE', 'ENUM', 'EQ', 'EQUALS', 'EXTERN', 'FLOAT', 'FLOAT_CONST', 'FOR', 'GE', 'GOTO', 'GT', 'HEX_FLOAT_CONST', 'ID', 'IF', 'INLINE', 'INT', 'INT_CONST_BIN', 'INT_CONST_CHAR', 'INT_CONST_DEC', 'INT_CONST_HEX', 'INT_CONST_OCT', 'LAND', 'LBRACE', 'LBRACKET', 'LE', 'LNOT', 'LONG', 'LOR', 'LPAREN', 'LSHIFT', 'LSHIFTEQUAL', 'LT', 'MINUS', 'MINUSEQUAL', 'MINUSMINUS', 'MOD', 'MODEQUAL', 'NE', 'NOT', 'OFFSETOF', 'OR', 'OREQUAL', 'PERIOD', 'PLUS', 'PLUSEQUAL', 'PLUSPLUS', 'PPHASH', 'PPPRAGMA', 'PPPRAGMASTR', 'RBRACE', 'RBRACKET', 'REGISTER', 'RESTRICT', 'RETURN', 'RPAREN', 'RSHIFT', 'RSHIFTEQUAL', 'SEMI', 'SHORT', 'SIGNED', 'SIZEOF', 'STATIC', 'STRING_LITERAL', 'STRUCT', 'SWITCH', 'TIMES', 'TIMESEQUAL', 'TYPEDEF', 'TYPEID', 'U16CHAR_CONST', 'U16STRING_LITERAL', 'U32CHAR_CONST', 'U32STRING_LITERAL', 'U8CHAR_CONST', 'U8STRING_LITERAL', 'UNION', 'UNSIGNED', 'VOID', 'VOLATILE', 'WCHAR_CONST', 'WHILE', 'WSTRING_LITERAL', 'XOR', 'XOREQUAL', '_ALIGNAS', '_ALIGNOF', '_ATOMIC', '_BOOL', '_COMPLEX', '_NORETURN', '_PRAGMA', '_STATIC_ASSERT', '_THREAD_LOCAL', '__INT128'))
4
+ _lexreflags = 64
5
+ _lexliterals = ''
6
+ _lexstateinfo = {'INITIAL': 'inclusive', 'ppline': 'exclusive', 'pppragma': 'exclusive'}
7
+ _lexstatere = {'INITIAL': [('(?P<t_PPHASH>[ \\t]*\\#)|(?P<t_NEWLINE>\\n+)|(?P<t_LBRACE>\\{)|(?P<t_RBRACE>\\})|(?P<t_FLOAT_CONST>((((([0-9]*\\.[0-9]+)|([0-9]+\\.))([eE][-+]?[0-9]+)?)|([0-9]+([eE][-+]?[0-9]+)))[FfLl]?))|(?P<t_HEX_FLOAT_CONST>(0[xX]([0-9a-fA-F]+|((([0-9a-fA-F]+)?\\.[0-9a-fA-F]+)|([0-9a-fA-F]+\\.)))([pP][+-]?[0-9]+)[FfLl]?))|(?P<t_INT_CONST_HEX>0[xX][0-9a-fA-F]+(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?)|(?P<t_INT_CONST_BIN>0[bB][01]+(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?)|(?P<t_BAD_CONST_OCT>0[0-7]*[89])|(?P<t_UNSUPPORTED_C_STYLE_COMMENT>\\/\\*)|(?P<t_UNSUPPORTED_CXX_STYLE_COMMENT>\\/\\/)|(?P<t_INT_CONST_OCT>0[0-7]*(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?)|(?P<t_INT_CONST_DEC>(0(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?)|([1-9][0-9]*(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?))|(?P<t_INT_CONST_CHAR>\'([^\'\\\\\\n]|(\\\\(([a-wyzA-Z._~!=&\\^\\-\\\\?\'"]|x(?![0-9a-fA-F]))|(\\d+)(?!\\d)|(x[0-9a-fA-F]+)(?![0-9a-fA-F])))){2,4}\')|(?P<t_CHAR_CONST>\'([^\'\\\\\\n]|(\\\\(([a-wyzA-Z._~!=&\\^\\-\\\\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!=)|(?P<t_OR>\\|)|(?P<t_PERIOD>\\.)|(?P<t_PLUS>\\+)|(?P<t_RBRACKET>\\])|(?P<t_RPAREN>\\))|(?P<t_RSHIFT>>>)|(?P<t_TIMES>\\*)|(?P<t_XOR>\\^)|(?P<t_AND>&)|(?P<t_COLON>:)|(?P<t_COMMA>,)|(?P<t_DIVIDE>/)|(?P<t_EQUALS>=)|(?P<t_GT>>)|(?P<t_LNOT>!)|(?P<t_LT><)|(?P<t_MINUS>-)|(?P<t_MOD>%)|(?P<t_NOT>~)|(?P<t_SEMI>;)', [None, ('t_PPHASH', 'PPHASH'), ('t_NEWLINE', 'NEWLINE'), ('t_LBRACE', 'LBRACE'), ('t_RBRACE', 'RBRACE'), ('t_FLOAT_CONST', 'FLOAT_CONST'), None, None, None, None, None, None, None, None, None, ('t_HEX_FLOAT_CONST', 'HEX_FLOAT_CONST'), None, None, None, None, None, None, None, ('t_INT_CONST_HEX', 'INT_CONST_HEX'), None, None, None, None, None, None, None, ('t_INT_CONST_BIN', 'INT_CONST_BIN'), None, None, None, None, None, None, None, ('t_BAD_CONST_OCT', 'BAD_CONST_OCT'), ('t_UNSUPPORTED_C_STYLE_COMMENT', 'UNSUPPORTED_C_STYLE_COMMENT'), ('t_UNSUPPORTED_CXX_STYLE_COMMENT', 'UNSUPPORTED_CXX_STYLE_COMMENT'), ('t_INT_CONST_OCT', 'INT_CONST_OCT'), None, None, None, None, None, None, None, ('t_INT_CONST_DEC', 'INT_CONST_DEC'), None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, ('t_INT_CONST_CHAR', 'INT_CONST_CHAR'), None, None, None, None, None, None, ('t_CHAR_CONST', 'CHAR_CONST'), None, None, None, None, None, None, ('t_WCHAR_CONST', 'WCHAR_CONST'), None, None, None, None, None, None, ('t_U8CHAR_CONST', 'U8CHAR_CONST'), None, None, None, None, None, None, ('t_U16CHAR_CONST', 'U16CHAR_CONST'), None, None, None, None, None, None, ('t_U32CHAR_CONST', 'U32CHAR_CONST'), None, None, None, None, None, None, ('t_UNMATCHED_QUOTE', 'UNMATCHED_QUOTE'), None, None, None, None, None, None, None, None, None, None, None, None, None, None, ('t_BAD_CHAR_CONST', 'BAD_CHAR_CONST'), None, None, None, None, None, None, None, None, None, None, ('t_WSTRING_LITERAL', 'WSTRING_LITERAL'), None, None, ('t_U8STRING_LITERAL', 'U8STRING_LITERAL'), None, None, ('t_U16STRING_LITERAL', 'U16STRING_LITERAL'), None, None, ('t_U32STRING_LITERAL', 'U32STRING_LITERAL'), None, None, ('t_BAD_STRING_LITERAL', 'BAD_STRING_LITERAL'), None, None, None, None, None, ('t_ID', 'ID'), (None, 'STRING_LITERAL'), None, None, (None, 'ELLIPSIS'), (None, 'LOR'), (None, 'PLUSPLUS'), (None, 'LSHIFTEQUAL'), (None, 'OREQUAL'), (None, 'PLUSEQUAL'), (None, 'RSHIFTEQUAL'), (None, 'TIMESEQUAL'), (None, 'XOREQUAL'), (None, 'ANDEQUAL'), (None, 'ARROW'), (None, 'CONDOP'), (None, 'DIVEQUAL'), (None, 'EQ'), (None, 'GE'), (None, 'LAND'), (None, 'LBRACKET'), (None, 'LE'), (None, 'LPAREN'), (None, 'LSHIFT'), (None, 'MINUSEQUAL'), (None, 'MINUSMINUS'), (None, 'MODEQUAL'), (None, 'NE'), (None, 'OR'), (None, 'PERIOD'), (None, 'PLUS'), (None, 'RBRACKET'), (None, 'RPAREN'), (None, 'RSHIFT'), (None, 'TIMES'), (None, 'XOR'), (None, 'AND'), (None, 'COLON'), (None, 'COMMA'), (None, 'DIVIDE'), (None, 'EQUALS'), (None, 'GT'), (None, 'LNOT'), (None, 'LT'), (None, 'MINUS'), (None, 'MOD'), (None, 'NOT'), (None, 'SEMI')])], 'ppline': [('(?P<t_ppline_FILENAME>"([^"\\\\\\n]|(\\\\[0-9a-zA-Z._~!=&\\^\\-\\\\?\'"]))*")|(?P<t_ppline_LINE_NUMBER>(0(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?)|([1-9][0-9]*(([uU]ll)|([uU]LL)|(ll[uU]?)|(LL[uU]?)|([uU][lL])|([lL][uU]?)|[uU])?))|(?P<t_ppline_NEWLINE>\\n)|(?P<t_ppline_PPLINE>line)', [None, ('t_ppline_FILENAME', 'FILENAME'), None, None, ('t_ppline_LINE_NUMBER', 'LINE_NUMBER'), None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, ('t_ppline_NEWLINE', 'NEWLINE'), ('t_ppline_PPLINE', 'PPLINE')])], 'pppragma': [('(?P<t_pppragma_NEWLINE>\\n)|(?P<t_pppragma_PPPRAGMA>pragma)|(?P<t_pppragma_STR>.+)', [None, ('t_pppragma_NEWLINE', 'NEWLINE'), ('t_pppragma_PPPRAGMA', 'PPPRAGMA'), ('t_pppragma_STR', 'STR')])]}
8
+ _lexstateignore = {'INITIAL': ' \t', 'ppline': ' \t', 'pppragma': ' \t'}
9
+ _lexstateerrorf = {'INITIAL': 't_error', 'ppline': 't_ppline_error', 'pppragma': 't_pppragma_error'}
10
+ _lexstateeoff = {}