webruby 0.2.7 → 0.9.1

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 (1537) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webruby/environment.rb +24 -8
  3. data/lib/webruby/rake/files.rake +6 -22
  4. data/lib/webruby/rake/general.rake +1 -1
  5. data/lib/webruby/rake/mruby.rake +1 -0
  6. data/lib/webruby/utility.rb +14 -0
  7. data/modules/mruby/AUTHORS +14 -0
  8. data/modules/mruby/CONTRIBUTING.md +7 -4
  9. data/modules/mruby/INSTALL +28 -11
  10. data/modules/mruby/MITL +13 -13
  11. data/modules/mruby/Makefile +4 -5
  12. data/modules/mruby/README.md +54 -49
  13. data/modules/mruby/Rakefile +36 -6
  14. data/modules/mruby/benchmark/ao-render.rb +1 -2
  15. data/modules/mruby/benchmark/bm_app_lc_fizzbuzz.rb +52 -0
  16. data/modules/mruby/benchmark/fib39.rb +0 -0
  17. data/modules/mruby/bintest/mrbc.rb +12 -0
  18. data/modules/mruby/build_config.rb +32 -2
  19. data/modules/mruby/doc/api/README.md +30 -0
  20. data/modules/mruby/doc/api/mruby.h.md +69 -0
  21. data/modules/mruby/doc/compile/README.md +208 -99
  22. data/modules/mruby/doc/debugger/README.md +370 -0
  23. data/modules/mruby/doc/language/Core.md +1590 -0
  24. data/modules/mruby/doc/language/README.md +9 -0
  25. data/modules/mruby/doc/language/generator.rb +15 -0
  26. data/modules/mruby/doc/language/mrbdoc/lib/mrbdoc_analyze.rb +231 -0
  27. data/modules/mruby/doc/language/mrbdoc/lib/mrbdoc_docu.rb +118 -0
  28. data/modules/mruby/doc/language/mrbdoc/mrbdoc.rb +38 -0
  29. data/modules/mruby/doc/mrbconf/README.md +160 -0
  30. data/modules/mruby/doc/mrbgems/README.md +136 -66
  31. data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/mrbgem.rake +1 -1
  32. data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/src/example.c +1 -1
  33. data/modules/mruby/examples/mrbgems/c_extension_example/mrbgem.rake +1 -1
  34. data/modules/mruby/examples/mrbgems/c_extension_example/src/example.c +1 -1
  35. data/modules/mruby/examples/mrbgems/ruby_extension_example/mrbgem.rake +1 -1
  36. data/modules/mruby/examples/targets/{ArduinoDue.rb → build_config_ArduinoDue.rb} +32 -6
  37. data/modules/mruby/examples/targets/build_config_IntelGalileo.rb +106 -0
  38. data/modules/mruby/examples/targets/{chipKitMax32.rb → build_config_chipKITMax32.rb} +26 -7
  39. data/modules/mruby/include/mrbconf.h +25 -1
  40. data/modules/mruby/include/mruby/array.h +32 -22
  41. data/modules/mruby/include/mruby/boxing_nan.h +94 -0
  42. data/modules/mruby/include/mruby/boxing_no.h +49 -0
  43. data/modules/mruby/include/mruby/boxing_word.h +119 -0
  44. data/modules/mruby/include/mruby/class.h +15 -13
  45. data/modules/mruby/include/mruby/compile.h +43 -36
  46. data/modules/mruby/include/mruby/data.h +13 -5
  47. data/modules/mruby/include/mruby/debug.h +9 -9
  48. data/modules/mruby/include/mruby/dump.h +32 -23
  49. data/modules/mruby/include/mruby/error.h +36 -0
  50. data/modules/mruby/include/mruby/gc.h +11 -6
  51. data/modules/mruby/include/mruby/hash.h +12 -12
  52. data/modules/mruby/include/mruby/irep.h +9 -3
  53. data/modules/mruby/include/mruby/khash.h +58 -41
  54. data/modules/mruby/include/mruby/numeric.h +38 -4
  55. data/modules/mruby/include/mruby/object.h +55 -0
  56. data/modules/mruby/include/mruby/opcode.h +160 -0
  57. data/modules/mruby/include/mruby/proc.h +19 -5
  58. data/modules/mruby/include/mruby/range.h +4 -3
  59. data/modules/mruby/include/mruby/re.h +20 -0
  60. data/modules/mruby/include/mruby/string.h +86 -47
  61. data/modules/mruby/include/mruby/value.h +100 -374
  62. data/modules/mruby/include/mruby/variable.h +34 -32
  63. data/modules/mruby/include/mruby/version.h +40 -0
  64. data/modules/mruby/include/mruby.h +211 -139
  65. data/modules/mruby/minirake +16 -9
  66. data/modules/mruby/mrbgems/default.gembox +12 -0
  67. data/modules/mruby/mrbgems/full-core.gembox +3 -3
  68. data/modules/mruby/mrbgems/mruby-array-ext/mrbgem.rake +1 -0
  69. data/modules/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +488 -8
  70. data/modules/mruby/mrbgems/mruby-array-ext/src/array.c +57 -31
  71. data/modules/mruby/mrbgems/mruby-array-ext/test/array.rb +231 -45
  72. data/modules/mruby/mrbgems/mruby-bin-debugger/bintest/mrdb.rb +286 -0
  73. data/modules/mruby/mrbgems/mruby-bin-debugger/bintest/print.rb +701 -0
  74. data/modules/mruby/mrbgems/mruby-bin-debugger/mrbgem.rake +9 -0
  75. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c +516 -0
  76. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.h +26 -0
  77. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c +235 -0
  78. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.h +14 -0
  79. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c +78 -0
  80. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.h +13 -0
  81. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c +428 -0
  82. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c +501 -0
  83. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/cmdprint.c +58 -0
  84. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/cmdrun.c +54 -0
  85. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +746 -0
  86. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h +163 -0
  87. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +16 -0
  88. data/modules/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdberror.h +20 -0
  89. data/modules/mruby/mrbgems/mruby-bin-mirb/bintest/mirb.rb +12 -0
  90. data/modules/mruby/mrbgems/mruby-bin-mirb/mrbgem.rake +14 -1
  91. data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +154 -72
  92. data/modules/mruby/mrbgems/mruby-bin-mruby/bintest/mruby.rb +46 -0
  93. data/modules/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +1 -0
  94. data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +37 -28
  95. data/modules/mruby/mrbgems/mruby-bin-mruby-config/mrbgem.rake +30 -0
  96. data/modules/mruby/mrbgems/mruby-bin-mruby-config/mruby-config +16 -0
  97. data/modules/mruby/mrbgems/mruby-bin-mruby-config/mruby-config.bat +30 -0
  98. data/modules/mruby/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb +73 -0
  99. data/modules/mruby/mrbgems/mruby-bin-strip/mrbgem.rake +6 -0
  100. data/modules/mruby/mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c +155 -0
  101. data/modules/mruby/mrbgems/mruby-enum-ext/mrbgem.rake +1 -0
  102. data/modules/mruby/mrbgems/mruby-enum-ext/mrblib/enum.rb +555 -21
  103. data/modules/mruby/mrbgems/mruby-enum-ext/test/enum.rb +119 -0
  104. data/modules/mruby/mrbgems/mruby-enum-lazy/mrbgem.rake +7 -0
  105. data/modules/mruby/mrbgems/mruby-enum-lazy/mrblib/lazy.rb +150 -0
  106. data/modules/mruby/mrbgems/mruby-enum-lazy/test/lazy.rb +47 -0
  107. data/modules/mruby/mrbgems/mruby-enumerator/mrbgem.rake +7 -0
  108. data/modules/mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb +636 -0
  109. data/modules/mruby/mrbgems/mruby-enumerator/test/enumerator.rb +537 -0
  110. data/modules/mruby/mrbgems/mruby-eval/mrbgem.rake +1 -0
  111. data/modules/mruby/mrbgems/mruby-eval/src/eval.c +243 -4
  112. data/modules/mruby/mrbgems/mruby-eval/test/eval.rb +80 -0
  113. data/modules/mruby/mrbgems/mruby-exit/mrbgem.rake +1 -0
  114. data/modules/mruby/mrbgems/mruby-exit/src/mruby-exit.c +1 -1
  115. data/modules/mruby/mrbgems/mruby-fiber/mrbgem.rake +1 -0
  116. data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +157 -51
  117. data/modules/mruby/mrbgems/mruby-fiber/test/fiber.rb +179 -35
  118. data/modules/mruby/mrbgems/mruby-hash-ext/mrbgem.rake +3 -0
  119. data/modules/mruby/mrbgems/mruby-hash-ext/mrblib/hash.rb +241 -1
  120. data/modules/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +11 -19
  121. data/modules/mruby/mrbgems/mruby-hash-ext/test/hash.rb +138 -1
  122. data/modules/mruby/mrbgems/mruby-kernel-ext/mrbgem.rake +5 -0
  123. data/modules/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +183 -0
  124. data/modules/mruby/mrbgems/mruby-kernel-ext/test/kernel.rb +53 -0
  125. data/modules/mruby/mrbgems/mruby-math/mrbgem.rake +1 -0
  126. data/modules/mruby/mrbgems/mruby-math/src/math.c +107 -14
  127. data/modules/mruby/mrbgems/mruby-math/test/math.rb +16 -0
  128. data/modules/mruby/mrbgems/mruby-numeric-ext/mrbgem.rake +1 -0
  129. data/modules/mruby/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb +5 -0
  130. data/modules/mruby/mrbgems/mruby-numeric-ext/test/numeric.rb +9 -1
  131. data/modules/mruby/mrbgems/mruby-object-ext/mrbgem.rake +1 -0
  132. data/modules/mruby/mrbgems/mruby-object-ext/mrblib/object.rb +19 -0
  133. data/modules/mruby/mrbgems/mruby-object-ext/src/object.c +5 -8
  134. data/modules/mruby/mrbgems/mruby-object-ext/test/object.rb +16 -0
  135. data/modules/mruby/mrbgems/mruby-objectspace/mrbgem.rake +1 -0
  136. data/modules/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +121 -53
  137. data/modules/mruby/mrbgems/mruby-objectspace/test/objectspace.rb +27 -4
  138. data/modules/mruby/mrbgems/mruby-print/mrbgem.rake +1 -0
  139. data/modules/mruby/mrbgems/mruby-print/src/print.c +3 -5
  140. data/modules/mruby/mrbgems/mruby-proc-ext/mrbgem.rake +1 -0
  141. data/modules/mruby/mrbgems/mruby-proc-ext/src/proc.c +89 -19
  142. data/modules/mruby/mrbgems/mruby-proc-ext/test/proc.c +56 -0
  143. data/modules/mruby/mrbgems/mruby-proc-ext/test/proc.rb +47 -0
  144. data/modules/mruby/mrbgems/mruby-random/mrbgem.rake +1 -0
  145. data/modules/mruby/mrbgems/mruby-random/src/mt19937ar.c +30 -25
  146. data/modules/mruby/mrbgems/mruby-random/src/mt19937ar.h +6 -3
  147. data/modules/mruby/mrbgems/mruby-random/src/random.c +157 -137
  148. data/modules/mruby/mrbgems/mruby-random/src/random.h +3 -3
  149. data/modules/mruby/mrbgems/mruby-random/test/random.rb +9 -9
  150. data/modules/mruby/mrbgems/mruby-range-ext/mrbgem.rake +1 -0
  151. data/modules/mruby/mrbgems/mruby-range-ext/src/range.c +57 -3
  152. data/modules/mruby/mrbgems/mruby-range-ext/test/range.rb +9 -0
  153. data/modules/mruby/mrbgems/mruby-sprintf/mrbgem.rake +1 -0
  154. data/modules/mruby/mrbgems/mruby-sprintf/mrblib/string.rb +9 -0
  155. data/modules/mruby/mrbgems/mruby-sprintf/src/sprintf.c +29 -23
  156. data/modules/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +7 -2
  157. data/modules/mruby/mrbgems/mruby-string-ext/mrbgem.rake +1 -0
  158. data/modules/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +250 -11
  159. data/modules/mruby/mrbgems/mruby-string-ext/src/string.c +220 -5
  160. data/modules/mruby/mrbgems/mruby-string-ext/test/string.rb +326 -4
  161. data/modules/mruby/mrbgems/mruby-string-utf8/mrbgem.rake +2 -0
  162. data/modules/mruby/mrbgems/mruby-string-utf8/src/string.c +486 -52
  163. data/modules/mruby/mrbgems/mruby-string-utf8/test/string.rb +97 -14
  164. data/modules/mruby/mrbgems/mruby-struct/mrbgem.rake +1 -0
  165. data/modules/mruby/mrbgems/mruby-struct/mrblib/struct.rb +31 -0
  166. data/modules/mruby/mrbgems/mruby-struct/src/struct.c +178 -196
  167. data/modules/mruby/mrbgems/mruby-struct/test/struct.rb +115 -61
  168. data/modules/mruby/mrbgems/mruby-symbol-ext/mrbgem.rake +1 -0
  169. data/modules/mruby/mrbgems/mruby-symbol-ext/mrblib/symbol.rb +22 -17
  170. data/modules/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +20 -11
  171. data/modules/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +14 -0
  172. data/modules/mruby/mrbgems/mruby-time/mrbgem.rake +1 -0
  173. data/modules/mruby/mrbgems/mruby-time/mrblib/time.rb +9 -0
  174. data/modules/mruby/mrbgems/mruby-time/src/time.c +98 -37
  175. data/modules/mruby/mrbgems/mruby-time/test/time.rb +152 -148
  176. data/modules/mruby/mrbgems/mruby-toplevel-ext/mrbgem.rake +1 -0
  177. data/modules/mruby/mrbgems/mruby-toplevel-ext/test/toplevel.rb +1 -1
  178. data/modules/mruby/mrblib/array.rb +110 -4
  179. data/modules/mruby/mrblib/class.rb +1 -22
  180. data/modules/mruby/mrblib/compar.rb +10 -30
  181. data/modules/mruby/mrblib/enum.rb +64 -52
  182. data/modules/mruby/mrblib/error.rb +9 -4
  183. data/modules/mruby/mrblib/hash.rb +164 -23
  184. data/modules/mruby/mrblib/kernel.rb +26 -22
  185. data/modules/mruby/mrblib/mrblib.rake +4 -4
  186. data/modules/mruby/mrblib/numeric.rb +22 -9
  187. data/modules/mruby/mrblib/range.rb +24 -2
  188. data/modules/mruby/mrblib/string.rb +15 -3
  189. data/modules/mruby/src/array.c +279 -339
  190. data/modules/mruby/src/backtrace.c +68 -16
  191. data/modules/mruby/src/class.c +539 -379
  192. data/modules/mruby/src/codegen.c +424 -207
  193. data/modules/mruby/src/compar.c +1 -1
  194. data/modules/mruby/src/crc.c +7 -6
  195. data/modules/mruby/src/debug.c +37 -36
  196. data/modules/mruby/src/dump.c +463 -213
  197. data/modules/mruby/src/enum.c +1 -1
  198. data/modules/mruby/src/error.c +91 -92
  199. data/modules/mruby/src/error.h +3 -19
  200. data/modules/mruby/src/etc.c +85 -82
  201. data/modules/mruby/src/gc.c +134 -108
  202. data/modules/mruby/src/hash.c +161 -565
  203. data/modules/mruby/src/init.c +2 -13
  204. data/modules/mruby/src/kernel.c +217 -251
  205. data/modules/mruby/src/load.c +280 -283
  206. data/modules/mruby/src/mrb_throw.h +41 -0
  207. data/modules/mruby/src/mruby_core.rake +57 -7
  208. data/modules/mruby/src/node.h +104 -104
  209. data/modules/mruby/src/numeric.c +221 -208
  210. data/modules/mruby/src/object.c +41 -42
  211. data/modules/mruby/src/opcode.h +2 -160
  212. data/modules/mruby/src/parse.y +3430 -3223
  213. data/modules/mruby/src/pool.c +13 -9
  214. data/modules/mruby/src/print.c +20 -17
  215. data/modules/mruby/src/proc.c +77 -21
  216. data/modules/mruby/src/range.c +55 -45
  217. data/modules/mruby/src/state.c +95 -31
  218. data/modules/mruby/src/string.c +462 -468
  219. data/modules/mruby/src/symbol.c +95 -85
  220. data/modules/mruby/src/variable.c +104 -74
  221. data/modules/mruby/src/version.c +13 -0
  222. data/modules/mruby/src/vm.c +528 -296
  223. data/modules/mruby/tasks/libmruby.rake +9 -5
  224. data/modules/mruby/tasks/mrbgem_spec.rake +130 -26
  225. data/modules/mruby/tasks/mrbgems.rake +21 -11
  226. data/modules/mruby/tasks/mrbgems_test.rake +46 -40
  227. data/modules/mruby/tasks/mruby_build.rake +54 -12
  228. data/modules/mruby/tasks/mruby_build_commands.rake +34 -5
  229. data/modules/mruby/tasks/mruby_build_gem.rake +25 -3
  230. data/modules/mruby/tasks/ruby_ext.rake +11 -2
  231. data/modules/mruby/tasks/toolchains/clang.rake +2 -1
  232. data/modules/mruby/tasks/toolchains/gcc.rake +26 -3
  233. data/modules/mruby/tasks/toolchains/visualcpp.rake +17 -8
  234. data/modules/mruby/test/assert.rb +30 -8
  235. data/modules/mruby/test/bintest.rb +10 -0
  236. data/modules/mruby/test/driver.c +74 -24
  237. data/modules/mruby/test/init_mrbtest.c +21 -2
  238. data/modules/mruby/test/mrbtest.rake +27 -5
  239. data/modules/mruby/test/t/argumenterror.rb +0 -5
  240. data/modules/mruby/test/t/array.rb +23 -7
  241. data/modules/mruby/test/t/bs_block.rb +32 -0
  242. data/modules/mruby/test/t/class.rb +29 -5
  243. data/modules/mruby/test/t/comparable.rb +20 -12
  244. data/modules/mruby/test/t/enumerable.rb +33 -7
  245. data/modules/mruby/test/t/exception.rb +63 -38
  246. data/modules/mruby/test/t/false.rb +2 -4
  247. data/modules/mruby/test/t/float.rb +39 -4
  248. data/modules/mruby/test/t/hash.rb +40 -6
  249. data/modules/mruby/test/t/indexerror.rb +0 -4
  250. data/modules/mruby/test/t/integer.rb +41 -5
  251. data/modules/mruby/test/t/kernel.rb +90 -3
  252. data/modules/mruby/test/t/localjumperror.rb +4 -4
  253. data/modules/mruby/test/t/methods.rb +1 -1
  254. data/modules/mruby/test/t/module.rb +43 -13
  255. data/modules/mruby/test/t/nameerror.rb +0 -4
  256. data/modules/mruby/test/t/nil.rb +5 -0
  257. data/modules/mruby/test/t/nomethoderror.rb +11 -2
  258. data/modules/mruby/test/t/numeric.rb +18 -4
  259. data/modules/mruby/test/t/proc.rb +59 -6
  260. data/modules/mruby/test/t/range.rb +15 -5
  261. data/modules/mruby/test/t/rangeerror.rb +0 -4
  262. data/modules/mruby/test/t/standarderror.rb +0 -4
  263. data/modules/mruby/test/t/string.rb +56 -12
  264. data/modules/mruby/test/t/superclass.rb +46 -0
  265. data/modules/mruby/test/t/symbol.rb +0 -4
  266. data/modules/mruby/test/t/syntax.rb +134 -1
  267. data/modules/mruby/test/t/true.rb +2 -4
  268. data/modules/mruby/test/t/typeerror.rb +0 -5
  269. data/modules/mruby/test/t/unicode.rb +35 -0
  270. data/modules/mruby/tools/mrbc/mrbc.c +9 -12
  271. data/modules/mruby/travis_config.rb +22 -2
  272. metadata +98 -1299
  273. data/modules/emscripten/AUTHORS +0 -117
  274. data/modules/emscripten/CONTRIBUTING.markdown +0 -5
  275. data/modules/emscripten/ChangeLog +0 -468
  276. data/modules/emscripten/LICENSE +0 -94
  277. data/modules/emscripten/README.markdown +0 -14
  278. data/modules/emscripten/cmake/Modules/FindOpenAL.cmake +0 -26
  279. data/modules/emscripten/cmake/Platform/Emscripten.cmake +0 -228
  280. data/modules/emscripten/em++ +0 -12
  281. data/modules/emscripten/em++.bat +0 -2
  282. data/modules/emscripten/em-config +0 -24
  283. data/modules/emscripten/em-config.bat +0 -2
  284. data/modules/emscripten/emar +0 -24
  285. data/modules/emscripten/emar.bat +0 -2
  286. data/modules/emscripten/emcc +0 -2069
  287. data/modules/emscripten/emcc.bat +0 -2
  288. data/modules/emscripten/emcc.py +0 -5
  289. data/modules/emscripten/emconfigure +0 -27
  290. data/modules/emscripten/emconfigure.bat +0 -2
  291. data/modules/emscripten/emlink.py +0 -33
  292. data/modules/emscripten/emmake +0 -29
  293. data/modules/emscripten/emmake.bat +0 -2
  294. data/modules/emscripten/emranlib +0 -9
  295. data/modules/emscripten/emranlib.bat +0 -2
  296. data/modules/emscripten/emrun +0 -1087
  297. data/modules/emscripten/emrun.bat +0 -2
  298. data/modules/emscripten/emscons +0 -20
  299. data/modules/emscripten/emscripten.py +0 -1347
  300. data/modules/emscripten/package.json +0 -7
  301. data/modules/emscripten/patches/README +0 -4
  302. data/modules/emscripten/patches/series +0 -2
  303. data/modules/emscripten/scons-tools/closure.py +0 -28
  304. data/modules/emscripten/scons-tools/emscripten.py +0 -364
  305. data/modules/emscripten/scons-tools/llvm.py +0 -34
  306. data/modules/emscripten/src/analyzer.js +0 -1781
  307. data/modules/emscripten/src/closure-externs.js +0 -110
  308. data/modules/emscripten/src/compiler.html +0 -48
  309. data/modules/emscripten/src/compiler.js +0 -331
  310. data/modules/emscripten/src/compiler_phase.html +0 -33
  311. data/modules/emscripten/src/corruptionCheck.js +0 -98
  312. data/modules/emscripten/src/determinstic.js +0 -20
  313. data/modules/emscripten/src/embind/embind.js +0 -1677
  314. data/modules/emscripten/src/embind/emval.js +0 -284
  315. data/modules/emscripten/src/emrun_postjs.js +0 -20
  316. data/modules/emscripten/src/emrun_prejs.js +0 -5
  317. data/modules/emscripten/src/emscripten-source-map.min.js +0 -31
  318. data/modules/emscripten/src/experimental/allow_loopvars_from_memsetcpy_inasm.diff +0 -97
  319. data/modules/emscripten/src/experimental/batching.diff +0 -44
  320. data/modules/emscripten/src/experimental/functypeopt.diff +0 -113
  321. data/modules/emscripten/src/experimental/multiple_heaps.diff +0 -175
  322. data/modules/emscripten/src/experimental/noncallgraphprofiling.diff +0 -197
  323. data/modules/emscripten/src/experimental/optimize_memcpy_for_ta1.diff +0 -124
  324. data/modules/emscripten/src/experimental/remove__label__s.diff +0 -140
  325. data/modules/emscripten/src/experimental/renderer_cache_hash.diff +0 -99
  326. data/modules/emscripten/src/experimental/sdl_key_forwarding.diff +0 -57
  327. data/modules/emscripten/src/experimental/simplifyGeneratedFunctionsDetection.diff +0 -336
  328. data/modules/emscripten/src/experimental/stringCache.diff +0 -147
  329. data/modules/emscripten/src/fastLong.js +0 -299
  330. data/modules/emscripten/src/gl-matrix.js +0 -1952
  331. data/modules/emscripten/src/headless.js +0 -295
  332. data/modules/emscripten/src/headlessCanvas.js +0 -618
  333. data/modules/emscripten/src/hello_world.js +0 -92
  334. data/modules/emscripten/src/intertyper.js +0 -1228
  335. data/modules/emscripten/src/jsifier.js +0 -1969
  336. data/modules/emscripten/src/library.js +0 -9196
  337. data/modules/emscripten/src/library_browser.js +0 -988
  338. data/modules/emscripten/src/library_egl.js +0 -564
  339. data/modules/emscripten/src/library_fs.js +0 -1619
  340. data/modules/emscripten/src/library_gc.js +0 -236
  341. data/modules/emscripten/src/library_gl.js +0 -5194
  342. data/modules/emscripten/src/library_glfw.js +0 -585
  343. data/modules/emscripten/src/library_glut.js +0 -504
  344. data/modules/emscripten/src/library_idbfs.js +0 -216
  345. data/modules/emscripten/src/library_jansson.js +0 -320
  346. data/modules/emscripten/src/library_memfs.js +0 -303
  347. data/modules/emscripten/src/library_nodefs.js +0 -286
  348. data/modules/emscripten/src/library_openal.js +0 -915
  349. data/modules/emscripten/src/library_path.js +0 -133
  350. data/modules/emscripten/src/library_sdl.js +0 -2728
  351. data/modules/emscripten/src/library_sockfs.js +0 -578
  352. data/modules/emscripten/src/library_strtok_r.c +0 -97
  353. data/modules/emscripten/src/library_tty.js +0 -146
  354. data/modules/emscripten/src/library_uuid.js +0 -140
  355. data/modules/emscripten/src/library_xlib.js +0 -23
  356. data/modules/emscripten/src/long.js +0 -1609
  357. data/modules/emscripten/src/modules.js +0 -543
  358. data/modules/emscripten/src/parseTools.js +0 -2723
  359. data/modules/emscripten/src/postamble.js +0 -239
  360. data/modules/emscripten/src/postamble_sharedlib.js +0 -16
  361. data/modules/emscripten/src/preamble.js +0 -1233
  362. data/modules/emscripten/src/preamble_sharedlib.js +0 -25
  363. data/modules/emscripten/src/proxyClient.js +0 -82
  364. data/modules/emscripten/src/proxyWorker.js +0 -143
  365. data/modules/emscripten/src/relooper/README.markdown +0 -14
  366. data/modules/emscripten/src/relooper/Relooper.cpp +0 -1301
  367. data/modules/emscripten/src/relooper/Relooper.h +0 -257
  368. data/modules/emscripten/src/relooper/doit.sh +0 -70
  369. data/modules/emscripten/src/relooper/emscripten/glue.js +0 -67
  370. data/modules/emscripten/src/relooper/emscripten/test.js +0 -44
  371. data/modules/emscripten/src/relooper/fuzzer.py +0 -131
  372. data/modules/emscripten/src/relooper/ministring.h +0 -35
  373. data/modules/emscripten/src/relooper/paper.pdf +0 -0
  374. data/modules/emscripten/src/relooper/test.cpp +0 -290
  375. data/modules/emscripten/src/relooper/test.txt +0 -317
  376. data/modules/emscripten/src/relooper/test2.c +0 -44
  377. data/modules/emscripten/src/relooper/test2.txt +0 -26
  378. data/modules/emscripten/src/relooper/test3.c +0 -42
  379. data/modules/emscripten/src/relooper/test3.txt +0 -56
  380. data/modules/emscripten/src/relooper/test4.cpp +0 -40
  381. data/modules/emscripten/src/relooper/test4.txt +0 -44
  382. data/modules/emscripten/src/relooper/test5.cpp +0 -40
  383. data/modules/emscripten/src/relooper/test5.txt +0 -56
  384. data/modules/emscripten/src/relooper/test6.cpp +0 -31
  385. data/modules/emscripten/src/relooper/test6.txt +0 -26
  386. data/modules/emscripten/src/relooper/test_dead.cpp +0 -28
  387. data/modules/emscripten/src/relooper/test_dead.txt +0 -9
  388. data/modules/emscripten/src/relooper/test_debug.cpp +0 -30
  389. data/modules/emscripten/src/relooper/test_debug.txt +0 -142
  390. data/modules/emscripten/src/relooper/test_fuzz1.cpp +0 -52
  391. data/modules/emscripten/src/relooper/test_fuzz1.txt +0 -72
  392. data/modules/emscripten/src/relooper/test_fuzz2.cpp +0 -34
  393. data/modules/emscripten/src/relooper/test_fuzz2.txt +0 -30
  394. data/modules/emscripten/src/relooper/test_fuzz3.cpp +0 -36
  395. data/modules/emscripten/src/relooper/test_fuzz3.txt +0 -25
  396. data/modules/emscripten/src/relooper/test_fuzz4.cpp +0 -38
  397. data/modules/emscripten/src/relooper/test_fuzz4.txt +0 -41
  398. data/modules/emscripten/src/relooper/test_fuzz5.cpp +0 -57
  399. data/modules/emscripten/src/relooper/test_fuzz5.txt +0 -86
  400. data/modules/emscripten/src/relooper/test_fuzz6.cpp +0 -322
  401. data/modules/emscripten/src/relooper/test_fuzz6.txt +0 -291
  402. data/modules/emscripten/src/relooper/test_inf.cpp +0 -813
  403. data/modules/emscripten/src/relooper/test_inf.txt +0 -1131
  404. data/modules/emscripten/src/relooper/testit.sh +0 -62
  405. data/modules/emscripten/src/relooper/updateit.sh +0 -17
  406. data/modules/emscripten/src/runtime.js +0 -604
  407. data/modules/emscripten/src/settings.js +0 -476
  408. data/modules/emscripten/src/shell.html +0 -95
  409. data/modules/emscripten/src/shell.js +0 -173
  410. data/modules/emscripten/src/shell_sharedlib.js +0 -29
  411. data/modules/emscripten/src/simd.js +0 -1128
  412. data/modules/emscripten/src/socket.io.js +0 -3870
  413. data/modules/emscripten/src/struct_info.json +0 -1077
  414. data/modules/emscripten/src/utility.js +0 -411
  415. data/modules/emscripten/src/wrtcp.js +0 -821
  416. data/modules/emscripten/system/bin/sdl-config +0 -13
  417. data/modules/emscripten/system/include/AL/al.h +0 -172
  418. data/modules/emscripten/system/include/AL/alc.h +0 -84
  419. data/modules/emscripten/system/include/EGL/egl.h +0 -329
  420. data/modules/emscripten/system/include/EGL/eglext.h +0 -398
  421. data/modules/emscripten/system/include/EGL/eglplatform.h +0 -141
  422. data/modules/emscripten/system/include/GL/freeglut_std.h +0 -628
  423. data/modules/emscripten/system/include/GL/gl.h +0 -2241
  424. data/modules/emscripten/system/include/GL/glew.h +0 -6
  425. data/modules/emscripten/system/include/GL/glext.h +0 -11127
  426. data/modules/emscripten/system/include/GL/glfw.h +0 -518
  427. data/modules/emscripten/system/include/GL/glu.h +0 -353
  428. data/modules/emscripten/system/include/GL/glut.h +0 -21
  429. data/modules/emscripten/system/include/GLES/gl.h +0 -770
  430. data/modules/emscripten/system/include/GLES/glext.h +0 -1278
  431. data/modules/emscripten/system/include/GLES/glplatform.h +0 -30
  432. data/modules/emscripten/system/include/GLES2/gl2.h +0 -621
  433. data/modules/emscripten/system/include/GLES2/gl2ext.h +0 -803
  434. data/modules/emscripten/system/include/GLES2/gl2platform.h +0 -30
  435. data/modules/emscripten/system/include/KHR/khrplatform.h +0 -277
  436. data/modules/emscripten/system/include/SDL/COPYING +0 -19
  437. data/modules/emscripten/system/include/SDL/SDL.h +0 -162
  438. data/modules/emscripten/system/include/SDL/SDL_assert.h +0 -241
  439. data/modules/emscripten/system/include/SDL/SDL_atomic.h +0 -318
  440. data/modules/emscripten/system/include/SDL/SDL_audio.h +0 -509
  441. data/modules/emscripten/system/include/SDL/SDL_blendmode.h +0 -60
  442. data/modules/emscripten/system/include/SDL/SDL_clipboard.h +0 -75
  443. data/modules/emscripten/system/include/SDL/SDL_compat.h +0 -365
  444. data/modules/emscripten/system/include/SDL/SDL_config.h +0 -48
  445. data/modules/emscripten/system/include/SDL/SDL_config.h.in +0 -297
  446. data/modules/emscripten/system/include/SDL/SDL_config_android.h +0 -133
  447. data/modules/emscripten/system/include/SDL/SDL_config_iphoneos.h +0 -148
  448. data/modules/emscripten/system/include/SDL/SDL_config_macosx.h +0 -172
  449. data/modules/emscripten/system/include/SDL/SDL_config_minimal.h +0 -74
  450. data/modules/emscripten/system/include/SDL/SDL_config_nintendods.h +0 -129
  451. data/modules/emscripten/system/include/SDL/SDL_config_pandora.h +0 -125
  452. data/modules/emscripten/system/include/SDL/SDL_config_windows.h +0 -207
  453. data/modules/emscripten/system/include/SDL/SDL_config_wiz.h +0 -119
  454. data/modules/emscripten/system/include/SDL/SDL_copying.h +0 -20
  455. data/modules/emscripten/system/include/SDL/SDL_cpuinfo.h +0 -150
  456. data/modules/emscripten/system/include/SDL/SDL_endian.h +0 -248
  457. data/modules/emscripten/system/include/SDL/SDL_error.h +0 -77
  458. data/modules/emscripten/system/include/SDL/SDL_events.h +0 -640
  459. data/modules/emscripten/system/include/SDL/SDL_gesture.h +0 -91
  460. data/modules/emscripten/system/include/SDL/SDL_gfxPrimitives.h +0 -246
  461. data/modules/emscripten/system/include/SDL/SDL_haptic.h +0 -1200
  462. data/modules/emscripten/system/include/SDL/SDL_hints.h +0 -206
  463. data/modules/emscripten/system/include/SDL/SDL_image.h +0 -138
  464. data/modules/emscripten/system/include/SDL/SDL_input.h +0 -87
  465. data/modules/emscripten/system/include/SDL/SDL_joystick.h +0 -208
  466. data/modules/emscripten/system/include/SDL/SDL_keyboard.h +0 -169
  467. data/modules/emscripten/system/include/SDL/SDL_keycode.h +0 -344
  468. data/modules/emscripten/system/include/SDL/SDL_loadso.h +0 -85
  469. data/modules/emscripten/system/include/SDL/SDL_log.h +0 -211
  470. data/modules/emscripten/system/include/SDL/SDL_main.h +0 -98
  471. data/modules/emscripten/system/include/SDL/SDL_mixer.h +0 -634
  472. data/modules/emscripten/system/include/SDL/SDL_mouse.h +0 -213
  473. data/modules/emscripten/system/include/SDL/SDL_mutex.h +0 -248
  474. data/modules/emscripten/system/include/SDL/SDL_name.h +0 -11
  475. data/modules/emscripten/system/include/SDL/SDL_opengl.h +0 -11116
  476. data/modules/emscripten/system/include/SDL/SDL_opengles.h +0 -38
  477. data/modules/emscripten/system/include/SDL/SDL_opengles2.h +0 -38
  478. data/modules/emscripten/system/include/SDL/SDL_pixels.h +0 -423
  479. data/modules/emscripten/system/include/SDL/SDL_platform.h +0 -160
  480. data/modules/emscripten/system/include/SDL/SDL_power.h +0 -79
  481. data/modules/emscripten/system/include/SDL/SDL_quit.h +0 -58
  482. data/modules/emscripten/system/include/SDL/SDL_rect.h +0 -136
  483. data/modules/emscripten/system/include/SDL/SDL_render.h +0 -615
  484. data/modules/emscripten/system/include/SDL/SDL_revision.h +0 -2
  485. data/modules/emscripten/system/include/SDL/SDL_revision.h.orig +0 -2
  486. data/modules/emscripten/system/include/SDL/SDL_rotozoom.h +0 -123
  487. data/modules/emscripten/system/include/SDL/SDL_rwops.h +0 -220
  488. data/modules/emscripten/system/include/SDL/SDL_scancode.h +0 -398
  489. data/modules/emscripten/system/include/SDL/SDL_shape.h +0 -147
  490. data/modules/emscripten/system/include/SDL/SDL_stdinc.h +0 -764
  491. data/modules/emscripten/system/include/SDL/SDL_surface.h +0 -499
  492. data/modules/emscripten/system/include/SDL/SDL_syswm.h +0 -241
  493. data/modules/emscripten/system/include/SDL/SDL_thread.h +0 -182
  494. data/modules/emscripten/system/include/SDL/SDL_timer.h +0 -108
  495. data/modules/emscripten/system/include/SDL/SDL_touch.h +0 -124
  496. data/modules/emscripten/system/include/SDL/SDL_ttf.h +0 -249
  497. data/modules/emscripten/system/include/SDL/SDL_types.h +0 -29
  498. data/modules/emscripten/system/include/SDL/SDL_version.h +0 -166
  499. data/modules/emscripten/system/include/SDL/SDL_video.h +0 -820
  500. data/modules/emscripten/system/include/SDL/begin_code.h +0 -135
  501. data/modules/emscripten/system/include/SDL/close_code.h +0 -37
  502. data/modules/emscripten/system/include/X11/X.h +0 -717
  503. data/modules/emscripten/system/include/X11/Xatom.h +0 -79
  504. data/modules/emscripten/system/include/X11/Xfuncproto.h +0 -127
  505. data/modules/emscripten/system/include/X11/Xlib.h +0 -4023
  506. data/modules/emscripten/system/include/X11/Xosdefs.h +0 -116
  507. data/modules/emscripten/system/include/X11/Xutil.h +0 -826
  508. data/modules/emscripten/system/include/X11/keysym.h +0 -73
  509. data/modules/emscripten/system/include/X11/keysymdef.h +0 -2389
  510. data/modules/emscripten/system/include/compat/ctype.h +0 -34
  511. data/modules/emscripten/system/include/compat/malloc.h +0 -48
  512. data/modules/emscripten/system/include/compat/math.h +0 -14
  513. data/modules/emscripten/system/include/compat/netdb.h +0 -22
  514. data/modules/emscripten/system/include/compat/stdarg.h +0 -16
  515. data/modules/emscripten/system/include/compat/stdlib.h +0 -16
  516. data/modules/emscripten/system/include/compat/string.h +0 -17
  517. data/modules/emscripten/system/include/compat/sys/socketvar.h +0 -14
  518. data/modules/emscripten/system/include/compat/sys/stat.h +0 -20
  519. data/modules/emscripten/system/include/compat/sys/timeb.h +0 -35
  520. data/modules/emscripten/system/include/compat/time.h +0 -18
  521. data/modules/emscripten/system/include/compat/unistd.h +0 -16
  522. data/modules/emscripten/system/include/compat/wchar.h +0 -23
  523. data/modules/emscripten/system/include/compat/wctype.h +0 -23
  524. data/modules/emscripten/system/include/compat/xlocale.h +0 -19
  525. data/modules/emscripten/system/include/emscripten/bind.h +0 -1210
  526. data/modules/emscripten/system/include/emscripten/emmintrin.h +0 -87
  527. data/modules/emscripten/system/include/emscripten/emscripten.h +0 -519
  528. data/modules/emscripten/system/include/emscripten/val.h +0 -311
  529. data/modules/emscripten/system/include/emscripten/vector.h +0 -34
  530. data/modules/emscripten/system/include/emscripten/wire.h +0 -393
  531. data/modules/emscripten/system/include/emscripten/xmmintrin.h +0 -131
  532. data/modules/emscripten/system/include/execinfo.h +0 -44
  533. data/modules/emscripten/system/include/gc.h +0 -70
  534. data/modules/emscripten/system/include/gfx/png.h +0 -3798
  535. data/modules/emscripten/system/include/gfx/pngconf.h +0 -1665
  536. data/modules/emscripten/system/include/gfx/tiff.h +0 -654
  537. data/modules/emscripten/system/include/gfx/tiffconf.h +0 -104
  538. data/modules/emscripten/system/include/gfx/tiffio.h +0 -526
  539. data/modules/emscripten/system/include/gfx/tiffvers.h +0 -9
  540. data/modules/emscripten/system/include/jansson.h +0 -323
  541. data/modules/emscripten/system/include/jansson_config.h +0 -54
  542. data/modules/emscripten/system/include/libc/aio.h +0 -69
  543. data/modules/emscripten/system/include/libc/alloca.h +0 -21
  544. data/modules/emscripten/system/include/libc/ar.h +0 -25
  545. data/modules/emscripten/system/include/libc/arpa/ftp.h +0 -35
  546. data/modules/emscripten/system/include/libc/arpa/inet.h +0 -36
  547. data/modules/emscripten/system/include/libc/arpa/nameser.h +0 -467
  548. data/modules/emscripten/system/include/libc/arpa/nameser_compat.h +0 -2
  549. data/modules/emscripten/system/include/libc/arpa/telnet.h +0 -251
  550. data/modules/emscripten/system/include/libc/arpa/tftp.h +0 -31
  551. data/modules/emscripten/system/include/libc/assert.h +0 -19
  552. data/modules/emscripten/system/include/libc/bits/alltypes.h +0 -397
  553. data/modules/emscripten/system/include/libc/bits/endian.h +0 -1
  554. data/modules/emscripten/system/include/libc/bits/errno.h +0 -134
  555. data/modules/emscripten/system/include/libc/bits/fcntl.h +0 -38
  556. data/modules/emscripten/system/include/libc/bits/fenv.h +0 -34
  557. data/modules/emscripten/system/include/libc/bits/float.h +0 -17
  558. data/modules/emscripten/system/include/libc/bits/io.h +0 -0
  559. data/modules/emscripten/system/include/libc/bits/ioctl.h +0 -197
  560. data/modules/emscripten/system/include/libc/bits/ipc.h +0 -14
  561. data/modules/emscripten/system/include/libc/bits/limits.h +0 -8
  562. data/modules/emscripten/system/include/libc/bits/mman.h +0 -62
  563. data/modules/emscripten/system/include/libc/bits/msg.h +0 -16
  564. data/modules/emscripten/system/include/libc/bits/posix.h +0 -2
  565. data/modules/emscripten/system/include/libc/bits/reg.h +0 -19
  566. data/modules/emscripten/system/include/libc/bits/setjmp.h +0 -1
  567. data/modules/emscripten/system/include/libc/bits/shm.h +0 -18
  568. data/modules/emscripten/system/include/libc/bits/signal.h +0 -112
  569. data/modules/emscripten/system/include/libc/bits/socket.h +0 -17
  570. data/modules/emscripten/system/include/libc/bits/stat.h +0 -22
  571. data/modules/emscripten/system/include/libc/bits/statfs.h +0 -7
  572. data/modules/emscripten/system/include/libc/bits/stdarg.h +0 -4
  573. data/modules/emscripten/system/include/libc/bits/stdint.h +0 -20
  574. data/modules/emscripten/system/include/libc/bits/syscall.h +0 -696
  575. data/modules/emscripten/system/include/libc/bits/termios.h +0 -160
  576. data/modules/emscripten/system/include/libc/bits/user.h +0 -48
  577. data/modules/emscripten/system/include/libc/byteswap.h +0 -26
  578. data/modules/emscripten/system/include/libc/complex.h +0 -125
  579. data/modules/emscripten/system/include/libc/cpio.h +0 -29
  580. data/modules/emscripten/system/include/libc/crypt.h +0 -20
  581. data/modules/emscripten/system/include/libc/ctype.h +0 -67
  582. data/modules/emscripten/system/include/libc/dirent.h +0 -79
  583. data/modules/emscripten/system/include/libc/dlfcn.h +0 -42
  584. data/modules/emscripten/system/include/libc/elf.h +0 -2555
  585. data/modules/emscripten/system/include/libc/endian.h +0 -82
  586. data/modules/emscripten/system/include/libc/err.h +0 -25
  587. data/modules/emscripten/system/include/libc/errno.h +0 -27
  588. data/modules/emscripten/system/include/libc/fcntl.h +0 -175
  589. data/modules/emscripten/system/include/libc/features.h +0 -32
  590. data/modules/emscripten/system/include/libc/fenv.h +0 -28
  591. data/modules/emscripten/system/include/libc/float.h +0 -34
  592. data/modules/emscripten/system/include/libc/fnmatch.h +0 -29
  593. data/modules/emscripten/system/include/libc/ftw.h +0 -42
  594. data/modules/emscripten/system/include/libc/getopt.h +0 -31
  595. data/modules/emscripten/system/include/libc/glob.h +0 -48
  596. data/modules/emscripten/system/include/libc/grp.h +0 -52
  597. data/modules/emscripten/system/include/libc/iconv.h +0 -24
  598. data/modules/emscripten/system/include/libc/ifaddrs.h +0 -35
  599. data/modules/emscripten/system/include/libc/inttypes.h +0 -227
  600. data/modules/emscripten/system/include/libc/iso646.h +0 -20
  601. data/modules/emscripten/system/include/libc/langinfo.h +0 -88
  602. data/modules/emscripten/system/include/libc/lastlog.h +0 -1
  603. data/modules/emscripten/system/include/libc/libgen.h +0 -15
  604. data/modules/emscripten/system/include/libc/libintl.h +0 -25
  605. data/modules/emscripten/system/include/libc/limits.h +0 -146
  606. data/modules/emscripten/system/include/libc/link.h +0 -54
  607. data/modules/emscripten/system/include/libc/locale.h +0 -82
  608. data/modules/emscripten/system/include/libc/malloc.h +0 -0
  609. data/modules/emscripten/system/include/libc/math.h +0 -422
  610. data/modules/emscripten/system/include/libc/memory.h +0 -1
  611. data/modules/emscripten/system/include/libc/mntent.h +0 -44
  612. data/modules/emscripten/system/include/libc/monetary.h +0 -23
  613. data/modules/emscripten/system/include/libc/mqueue.h +0 -36
  614. data/modules/emscripten/system/include/libc/net/ethernet.h +0 -55
  615. data/modules/emscripten/system/include/libc/net/if.h +0 -135
  616. data/modules/emscripten/system/include/libc/net/if_arp.h +0 -133
  617. data/modules/emscripten/system/include/libc/net/route.h +0 -124
  618. data/modules/emscripten/system/include/libc/netdb.h +0 -161
  619. data/modules/emscripten/system/include/libc/netinet/ether.h +0 -14
  620. data/modules/emscripten/system/include/libc/netinet/icmp6.h +0 -305
  621. data/modules/emscripten/system/include/libc/netinet/if_ether.h +0 -126
  622. data/modules/emscripten/system/include/libc/netinet/in.h +0 -336
  623. data/modules/emscripten/system/include/libc/netinet/in_systm.h +0 -9
  624. data/modules/emscripten/system/include/libc/netinet/ip.h +0 -186
  625. data/modules/emscripten/system/include/libc/netinet/ip6.h +0 -142
  626. data/modules/emscripten/system/include/libc/netinet/ip_icmp.h +0 -192
  627. data/modules/emscripten/system/include/libc/netinet/tcp.h +0 -71
  628. data/modules/emscripten/system/include/libc/netinet/udp.h +0 -35
  629. data/modules/emscripten/system/include/libc/netpacket/packet.h +0 -44
  630. data/modules/emscripten/system/include/libc/nl_types.h +0 -22
  631. data/modules/emscripten/system/include/libc/paths.h +0 -32
  632. data/modules/emscripten/system/include/libc/poll.h +0 -46
  633. data/modules/emscripten/system/include/libc/pthread.h +0 -222
  634. data/modules/emscripten/system/include/libc/pty.h +0 -18
  635. data/modules/emscripten/system/include/libc/pwd.h +0 -49
  636. data/modules/emscripten/system/include/libc/readme.txt +0 -3
  637. data/modules/emscripten/system/include/libc/regex.h +0 -62
  638. data/modules/emscripten/system/include/libc/resolv.h +0 -144
  639. data/modules/emscripten/system/include/libc/sched.h +0 -132
  640. data/modules/emscripten/system/include/libc/search.h +0 -51
  641. data/modules/emscripten/system/include/libc/semaphore.h +0 -35
  642. data/modules/emscripten/system/include/libc/setjmp.h +0 -42
  643. data/modules/emscripten/system/include/libc/shadow.h +0 -44
  644. data/modules/emscripten/system/include/libc/signal.h +0 -255
  645. data/modules/emscripten/system/include/libc/spawn.h +0 -74
  646. data/modules/emscripten/system/include/libc/stdalign.h +0 -15
  647. data/modules/emscripten/system/include/libc/stdarg.h +0 -25
  648. data/modules/emscripten/system/include/libc/stdbool.h +0 -14
  649. data/modules/emscripten/system/include/libc/stddef.h +0 -18
  650. data/modules/emscripten/system/include/libc/stdint.h +0 -117
  651. data/modules/emscripten/system/include/libc/stdio.h +0 -199
  652. data/modules/emscripten/system/include/libc/stdio_ext.h +0 -34
  653. data/modules/emscripten/system/include/libc/stdlib.h +0 -171
  654. data/modules/emscripten/system/include/libc/stdnoreturn.h +0 -5
  655. data/modules/emscripten/system/include/libc/string.h +0 -102
  656. data/modules/emscripten/system/include/libc/strings.h +0 -35
  657. data/modules/emscripten/system/include/libc/stropts.h +0 -139
  658. data/modules/emscripten/system/include/libc/sys/acct.h +0 -75
  659. data/modules/emscripten/system/include/libc/sys/cachectl.h +0 -22
  660. data/modules/emscripten/system/include/libc/sys/dir.h +0 -2
  661. data/modules/emscripten/system/include/libc/sys/epoll.h +0 -67
  662. data/modules/emscripten/system/include/libc/sys/errno.h +0 -2
  663. data/modules/emscripten/system/include/libc/sys/eventfd.h +0 -26
  664. data/modules/emscripten/system/include/libc/sys/fcntl.h +0 -2
  665. data/modules/emscripten/system/include/libc/sys/file.h +0 -21
  666. data/modules/emscripten/system/include/libc/sys/fsuid.h +0 -20
  667. data/modules/emscripten/system/include/libc/sys/inotify.h +0 -57
  668. data/modules/emscripten/system/include/libc/sys/io.h +0 -17
  669. data/modules/emscripten/system/include/libc/sys/ioctl.h +0 -14
  670. data/modules/emscripten/system/include/libc/sys/ipc.h +0 -42
  671. data/modules/emscripten/system/include/libc/sys/klog.h +0 -14
  672. data/modules/emscripten/system/include/libc/sys/mman.h +0 -55
  673. data/modules/emscripten/system/include/libc/sys/mount.h +0 -72
  674. data/modules/emscripten/system/include/libc/sys/msg.h +0 -52
  675. data/modules/emscripten/system/include/libc/sys/mtio.h +0 -188
  676. data/modules/emscripten/system/include/libc/sys/param.h +0 -35
  677. data/modules/emscripten/system/include/libc/sys/personality.h +0 -46
  678. data/modules/emscripten/system/include/libc/sys/poll.h +0 -2
  679. data/modules/emscripten/system/include/libc/sys/prctl.h +0 -101
  680. data/modules/emscripten/system/include/libc/sys/procfs.h +0 -65
  681. data/modules/emscripten/system/include/libc/sys/ptrace.h +0 -96
  682. data/modules/emscripten/system/include/libc/sys/reboot.h +0 -20
  683. data/modules/emscripten/system/include/libc/sys/reg.h +0 -9
  684. data/modules/emscripten/system/include/libc/sys/resource.h +0 -103
  685. data/modules/emscripten/system/include/libc/sys/select.h +0 -42
  686. data/modules/emscripten/system/include/libc/sys/sem.h +0 -82
  687. data/modules/emscripten/system/include/libc/sys/sendfile.h +0 -22
  688. data/modules/emscripten/system/include/libc/sys/shm.h +0 -61
  689. data/modules/emscripten/system/include/libc/sys/signal.h +0 -2
  690. data/modules/emscripten/system/include/libc/sys/signalfd.h +0 -44
  691. data/modules/emscripten/system/include/libc/sys/socket.h +0 -299
  692. data/modules/emscripten/system/include/libc/sys/stat.h +0 -114
  693. data/modules/emscripten/system/include/libc/sys/statfs.h +0 -32
  694. data/modules/emscripten/system/include/libc/sys/statvfs.h +0 -57
  695. data/modules/emscripten/system/include/libc/sys/stropts.h +0 -1
  696. data/modules/emscripten/system/include/libc/sys/swap.h +0 -21
  697. data/modules/emscripten/system/include/libc/sys/syscall.h +0 -6
  698. data/modules/emscripten/system/include/libc/sys/sysctl.h +0 -17
  699. data/modules/emscripten/system/include/libc/sys/sysinfo.h +0 -36
  700. data/modules/emscripten/system/include/libc/sys/syslog.h +0 -1
  701. data/modules/emscripten/system/include/libc/sys/sysmacros.h +0 -15
  702. data/modules/emscripten/system/include/libc/sys/termios.h +0 -2
  703. data/modules/emscripten/system/include/libc/sys/time.h +0 -57
  704. data/modules/emscripten/system/include/libc/sys/timerfd.h +0 -24
  705. data/modules/emscripten/system/include/libc/sys/times.h +0 -26
  706. data/modules/emscripten/system/include/libc/sys/timex.h +0 -98
  707. data/modules/emscripten/system/include/libc/sys/ttydefaults.h +0 -39
  708. data/modules/emscripten/system/include/libc/sys/types.h +0 -91
  709. data/modules/emscripten/system/include/libc/sys/ucontext.h +0 -1
  710. data/modules/emscripten/system/include/libc/sys/uio.h +0 -48
  711. data/modules/emscripten/system/include/libc/sys/un.h +0 -32
  712. data/modules/emscripten/system/include/libc/sys/user.h +0 -16
  713. data/modules/emscripten/system/include/libc/sys/utsname.h +0 -30
  714. data/modules/emscripten/system/include/libc/sys/vfs.h +0 -1
  715. data/modules/emscripten/system/include/libc/sys/wait.h +0 -55
  716. data/modules/emscripten/system/include/libc/sys/xattr.h +0 -30
  717. data/modules/emscripten/system/include/libc/syscall.h +0 -1
  718. data/modules/emscripten/system/include/libc/sysexits.h +0 -21
  719. data/modules/emscripten/system/include/libc/syslog.h +0 -104
  720. data/modules/emscripten/system/include/libc/tar.h +0 -33
  721. data/modules/emscripten/system/include/libc/termios.h +0 -46
  722. data/modules/emscripten/system/include/libc/tgmath.h +0 -270
  723. data/modules/emscripten/system/include/libc/time.h +0 -132
  724. data/modules/emscripten/system/include/libc/ucontext.h +0 -25
  725. data/modules/emscripten/system/include/libc/ulimit.h +0 -17
  726. data/modules/emscripten/system/include/libc/unistd.h +0 -519
  727. data/modules/emscripten/system/include/libc/utime.h +0 -24
  728. data/modules/emscripten/system/include/libc/utmp.h +0 -47
  729. data/modules/emscripten/system/include/libc/utmpx.h +0 -58
  730. data/modules/emscripten/system/include/libc/values.h +0 -39
  731. data/modules/emscripten/system/include/libc/wchar.h +0 -183
  732. data/modules/emscripten/system/include/libc/wctype.h +0 -77
  733. data/modules/emscripten/system/include/libc/wordexp.h +0 -42
  734. data/modules/emscripten/system/include/libcxx/CREDITS.TXT +0 -123
  735. data/modules/emscripten/system/include/libcxx/LICENSE.txt +0 -76
  736. data/modules/emscripten/system/include/libcxx/__bit_reference +0 -1287
  737. data/modules/emscripten/system/include/libcxx/__config +0 -610
  738. data/modules/emscripten/system/include/libcxx/__debug +0 -218
  739. data/modules/emscripten/system/include/libcxx/__functional_03 +0 -2130
  740. data/modules/emscripten/system/include/libcxx/__functional_base +0 -615
  741. data/modules/emscripten/system/include/libcxx/__functional_base_03 +0 -1087
  742. data/modules/emscripten/system/include/libcxx/__hash_table +0 -2457
  743. data/modules/emscripten/system/include/libcxx/__locale +0 -1445
  744. data/modules/emscripten/system/include/libcxx/__mutex_base +0 -407
  745. data/modules/emscripten/system/include/libcxx/__split_buffer +0 -654
  746. data/modules/emscripten/system/include/libcxx/__sso_allocator +0 -77
  747. data/modules/emscripten/system/include/libcxx/__std_stream +0 -359
  748. data/modules/emscripten/system/include/libcxx/__tree +0 -2309
  749. data/modules/emscripten/system/include/libcxx/__tuple +0 -305
  750. data/modules/emscripten/system/include/libcxx/__tuple_03 +0 -27
  751. data/modules/emscripten/system/include/libcxx/__undef_min_max +0 -27
  752. data/modules/emscripten/system/include/libcxx/algorithm +0 -5679
  753. data/modules/emscripten/system/include/libcxx/array +0 -342
  754. data/modules/emscripten/system/include/libcxx/atomic +0 -1531
  755. data/modules/emscripten/system/include/libcxx/bitset +0 -1081
  756. data/modules/emscripten/system/include/libcxx/cassert +0 -25
  757. data/modules/emscripten/system/include/libcxx/ccomplex +0 -29
  758. data/modules/emscripten/system/include/libcxx/cctype +0 -164
  759. data/modules/emscripten/system/include/libcxx/cerrno +0 -393
  760. data/modules/emscripten/system/include/libcxx/cfenv +0 -82
  761. data/modules/emscripten/system/include/libcxx/cfloat +0 -78
  762. data/modules/emscripten/system/include/libcxx/chrono +0 -1027
  763. data/modules/emscripten/system/include/libcxx/cinttypes +0 -259
  764. data/modules/emscripten/system/include/libcxx/ciso646 +0 -25
  765. data/modules/emscripten/system/include/libcxx/climits +0 -48
  766. data/modules/emscripten/system/include/libcxx/clocale +0 -53
  767. data/modules/emscripten/system/include/libcxx/cmath +0 -1690
  768. data/modules/emscripten/system/include/libcxx/codecvt +0 -550
  769. data/modules/emscripten/system/include/libcxx/complex +0 -1567
  770. data/modules/emscripten/system/include/libcxx/complex.h +0 -35
  771. data/modules/emscripten/system/include/libcxx/condition_variable +0 -256
  772. data/modules/emscripten/system/include/libcxx/csetjmp +0 -52
  773. data/modules/emscripten/system/include/libcxx/csignal +0 -58
  774. data/modules/emscripten/system/include/libcxx/cstdarg +0 -48
  775. data/modules/emscripten/system/include/libcxx/cstdbool +0 -32
  776. data/modules/emscripten/system/include/libcxx/cstddef +0 -103
  777. data/modules/emscripten/system/include/libcxx/cstdint +0 -191
  778. data/modules/emscripten/system/include/libcxx/cstdio +0 -182
  779. data/modules/emscripten/system/include/libcxx/cstdlib +0 -172
  780. data/modules/emscripten/system/include/libcxx/cstring +0 -112
  781. data/modules/emscripten/system/include/libcxx/ctgmath +0 -29
  782. data/modules/emscripten/system/include/libcxx/ctime +0 -72
  783. data/modules/emscripten/system/include/libcxx/cwchar +0 -217
  784. data/modules/emscripten/system/include/libcxx/cwctype +0 -213
  785. data/modules/emscripten/system/include/libcxx/deque +0 -2873
  786. data/modules/emscripten/system/include/libcxx/dynarray +0 -311
  787. data/modules/emscripten/system/include/libcxx/exception +0 -250
  788. data/modules/emscripten/system/include/libcxx/ext/__hash +0 -46
  789. data/modules/emscripten/system/include/libcxx/ext/hash_map +0 -1007
  790. data/modules/emscripten/system/include/libcxx/ext/hash_set +0 -661
  791. data/modules/emscripten/system/include/libcxx/forward_list +0 -1663
  792. data/modules/emscripten/system/include/libcxx/fstream +0 -1431
  793. data/modules/emscripten/system/include/libcxx/functional +0 -2418
  794. data/modules/emscripten/system/include/libcxx/future +0 -2615
  795. data/modules/emscripten/system/include/libcxx/initializer_list +0 -118
  796. data/modules/emscripten/system/include/libcxx/iomanip +0 -651
  797. data/modules/emscripten/system/include/libcxx/ios +0 -1023
  798. data/modules/emscripten/system/include/libcxx/iosfwd +0 -194
  799. data/modules/emscripten/system/include/libcxx/iostream +0 -60
  800. data/modules/emscripten/system/include/libcxx/istream +0 -1716
  801. data/modules/emscripten/system/include/libcxx/iterator +0 -1568
  802. data/modules/emscripten/system/include/libcxx/limits +0 -813
  803. data/modules/emscripten/system/include/libcxx/list +0 -2355
  804. data/modules/emscripten/system/include/libcxx/locale +0 -4465
  805. data/modules/emscripten/system/include/libcxx/map +0 -2045
  806. data/modules/emscripten/system/include/libcxx/memory +0 -5448
  807. data/modules/emscripten/system/include/libcxx/mutex +0 -566
  808. data/modules/emscripten/system/include/libcxx/new +0 -146
  809. data/modules/emscripten/system/include/libcxx/numeric +0 -197
  810. data/modules/emscripten/system/include/libcxx/optional +0 -697
  811. data/modules/emscripten/system/include/libcxx/ostream +0 -1295
  812. data/modules/emscripten/system/include/libcxx/queue +0 -717
  813. data/modules/emscripten/system/include/libcxx/random +0 -6725
  814. data/modules/emscripten/system/include/libcxx/ratio +0 -487
  815. data/modules/emscripten/system/include/libcxx/readme.txt +0 -1
  816. data/modules/emscripten/system/include/libcxx/regex +0 -6487
  817. data/modules/emscripten/system/include/libcxx/scoped_allocator +0 -578
  818. data/modules/emscripten/system/include/libcxx/set +0 -1189
  819. data/modules/emscripten/system/include/libcxx/shared_mutex +0 -419
  820. data/modules/emscripten/system/include/libcxx/sstream +0 -972
  821. data/modules/emscripten/system/include/libcxx/stack +0 -292
  822. data/modules/emscripten/system/include/libcxx/stdexcept +0 -162
  823. data/modules/emscripten/system/include/libcxx/streambuf +0 -564
  824. data/modules/emscripten/system/include/libcxx/string +0 -4198
  825. data/modules/emscripten/system/include/libcxx/strstream +0 -400
  826. data/modules/emscripten/system/include/libcxx/support/ibm/limits.h +0 -99
  827. data/modules/emscripten/system/include/libcxx/support/ibm/support.h +0 -54
  828. data/modules/emscripten/system/include/libcxx/support/ibm/xlocale.h +0 -326
  829. data/modules/emscripten/system/include/libcxx/support/solaris/floatingpoint.h +0 -5
  830. data/modules/emscripten/system/include/libcxx/support/solaris/wchar.h +0 -38
  831. data/modules/emscripten/system/include/libcxx/support/solaris/xlocale.h +0 -146
  832. data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +0 -79
  833. data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +0 -129
  834. data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +0 -115
  835. data/modules/emscripten/system/include/libcxx/support/win32/support.h +0 -119
  836. data/modules/emscripten/system/include/libcxx/system_error +0 -642
  837. data/modules/emscripten/system/include/libcxx/tgmath.h +0 -29
  838. data/modules/emscripten/system/include/libcxx/thread +0 -458
  839. data/modules/emscripten/system/include/libcxx/tuple +0 -1102
  840. data/modules/emscripten/system/include/libcxx/type_traits +0 -3292
  841. data/modules/emscripten/system/include/libcxx/typeindex +0 -103
  842. data/modules/emscripten/system/include/libcxx/typeinfo +0 -124
  843. data/modules/emscripten/system/include/libcxx/unordered_map +0 -2078
  844. data/modules/emscripten/system/include/libcxx/unordered_set +0 -1379
  845. data/modules/emscripten/system/include/libcxx/utility +0 -768
  846. data/modules/emscripten/system/include/libcxx/valarray +0 -4779
  847. data/modules/emscripten/system/include/libcxx/vector +0 -3246
  848. data/modules/emscripten/system/include/unwind.h +0 -154
  849. data/modules/emscripten/system/include/uuid/uuid.h +0 -35
  850. data/modules/emscripten/system/include/zconf.h +0 -428
  851. data/modules/emscripten/system/include/zlib.h +0 -1613
  852. data/modules/emscripten/system/lib/compiler-rt/LICENSE.TXT +0 -97
  853. data/modules/emscripten/system/lib/compiler-rt/divdi3.c +0 -47
  854. data/modules/emscripten/system/lib/compiler-rt/int_endianness.h +0 -116
  855. data/modules/emscripten/system/lib/compiler-rt/int_lib.h +0 -46
  856. data/modules/emscripten/system/lib/compiler-rt/int_math.h +0 -67
  857. data/modules/emscripten/system/lib/compiler-rt/int_types.h +0 -140
  858. data/modules/emscripten/system/lib/compiler-rt/int_util.h +0 -29
  859. data/modules/emscripten/system/lib/compiler-rt/muldi3.c +0 -56
  860. data/modules/emscripten/system/lib/compiler-rt/readme.txt +0 -20
  861. data/modules/emscripten/system/lib/compiler-rt/udivdi3.c +0 -36
  862. data/modules/emscripten/system/lib/compiler-rt/udivmoddi4.c +0 -251
  863. data/modules/emscripten/system/lib/debugging.cpp +0 -24
  864. data/modules/emscripten/system/lib/dlmalloc.c +0 -6297
  865. data/modules/emscripten/system/lib/embind/bind.cpp +0 -63
  866. data/modules/emscripten/system/lib/libc/gen/err.c +0 -49
  867. data/modules/emscripten/system/lib/libc/gen/errx.c +0 -49
  868. data/modules/emscripten/system/lib/libc/gen/verr.c +0 -58
  869. data/modules/emscripten/system/lib/libc/gen/verrx.c +0 -51
  870. data/modules/emscripten/system/lib/libc/gen/vwarn.c +0 -55
  871. data/modules/emscripten/system/lib/libc/gen/vwarnx.c +0 -48
  872. data/modules/emscripten/system/lib/libc/gen/warn.c +0 -49
  873. data/modules/emscripten/system/lib/libc/gen/warnx.c +0 -49
  874. data/modules/emscripten/system/lib/libc/musl/COPYRIGHT +0 -92
  875. data/modules/emscripten/system/lib/libc/musl/readme.txt +0 -9
  876. data/modules/emscripten/system/lib/libc/musl/src/ctype/alpha.h +0 -125
  877. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswalnum.c +0 -7
  878. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswalpha.c +0 -14
  879. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswblank.c +0 -8
  880. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswcntrl.c +0 -10
  881. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswctype.c +0 -63
  882. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswdigit.c +0 -9
  883. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswgraph.c +0 -7
  884. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswlower.c +0 -6
  885. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswprint.c +0 -19
  886. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswpunct.c +0 -12
  887. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswspace.c +0 -19
  888. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswupper.c +0 -6
  889. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswxdigit.c +0 -7
  890. data/modules/emscripten/system/lib/libc/musl/src/ctype/nonspacing.h +0 -62
  891. data/modules/emscripten/system/lib/libc/musl/src/ctype/punct.h +0 -109
  892. data/modules/emscripten/system/lib/libc/musl/src/ctype/towctrans.c +0 -268
  893. data/modules/emscripten/system/lib/libc/musl/src/ctype/wcswidth.c +0 -8
  894. data/modules/emscripten/system/lib/libc/musl/src/ctype/wctrans.c +0 -16
  895. data/modules/emscripten/system/lib/libc/musl/src/ctype/wcwidth.c +0 -29
  896. data/modules/emscripten/system/lib/libc/musl/src/ctype/wide.h +0 -42
  897. data/modules/emscripten/system/lib/libc/musl/src/internal/libc.c +0 -22
  898. data/modules/emscripten/system/lib/libc/musl/src/internal/libc.h +0 -71
  899. data/modules/emscripten/system/lib/libc/musl/src/internal/locale_impl.h +0 -5
  900. data/modules/emscripten/system/lib/libc/musl/src/internal/stdio_impl.h +0 -92
  901. data/modules/emscripten/system/lib/libc/musl/src/locale/big5.h +0 -1085
  902. data/modules/emscripten/system/lib/libc/musl/src/locale/codepages.h +0 -238
  903. data/modules/emscripten/system/lib/libc/musl/src/locale/gb18030.h +0 -1836
  904. data/modules/emscripten/system/lib/libc/musl/src/locale/hkscs.h +0 -390
  905. data/modules/emscripten/system/lib/libc/musl/src/locale/iconv.c +0 -454
  906. data/modules/emscripten/system/lib/libc/musl/src/locale/iswalnum_l.c +0 -6
  907. data/modules/emscripten/system/lib/libc/musl/src/locale/iswalpha_l.c +0 -6
  908. data/modules/emscripten/system/lib/libc/musl/src/locale/iswblank_l.c +0 -6
  909. data/modules/emscripten/system/lib/libc/musl/src/locale/iswcntrl_l.c +0 -6
  910. data/modules/emscripten/system/lib/libc/musl/src/locale/iswctype_l.c +0 -9
  911. data/modules/emscripten/system/lib/libc/musl/src/locale/iswdigit_l.c +0 -6
  912. data/modules/emscripten/system/lib/libc/musl/src/locale/iswgraph_l.c +0 -6
  913. data/modules/emscripten/system/lib/libc/musl/src/locale/iswlower_l.c +0 -6
  914. data/modules/emscripten/system/lib/libc/musl/src/locale/iswprint_l.c +0 -6
  915. data/modules/emscripten/system/lib/libc/musl/src/locale/iswpunct_l.c +0 -6
  916. data/modules/emscripten/system/lib/libc/musl/src/locale/iswspace_l.c +0 -6
  917. data/modules/emscripten/system/lib/libc/musl/src/locale/iswupper_l.c +0 -6
  918. data/modules/emscripten/system/lib/libc/musl/src/locale/iswxdigit_l.c +0 -6
  919. data/modules/emscripten/system/lib/libc/musl/src/locale/jis0208.h +0 -550
  920. data/modules/emscripten/system/lib/libc/musl/src/locale/ksc.h +0 -640
  921. data/modules/emscripten/system/lib/libc/musl/src/locale/legacychars.h +0 -39
  922. data/modules/emscripten/system/lib/libc/musl/src/locale/strfmon.c +0 -101
  923. data/modules/emscripten/system/lib/libc/musl/src/locale/strxfrm.c +0 -18
  924. data/modules/emscripten/system/lib/libc/musl/src/locale/towctrans_l.c +0 -6
  925. data/modules/emscripten/system/lib/libc/musl/src/locale/towlower_l.c +0 -9
  926. data/modules/emscripten/system/lib/libc/musl/src/locale/towupper_l.c +0 -9
  927. data/modules/emscripten/system/lib/libc/musl/src/locale/wcscoll.c +0 -16
  928. data/modules/emscripten/system/lib/libc/musl/src/locale/wcscoll_l.c +0 -6
  929. data/modules/emscripten/system/lib/libc/musl/src/locale/wcsxfrm.c +0 -21
  930. data/modules/emscripten/system/lib/libc/musl/src/locale/wcsxfrm_l.c +0 -6
  931. data/modules/emscripten/system/lib/libc/musl/src/locale/wctrans_l.c +0 -6
  932. data/modules/emscripten/system/lib/libc/musl/src/locale/wctype_l.c +0 -9
  933. data/modules/emscripten/system/lib/libc/musl/src/multibyte/btowc.c +0 -7
  934. data/modules/emscripten/system/lib/libc/musl/src/multibyte/internal.c +0 -38
  935. data/modules/emscripten/system/lib/libc/musl/src/multibyte/internal.h +0 -22
  936. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mblen.c +0 -17
  937. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbrlen.c +0 -18
  938. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbrtowc.c +0 -57
  939. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsinit.c +0 -17
  940. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsnrtowcs.c +0 -65
  941. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsrtowcs.c +0 -100
  942. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbstowcs.c +0 -7
  943. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbtowc.c +0 -53
  944. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcrtomb.c +0 -38
  945. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcsnrtombs.c +0 -52
  946. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcsrtombs.c +0 -58
  947. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcstombs.c +0 -7
  948. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wctob.c +0 -8
  949. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wctomb.c +0 -18
  950. data/modules/emscripten/system/lib/libc/musl/src/regex/regcomp.c +0 -3352
  951. data/modules/emscripten/system/lib/libc/musl/src/regex/regerror.c +0 -35
  952. data/modules/emscripten/system/lib/libc/musl/src/regex/regexec.c +0 -1011
  953. data/modules/emscripten/system/lib/libc/musl/src/regex/tre-mem.c +0 -158
  954. data/modules/emscripten/system/lib/libc/musl/src/regex/tre.h +0 -231
  955. data/modules/emscripten/system/lib/libc/musl/src/stdio/fwprintf.c +0 -13
  956. data/modules/emscripten/system/lib/libc/musl/src/stdio/swprintf.c +0 -14
  957. data/modules/emscripten/system/lib/libc/musl/src/stdio/vfwprintf.c +0 -361
  958. data/modules/emscripten/system/lib/libc/musl/src/stdio/vswprintf.c +0 -53
  959. data/modules/emscripten/system/lib/libc/musl/src/stdio/vwprintf.c +0 -7
  960. data/modules/emscripten/system/lib/libc/musl/src/stdio/wprintf.c +0 -13
  961. data/modules/emscripten/system/lib/libc/musl/src/stdlib/ecvt.c +0 -19
  962. data/modules/emscripten/system/lib/libc/musl/src/stdlib/fcvt.c +0 -25
  963. data/modules/emscripten/system/lib/libc/musl/src/stdlib/gcvt.c +0 -8
  964. data/modules/emscripten/system/lib/libc/musl/src/string/wcpcpy.c +0 -6
  965. data/modules/emscripten/system/lib/libc/musl/src/string/wcpncpy.c +0 -6
  966. data/modules/emscripten/system/lib/libc/musl/src/string/wcscasecmp.c +0 -7
  967. data/modules/emscripten/system/lib/libc/musl/src/string/wcscasecmp_l.c +0 -6
  968. data/modules/emscripten/system/lib/libc/musl/src/string/wcscat.c +0 -7
  969. data/modules/emscripten/system/lib/libc/musl/src/string/wcschr.c +0 -8
  970. data/modules/emscripten/system/lib/libc/musl/src/string/wcscmp.c +0 -7
  971. data/modules/emscripten/system/lib/libc/musl/src/string/wcscpy.c +0 -8
  972. data/modules/emscripten/system/lib/libc/musl/src/string/wcscspn.c +0 -10
  973. data/modules/emscripten/system/lib/libc/musl/src/string/wcsdup.c +0 -11
  974. data/modules/emscripten/system/lib/libc/musl/src/string/wcslen.c +0 -8
  975. data/modules/emscripten/system/lib/libc/musl/src/string/wcsncasecmp.c +0 -9
  976. data/modules/emscripten/system/lib/libc/musl/src/string/wcsncasecmp_l.c +0 -6
  977. data/modules/emscripten/system/lib/libc/musl/src/string/wcsncat.c +0 -10
  978. data/modules/emscripten/system/lib/libc/musl/src/string/wcsncmp.c +0 -7
  979. data/modules/emscripten/system/lib/libc/musl/src/string/wcsncpy.c +0 -9
  980. data/modules/emscripten/system/lib/libc/musl/src/string/wcsnlen.c +0 -8
  981. data/modules/emscripten/system/lib/libc/musl/src/string/wcspbrk.c +0 -7
  982. data/modules/emscripten/system/lib/libc/musl/src/string/wcsrchr.c +0 -8
  983. data/modules/emscripten/system/lib/libc/musl/src/string/wcsspn.c +0 -8
  984. data/modules/emscripten/system/lib/libc/musl/src/string/wcsstr.c +0 -108
  985. data/modules/emscripten/system/lib/libc/musl/src/string/wcstok.c +0 -12
  986. data/modules/emscripten/system/lib/libc/musl/src/string/wcswcs.c +0 -6
  987. data/modules/emscripten/system/lib/libc/musl/src/string/wmemchr.c +0 -8
  988. data/modules/emscripten/system/lib/libc/musl/src/string/wmemcmp.c +0 -8
  989. data/modules/emscripten/system/lib/libc/musl/src/string/wmemcpy.c +0 -9
  990. data/modules/emscripten/system/lib/libc/musl/src/string/wmemmove.c +0 -12
  991. data/modules/emscripten/system/lib/libc/musl/src/string/wmemset.c +0 -9
  992. data/modules/emscripten/system/lib/libc/stdlib/getopt_long.c +0 -511
  993. data/modules/emscripten/system/lib/libc/stdlib/strtod.c +0 -305
  994. data/modules/emscripten/system/lib/libc.symbols +0 -81
  995. data/modules/emscripten/system/lib/libcextra.symbols +0 -115
  996. data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +0 -123
  997. data/modules/emscripten/system/lib/libcxx/LICENSE.txt +0 -76
  998. data/modules/emscripten/system/lib/libcxx/algorithm.cpp +0 -84
  999. data/modules/emscripten/system/lib/libcxx/bind.cpp +0 -30
  1000. data/modules/emscripten/system/lib/libcxx/chrono.cpp +0 -132
  1001. data/modules/emscripten/system/lib/libcxx/condition_variable.cpp +0 -81
  1002. data/modules/emscripten/system/lib/libcxx/debug.cpp +0 -530
  1003. data/modules/emscripten/system/lib/libcxx/exception.cpp +0 -307
  1004. data/modules/emscripten/system/lib/libcxx/future.cpp +0 -291
  1005. data/modules/emscripten/system/lib/libcxx/hash.cpp +0 -570
  1006. data/modules/emscripten/system/lib/libcxx/ios.cpp +0 -460
  1007. data/modules/emscripten/system/lib/libcxx/iostream.cpp +0 -68
  1008. data/modules/emscripten/system/lib/libcxx/locale.cpp +0 -6169
  1009. data/modules/emscripten/system/lib/libcxx/memory.cpp +0 -223
  1010. data/modules/emscripten/system/lib/libcxx/mutex.cpp +0 -253
  1011. data/modules/emscripten/system/lib/libcxx/new.cpp +0 -239
  1012. data/modules/emscripten/system/lib/libcxx/optional.cpp +0 -25
  1013. data/modules/emscripten/system/lib/libcxx/random.cpp +0 -74
  1014. data/modules/emscripten/system/lib/libcxx/readme.txt +0 -1
  1015. data/modules/emscripten/system/lib/libcxx/regex.cpp +0 -325
  1016. data/modules/emscripten/system/lib/libcxx/shared_mutex.cpp +0 -101
  1017. data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +0 -200
  1018. data/modules/emscripten/system/lib/libcxx/string.cpp +0 -530
  1019. data/modules/emscripten/system/lib/libcxx/strstream.cpp +0 -329
  1020. data/modules/emscripten/system/lib/libcxx/support/solaris/README +0 -4
  1021. data/modules/emscripten/system/lib/libcxx/support/solaris/mbsnrtowcs.inc +0 -76
  1022. data/modules/emscripten/system/lib/libcxx/support/solaris/wcsnrtombs.inc +0 -93
  1023. data/modules/emscripten/system/lib/libcxx/support/solaris/xlocale.c +0 -245
  1024. data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +0 -95
  1025. data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +0 -166
  1026. data/modules/emscripten/system/lib/libcxx/symbols +0 -2699
  1027. data/modules/emscripten/system/lib/libcxx/system_error.cpp +0 -205
  1028. data/modules/emscripten/system/lib/libcxx/thread.cpp +0 -225
  1029. data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +0 -73
  1030. data/modules/emscripten/system/lib/libcxx/utility.cpp +0 -17
  1031. data/modules/emscripten/system/lib/libcxx/valarray.cpp +0 -56
  1032. data/modules/emscripten/system/lib/libcxxabi/CREDITS.TXT +0 -38
  1033. data/modules/emscripten/system/lib/libcxxabi/LICENSE.TXT +0 -76
  1034. data/modules/emscripten/system/lib/libcxxabi/include/cxa_demangle.h +0 -167
  1035. data/modules/emscripten/system/lib/libcxxabi/include/cxxabi.h +0 -175
  1036. data/modules/emscripten/system/lib/libcxxabi/lib/buildit +0 -99
  1037. data/modules/emscripten/system/lib/libcxxabi/readme.txt +0 -1
  1038. data/modules/emscripten/system/lib/libcxxabi/src/abort_message.cpp +0 -50
  1039. data/modules/emscripten/system/lib/libcxxabi/src/abort_message.h +0 -33
  1040. data/modules/emscripten/system/lib/libcxxabi/src/cxa_aux_runtime.cpp +0 -34
  1041. data/modules/emscripten/system/lib/libcxxabi/src/cxa_demangle.cpp +0 -11036
  1042. data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception.cpp +0 -622
  1043. data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception.hpp +0 -123
  1044. data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception_storage.cpp +0 -91
  1045. data/modules/emscripten/system/lib/libcxxabi/src/cxa_guard.cpp +0 -231
  1046. data/modules/emscripten/system/lib/libcxxabi/src/cxa_handlers.cpp +0 -125
  1047. data/modules/emscripten/system/lib/libcxxabi/src/cxa_handlers.hpp +0 -54
  1048. data/modules/emscripten/system/lib/libcxxabi/src/cxa_new_delete.cpp +0 -242
  1049. data/modules/emscripten/system/lib/libcxxabi/src/cxa_personality.cpp +0 -1055
  1050. data/modules/emscripten/system/lib/libcxxabi/src/cxa_unexpected.cpp +0 -27
  1051. data/modules/emscripten/system/lib/libcxxabi/src/cxa_vector.cpp +0 -367
  1052. data/modules/emscripten/system/lib/libcxxabi/src/cxa_virtual.cpp +0 -31
  1053. data/modules/emscripten/system/lib/libcxxabi/src/exception.cpp +0 -41
  1054. data/modules/emscripten/system/lib/libcxxabi/src/fallback_malloc.ipp +0 -174
  1055. data/modules/emscripten/system/lib/libcxxabi/src/private_typeinfo.cpp +0 -1146
  1056. data/modules/emscripten/system/lib/libcxxabi/src/private_typeinfo.h +0 -248
  1057. data/modules/emscripten/system/lib/libcxxabi/src/stdexcept.cpp +0 -169
  1058. data/modules/emscripten/system/lib/libcxxabi/src/typeinfo.cpp +0 -53
  1059. data/modules/emscripten/system/lib/libcxxabi/symbols +0 -236
  1060. data/modules/emscripten/system/lib/sdl.cpp +0 -13
  1061. data/modules/emscripten/system/lib/sdl.symbols +0 -1
  1062. data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/CppHeaderParser.py +0 -2347
  1063. data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/__init__.py +0 -4
  1064. data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/doc/CppHeaderParser.html +0 -657
  1065. data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/examples/SampleClass.h +0 -147
  1066. data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/examples/readSampleClass.py +0 -74
  1067. data/modules/emscripten/third_party/CppHeaderParser/PKG-INFO +0 -249
  1068. data/modules/emscripten/third_party/CppHeaderParser/README.html +0 -544
  1069. data/modules/emscripten/third_party/CppHeaderParser/README.txt +0 -226
  1070. data/modules/emscripten/third_party/CppHeaderParser/setup.py +0 -43
  1071. data/modules/emscripten/third_party/ansidecl.h +0 -371
  1072. data/modules/emscripten/third_party/closure-compiler/COPYING +0 -202
  1073. data/modules/emscripten/third_party/closure-compiler/README +0 -292
  1074. data/modules/emscripten/third_party/closure-compiler/compiler.jar +0 -0
  1075. data/modules/emscripten/third_party/closure-compiler/readme.txt +0 -3
  1076. data/modules/emscripten/third_party/cp-demangle.h +0 -161
  1077. data/modules/emscripten/third_party/demangle.h +0 -549
  1078. data/modules/emscripten/third_party/demangler.py +0 -49
  1079. data/modules/emscripten/third_party/gcc_demangler.c +0 -4226
  1080. data/modules/emscripten/third_party/gcc_demangler.js +0 -21282
  1081. data/modules/emscripten/third_party/jni/emjvm.cpp +0 -133
  1082. data/modules/emscripten/third_party/jni/emjvm.h +0 -8
  1083. data/modules/emscripten/third_party/jni/emjvm.js +0 -185
  1084. data/modules/emscripten/third_party/jni/jni.h +0 -1154
  1085. data/modules/emscripten/third_party/libiberty.h +0 -634
  1086. data/modules/emscripten/third_party/lzma.js/README.markdown +0 -37
  1087. data/modules/emscripten/third_party/lzma.js/doit.bat +0 -4
  1088. data/modules/emscripten/third_party/lzma.js/doit.sh +0 -44
  1089. data/modules/emscripten/third_party/lzma.js/lzip/AUTHORS +0 -7
  1090. data/modules/emscripten/third_party/lzma.js/lzip/COPYING +0 -676
  1091. data/modules/emscripten/third_party/lzma.js/lzip/ChangeLog +0 -201
  1092. data/modules/emscripten/third_party/lzma.js/lzip/INSTALL +0 -56
  1093. data/modules/emscripten/third_party/lzma.js/lzip/Makefile +0 -160
  1094. data/modules/emscripten/third_party/lzma.js/lzip/Makefile.in +0 -138
  1095. data/modules/emscripten/third_party/lzma.js/lzip/NEWS +0 -22
  1096. data/modules/emscripten/third_party/lzma.js/lzip/README +0 -77
  1097. data/modules/emscripten/third_party/lzma.js/lzip/arg_parser.cc +0 -204
  1098. data/modules/emscripten/third_party/lzma.js/lzip/arg_parser.h +0 -106
  1099. data/modules/emscripten/third_party/lzma.js/lzip/configure +0 -192
  1100. data/modules/emscripten/third_party/lzma.js/lzip/decoder.cc +0 -252
  1101. data/modules/emscripten/third_party/lzma.js/lzip/decoder.h +0 -268
  1102. data/modules/emscripten/third_party/lzma.js/lzip/encoder.cc +0 -643
  1103. data/modules/emscripten/third_party/lzma.js/lzip/encoder.h +0 -582
  1104. data/modules/emscripten/third_party/lzma.js/lzip/fast_encoder.cc +0 -378
  1105. data/modules/emscripten/third_party/lzma.js/lzip/fast_encoder.h +0 -171
  1106. data/modules/emscripten/third_party/lzma.js/lzip/lzip.h +0 -264
  1107. data/modules/emscripten/third_party/lzma.js/lzip/main.cc +0 -545
  1108. data/modules/emscripten/third_party/lzma.js/lzma-decoder.js +0 -27
  1109. data/modules/emscripten/third_party/lzma.js/lzma-full.js +0 -27
  1110. data/modules/emscripten/third_party/lzma.js/native_test.sh +0 -5
  1111. data/modules/emscripten/third_party/lzma.js/post.js +0 -13
  1112. data/modules/emscripten/third_party/lzma.js/pre.js +0 -13
  1113. data/modules/emscripten/third_party/lzma.js/test-decoder.js +0 -39
  1114. data/modules/emscripten/third_party/lzma.js/test-full.html +0 -9
  1115. data/modules/emscripten/third_party/lzma.js/test-full.js +0 -78
  1116. data/modules/emscripten/third_party/ply/ANNOUNCE +0 -40
  1117. data/modules/emscripten/third_party/ply/CHANGES +0 -1093
  1118. data/modules/emscripten/third_party/ply/PKG-INFO +0 -22
  1119. data/modules/emscripten/third_party/ply/README +0 -271
  1120. data/modules/emscripten/third_party/ply/TODO +0 -16
  1121. data/modules/emscripten/third_party/ply/doc/internal.html +0 -874
  1122. data/modules/emscripten/third_party/ply/doc/makedoc.py +0 -194
  1123. data/modules/emscripten/third_party/ply/doc/ply.html +0 -3262
  1124. data/modules/emscripten/third_party/ply/example/BASIC/README +0 -79
  1125. data/modules/emscripten/third_party/ply/example/BASIC/basic.py +0 -71
  1126. data/modules/emscripten/third_party/ply/example/BASIC/basiclex.py +0 -74
  1127. data/modules/emscripten/third_party/ply/example/BASIC/basiclog.py +0 -79
  1128. data/modules/emscripten/third_party/ply/example/BASIC/basinterp.py +0 -441
  1129. data/modules/emscripten/third_party/ply/example/BASIC/basparse.py +0 -424
  1130. data/modules/emscripten/third_party/ply/example/BASIC/dim.bas +0 -14
  1131. data/modules/emscripten/third_party/ply/example/BASIC/func.bas +0 -5
  1132. data/modules/emscripten/third_party/ply/example/BASIC/gcd.bas +0 -22
  1133. data/modules/emscripten/third_party/ply/example/BASIC/gosub.bas +0 -13
  1134. data/modules/emscripten/third_party/ply/example/BASIC/hello.bas +0 -4
  1135. data/modules/emscripten/third_party/ply/example/BASIC/linear.bas +0 -17
  1136. data/modules/emscripten/third_party/ply/example/BASIC/maxsin.bas +0 -12
  1137. data/modules/emscripten/third_party/ply/example/BASIC/powers.bas +0 -13
  1138. data/modules/emscripten/third_party/ply/example/BASIC/rand.bas +0 -4
  1139. data/modules/emscripten/third_party/ply/example/BASIC/sales.bas +0 -20
  1140. data/modules/emscripten/third_party/ply/example/BASIC/sears.bas +0 -18
  1141. data/modules/emscripten/third_party/ply/example/BASIC/sqrt1.bas +0 -5
  1142. data/modules/emscripten/third_party/ply/example/BASIC/sqrt2.bas +0 -4
  1143. data/modules/emscripten/third_party/ply/example/GardenSnake/GardenSnake.py +0 -709
  1144. data/modules/emscripten/third_party/ply/example/GardenSnake/README +0 -5
  1145. data/modules/emscripten/third_party/ply/example/README +0 -10
  1146. data/modules/emscripten/third_party/ply/example/ansic/README +0 -2
  1147. data/modules/emscripten/third_party/ply/example/ansic/clex.py +0 -164
  1148. data/modules/emscripten/third_party/ply/example/ansic/cparse.py +0 -863
  1149. data/modules/emscripten/third_party/ply/example/calc/calc.py +0 -107
  1150. data/modules/emscripten/third_party/ply/example/calcdebug/calc.py +0 -113
  1151. data/modules/emscripten/third_party/ply/example/classcalc/calc.py +0 -157
  1152. data/modules/emscripten/third_party/ply/example/cleanup.sh +0 -2
  1153. data/modules/emscripten/third_party/ply/example/closurecalc/calc.py +0 -130
  1154. data/modules/emscripten/third_party/ply/example/hedit/hedit.py +0 -48
  1155. data/modules/emscripten/third_party/ply/example/newclasscalc/calc.py +0 -160
  1156. data/modules/emscripten/third_party/ply/example/optcalc/README +0 -9
  1157. data/modules/emscripten/third_party/ply/example/optcalc/calc.py +0 -119
  1158. data/modules/emscripten/third_party/ply/example/unicalc/calc.py +0 -117
  1159. data/modules/emscripten/third_party/ply/example/yply/README +0 -41
  1160. data/modules/emscripten/third_party/ply/example/yply/ylex.py +0 -112
  1161. data/modules/emscripten/third_party/ply/example/yply/yparse.py +0 -217
  1162. data/modules/emscripten/third_party/ply/example/yply/yply.py +0 -53
  1163. data/modules/emscripten/third_party/ply/ply/__init__.py +0 -4
  1164. data/modules/emscripten/third_party/ply/ply/cpp.py +0 -898
  1165. data/modules/emscripten/third_party/ply/ply/ctokens.py +0 -133
  1166. data/modules/emscripten/third_party/ply/ply/lex.py +0 -1058
  1167. data/modules/emscripten/third_party/ply/ply/yacc.py +0 -3276
  1168. data/modules/emscripten/third_party/ply/setup.py +0 -31
  1169. data/modules/emscripten/third_party/ply/test/README +0 -7
  1170. data/modules/emscripten/third_party/ply/test/calclex.py +0 -49
  1171. data/modules/emscripten/third_party/ply/test/cleanup.sh +0 -4
  1172. data/modules/emscripten/third_party/ply/test/lex_closure.py +0 -54
  1173. data/modules/emscripten/third_party/ply/test/lex_doc1.py +0 -26
  1174. data/modules/emscripten/third_party/ply/test/lex_dup1.py +0 -29
  1175. data/modules/emscripten/third_party/ply/test/lex_dup2.py +0 -33
  1176. data/modules/emscripten/third_party/ply/test/lex_dup3.py +0 -31
  1177. data/modules/emscripten/third_party/ply/test/lex_empty.py +0 -20
  1178. data/modules/emscripten/third_party/ply/test/lex_error1.py +0 -24
  1179. data/modules/emscripten/third_party/ply/test/lex_error2.py +0 -26
  1180. data/modules/emscripten/third_party/ply/test/lex_error3.py +0 -27
  1181. data/modules/emscripten/third_party/ply/test/lex_error4.py +0 -27
  1182. data/modules/emscripten/third_party/ply/test/lex_hedit.py +0 -47
  1183. data/modules/emscripten/third_party/ply/test/lex_ignore.py +0 -31
  1184. data/modules/emscripten/third_party/ply/test/lex_ignore2.py +0 -29
  1185. data/modules/emscripten/third_party/ply/test/lex_literal1.py +0 -25
  1186. data/modules/emscripten/third_party/ply/test/lex_literal2.py +0 -25
  1187. data/modules/emscripten/third_party/ply/test/lex_many_tokens.py +0 -27
  1188. data/modules/emscripten/third_party/ply/test/lex_module.py +0 -10
  1189. data/modules/emscripten/third_party/ply/test/lex_module_import.py +0 -42
  1190. data/modules/emscripten/third_party/ply/test/lex_object.py +0 -55
  1191. data/modules/emscripten/third_party/ply/test/lex_opt_alias.py +0 -54
  1192. data/modules/emscripten/third_party/ply/test/lex_optimize.py +0 -50
  1193. data/modules/emscripten/third_party/ply/test/lex_optimize2.py +0 -50
  1194. data/modules/emscripten/third_party/ply/test/lex_optimize3.py +0 -52
  1195. data/modules/emscripten/third_party/ply/test/lex_re1.py +0 -27
  1196. data/modules/emscripten/third_party/ply/test/lex_re2.py +0 -27
  1197. data/modules/emscripten/third_party/ply/test/lex_re3.py +0 -29
  1198. data/modules/emscripten/third_party/ply/test/lex_rule1.py +0 -27
  1199. data/modules/emscripten/third_party/ply/test/lex_rule2.py +0 -29
  1200. data/modules/emscripten/third_party/ply/test/lex_rule3.py +0 -27
  1201. data/modules/emscripten/third_party/ply/test/lex_state1.py +0 -40
  1202. data/modules/emscripten/third_party/ply/test/lex_state2.py +0 -40
  1203. data/modules/emscripten/third_party/ply/test/lex_state3.py +0 -42
  1204. data/modules/emscripten/third_party/ply/test/lex_state4.py +0 -41
  1205. data/modules/emscripten/third_party/ply/test/lex_state5.py +0 -40
  1206. data/modules/emscripten/third_party/ply/test/lex_state_noerror.py +0 -39
  1207. data/modules/emscripten/third_party/ply/test/lex_state_norule.py +0 -40
  1208. data/modules/emscripten/third_party/ply/test/lex_state_try.py +0 -45
  1209. data/modules/emscripten/third_party/ply/test/lex_token1.py +0 -19
  1210. data/modules/emscripten/third_party/ply/test/lex_token2.py +0 -22
  1211. data/modules/emscripten/third_party/ply/test/lex_token3.py +0 -24
  1212. data/modules/emscripten/third_party/ply/test/lex_token4.py +0 -26
  1213. data/modules/emscripten/third_party/ply/test/lex_token5.py +0 -31
  1214. data/modules/emscripten/third_party/ply/test/lex_token_dup.py +0 -29
  1215. data/modules/emscripten/third_party/ply/test/testlex.py +0 -606
  1216. data/modules/emscripten/third_party/ply/test/testyacc.py +0 -347
  1217. data/modules/emscripten/third_party/ply/test/yacc_badargs.py +0 -68
  1218. data/modules/emscripten/third_party/ply/test/yacc_badid.py +0 -77
  1219. data/modules/emscripten/third_party/ply/test/yacc_badprec.py +0 -64
  1220. data/modules/emscripten/third_party/ply/test/yacc_badprec2.py +0 -68
  1221. data/modules/emscripten/third_party/ply/test/yacc_badprec3.py +0 -68
  1222. data/modules/emscripten/third_party/ply/test/yacc_badrule.py +0 -68
  1223. data/modules/emscripten/third_party/ply/test/yacc_badtok.py +0 -68
  1224. data/modules/emscripten/third_party/ply/test/yacc_dup.py +0 -68
  1225. data/modules/emscripten/third_party/ply/test/yacc_error1.py +0 -68
  1226. data/modules/emscripten/third_party/ply/test/yacc_error2.py +0 -68
  1227. data/modules/emscripten/third_party/ply/test/yacc_error3.py +0 -67
  1228. data/modules/emscripten/third_party/ply/test/yacc_error4.py +0 -72
  1229. data/modules/emscripten/third_party/ply/test/yacc_inf.py +0 -56
  1230. data/modules/emscripten/third_party/ply/test/yacc_literal.py +0 -69
  1231. data/modules/emscripten/third_party/ply/test/yacc_misplaced.py +0 -68
  1232. data/modules/emscripten/third_party/ply/test/yacc_missing1.py +0 -68
  1233. data/modules/emscripten/third_party/ply/test/yacc_nested.py +0 -33
  1234. data/modules/emscripten/third_party/ply/test/yacc_nodoc.py +0 -67
  1235. data/modules/emscripten/third_party/ply/test/yacc_noerror.py +0 -66
  1236. data/modules/emscripten/third_party/ply/test/yacc_nop.py +0 -68
  1237. data/modules/emscripten/third_party/ply/test/yacc_notfunc.py +0 -66
  1238. data/modules/emscripten/third_party/ply/test/yacc_notok.py +0 -67
  1239. data/modules/emscripten/third_party/ply/test/yacc_prec1.py +0 -68
  1240. data/modules/emscripten/third_party/ply/test/yacc_rr.py +0 -72
  1241. data/modules/emscripten/third_party/ply/test/yacc_rr_unused.py +0 -30
  1242. data/modules/emscripten/third_party/ply/test/yacc_simple.py +0 -68
  1243. data/modules/emscripten/third_party/ply/test/yacc_sr.py +0 -63
  1244. data/modules/emscripten/third_party/ply/test/yacc_term1.py +0 -68
  1245. data/modules/emscripten/third_party/ply/test/yacc_unused.py +0 -77
  1246. data/modules/emscripten/third_party/ply/test/yacc_unused_rule.py +0 -72
  1247. data/modules/emscripten/third_party/ply/test/yacc_uprec.py +0 -63
  1248. data/modules/emscripten/third_party/ply/test/yacc_uprec2.py +0 -63
  1249. data/modules/emscripten/third_party/readme.txt +0 -7
  1250. data/modules/emscripten/third_party/stb_image.c +0 -4673
  1251. data/modules/emscripten/third_party/websockify/CHANGES.txt +0 -23
  1252. data/modules/emscripten/third_party/websockify/LICENSE.txt +0 -16
  1253. data/modules/emscripten/third_party/websockify/MANIFEST.in +0 -1
  1254. data/modules/emscripten/third_party/websockify/Makefile +0 -11
  1255. data/modules/emscripten/third_party/websockify/README.md +0 -168
  1256. data/modules/emscripten/third_party/websockify/Windows/Windows Service Readme.txt +0 -39
  1257. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Program.cs +0 -24
  1258. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.Designer.cs +0 -61
  1259. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.cs +0 -19
  1260. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.resx +0 -129
  1261. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Properties/AssemblyInfo.cs +0 -36
  1262. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Service1.Designer.cs +0 -37
  1263. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Service1.cs +0 -41
  1264. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/noVNC Websocket.csproj +0 -75
  1265. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/noVNC Websocket.sln +0 -20
  1266. data/modules/emscripten/third_party/websockify/docs/LICENSE.GPL-3 +0 -621
  1267. data/modules/emscripten/third_party/websockify/docs/LICENSE.LGPL-3 +0 -165
  1268. data/modules/emscripten/third_party/websockify/docs/LICENSE.MPL-2.0 +0 -373
  1269. data/modules/emscripten/third_party/websockify/docs/TODO +0 -9
  1270. data/modules/emscripten/third_party/websockify/docs/flash_policy.txt +0 -4
  1271. data/modules/emscripten/third_party/websockify/docs/latency_results.txt +0 -114
  1272. data/modules/emscripten/third_party/websockify/docs/notes +0 -17
  1273. data/modules/emscripten/third_party/websockify/docs/release.txt +0 -9
  1274. data/modules/emscripten/third_party/websockify/docs/websockify.1 +0 -110
  1275. data/modules/emscripten/third_party/websockify/include/VT100.js +0 -919
  1276. data/modules/emscripten/third_party/websockify/include/base64.js +0 -114
  1277. data/modules/emscripten/third_party/websockify/include/keysym.js +0 -99
  1278. data/modules/emscripten/third_party/websockify/include/util.js +0 -359
  1279. data/modules/emscripten/third_party/websockify/include/web-socket-js/README.txt +0 -109
  1280. data/modules/emscripten/third_party/websockify/include/web-socket-js/WebSocketMain.swf +0 -0
  1281. data/modules/emscripten/third_party/websockify/include/web-socket-js/swfobject.js +0 -4
  1282. data/modules/emscripten/third_party/websockify/include/web-socket-js/web_socket.js +0 -391
  1283. data/modules/emscripten/third_party/websockify/include/websock.js +0 -422
  1284. data/modules/emscripten/third_party/websockify/include/webutil.js +0 -216
  1285. data/modules/emscripten/third_party/websockify/include/wsirc.js +0 -235
  1286. data/modules/emscripten/third_party/websockify/include/wstelnet.js +0 -335
  1287. data/modules/emscripten/third_party/websockify/other/Makefile +0 -14
  1288. data/modules/emscripten/third_party/websockify/other/README.md +0 -51
  1289. data/modules/emscripten/third_party/websockify/other/launch.sh +0 -108
  1290. data/modules/emscripten/third_party/websockify/other/project.clj +0 -13
  1291. data/modules/emscripten/third_party/websockify/other/websocket.c +0 -802
  1292. data/modules/emscripten/third_party/websockify/other/websocket.h +0 -84
  1293. data/modules/emscripten/third_party/websockify/other/websocket.rb +0 -456
  1294. data/modules/emscripten/third_party/websockify/other/websockify.c +0 -385
  1295. data/modules/emscripten/third_party/websockify/other/websockify.clj +0 -233
  1296. data/modules/emscripten/third_party/websockify/other/websockify.js +0 -196
  1297. data/modules/emscripten/third_party/websockify/other/websockify.rb +0 -171
  1298. data/modules/emscripten/third_party/websockify/other/wswrap +0 -22
  1299. data/modules/emscripten/third_party/websockify/rebind +0 -18
  1300. data/modules/emscripten/third_party/websockify/rebind.c +0 -94
  1301. data/modules/emscripten/third_party/websockify/run +0 -5
  1302. data/modules/emscripten/third_party/websockify/setup.py +0 -30
  1303. data/modules/emscripten/third_party/websockify/tests/b64_vs_utf8.py +0 -29
  1304. data/modules/emscripten/third_party/websockify/tests/base64.html +0 -91
  1305. data/modules/emscripten/third_party/websockify/tests/base64.js +0 -12
  1306. data/modules/emscripten/third_party/websockify/tests/echo.html +0 -148
  1307. data/modules/emscripten/third_party/websockify/tests/echo.py +0 -75
  1308. data/modules/emscripten/third_party/websockify/tests/echo.rb +0 -62
  1309. data/modules/emscripten/third_party/websockify/tests/latency.html +0 -290
  1310. data/modules/emscripten/third_party/websockify/tests/latency.py +0 -75
  1311. data/modules/emscripten/third_party/websockify/tests/load.html +0 -250
  1312. data/modules/emscripten/third_party/websockify/tests/load.py +0 -167
  1313. data/modules/emscripten/third_party/websockify/tests/plain_echo.html +0 -168
  1314. data/modules/emscripten/third_party/websockify/tests/simple.html +0 -68
  1315. data/modules/emscripten/third_party/websockify/tests/utf8-list.py +0 -22
  1316. data/modules/emscripten/third_party/websockify/websockify/__init__.py +0 -2
  1317. data/modules/emscripten/third_party/websockify/websockify/websocket.py +0 -982
  1318. data/modules/emscripten/third_party/websockify/websockify/websocketproxy.py +0 -393
  1319. data/modules/emscripten/third_party/websockify/websockify.py +0 -5
  1320. data/modules/emscripten/third_party/websockify/wsirc.html +0 -99
  1321. data/modules/emscripten/third_party/websockify/wstelnet.html +0 -74
  1322. data/modules/emscripten/tools/__init__.py +0 -0
  1323. data/modules/emscripten/tools/asm_module.py +0 -275
  1324. data/modules/emscripten/tools/autodebugger.py +0 -291
  1325. data/modules/emscripten/tools/autodebugger_c.py +0 -37
  1326. data/modules/emscripten/tools/autodebugger_indenter.py +0 -18
  1327. data/modules/emscripten/tools/autodebugger_js.py +0 -47
  1328. data/modules/emscripten/tools/autodediffer.py +0 -60
  1329. data/modules/emscripten/tools/bindings_generator.py +0 -832
  1330. data/modules/emscripten/tools/bisect_pair.py +0 -88
  1331. data/modules/emscripten/tools/cache.py +0 -196
  1332. data/modules/emscripten/tools/clean_webconsole.py +0 -34
  1333. data/modules/emscripten/tools/crunch-worker.js +0 -124
  1334. data/modules/emscripten/tools/diff_autodebugger.py +0 -15
  1335. data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +0 -307
  1336. data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +0 -382
  1337. data/modules/emscripten/tools/eliminator/eliminator-test-output.js +0 -6136
  1338. data/modules/emscripten/tools/eliminator/eliminator-test.js +0 -8879
  1339. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/README.html +0 -888
  1340. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/README.org +0 -463
  1341. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/bin/uglifyjs +0 -317
  1342. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/docstyle.css +0 -75
  1343. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/object-ast.js +0 -75
  1344. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js +0 -1363
  1345. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/process.js +0 -2005
  1346. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/squeeze-more.js +0 -51
  1347. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/package.json +0 -22
  1348. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/beautify.js +0 -28
  1349. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/testparser.js +0 -402
  1350. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array1.js +0 -1
  1351. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array2.js +0 -1
  1352. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array3.js +0 -1
  1353. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array4.js +0 -1
  1354. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/assignment.js +0 -1
  1355. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +0 -1
  1356. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/const.js +0 -1
  1357. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +0 -1
  1358. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +0 -1
  1359. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/if.js +0 -1
  1360. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +0 -1
  1361. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/ifreturn2.js +0 -1
  1362. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue10.js +0 -1
  1363. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue11.js +0 -1
  1364. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue13.js +0 -1
  1365. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue14.js +0 -1
  1366. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue16.js +0 -1
  1367. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue17.js +0 -1
  1368. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue20.js +0 -1
  1369. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue21.js +0 -1
  1370. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue25.js +0 -1
  1371. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue27.js +0 -1
  1372. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue28.js +0 -1
  1373. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue29.js +0 -1
  1374. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue30.js +0 -1
  1375. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue34.js +0 -1
  1376. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue4.js +0 -1
  1377. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue48.js +0 -1
  1378. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue50.js +0 -1
  1379. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue53.js +0 -1
  1380. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +0 -1
  1381. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue68.js +0 -1
  1382. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue69.js +0 -1
  1383. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue9.js +0 -1
  1384. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/mangle.js +0 -1
  1385. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +0 -1
  1386. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/var.js +0 -1
  1387. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/with.js +0 -1
  1388. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array1.js +0 -3
  1389. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array2.js +0 -4
  1390. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array3.js +0 -4
  1391. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array4.js +0 -6
  1392. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/assignment.js +0 -20
  1393. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/concatstring.js +0 -3
  1394. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/const.js +0 -5
  1395. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +0 -4
  1396. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/forstatement.js +0 -10
  1397. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/if.js +0 -6
  1398. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +0 -9
  1399. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/ifreturn2.js +0 -16
  1400. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue10.js +0 -1
  1401. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue11.js +0 -3
  1402. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue13.js +0 -1
  1403. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue14.js +0 -1
  1404. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue16.js +0 -1
  1405. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue17.js +0 -4
  1406. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue20.js +0 -1
  1407. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue21.js +0 -6
  1408. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue25.js +0 -7
  1409. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue27.js +0 -1
  1410. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue28.js +0 -3
  1411. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue29.js +0 -1
  1412. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue30.js +0 -3
  1413. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue34.js +0 -3
  1414. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue4.js +0 -3
  1415. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue48.js +0 -1
  1416. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue50.js +0 -9
  1417. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue53.js +0 -1
  1418. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +0 -3
  1419. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue68.js +0 -5
  1420. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue69.js +0 -1
  1421. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue9.js +0 -4
  1422. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/mangle.js +0 -5
  1423. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +0 -3
  1424. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/var.js +0 -3
  1425. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/with.js +0 -2
  1426. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/scripts.js +0 -55
  1427. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/hoist.js +0 -33
  1428. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/instrument.js +0 -97
  1429. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/instrument2.js +0 -138
  1430. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/test.js +0 -16
  1431. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/uglify-js.js +0 -17
  1432. data/modules/emscripten/tools/eliminator/safe-eliminator-test-output.js +0 -85
  1433. data/modules/emscripten/tools/eliminator/safe-eliminator-test.js +0 -103
  1434. data/modules/emscripten/tools/emconfiguren.py +0 -19
  1435. data/modules/emscripten/tools/emmaken.py +0 -230
  1436. data/modules/emscripten/tools/emmakenxx.py +0 -18
  1437. data/modules/emscripten/tools/exec_llvm.py +0 -50
  1438. data/modules/emscripten/tools/file2json.py +0 -49
  1439. data/modules/emscripten/tools/file_packager.py +0 -719
  1440. data/modules/emscripten/tools/find_bigfuncs.py +0 -23
  1441. data/modules/emscripten/tools/find_bigis.py +0 -18
  1442. data/modules/emscripten/tools/find_bigvars.py +0 -24
  1443. data/modules/emscripten/tools/fix_closure.py +0 -88
  1444. data/modules/emscripten/tools/gen_struct_info.py +0 -509
  1445. data/modules/emscripten/tools/ie7_fix.py +0 -14
  1446. data/modules/emscripten/tools/js-optimizer.js +0 -4023
  1447. data/modules/emscripten/tools/js_optimizer.py +0 -357
  1448. data/modules/emscripten/tools/jsrun.py +0 -37
  1449. data/modules/emscripten/tools/ll-strip.py +0 -56
  1450. data/modules/emscripten/tools/make_file.py +0 -19
  1451. data/modules/emscripten/tools/make_minigzip.py +0 -13
  1452. data/modules/emscripten/tools/merge_asm.py +0 -26
  1453. data/modules/emscripten/tools/namespacer.py +0 -95
  1454. data/modules/emscripten/tools/nativize_llvm.py +0 -34
  1455. data/modules/emscripten/tools/node_modules/source-map/CHANGELOG.md +0 -58
  1456. data/modules/emscripten/tools/node_modules/source-map/LICENSE +0 -28
  1457. data/modules/emscripten/tools/node_modules/source-map/Makefile.dryice.js +0 -166
  1458. data/modules/emscripten/tools/node_modules/source-map/README.md +0 -347
  1459. data/modules/emscripten/tools/node_modules/source-map/build/assert-shim.js +0 -56
  1460. data/modules/emscripten/tools/node_modules/source-map/build/mini-require.js +0 -152
  1461. data/modules/emscripten/tools/node_modules/source-map/build/prefix-source-map.jsm +0 -20
  1462. data/modules/emscripten/tools/node_modules/source-map/build/prefix-utils.jsm +0 -18
  1463. data/modules/emscripten/tools/node_modules/source-map/build/suffix-browser.js +0 -8
  1464. data/modules/emscripten/tools/node_modules/source-map/build/suffix-source-map.jsm +0 -6
  1465. data/modules/emscripten/tools/node_modules/source-map/build/suffix-utils.jsm +0 -21
  1466. data/modules/emscripten/tools/node_modules/source-map/build/test-prefix.js +0 -8
  1467. data/modules/emscripten/tools/node_modules/source-map/build/test-suffix.js +0 -3
  1468. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/array-set.js +0 -96
  1469. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/base64-vlq.js +0 -144
  1470. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js +0 -42
  1471. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/binary-search.js +0 -81
  1472. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-map-consumer.js +0 -430
  1473. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-map-generator.js +0 -381
  1474. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-node.js +0 -353
  1475. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/util.js +0 -117
  1476. data/modules/emscripten/tools/node_modules/source-map/lib/source-map.js +0 -8
  1477. data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/LICENSE +0 -58
  1478. data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/README.md +0 -119
  1479. data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/amdefine.js +0 -299
  1480. data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/package.json +0 -33
  1481. data/modules/emscripten/tools/node_modules/source-map/package.json +0 -74
  1482. data/modules/emscripten/tools/node_modules/source-map/test/run-tests.js +0 -73
  1483. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-api.js +0 -26
  1484. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-array-set.js +0 -71
  1485. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-base64-vlq.js +0 -24
  1486. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-base64.js +0 -35
  1487. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-binary-search.js +0 -54
  1488. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-dog-fooding.js +0 -72
  1489. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-map-consumer.js +0 -306
  1490. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-map-generator.js +0 -391
  1491. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-node.js +0 -282
  1492. data/modules/emscripten/tools/node_modules/source-map/test/source-map/util.js +0 -152
  1493. data/modules/emscripten/tools/reproduceriter.js +0 -216
  1494. data/modules/emscripten/tools/reproduceriter.py +0 -160
  1495. data/modules/emscripten/tools/response_file.py +0 -34
  1496. data/modules/emscripten/tools/scan_js.py +0 -20
  1497. data/modules/emscripten/tools/scan_ll.py +0 -18
  1498. data/modules/emscripten/tools/scons/site_scons/site_tools/emscripten/__init__.py +0 -3
  1499. data/modules/emscripten/tools/scons/site_scons/site_tools/emscripten/emscripten.py +0 -46
  1500. data/modules/emscripten/tools/settings_template_readonly.py +0 -49
  1501. data/modules/emscripten/tools/shared.py +0 -1705
  1502. data/modules/emscripten/tools/source-maps/sourcemap2json.js +0 -15
  1503. data/modules/emscripten/tools/source-maps/sourcemapper.js +0 -208
  1504. data/modules/emscripten/tools/split.py +0 -105
  1505. data/modules/emscripten/tools/split_asm.py +0 -30
  1506. data/modules/emscripten/tools/tempfiles.py +0 -41
  1507. data/modules/emscripten/tools/test-js-optimizer-asm-last-output.js +0 -75
  1508. data/modules/emscripten/tools/test-js-optimizer-asm-last.js +0 -91
  1509. data/modules/emscripten/tools/test-js-optimizer-asm-minlast-output.js +0 -2
  1510. data/modules/emscripten/tools/test-js-optimizer-asm-minlast.js +0 -8
  1511. data/modules/emscripten/tools/test-js-optimizer-asm-outline1-output.js +0 -929
  1512. data/modules/emscripten/tools/test-js-optimizer-asm-outline1.js +0 -351
  1513. data/modules/emscripten/tools/test-js-optimizer-asm-outline2-output.js +0 -793
  1514. data/modules/emscripten/tools/test-js-optimizer-asm-outline2.js +0 -606
  1515. data/modules/emscripten/tools/test-js-optimizer-asm-outline3-output.js +0 -28
  1516. data/modules/emscripten/tools/test-js-optimizer-asm-outline3.js +0 -30
  1517. data/modules/emscripten/tools/test-js-optimizer-asm-pre-output.js +0 -522
  1518. data/modules/emscripten/tools/test-js-optimizer-asm-pre.js +0 -533
  1519. data/modules/emscripten/tools/test-js-optimizer-asm-regs-min-output.js +0 -36
  1520. data/modules/emscripten/tools/test-js-optimizer-asm-regs-min.js +0 -37
  1521. data/modules/emscripten/tools/test-js-optimizer-asm-regs-output.js +0 -106
  1522. data/modules/emscripten/tools/test-js-optimizer-asm-regs.js +0 -110
  1523. data/modules/emscripten/tools/test-js-optimizer-asm-relocate-output.js +0 -9
  1524. data/modules/emscripten/tools/test-js-optimizer-asm-relocate.js +0 -12
  1525. data/modules/emscripten/tools/test-js-optimizer-output.js +0 -291
  1526. data/modules/emscripten/tools/test-js-optimizer-regs-output.js +0 -232
  1527. data/modules/emscripten/tools/test-js-optimizer-regs.js +0 -237
  1528. data/modules/emscripten/tools/test-js-optimizer-t2-output.js +0 -91
  1529. data/modules/emscripten/tools/test-js-optimizer-t2.js +0 -92
  1530. data/modules/emscripten/tools/test-js-optimizer-t2c-output.js +0 -17
  1531. data/modules/emscripten/tools/test-js-optimizer-t2c.js +0 -18
  1532. data/modules/emscripten/tools/test-js-optimizer-t3-output.js +0 -49
  1533. data/modules/emscripten/tools/test-js-optimizer-t3.js +0 -50
  1534. data/modules/emscripten/tools/test-js-optimizer.js +0 -401
  1535. data/modules/emscripten/tools/validate_asmjs.py +0 -82
  1536. data/modules/mruby/mrblib/print.rb +0 -18
  1537. data/modules/mruby/src/re.h +0 -12
@@ -1,3262 +0,0 @@
1
- <html>
2
- <head>
3
- <title>PLY (Python Lex-Yacc)</title>
4
- </head>
5
- <body bgcolor="#ffffff">
6
-
7
- <h1>PLY (Python Lex-Yacc)</h1>
8
-
9
- <b>
10
- David M. Beazley <br>
11
- dave@dabeaz.com<br>
12
- </b>
13
-
14
- <p>
15
- <b>PLY Version: 3.4</b>
16
- <p>
17
-
18
- <!-- INDEX -->
19
- <div class="sectiontoc">
20
- <ul>
21
- <li><a href="#ply_nn1">Preface and Requirements</a>
22
- <li><a href="#ply_nn1">Introduction</a>
23
- <li><a href="#ply_nn2">PLY Overview</a>
24
- <li><a href="#ply_nn3">Lex</a>
25
- <ul>
26
- <li><a href="#ply_nn4">Lex Example</a>
27
- <li><a href="#ply_nn5">The tokens list</a>
28
- <li><a href="#ply_nn6">Specification of tokens</a>
29
- <li><a href="#ply_nn7">Token values</a>
30
- <li><a href="#ply_nn8">Discarded tokens</a>
31
- <li><a href="#ply_nn9">Line numbers and positional information</a>
32
- <li><a href="#ply_nn10">Ignored characters</a>
33
- <li><a href="#ply_nn11">Literal characters</a>
34
- <li><a href="#ply_nn12">Error handling</a>
35
- <li><a href="#ply_nn13">Building and using the lexer</a>
36
- <li><a href="#ply_nn14">The @TOKEN decorator</a>
37
- <li><a href="#ply_nn15">Optimized mode</a>
38
- <li><a href="#ply_nn16">Debugging</a>
39
- <li><a href="#ply_nn17">Alternative specification of lexers</a>
40
- <li><a href="#ply_nn18">Maintaining state</a>
41
- <li><a href="#ply_nn19">Lexer cloning</a>
42
- <li><a href="#ply_nn20">Internal lexer state</a>
43
- <li><a href="#ply_nn21">Conditional lexing and start conditions</a>
44
- <li><a href="#ply_nn21">Miscellaneous Issues</a>
45
- </ul>
46
- <li><a href="#ply_nn22">Parsing basics</a>
47
- <li><a href="#ply_nn23">Yacc</a>
48
- <ul>
49
- <li><a href="#ply_nn24">An example</a>
50
- <li><a href="#ply_nn25">Combining Grammar Rule Functions</a>
51
- <li><a href="#ply_nn26">Character Literals</a>
52
- <li><a href="#ply_nn26">Empty Productions</a>
53
- <li><a href="#ply_nn28">Changing the starting symbol</a>
54
- <li><a href="#ply_nn27">Dealing With Ambiguous Grammars</a>
55
- <li><a href="#ply_nn28">The parser.out file</a>
56
- <li><a href="#ply_nn29">Syntax Error Handling</a>
57
- <ul>
58
- <li><a href="#ply_nn30">Recovery and resynchronization with error rules</a>
59
- <li><a href="#ply_nn31">Panic mode recovery</a>
60
- <li><a href="#ply_nn35">Signaling an error from a production</a>
61
- <li><a href="#ply_nn32">General comments on error handling</a>
62
- </ul>
63
- <li><a href="#ply_nn33">Line Number and Position Tracking</a>
64
- <li><a href="#ply_nn34">AST Construction</a>
65
- <li><a href="#ply_nn35">Embedded Actions</a>
66
- <li><a href="#ply_nn36">Miscellaneous Yacc Notes</a>
67
- </ul>
68
- <li><a href="#ply_nn37">Multiple Parsers and Lexers</a>
69
- <li><a href="#ply_nn38">Using Python's Optimized Mode</a>
70
- <li><a href="#ply_nn44">Advanced Debugging</a>
71
- <ul>
72
- <li><a href="#ply_nn45">Debugging the lex() and yacc() commands</a>
73
- <li><a href="#ply_nn46">Run-time Debugging</a>
74
- </ul>
75
- <li><a href="#ply_nn39">Where to go from here?</a>
76
- </ul>
77
- </div>
78
- <!-- INDEX -->
79
-
80
-
81
-
82
- <H2><a name="ply_nn1"></a>1. Preface and Requirements</H2>
83
-
84
-
85
- <p>
86
- This document provides an overview of lexing and parsing with PLY.
87
- Given the intrinsic complexity of parsing, I would strongly advise
88
- that you read (or at least skim) this entire document before jumping
89
- into a big development project with PLY.
90
- </p>
91
-
92
- <p>
93
- PLY-3.0 is compatible with both Python 2 and Python 3. Be aware that
94
- Python 3 support is new and has not been extensively tested (although
95
- all of the examples and unit tests pass under Python 3.0). If you are
96
- using Python 2, you should try to use Python 2.4 or newer. Although PLY
97
- works with versions as far back as Python 2.2, some of its optional features
98
- require more modern library modules.
99
- </p>
100
-
101
- <H2><a name="ply_nn1"></a>2. Introduction</H2>
102
-
103
-
104
- PLY is a pure-Python implementation of the popular compiler
105
- construction tools lex and yacc. The main goal of PLY is to stay
106
- fairly faithful to the way in which traditional lex/yacc tools work.
107
- This includes supporting LALR(1) parsing as well as providing
108
- extensive input validation, error reporting, and diagnostics. Thus,
109
- if you've used yacc in another programming language, it should be
110
- relatively straightforward to use PLY.
111
-
112
- <p>
113
- Early versions of PLY were developed to support an Introduction to
114
- Compilers Course I taught in 2001 at the University of Chicago. In this course,
115
- students built a fully functional compiler for a simple Pascal-like
116
- language. Their compiler, implemented entirely in Python, had to
117
- include lexical analysis, parsing, type checking, type inference,
118
- nested scoping, and code generation for the SPARC processor.
119
- Approximately 30 different compiler implementations were completed in
120
- this course. Most of PLY's interface and operation has been influenced by common
121
- usability problems encountered by students. Since 2001, PLY has
122
- continued to be improved as feedback has been received from users.
123
- PLY-3.0 represents a major refactoring of the original implementation
124
- with an eye towards future enhancements.
125
-
126
- <p>
127
- Since PLY was primarily developed as an instructional tool, you will
128
- find it to be fairly picky about token and grammar rule
129
- specification. In part, this
130
- added formality is meant to catch common programming mistakes made by
131
- novice users. However, advanced users will also find such features to
132
- be useful when building complicated grammars for real programming
133
- languages. It should also be noted that PLY does not provide much in
134
- the way of bells and whistles (e.g., automatic construction of
135
- abstract syntax trees, tree traversal, etc.). Nor would I consider it
136
- to be a parsing framework. Instead, you will find a bare-bones, yet
137
- fully capable lex/yacc implementation written entirely in Python.
138
-
139
- <p>
140
- The rest of this document assumes that you are somewhat familar with
141
- parsing theory, syntax directed translation, and the use of compiler
142
- construction tools such as lex and yacc in other programming
143
- languages. If you are unfamilar with these topics, you will probably
144
- want to consult an introductory text such as "Compilers: Principles,
145
- Techniques, and Tools", by Aho, Sethi, and Ullman. O'Reilly's "Lex
146
- and Yacc" by John Levine may also be handy. In fact, the O'Reilly book can be
147
- used as a reference for PLY as the concepts are virtually identical.
148
-
149
- <H2><a name="ply_nn2"></a>3. PLY Overview</H2>
150
-
151
-
152
- PLY consists of two separate modules; <tt>lex.py</tt> and
153
- <tt>yacc.py</tt>, both of which are found in a Python package
154
- called <tt>ply</tt>. The <tt>lex.py</tt> module is used to break input text into a
155
- collection of tokens specified by a collection of regular expression
156
- rules. <tt>yacc.py</tt> is used to recognize language syntax that has
157
- been specified in the form of a context free grammar. <tt>yacc.py</tt> uses LR parsing and generates its parsing tables
158
- using either the LALR(1) (the default) or SLR table generation algorithms.
159
-
160
- <p>
161
- The two tools are meant to work together. Specifically,
162
- <tt>lex.py</tt> provides an external interface in the form of a
163
- <tt>token()</tt> function that returns the next valid token on the
164
- input stream. <tt>yacc.py</tt> calls this repeatedly to retrieve
165
- tokens and invoke grammar rules. The output of <tt>yacc.py</tt> is
166
- often an Abstract Syntax Tree (AST). However, this is entirely up to
167
- the user. If desired, <tt>yacc.py</tt> can also be used to implement
168
- simple one-pass compilers.
169
-
170
- <p>
171
- Like its Unix counterpart, <tt>yacc.py</tt> provides most of the
172
- features you expect including extensive error checking, grammar
173
- validation, support for empty productions, error tokens, and ambiguity
174
- resolution via precedence rules. In fact, everything that is possible in traditional yacc
175
- should be supported in PLY.
176
-
177
- <p>
178
- The primary difference between
179
- <tt>yacc.py</tt> and Unix <tt>yacc</tt> is that <tt>yacc.py</tt>
180
- doesn't involve a separate code-generation process.
181
- Instead, PLY relies on reflection (introspection)
182
- to build its lexers and parsers. Unlike traditional lex/yacc which
183
- require a special input file that is converted into a separate source
184
- file, the specifications given to PLY <em>are</em> valid Python
185
- programs. This means that there are no extra source files nor is
186
- there a special compiler construction step (e.g., running yacc to
187
- generate Python code for the compiler). Since the generation of the
188
- parsing tables is relatively expensive, PLY caches the results and
189
- saves them to a file. If no changes are detected in the input source,
190
- the tables are read from the cache. Otherwise, they are regenerated.
191
-
192
- <H2><a name="ply_nn3"></a>4. Lex</H2>
193
-
194
-
195
- <tt>lex.py</tt> is used to tokenize an input string. For example, suppose
196
- you're writing a programming language and a user supplied the following input string:
197
-
198
- <blockquote>
199
- <pre>
200
- x = 3 + 42 * (s - t)
201
- </pre>
202
- </blockquote>
203
-
204
- A tokenizer splits the string into individual tokens
205
-
206
- <blockquote>
207
- <pre>
208
- 'x','=', '3', '+', '42', '*', '(', 's', '-', 't', ')'
209
- </pre>
210
- </blockquote>
211
-
212
- Tokens are usually given names to indicate what they are. For example:
213
-
214
- <blockquote>
215
- <pre>
216
- 'ID','EQUALS','NUMBER','PLUS','NUMBER','TIMES',
217
- 'LPAREN','ID','MINUS','ID','RPAREN'
218
- </pre>
219
- </blockquote>
220
-
221
- More specifically, the input is broken into pairs of token types and values. For example:
222
-
223
- <blockquote>
224
- <pre>
225
- ('ID','x'), ('EQUALS','='), ('NUMBER','3'),
226
- ('PLUS','+'), ('NUMBER','42), ('TIMES','*'),
227
- ('LPAREN','('), ('ID','s'), ('MINUS','-'),
228
- ('ID','t'), ('RPAREN',')'
229
- </pre>
230
- </blockquote>
231
-
232
- The identification of tokens is typically done by writing a series of regular expression
233
- rules. The next section shows how this is done using <tt>lex.py</tt>.
234
-
235
- <H3><a name="ply_nn4"></a>4.1 Lex Example</H3>
236
-
237
-
238
- The following example shows how <tt>lex.py</tt> is used to write a simple tokenizer.
239
-
240
- <blockquote>
241
- <pre>
242
- # ------------------------------------------------------------
243
- # calclex.py
244
- #
245
- # tokenizer for a simple expression evaluator for
246
- # numbers and +,-,*,/
247
- # ------------------------------------------------------------
248
- import ply.lex as lex
249
-
250
- # List of token names. This is always required
251
- tokens = (
252
- 'NUMBER',
253
- 'PLUS',
254
- 'MINUS',
255
- 'TIMES',
256
- 'DIVIDE',
257
- 'LPAREN',
258
- 'RPAREN',
259
- )
260
-
261
- # Regular expression rules for simple tokens
262
- t_PLUS = r'\+'
263
- t_MINUS = r'-'
264
- t_TIMES = r'\*'
265
- t_DIVIDE = r'/'
266
- t_LPAREN = r'\('
267
- t_RPAREN = r'\)'
268
-
269
- # A regular expression rule with some action code
270
- def t_NUMBER(t):
271
- r'\d+'
272
- t.value = int(t.value)
273
- return t
274
-
275
- # Define a rule so we can track line numbers
276
- def t_newline(t):
277
- r'\n+'
278
- t.lexer.lineno += len(t.value)
279
-
280
- # A string containing ignored characters (spaces and tabs)
281
- t_ignore = ' \t'
282
-
283
- # Error handling rule
284
- def t_error(t):
285
- print "Illegal character '%s'" % t.value[0]
286
- t.lexer.skip(1)
287
-
288
- # Build the lexer
289
- lexer = lex.lex()
290
-
291
- </pre>
292
- </blockquote>
293
- To use the lexer, you first need to feed it some input text using
294
- its <tt>input()</tt> method. After that, repeated calls
295
- to <tt>token()</tt> produce tokens. The following code shows how this
296
- works:
297
-
298
- <blockquote>
299
- <pre>
300
-
301
- # Test it out
302
- data = '''
303
- 3 + 4 * 10
304
- + -20 *2
305
- '''
306
-
307
- # Give the lexer some input
308
- lexer.input(data)
309
-
310
- # Tokenize
311
- while True:
312
- tok = lexer.token()
313
- if not tok: break # No more input
314
- print tok
315
- </pre>
316
- </blockquote>
317
-
318
- When executed, the example will produce the following output:
319
-
320
- <blockquote>
321
- <pre>
322
- $ python example.py
323
- LexToken(NUMBER,3,2,1)
324
- LexToken(PLUS,'+',2,3)
325
- LexToken(NUMBER,4,2,5)
326
- LexToken(TIMES,'*',2,7)
327
- LexToken(NUMBER,10,2,10)
328
- LexToken(PLUS,'+',3,14)
329
- LexToken(MINUS,'-',3,16)
330
- LexToken(NUMBER,20,3,18)
331
- LexToken(TIMES,'*',3,20)
332
- LexToken(NUMBER,2,3,21)
333
- </pre>
334
- </blockquote>
335
-
336
- Lexers also support the iteration protocol. So, you can write the above loop as follows:
337
-
338
- <blockquote>
339
- <pre>
340
- for tok in lexer:
341
- print tok
342
- </pre>
343
- </blockquote>
344
-
345
- The tokens returned by <tt>lexer.token()</tt> are instances
346
- of <tt>LexToken</tt>. This object has
347
- attributes <tt>tok.type</tt>, <tt>tok.value</tt>,
348
- <tt>tok.lineno</tt>, and <tt>tok.lexpos</tt>. The following code shows an example of
349
- accessing these attributes:
350
-
351
- <blockquote>
352
- <pre>
353
- # Tokenize
354
- while True:
355
- tok = lexer.token()
356
- if not tok: break # No more input
357
- print tok.type, tok.value, tok.line, tok.lexpos
358
- </pre>
359
- </blockquote>
360
-
361
- The <tt>tok.type</tt> and <tt>tok.value</tt> attributes contain the
362
- type and value of the token itself.
363
- <tt>tok.line</tt> and <tt>tok.lexpos</tt> contain information about
364
- the location of the token. <tt>tok.lexpos</tt> is the index of the
365
- token relative to the start of the input text.
366
-
367
- <H3><a name="ply_nn5"></a>4.2 The tokens list</H3>
368
-
369
-
370
- All lexers must provide a list <tt>tokens</tt> that defines all of the possible token
371
- names that can be produced by the lexer. This list is always required
372
- and is used to perform a variety of validation checks. The tokens list is also used by the
373
- <tt>yacc.py</tt> module to identify terminals.
374
-
375
- <p>
376
- In the example, the following code specified the token names:
377
-
378
- <blockquote>
379
- <pre>
380
- tokens = (
381
- 'NUMBER',
382
- 'PLUS',
383
- 'MINUS',
384
- 'TIMES',
385
- 'DIVIDE',
386
- 'LPAREN',
387
- 'RPAREN',
388
- )
389
- </pre>
390
- </blockquote>
391
-
392
- <H3><a name="ply_nn6"></a>4.3 Specification of tokens</H3>
393
-
394
-
395
- Each token is specified by writing a regular expression rule. Each of these rules are
396
- are defined by making declarations with a special prefix <tt>t_</tt> to indicate that it
397
- defines a token. For simple tokens, the regular expression can
398
- be specified as strings such as this (note: Python raw strings are used since they are the
399
- most convenient way to write regular expression strings):
400
-
401
- <blockquote>
402
- <pre>
403
- t_PLUS = r'\+'
404
- </pre>
405
- </blockquote>
406
-
407
- In this case, the name following the <tt>t_</tt> must exactly match one of the
408
- names supplied in <tt>tokens</tt>. If some kind of action needs to be performed,
409
- a token rule can be specified as a function. For example, this rule matches numbers and
410
- converts the string into a Python integer.
411
-
412
- <blockquote>
413
- <pre>
414
- def t_NUMBER(t):
415
- r'\d+'
416
- t.value = int(t.value)
417
- return t
418
- </pre>
419
- </blockquote>
420
-
421
- When a function is used, the regular expression rule is specified in the function documentation string.
422
- The function always takes a single argument which is an instance of
423
- <tt>LexToken</tt>. This object has attributes of <tt>t.type</tt> which is the token type (as a string),
424
- <tt>t.value</tt> which is the lexeme (the actual text matched), <tt>t.lineno</tt> which is the current line number, and <tt>t.lexpos</tt> which
425
- is the position of the token relative to the beginning of the input text.
426
- By default, <tt>t.type</tt> is set to the name following the <tt>t_</tt> prefix. The action
427
- function can modify the contents of the <tt>LexToken</tt> object as appropriate. However,
428
- when it is done, the resulting token should be returned. If no value is returned by the action
429
- function, the token is simply discarded and the next token read.
430
-
431
- <p>
432
- Internally, <tt>lex.py</tt> uses the <tt>re</tt> module to do its patten matching. When building the master regular expression,
433
- rules are added in the following order:
434
- <p>
435
- <ol>
436
- <li>All tokens defined by functions are added in the same order as they appear in the lexer file.
437
- <li>Tokens defined by strings are added next by sorting them in order of decreasing regular expression length (longer expressions
438
- are added first).
439
- </ol>
440
- <p>
441
- Without this ordering, it can be difficult to correctly match certain types of tokens. For example, if you
442
- wanted to have separate tokens for "=" and "==", you need to make sure that "==" is checked first. By sorting regular
443
- expressions in order of decreasing length, this problem is solved for rules defined as strings. For functions,
444
- the order can be explicitly controlled since rules appearing first are checked first.
445
-
446
- <p>
447
- To handle reserved words, you should write a single rule to match an
448
- identifier and do a special name lookup in a function like this:
449
-
450
- <blockquote>
451
- <pre>
452
- reserved = {
453
- 'if' : 'IF',
454
- 'then' : 'THEN',
455
- 'else' : 'ELSE',
456
- 'while' : 'WHILE',
457
- ...
458
- }
459
-
460
- tokens = ['LPAREN','RPAREN',...,'ID'] + list(reserved.values())
461
-
462
- def t_ID(t):
463
- r'[a-zA-Z_][a-zA-Z_0-9]*'
464
- t.type = reserved.get(t.value,'ID') # Check for reserved words
465
- return t
466
- </pre>
467
- </blockquote>
468
-
469
- This approach greatly reduces the number of regular expression rules and is likely to make things a little faster.
470
-
471
- <p>
472
- <b>Note:</b> You should avoid writing individual rules for reserved words. For example, if you write rules like this,
473
-
474
- <blockquote>
475
- <pre>
476
- t_FOR = r'for'
477
- t_PRINT = r'print'
478
- </pre>
479
- </blockquote>
480
-
481
- those rules will be triggered for identifiers that include those words as a prefix such as "forget" or "printed". This is probably not
482
- what you want.
483
-
484
- <H3><a name="ply_nn7"></a>4.4 Token values</H3>
485
-
486
-
487
- When tokens are returned by lex, they have a value that is stored in the <tt>value</tt> attribute. Normally, the value is the text
488
- that was matched. However, the value can be assigned to any Python object. For instance, when lexing identifiers, you may
489
- want to return both the identifier name and information from some sort of symbol table. To do this, you might write a rule like this:
490
-
491
- <blockquote>
492
- <pre>
493
- def t_ID(t):
494
- ...
495
- # Look up symbol table information and return a tuple
496
- t.value = (t.value, symbol_lookup(t.value))
497
- ...
498
- return t
499
- </pre>
500
- </blockquote>
501
-
502
- It is important to note that storing data in other attribute names is <em>not</em> recommended. The <tt>yacc.py</tt> module only exposes the
503
- contents of the <tt>value</tt> attribute. Thus, accessing other attributes may be unnecessarily awkward. If you
504
- need to store multiple values on a token, assign a tuple, dictionary, or instance to <tt>value</tt>.
505
-
506
- <H3><a name="ply_nn8"></a>4.5 Discarded tokens</H3>
507
-
508
-
509
- To discard a token, such as a comment, simply define a token rule that returns no value. For example:
510
-
511
- <blockquote>
512
- <pre>
513
- def t_COMMENT(t):
514
- r'\#.*'
515
- pass
516
- # No return value. Token discarded
517
- </pre>
518
- </blockquote>
519
-
520
- Alternatively, you can include the prefix "ignore_" in the token declaration to force a token to be ignored. For example:
521
-
522
- <blockquote>
523
- <pre>
524
- t_ignore_COMMENT = r'\#.*'
525
- </pre>
526
- </blockquote>
527
-
528
- Be advised that if you are ignoring many different kinds of text, you may still want to use functions since these provide more precise
529
- control over the order in which regular expressions are matched (i.e., functions are matched in order of specification whereas strings are
530
- sorted by regular expression length).
531
-
532
- <H3><a name="ply_nn9"></a>4.6 Line numbers and positional information</H3>
533
-
534
-
535
- <p>By default, <tt>lex.py</tt> knows nothing about line numbers. This is because <tt>lex.py</tt> doesn't know anything
536
- about what constitutes a "line" of input (e.g., the newline character or even if the input is textual data).
537
- To update this information, you need to write a special rule. In the example, the <tt>t_newline()</tt> rule shows how to do this.
538
-
539
- <blockquote>
540
- <pre>
541
- # Define a rule so we can track line numbers
542
- def t_newline(t):
543
- r'\n+'
544
- t.lexer.lineno += len(t.value)
545
- </pre>
546
- </blockquote>
547
- Within the rule, the <tt>lineno</tt> attribute of the underlying lexer <tt>t.lexer</tt> is updated.
548
- After the line number is updated, the token is simply discarded since nothing is returned.
549
-
550
- <p>
551
- <tt>lex.py</tt> does not perform and kind of automatic column tracking. However, it does record positional
552
- information related to each token in the <tt>lexpos</tt> attribute. Using this, it is usually possible to compute
553
- column information as a separate step. For instance, just count backwards until you reach a newline.
554
-
555
- <blockquote>
556
- <pre>
557
- # Compute column.
558
- # input is the input text string
559
- # token is a token instance
560
- def find_column(input,token):
561
- last_cr = input.rfind('\n',0,token.lexpos)
562
- if last_cr < 0:
563
- last_cr = 0
564
- column = (token.lexpos - last_cr) + 1
565
- return column
566
- </pre>
567
- </blockquote>
568
-
569
- Since column information is often only useful in the context of error handling, calculating the column
570
- position can be performed when needed as opposed to doing it for each token.
571
-
572
- <H3><a name="ply_nn10"></a>4.7 Ignored characters</H3>
573
-
574
-
575
- <p>
576
- The special <tt>t_ignore</tt> rule is reserved by <tt>lex.py</tt> for characters
577
- that should be completely ignored in the input stream.
578
- Usually this is used to skip over whitespace and other non-essential characters.
579
- Although it is possible to define a regular expression rule for whitespace in a manner
580
- similar to <tt>t_newline()</tt>, the use of <tt>t_ignore</tt> provides substantially better
581
- lexing performance because it is handled as a special case and is checked in a much
582
- more efficient manner than the normal regular expression rules.
583
-
584
- <H3><a name="ply_nn11"></a>4.8 Literal characters</H3>
585
-
586
-
587
- <p>
588
- Literal characters can be specified by defining a variable <tt>literals</tt> in your lexing module. For example:
589
-
590
- <blockquote>
591
- <pre>
592
- literals = [ '+','-','*','/' ]
593
- </pre>
594
- </blockquote>
595
-
596
- or alternatively
597
-
598
- <blockquote>
599
- <pre>
600
- literals = "+-*/"
601
- </pre>
602
- </blockquote>
603
-
604
- A literal character is simply a single character that is returned "as is" when encountered by the lexer. Literals are checked
605
- after all of the defined regular expression rules. Thus, if a rule starts with one of the literal characters, it will always
606
- take precedence.
607
- <p>
608
- When a literal token is returned, both its <tt>type</tt> and <tt>value</tt> attributes are set to the character itself. For example, <tt>'+'</tt>.
609
-
610
- <H3><a name="ply_nn12"></a>4.9 Error handling</H3>
611
-
612
-
613
- <p>
614
- Finally, the <tt>t_error()</tt>
615
- function is used to handle lexing errors that occur when illegal
616
- characters are detected. In this case, the <tt>t.value</tt> attribute contains the
617
- rest of the input string that has not been tokenized. In the example, the error function
618
- was defined as follows:
619
-
620
- <blockquote>
621
- <pre>
622
- # Error handling rule
623
- def t_error(t):
624
- print "Illegal character '%s'" % t.value[0]
625
- t.lexer.skip(1)
626
- </pre>
627
- </blockquote>
628
-
629
- In this case, we simply print the offending character and skip ahead one character by calling <tt>t.lexer.skip(1)</tt>.
630
-
631
- <H3><a name="ply_nn13"></a>4.10 Building and using the lexer</H3>
632
-
633
-
634
- <p>
635
- To build the lexer, the function <tt>lex.lex()</tt> is used. This function
636
- uses Python reflection (or introspection) to read the the regular expression rules
637
- out of the calling context and build the lexer. Once the lexer has been built, two methods can
638
- be used to control the lexer.
639
-
640
- <ul>
641
- <li><tt>lexer.input(data)</tt>. Reset the lexer and store a new input string.
642
- <li><tt>lexer.token()</tt>. Return the next token. Returns a special <tt>LexToken</tt> instance on success or
643
- None if the end of the input text has been reached.
644
- </ul>
645
-
646
- The preferred way to use PLY is to invoke the above methods directly on the lexer object returned by the
647
- <tt>lex()</tt> function. The legacy interface to PLY involves module-level functions <tt>lex.input()</tt> and <tt>lex.token()</tt>.
648
- For example:
649
-
650
- <blockquote>
651
- <pre>
652
- lex.lex()
653
- lex.input(sometext)
654
- while 1:
655
- tok = lex.token()
656
- if not tok: break
657
- print tok
658
- </pre>
659
- </blockquote>
660
-
661
- <p>
662
- In this example, the module-level functions <tt>lex.input()</tt> and <tt>lex.token()</tt> are bound to the <tt>input()</tt>
663
- and <tt>token()</tt> methods of the last lexer created by the lex module. This interface may go away at some point so
664
- it's probably best not to use it.
665
-
666
- <H3><a name="ply_nn14"></a>4.11 The @TOKEN decorator</H3>
667
-
668
-
669
- In some applications, you may want to define build tokens from as a series of
670
- more complex regular expression rules. For example:
671
-
672
- <blockquote>
673
- <pre>
674
- digit = r'([0-9])'
675
- nondigit = r'([_A-Za-z])'
676
- identifier = r'(' + nondigit + r'(' + digit + r'|' + nondigit + r')*)'
677
-
678
- def t_ID(t):
679
- # want docstring to be identifier above. ?????
680
- ...
681
- </pre>
682
- </blockquote>
683
-
684
- In this case, we want the regular expression rule for <tt>ID</tt> to be one of the variables above. However, there is no
685
- way to directly specify this using a normal documentation string. To solve this problem, you can use the <tt>@TOKEN</tt>
686
- decorator. For example:
687
-
688
- <blockquote>
689
- <pre>
690
- from ply.lex import TOKEN
691
-
692
- @TOKEN(identifier)
693
- def t_ID(t):
694
- ...
695
- </pre>
696
- </blockquote>
697
-
698
- This will attach <tt>identifier</tt> to the docstring for <tt>t_ID()</tt> allowing <tt>lex.py</tt> to work normally. An alternative
699
- approach this problem is to set the docstring directly like this:
700
-
701
- <blockquote>
702
- <pre>
703
- def t_ID(t):
704
- ...
705
-
706
- t_ID.__doc__ = identifier
707
- </pre>
708
- </blockquote>
709
-
710
- <b>NOTE:</b> Use of <tt>@TOKEN</tt> requires Python-2.4 or newer. If you're concerned about backwards compatibility with older
711
- versions of Python, use the alternative approach of setting the docstring directly.
712
-
713
- <H3><a name="ply_nn15"></a>4.12 Optimized mode</H3>
714
-
715
-
716
- For improved performance, it may be desirable to use Python's
717
- optimized mode (e.g., running Python with the <tt>-O</tt>
718
- option). However, doing so causes Python to ignore documentation
719
- strings. This presents special problems for <tt>lex.py</tt>. To
720
- handle this case, you can create your lexer using
721
- the <tt>optimize</tt> option as follows:
722
-
723
- <blockquote>
724
- <pre>
725
- lexer = lex.lex(optimize=1)
726
- </pre>
727
- </blockquote>
728
-
729
- Next, run Python in its normal operating mode. When you do
730
- this, <tt>lex.py</tt> will write a file called <tt>lextab.py</tt> to
731
- the current directory. This file contains all of the regular
732
- expression rules and tables used during lexing. On subsequent
733
- executions,
734
- <tt>lextab.py</tt> will simply be imported to build the lexer. This
735
- approach substantially improves the startup time of the lexer and it
736
- works in Python's optimized mode.
737
-
738
- <p>
739
- To change the name of the lexer-generated file, use the <tt>lextab</tt> keyword argument. For example:
740
-
741
- <blockquote>
742
- <pre>
743
- lexer = lex.lex(optimize=1,lextab="footab")
744
- </pre>
745
- </blockquote>
746
-
747
- When running in optimized mode, it is important to note that lex disables most error checking. Thus, this is really only recommended
748
- if you're sure everything is working correctly and you're ready to start releasing production code.
749
-
750
- <H3><a name="ply_nn16"></a>4.13 Debugging</H3>
751
-
752
-
753
- For the purpose of debugging, you can run <tt>lex()</tt> in a debugging mode as follows:
754
-
755
- <blockquote>
756
- <pre>
757
- lexer = lex.lex(debug=1)
758
- </pre>
759
- </blockquote>
760
-
761
- <p>
762
- This will produce various sorts of debugging information including all of the added rules,
763
- the master regular expressions used by the lexer, and tokens generating during lexing.
764
- </p>
765
-
766
- <p>
767
- In addition, <tt>lex.py</tt> comes with a simple main function which
768
- will either tokenize input read from standard input or from a file specified
769
- on the command line. To use it, simply put this in your lexer:
770
- </p>
771
-
772
- <blockquote>
773
- <pre>
774
- if __name__ == '__main__':
775
- lex.runmain()
776
- </pre>
777
- </blockquote>
778
-
779
- Please refer to the "Debugging" section near the end for some more advanced details
780
- of debugging.
781
-
782
- <H3><a name="ply_nn17"></a>4.14 Alternative specification of lexers</H3>
783
-
784
-
785
- As shown in the example, lexers are specified all within one Python module. If you want to
786
- put token rules in a different module from the one in which you invoke <tt>lex()</tt>, use the
787
- <tt>module</tt> keyword argument.
788
-
789
- <p>
790
- For example, you might have a dedicated module that just contains
791
- the token rules:
792
-
793
- <blockquote>
794
- <pre>
795
- # module: tokrules.py
796
- # This module just contains the lexing rules
797
-
798
- # List of token names. This is always required
799
- tokens = (
800
- 'NUMBER',
801
- 'PLUS',
802
- 'MINUS',
803
- 'TIMES',
804
- 'DIVIDE',
805
- 'LPAREN',
806
- 'RPAREN',
807
- )
808
-
809
- # Regular expression rules for simple tokens
810
- t_PLUS = r'\+'
811
- t_MINUS = r'-'
812
- t_TIMES = r'\*'
813
- t_DIVIDE = r'/'
814
- t_LPAREN = r'\('
815
- t_RPAREN = r'\)'
816
-
817
- # A regular expression rule with some action code
818
- def t_NUMBER(t):
819
- r'\d+'
820
- t.value = int(t.value)
821
- return t
822
-
823
- # Define a rule so we can track line numbers
824
- def t_newline(t):
825
- r'\n+'
826
- t.lexer.lineno += len(t.value)
827
-
828
- # A string containing ignored characters (spaces and tabs)
829
- t_ignore = ' \t'
830
-
831
- # Error handling rule
832
- def t_error(t):
833
- print "Illegal character '%s'" % t.value[0]
834
- t.lexer.skip(1)
835
- </pre>
836
- </blockquote>
837
-
838
- Now, if you wanted to build a tokenizer from these rules from within a different module, you would do the following (shown for Python interactive mode):
839
-
840
- <blockquote>
841
- <pre>
842
- >>> import tokrules
843
- >>> <b>lexer = lex.lex(module=tokrules)</b>
844
- >>> lexer.input("3 + 4")
845
- >>> lexer.token()
846
- LexToken(NUMBER,3,1,1,0)
847
- >>> lexer.token()
848
- LexToken(PLUS,'+',1,2)
849
- >>> lexer.token()
850
- LexToken(NUMBER,4,1,4)
851
- >>> lexer.token()
852
- None
853
- >>>
854
- </pre>
855
- </blockquote>
856
-
857
- The <tt>module</tt> option can also be used to define lexers from instances of a class. For example:
858
-
859
- <blockquote>
860
- <pre>
861
- import ply.lex as lex
862
-
863
- class MyLexer:
864
- # List of token names. This is always required
865
- tokens = (
866
- 'NUMBER',
867
- 'PLUS',
868
- 'MINUS',
869
- 'TIMES',
870
- 'DIVIDE',
871
- 'LPAREN',
872
- 'RPAREN',
873
- )
874
-
875
- # Regular expression rules for simple tokens
876
- t_PLUS = r'\+'
877
- t_MINUS = r'-'
878
- t_TIMES = r'\*'
879
- t_DIVIDE = r'/'
880
- t_LPAREN = r'\('
881
- t_RPAREN = r'\)'
882
-
883
- # A regular expression rule with some action code
884
- # Note addition of self parameter since we're in a class
885
- def t_NUMBER(self,t):
886
- r'\d+'
887
- t.value = int(t.value)
888
- return t
889
-
890
- # Define a rule so we can track line numbers
891
- def t_newline(self,t):
892
- r'\n+'
893
- t.lexer.lineno += len(t.value)
894
-
895
- # A string containing ignored characters (spaces and tabs)
896
- t_ignore = ' \t'
897
-
898
- # Error handling rule
899
- def t_error(self,t):
900
- print "Illegal character '%s'" % t.value[0]
901
- t.lexer.skip(1)
902
-
903
- <b># Build the lexer
904
- def build(self,**kwargs):
905
- self.lexer = lex.lex(module=self, **kwargs)</b>
906
-
907
- # Test it output
908
- def test(self,data):
909
- self.lexer.input(data)
910
- while True:
911
- tok = lexer.token()
912
- if not tok: break
913
- print tok
914
-
915
- # Build the lexer and try it out
916
- m = MyLexer()
917
- m.build() # Build the lexer
918
- m.test("3 + 4") # Test it
919
- </pre>
920
- </blockquote>
921
-
922
-
923
- When building a lexer from class, <em>you should construct the lexer from
924
- an instance of the class</em>, not the class object itself. This is because
925
- PLY only works properly if the lexer actions are defined by bound-methods.
926
-
927
- <p>
928
- When using the <tt>module</tt> option to <tt>lex()</tt>, PLY collects symbols
929
- from the underlying object using the <tt>dir()</tt> function. There is no
930
- direct access to the <tt>__dict__</tt> attribute of the object supplied as a
931
- module value.
932
-
933
- <P>
934
- Finally, if you want to keep things nicely encapsulated, but don't want to use a
935
- full-fledged class definition, lexers can be defined using closures. For example:
936
-
937
- <blockquote>
938
- <pre>
939
- import ply.lex as lex
940
-
941
- # List of token names. This is always required
942
- tokens = (
943
- 'NUMBER',
944
- 'PLUS',
945
- 'MINUS',
946
- 'TIMES',
947
- 'DIVIDE',
948
- 'LPAREN',
949
- 'RPAREN',
950
- )
951
-
952
- def MyLexer():
953
- # Regular expression rules for simple tokens
954
- t_PLUS = r'\+'
955
- t_MINUS = r'-'
956
- t_TIMES = r'\*'
957
- t_DIVIDE = r'/'
958
- t_LPAREN = r'\('
959
- t_RPAREN = r'\)'
960
-
961
- # A regular expression rule with some action code
962
- def t_NUMBER(t):
963
- r'\d+'
964
- t.value = int(t.value)
965
- return t
966
-
967
- # Define a rule so we can track line numbers
968
- def t_newline(t):
969
- r'\n+'
970
- t.lexer.lineno += len(t.value)
971
-
972
- # A string containing ignored characters (spaces and tabs)
973
- t_ignore = ' \t'
974
-
975
- # Error handling rule
976
- def t_error(t):
977
- print "Illegal character '%s'" % t.value[0]
978
- t.lexer.skip(1)
979
-
980
- # Build the lexer from my environment and return it
981
- return lex.lex()
982
- </pre>
983
- </blockquote>
984
-
985
-
986
- <H3><a name="ply_nn18"></a>4.15 Maintaining state</H3>
987
-
988
-
989
- In your lexer, you may want to maintain a variety of state
990
- information. This might include mode settings, symbol tables, and
991
- other details. As an example, suppose that you wanted to keep
992
- track of how many NUMBER tokens had been encountered.
993
-
994
- <p>
995
- One way to do this is to keep a set of global variables in the module
996
- where you created the lexer. For example:
997
-
998
- <blockquote>
999
- <pre>
1000
- num_count = 0
1001
- def t_NUMBER(t):
1002
- r'\d+'
1003
- global num_count
1004
- num_count += 1
1005
- t.value = int(t.value)
1006
- return t
1007
- </pre>
1008
- </blockquote>
1009
-
1010
- If you don't like the use of a global variable, another place to store
1011
- information is inside the Lexer object created by <tt>lex()</tt>.
1012
- To this, you can use the <tt>lexer</tt> attribute of tokens passed to
1013
- the various rules. For example:
1014
-
1015
- <blockquote>
1016
- <pre>
1017
- def t_NUMBER(t):
1018
- r'\d+'
1019
- t.lexer.num_count += 1 # Note use of lexer attribute
1020
- t.value = int(t.value)
1021
- return t
1022
-
1023
- lexer = lex.lex()
1024
- lexer.num_count = 0 # Set the initial count
1025
- </pre>
1026
- </blockquote>
1027
-
1028
- This latter approach has the advantage of being simple and working
1029
- correctly in applications where multiple instantiations of a given
1030
- lexer exist in the same application. However, this might also feel
1031
- like a gross violation of encapsulation to OO purists.
1032
- Just to put your mind at some ease, all
1033
- internal attributes of the lexer (with the exception of <tt>lineno</tt>) have names that are prefixed
1034
- by <tt>lex</tt> (e.g., <tt>lexdata</tt>,<tt>lexpos</tt>, etc.). Thus,
1035
- it is perfectly safe to store attributes in the lexer that
1036
- don't have names starting with that prefix or a name that conlicts with one of the
1037
- predefined methods (e.g., <tt>input()</tt>, <tt>token()</tt>, etc.).
1038
-
1039
- <p>
1040
- If you don't like assigning values on the lexer object, you can define your lexer as a class as
1041
- shown in the previous section:
1042
-
1043
- <blockquote>
1044
- <pre>
1045
- class MyLexer:
1046
- ...
1047
- def t_NUMBER(self,t):
1048
- r'\d+'
1049
- self.num_count += 1
1050
- t.value = int(t.value)
1051
- return t
1052
-
1053
- def build(self, **kwargs):
1054
- self.lexer = lex.lex(object=self,**kwargs)
1055
-
1056
- def __init__(self):
1057
- self.num_count = 0
1058
- </pre>
1059
- </blockquote>
1060
-
1061
- The class approach may be the easiest to manage if your application is
1062
- going to be creating multiple instances of the same lexer and you need
1063
- to manage a lot of state.
1064
-
1065
- <p>
1066
- State can also be managed through closures. For example, in Python 3:
1067
-
1068
- <blockquote>
1069
- <pre>
1070
- def MyLexer():
1071
- num_count = 0
1072
- ...
1073
- def t_NUMBER(t):
1074
- r'\d+'
1075
- nonlocal num_count
1076
- num_count += 1
1077
- t.value = int(t.value)
1078
- return t
1079
- ...
1080
- </pre>
1081
- </blockquote>
1082
-
1083
- <H3><a name="ply_nn19"></a>4.16 Lexer cloning</H3>
1084
-
1085
-
1086
- <p>
1087
- If necessary, a lexer object can be duplicated by invoking its <tt>clone()</tt> method. For example:
1088
-
1089
- <blockquote>
1090
- <pre>
1091
- lexer = lex.lex()
1092
- ...
1093
- newlexer = lexer.clone()
1094
- </pre>
1095
- </blockquote>
1096
-
1097
- When a lexer is cloned, the copy is exactly identical to the original lexer
1098
- including any input text and internal state. However, the clone allows a
1099
- different set of input text to be supplied which may be processed separately.
1100
- This may be useful in situations when you are writing a parser/compiler that
1101
- involves recursive or reentrant processing. For instance, if you
1102
- needed to scan ahead in the input for some reason, you could create a
1103
- clone and use it to look ahead. Or, if you were implementing some kind of preprocessor,
1104
- cloned lexers could be used to handle different input files.
1105
-
1106
- <p>
1107
- Creating a clone is different than calling <tt>lex.lex()</tt> in that
1108
- PLY doesn't regenerate any of the internal tables or regular expressions. So,
1109
-
1110
- <p>
1111
- Special considerations need to be made when cloning lexers that also
1112
- maintain their own internal state using classes or closures. Namely,
1113
- you need to be aware that the newly created lexers will share all of
1114
- this state with the original lexer. For example, if you defined a
1115
- lexer as a class and did this:
1116
-
1117
- <blockquote>
1118
- <pre>
1119
- m = MyLexer()
1120
- a = lex.lex(object=m) # Create a lexer
1121
-
1122
- b = a.clone() # Clone the lexer
1123
- </pre>
1124
- </blockquote>
1125
-
1126
- Then both <tt>a</tt> and <tt>b</tt> are going to be bound to the same
1127
- object <tt>m</tt> and any changes to <tt>m</tt> will be reflected in both lexers. It's
1128
- important to emphasize that <tt>clone()</tt> is only meant to create a new lexer
1129
- that reuses the regular expressions and environment of another lexer. If you
1130
- need to make a totally new copy of a lexer, then call <tt>lex()</tt> again.
1131
-
1132
- <H3><a name="ply_nn20"></a>4.17 Internal lexer state</H3>
1133
-
1134
-
1135
- A Lexer object <tt>lexer</tt> has a number of internal attributes that may be useful in certain
1136
- situations.
1137
-
1138
- <p>
1139
- <tt>lexer.lexpos</tt>
1140
- <blockquote>
1141
- This attribute is an integer that contains the current position within the input text. If you modify
1142
- the value, it will change the result of the next call to <tt>token()</tt>. Within token rule functions, this points
1143
- to the first character <em>after</em> the matched text. If the value is modified within a rule, the next returned token will be
1144
- matched at the new position.
1145
- </blockquote>
1146
-
1147
- <p>
1148
- <tt>lexer.lineno</tt>
1149
- <blockquote>
1150
- The current value of the line number attribute stored in the lexer. PLY only specifies that the attribute
1151
- exists---it never sets, updates, or performs any processing with it. If you want to track line numbers,
1152
- you will need to add code yourself (see the section on line numbers and positional information).
1153
- </blockquote>
1154
-
1155
- <p>
1156
- <tt>lexer.lexdata</tt>
1157
- <blockquote>
1158
- The current input text stored in the lexer. This is the string passed with the <tt>input()</tt> method. It
1159
- would probably be a bad idea to modify this unless you really know what you're doing.
1160
- </blockquote>
1161
-
1162
- <P>
1163
- <tt>lexer.lexmatch</tt>
1164
- <blockquote>
1165
- This is the raw <tt>Match</tt> object returned by the Python <tt>re.match()</tt> function (used internally by PLY) for the
1166
- current token. If you have written a regular expression that contains named groups, you can use this to retrieve those values.
1167
- Note: This attribute is only updated when tokens are defined and processed by functions.
1168
- </blockquote>
1169
-
1170
- <H3><a name="ply_nn21"></a>4.18 Conditional lexing and start conditions</H3>
1171
-
1172
-
1173
- In advanced parsing applications, it may be useful to have different
1174
- lexing states. For instance, you may want the occurrence of a certain
1175
- token or syntactic construct to trigger a different kind of lexing.
1176
- PLY supports a feature that allows the underlying lexer to be put into
1177
- a series of different states. Each state can have its own tokens,
1178
- lexing rules, and so forth. The implementation is based largely on
1179
- the "start condition" feature of GNU flex. Details of this can be found
1180
- at <a
1181
- href="http://www.gnu.org/software/flex/manual/html_chapter/flex_11.html">http://www.gnu.org/software/flex/manual/html_chapter/flex_11.html.</a>.
1182
-
1183
- <p>
1184
- To define a new lexing state, it must first be declared. This is done by including a "states" declaration in your
1185
- lex file. For example:
1186
-
1187
- <blockquote>
1188
- <pre>
1189
- states = (
1190
- ('foo','exclusive'),
1191
- ('bar','inclusive'),
1192
- )
1193
- </pre>
1194
- </blockquote>
1195
-
1196
- This declaration declares two states, <tt>'foo'</tt>
1197
- and <tt>'bar'</tt>. States may be of two types; <tt>'exclusive'</tt>
1198
- and <tt>'inclusive'</tt>. An exclusive state completely overrides the
1199
- default behavior of the lexer. That is, lex will only return tokens
1200
- and apply rules defined specifically for that state. An inclusive
1201
- state adds additional tokens and rules to the default set of rules.
1202
- Thus, lex will return both the tokens defined by default in addition
1203
- to those defined for the inclusive state.
1204
-
1205
- <p>
1206
- Once a state has been declared, tokens and rules are declared by including the
1207
- state name in token/rule declaration. For example:
1208
-
1209
- <blockquote>
1210
- <pre>
1211
- t_foo_NUMBER = r'\d+' # Token 'NUMBER' in state 'foo'
1212
- t_bar_ID = r'[a-zA-Z_][a-zA-Z0-9_]*' # Token 'ID' in state 'bar'
1213
-
1214
- def t_foo_newline(t):
1215
- r'\n'
1216
- t.lexer.lineno += 1
1217
- </pre>
1218
- </blockquote>
1219
-
1220
- A token can be declared in multiple states by including multiple state names in the declaration. For example:
1221
-
1222
- <blockquote>
1223
- <pre>
1224
- t_foo_bar_NUMBER = r'\d+' # Defines token 'NUMBER' in both state 'foo' and 'bar'
1225
- </pre>
1226
- </blockquote>
1227
-
1228
- Alternative, a token can be declared in all states using the 'ANY' in the name.
1229
-
1230
- <blockquote>
1231
- <pre>
1232
- t_ANY_NUMBER = r'\d+' # Defines a token 'NUMBER' in all states
1233
- </pre>
1234
- </blockquote>
1235
-
1236
- If no state name is supplied, as is normally the case, the token is associated with a special state <tt>'INITIAL'</tt>. For example,
1237
- these two declarations are identical:
1238
-
1239
- <blockquote>
1240
- <pre>
1241
- t_NUMBER = r'\d+'
1242
- t_INITIAL_NUMBER = r'\d+'
1243
- </pre>
1244
- </blockquote>
1245
-
1246
- <p>
1247
- States are also associated with the special <tt>t_ignore</tt> and <tt>t_error()</tt> declarations. For example, if a state treats
1248
- these differently, you can declare:
1249
-
1250
- <blockquote>
1251
- <pre>
1252
- t_foo_ignore = " \t\n" # Ignored characters for state 'foo'
1253
-
1254
- def t_bar_error(t): # Special error handler for state 'bar'
1255
- pass
1256
- </pre>
1257
- </blockquote>
1258
-
1259
- By default, lexing operates in the <tt>'INITIAL'</tt> state. This state includes all of the normally defined tokens.
1260
- For users who aren't using different states, this fact is completely transparent. If, during lexing or parsing, you want to change
1261
- the lexing state, use the <tt>begin()</tt> method. For example:
1262
-
1263
- <blockquote>
1264
- <pre>
1265
- def t_begin_foo(t):
1266
- r'start_foo'
1267
- t.lexer.begin('foo') # Starts 'foo' state
1268
- </pre>
1269
- </blockquote>
1270
-
1271
- To get out of a state, you use <tt>begin()</tt> to switch back to the initial state. For example:
1272
-
1273
- <blockquote>
1274
- <pre>
1275
- def t_foo_end(t):
1276
- r'end_foo'
1277
- t.lexer.begin('INITIAL') # Back to the initial state
1278
- </pre>
1279
- </blockquote>
1280
-
1281
- The management of states can also be done with a stack. For example:
1282
-
1283
- <blockquote>
1284
- <pre>
1285
- def t_begin_foo(t):
1286
- r'start_foo'
1287
- t.lexer.push_state('foo') # Starts 'foo' state
1288
-
1289
- def t_foo_end(t):
1290
- r'end_foo'
1291
- t.lexer.pop_state() # Back to the previous state
1292
- </pre>
1293
- </blockquote>
1294
-
1295
- <p>
1296
- The use of a stack would be useful in situations where there are many ways of entering a new lexing state and you merely want to go back
1297
- to the previous state afterwards.
1298
-
1299
- <P>
1300
- An example might help clarify. Suppose you were writing a parser and you wanted to grab sections of arbitrary C code enclosed by
1301
- curly braces. That is, whenever you encounter a starting brace '{', you want to read all of the enclosed code up to the ending brace '}'
1302
- and return it as a string. Doing this with a normal regular expression rule is nearly (if not actually) impossible. This is because braces can
1303
- be nested and can be included in comments and strings. Thus, simply matching up to the first matching '}' character isn't good enough. Here is how
1304
- you might use lexer states to do this:
1305
-
1306
- <blockquote>
1307
- <pre>
1308
- # Declare the state
1309
- states = (
1310
- ('ccode','exclusive'),
1311
- )
1312
-
1313
- # Match the first {. Enter ccode state.
1314
- def t_ccode(t):
1315
- r'\{'
1316
- t.lexer.code_start = t.lexer.lexpos # Record the starting position
1317
- t.lexer.level = 1 # Initial brace level
1318
- t.lexer.begin('ccode') # Enter 'ccode' state
1319
-
1320
- # Rules for the ccode state
1321
- def t_ccode_lbrace(t):
1322
- r'\{'
1323
- t.lexer.level +=1
1324
-
1325
- def t_ccode_rbrace(t):
1326
- r'\}'
1327
- t.lexer.level -=1
1328
-
1329
- # If closing brace, return the code fragment
1330
- if t.lexer.level == 0:
1331
- t.value = t.lexer.lexdata[t.lexer.code_start:t.lexer.lexpos+1]
1332
- t.type = "CCODE"
1333
- t.lexer.lineno += t.value.count('\n')
1334
- t.lexer.begin('INITIAL')
1335
- return t
1336
-
1337
- # C or C++ comment (ignore)
1338
- def t_ccode_comment(t):
1339
- r'(/\*(.|\n)*?*/)|(//.*)'
1340
- pass
1341
-
1342
- # C string
1343
- def t_ccode_string(t):
1344
- r'\"([^\\\n]|(\\.))*?\"'
1345
-
1346
- # C character literal
1347
- def t_ccode_char(t):
1348
- r'\'([^\\\n]|(\\.))*?\''
1349
-
1350
- # Any sequence of non-whitespace characters (not braces, strings)
1351
- def t_ccode_nonspace(t):
1352
- r'[^\s\{\}\'\"]+'
1353
-
1354
- # Ignored characters (whitespace)
1355
- t_ccode_ignore = " \t\n"
1356
-
1357
- # For bad characters, we just skip over it
1358
- def t_ccode_error(t):
1359
- t.lexer.skip(1)
1360
- </pre>
1361
- </blockquote>
1362
-
1363
- In this example, the occurrence of the first '{' causes the lexer to record the starting position and enter a new state <tt>'ccode'</tt>. A collection of rules then match
1364
- various parts of the input that follow (comments, strings, etc.). All of these rules merely discard the token (by not returning a value).
1365
- However, if the closing right brace is encountered, the rule <tt>t_ccode_rbrace</tt> collects all of the code (using the earlier recorded starting
1366
- position), stores it, and returns a token 'CCODE' containing all of that text. When returning the token, the lexing state is restored back to its
1367
- initial state.
1368
-
1369
- <H3><a name="ply_nn21"></a>4.19 Miscellaneous Issues</H3>
1370
-
1371
-
1372
- <P>
1373
- <li>The lexer requires input to be supplied as a single input string. Since most machines have more than enough memory, this
1374
- rarely presents a performance concern. However, it means that the lexer currently can't be used with streaming data
1375
- such as open files or sockets. This limitation is primarily a side-effect of using the <tt>re</tt> module.
1376
-
1377
- <p>
1378
- <li>The lexer should work properly with both Unicode strings given as token and pattern matching rules as
1379
- well as for input text.
1380
-
1381
- <p>
1382
- <li>If you need to supply optional flags to the re.compile() function, use the reflags option to lex. For example:
1383
-
1384
- <blockquote>
1385
- <pre>
1386
- lex.lex(reflags=re.UNICODE)
1387
- </pre>
1388
- </blockquote>
1389
-
1390
- <p>
1391
- <li>Since the lexer is written entirely in Python, its performance is
1392
- largely determined by that of the Python <tt>re</tt> module. Although
1393
- the lexer has been written to be as efficient as possible, it's not
1394
- blazingly fast when used on very large input files. If
1395
- performance is concern, you might consider upgrading to the most
1396
- recent version of Python, creating a hand-written lexer, or offloading
1397
- the lexer into a C extension module.
1398
-
1399
- <p>
1400
- If you are going to create a hand-written lexer and you plan to use it with <tt>yacc.py</tt>,
1401
- it only needs to conform to the following requirements:
1402
-
1403
- <ul>
1404
- <li>It must provide a <tt>token()</tt> method that returns the next token or <tt>None</tt> if no more
1405
- tokens are available.
1406
- <li>The <tt>token()</tt> method must return an object <tt>tok</tt> that has <tt>type</tt> and <tt>value</tt> attributes. If
1407
- line number tracking is being used, then the token should also define a <tt>lineno</tt> attribute.
1408
- </ul>
1409
-
1410
- <H2><a name="ply_nn22"></a>5. Parsing basics</H2>
1411
-
1412
-
1413
- <tt>yacc.py</tt> is used to parse language syntax. Before showing an
1414
- example, there are a few important bits of background that must be
1415
- mentioned. First, <em>syntax</em> is usually specified in terms of a BNF grammar.
1416
- For example, if you wanted to parse
1417
- simple arithmetic expressions, you might first write an unambiguous
1418
- grammar specification like this:
1419
-
1420
- <blockquote>
1421
- <pre>
1422
- expression : expression + term
1423
- | expression - term
1424
- | term
1425
-
1426
- term : term * factor
1427
- | term / factor
1428
- | factor
1429
-
1430
- factor : NUMBER
1431
- | ( expression )
1432
- </pre>
1433
- </blockquote>
1434
-
1435
- In the grammar, symbols such as <tt>NUMBER</tt>, <tt>+</tt>, <tt>-</tt>, <tt>*</tt>, and <tt>/</tt> are known
1436
- as <em>terminals</em> and correspond to raw input tokens. Identifiers such as <tt>term</tt> and <tt>factor</tt> refer to
1437
- grammar rules comprised of a collection of terminals and other rules. These identifiers are known as <em>non-terminals</em>.
1438
- <P>
1439
-
1440
- The semantic behavior of a language is often specified using a
1441
- technique known as syntax directed translation. In syntax directed
1442
- translation, attributes are attached to each symbol in a given grammar
1443
- rule along with an action. Whenever a particular grammar rule is
1444
- recognized, the action describes what to do. For example, given the
1445
- expression grammar above, you might write the specification for a
1446
- simple calculator like this:
1447
-
1448
- <blockquote>
1449
- <pre>
1450
- Grammar Action
1451
- -------------------------------- --------------------------------------------
1452
- expression0 : expression1 + term expression0.val = expression1.val + term.val
1453
- | expression1 - term expression0.val = expression1.val - term.val
1454
- | term expression0.val = term.val
1455
-
1456
- term0 : term1 * factor term0.val = term1.val * factor.val
1457
- | term1 / factor term0.val = term1.val / factor.val
1458
- | factor term0.val = factor.val
1459
-
1460
- factor : NUMBER factor.val = int(NUMBER.lexval)
1461
- | ( expression ) factor.val = expression.val
1462
- </pre>
1463
- </blockquote>
1464
-
1465
- A good way to think about syntax directed translation is to
1466
- view each symbol in the grammar as a kind of object. Associated
1467
- with each symbol is a value representing its "state" (for example, the
1468
- <tt>val</tt> attribute above). Semantic
1469
- actions are then expressed as a collection of functions or methods
1470
- that operate on the symbols and associated values.
1471
-
1472
- <p>
1473
- Yacc uses a parsing technique known as LR-parsing or shift-reduce parsing. LR parsing is a
1474
- bottom up technique that tries to recognize the right-hand-side of various grammar rules.
1475
- Whenever a valid right-hand-side is found in the input, the appropriate action code is triggered and the
1476
- grammar symbols are replaced by the grammar symbol on the left-hand-side.
1477
-
1478
- <p>
1479
- LR parsing is commonly implemented by shifting grammar symbols onto a
1480
- stack and looking at the stack and the next input token for patterns that
1481
- match one of the grammar rules.
1482
- The details of the algorithm can be found in a compiler textbook, but the
1483
- following example illustrates the steps that are performed if you
1484
- wanted to parse the expression
1485
- <tt>3 + 5 * (10 - 20)</tt> using the grammar defined above. In the example,
1486
- the special symbol <tt>$</tt> represents the end of input.
1487
-
1488
-
1489
- <blockquote>
1490
- <pre>
1491
- Step Symbol Stack Input Tokens Action
1492
- ---- --------------------- --------------------- -------------------------------
1493
- 1 3 + 5 * ( 10 - 20 )$ Shift 3
1494
- 2 3 + 5 * ( 10 - 20 )$ Reduce factor : NUMBER
1495
- 3 factor + 5 * ( 10 - 20 )$ Reduce term : factor
1496
- 4 term + 5 * ( 10 - 20 )$ Reduce expr : term
1497
- 5 expr + 5 * ( 10 - 20 )$ Shift +
1498
- 6 expr + 5 * ( 10 - 20 )$ Shift 5
1499
- 7 expr + 5 * ( 10 - 20 )$ Reduce factor : NUMBER
1500
- 8 expr + factor * ( 10 - 20 )$ Reduce term : factor
1501
- 9 expr + term * ( 10 - 20 )$ Shift *
1502
- 10 expr + term * ( 10 - 20 )$ Shift (
1503
- 11 expr + term * ( 10 - 20 )$ Shift 10
1504
- 12 expr + term * ( 10 - 20 )$ Reduce factor : NUMBER
1505
- 13 expr + term * ( factor - 20 )$ Reduce term : factor
1506
- 14 expr + term * ( term - 20 )$ Reduce expr : term
1507
- 15 expr + term * ( expr - 20 )$ Shift -
1508
- 16 expr + term * ( expr - 20 )$ Shift 20
1509
- 17 expr + term * ( expr - 20 )$ Reduce factor : NUMBER
1510
- 18 expr + term * ( expr - factor )$ Reduce term : factor
1511
- 19 expr + term * ( expr - term )$ Reduce expr : expr - term
1512
- 20 expr + term * ( expr )$ Shift )
1513
- 21 expr + term * ( expr ) $ Reduce factor : (expr)
1514
- 22 expr + term * factor $ Reduce term : term * factor
1515
- 23 expr + term $ Reduce expr : expr + term
1516
- 24 expr $ Reduce expr
1517
- 25 $ Success!
1518
- </pre>
1519
- </blockquote>
1520
-
1521
- When parsing the expression, an underlying state machine and the
1522
- current input token determine what happens next. If the next token
1523
- looks like part of a valid grammar rule (based on other items on the
1524
- stack), it is generally shifted onto the stack. If the top of the
1525
- stack contains a valid right-hand-side of a grammar rule, it is
1526
- usually "reduced" and the symbols replaced with the symbol on the
1527
- left-hand-side. When this reduction occurs, the appropriate action is
1528
- triggered (if defined). If the input token can't be shifted and the
1529
- top of stack doesn't match any grammar rules, a syntax error has
1530
- occurred and the parser must take some kind of recovery step (or bail
1531
- out). A parse is only successful if the parser reaches a state where
1532
- the symbol stack is empty and there are no more input tokens.
1533
-
1534
- <p>
1535
- It is important to note that the underlying implementation is built
1536
- around a large finite-state machine that is encoded in a collection of
1537
- tables. The construction of these tables is non-trivial and
1538
- beyond the scope of this discussion. However, subtle details of this
1539
- process explain why, in the example above, the parser chooses to shift
1540
- a token onto the stack in step 9 rather than reducing the
1541
- rule <tt>expr : expr + term</tt>.
1542
-
1543
- <H2><a name="ply_nn23"></a>6. Yacc</H2>
1544
-
1545
-
1546
- The <tt>ply.yacc</tt> module implements the parsing component of PLY.
1547
- The name "yacc" stands for "Yet Another Compiler Compiler" and is
1548
- borrowed from the Unix tool of the same name.
1549
-
1550
- <H3><a name="ply_nn24"></a>6.1 An example</H3>
1551
-
1552
-
1553
- Suppose you wanted to make a grammar for simple arithmetic expressions as previously described. Here is
1554
- how you would do it with <tt>yacc.py</tt>:
1555
-
1556
- <blockquote>
1557
- <pre>
1558
- # Yacc example
1559
-
1560
- import ply.yacc as yacc
1561
-
1562
- # Get the token map from the lexer. This is required.
1563
- from calclex import tokens
1564
-
1565
- def p_expression_plus(p):
1566
- 'expression : expression PLUS term'
1567
- p[0] = p[1] + p[3]
1568
-
1569
- def p_expression_minus(p):
1570
- 'expression : expression MINUS term'
1571
- p[0] = p[1] - p[3]
1572
-
1573
- def p_expression_term(p):
1574
- 'expression : term'
1575
- p[0] = p[1]
1576
-
1577
- def p_term_times(p):
1578
- 'term : term TIMES factor'
1579
- p[0] = p[1] * p[3]
1580
-
1581
- def p_term_div(p):
1582
- 'term : term DIVIDE factor'
1583
- p[0] = p[1] / p[3]
1584
-
1585
- def p_term_factor(p):
1586
- 'term : factor'
1587
- p[0] = p[1]
1588
-
1589
- def p_factor_num(p):
1590
- 'factor : NUMBER'
1591
- p[0] = p[1]
1592
-
1593
- def p_factor_expr(p):
1594
- 'factor : LPAREN expression RPAREN'
1595
- p[0] = p[2]
1596
-
1597
- # Error rule for syntax errors
1598
- def p_error(p):
1599
- print "Syntax error in input!"
1600
-
1601
- # Build the parser
1602
- parser = yacc.yacc()
1603
-
1604
- while True:
1605
- try:
1606
- s = raw_input('calc > ')
1607
- except EOFError:
1608
- break
1609
- if not s: continue
1610
- result = parser.parse(s)
1611
- print result
1612
- </pre>
1613
- </blockquote>
1614
-
1615
- In this example, each grammar rule is defined by a Python function
1616
- where the docstring to that function contains the appropriate
1617
- context-free grammar specification. The statements that make up the
1618
- function body implement the semantic actions of the rule. Each function
1619
- accepts a single argument <tt>p</tt> that is a sequence containing the
1620
- values of each grammar symbol in the corresponding rule. The values
1621
- of <tt>p[i]</tt> are mapped to grammar symbols as shown here:
1622
-
1623
- <blockquote>
1624
- <pre>
1625
- def p_expression_plus(p):
1626
- 'expression : expression PLUS term'
1627
- # ^ ^ ^ ^
1628
- # p[0] p[1] p[2] p[3]
1629
-
1630
- p[0] = p[1] + p[3]
1631
- </pre>
1632
- </blockquote>
1633
-
1634
- <p>
1635
- For tokens, the "value" of the corresponding <tt>p[i]</tt> is the
1636
- <em>same</em> as the <tt>p.value</tt> attribute assigned in the lexer
1637
- module. For non-terminals, the value is determined by whatever is
1638
- placed in <tt>p[0]</tt> when rules are reduced. This value can be
1639
- anything at all. However, it probably most common for the value to be
1640
- a simple Python type, a tuple, or an instance. In this example, we
1641
- are relying on the fact that the <tt>NUMBER</tt> token stores an
1642
- integer value in its value field. All of the other rules simply
1643
- perform various types of integer operations and propagate the result.
1644
- </p>
1645
-
1646
- <p>
1647
- Note: The use of negative indices have a special meaning in
1648
- yacc---specially <tt>p[-1]</tt> does not have the same value
1649
- as <tt>p[3]</tt> in this example. Please see the section on "Embedded
1650
- Actions" for further details.
1651
- </p>
1652
-
1653
- <p>
1654
- The first rule defined in the yacc specification determines the
1655
- starting grammar symbol (in this case, a rule for <tt>expression</tt>
1656
- appears first). Whenever the starting rule is reduced by the parser
1657
- and no more input is available, parsing stops and the final value is
1658
- returned (this value will be whatever the top-most rule placed
1659
- in <tt>p[0]</tt>). Note: an alternative starting symbol can be
1660
- specified using the <tt>start</tt> keyword argument to
1661
- <tt>yacc()</tt>.
1662
-
1663
- <p>The <tt>p_error(p)</tt> rule is defined to catch syntax errors.
1664
- See the error handling section below for more detail.
1665
-
1666
- <p>
1667
- To build the parser, call the <tt>yacc.yacc()</tt> function. This
1668
- function looks at the module and attempts to construct all of the LR
1669
- parsing tables for the grammar you have specified. The first
1670
- time <tt>yacc.yacc()</tt> is invoked, you will get a message such as
1671
- this:
1672
-
1673
- <blockquote>
1674
- <pre>
1675
- $ python calcparse.py
1676
- Generating LALR tables
1677
- calc >
1678
- </pre>
1679
- </blockquote>
1680
-
1681
- Since table construction is relatively expensive (especially for large
1682
- grammars), the resulting parsing table is written to the current
1683
- directory in a file called <tt>parsetab.py</tt>. In addition, a
1684
- debugging file called <tt>parser.out</tt> is created. On subsequent
1685
- executions, <tt>yacc</tt> will reload the table from
1686
- <tt>parsetab.py</tt> unless it has detected a change in the underlying
1687
- grammar (in which case the tables and <tt>parsetab.py</tt> file are
1688
- regenerated). Note: The names of parser output files can be changed
1689
- if necessary. See the <a href="reference.html">PLY Reference</a> for details.
1690
-
1691
- <p>
1692
- If any errors are detected in your grammar specification, <tt>yacc.py</tt> will produce
1693
- diagnostic messages and possibly raise an exception. Some of the errors that can be detected include:
1694
-
1695
- <ul>
1696
- <li>Duplicated function names (if more than one rule function have the same name in the grammar file).
1697
- <li>Shift/reduce and reduce/reduce conflicts generated by ambiguous grammars.
1698
- <li>Badly specified grammar rules.
1699
- <li>Infinite recursion (rules that can never terminate).
1700
- <li>Unused rules and tokens
1701
- <li>Undefined rules and tokens
1702
- </ul>
1703
-
1704
- The next few sections discuss grammar specification in more detail.
1705
-
1706
- <p>
1707
- The final part of the example shows how to actually run the parser
1708
- created by
1709
- <tt>yacc()</tt>. To run the parser, you simply have to call
1710
- the <tt>parse()</tt> with a string of input text. This will run all
1711
- of the grammar rules and return the result of the entire parse. This
1712
- result return is the value assigned to <tt>p[0]</tt> in the starting
1713
- grammar rule.
1714
-
1715
- <H3><a name="ply_nn25"></a>6.2 Combining Grammar Rule Functions</H3>
1716
-
1717
-
1718
- When grammar rules are similar, they can be combined into a single function.
1719
- For example, consider the two rules in our earlier example:
1720
-
1721
- <blockquote>
1722
- <pre>
1723
- def p_expression_plus(p):
1724
- 'expression : expression PLUS term'
1725
- p[0] = p[1] + p[3]
1726
-
1727
- def p_expression_minus(t):
1728
- 'expression : expression MINUS term'
1729
- p[0] = p[1] - p[3]
1730
- </pre>
1731
- </blockquote>
1732
-
1733
- Instead of writing two functions, you might write a single function like this:
1734
-
1735
- <blockquote>
1736
- <pre>
1737
- def p_expression(p):
1738
- '''expression : expression PLUS term
1739
- | expression MINUS term'''
1740
- if p[2] == '+':
1741
- p[0] = p[1] + p[3]
1742
- elif p[2] == '-':
1743
- p[0] = p[1] - p[3]
1744
- </pre>
1745
- </blockquote>
1746
-
1747
- In general, the doc string for any given function can contain multiple grammar rules. So, it would
1748
- have also been legal (although possibly confusing) to write this:
1749
-
1750
- <blockquote>
1751
- <pre>
1752
- def p_binary_operators(p):
1753
- '''expression : expression PLUS term
1754
- | expression MINUS term
1755
- term : term TIMES factor
1756
- | term DIVIDE factor'''
1757
- if p[2] == '+':
1758
- p[0] = p[1] + p[3]
1759
- elif p[2] == '-':
1760
- p[0] = p[1] - p[3]
1761
- elif p[2] == '*':
1762
- p[0] = p[1] * p[3]
1763
- elif p[2] == '/':
1764
- p[0] = p[1] / p[3]
1765
- </pre>
1766
- </blockquote>
1767
-
1768
- When combining grammar rules into a single function, it is usually a good idea for all of the rules to have
1769
- a similar structure (e.g., the same number of terms). Otherwise, the corresponding action code may be more
1770
- complicated than necessary. However, it is possible to handle simple cases using len(). For example:
1771
-
1772
- <blockquote>
1773
- <pre>
1774
- def p_expressions(p):
1775
- '''expression : expression MINUS expression
1776
- | MINUS expression'''
1777
- if (len(p) == 4):
1778
- p[0] = p[1] - p[3]
1779
- elif (len(p) == 3):
1780
- p[0] = -p[2]
1781
- </pre>
1782
- </blockquote>
1783
-
1784
- If parsing performance is a concern, you should resist the urge to put
1785
- too much conditional processing into a single grammar rule as shown in
1786
- these examples. When you add checks to see which grammar rule is
1787
- being handled, you are actually duplicating the work that the parser
1788
- has already performed (i.e., the parser already knows exactly what rule it
1789
- matched). You can eliminate this overhead by using a
1790
- separate <tt>p_rule()</tt> function for each grammar rule.
1791
-
1792
- <H3><a name="ply_nn26"></a>6.3 Character Literals</H3>
1793
-
1794
-
1795
- If desired, a grammar may contain tokens defined as single character literals. For example:
1796
-
1797
- <blockquote>
1798
- <pre>
1799
- def p_binary_operators(p):
1800
- '''expression : expression '+' term
1801
- | expression '-' term
1802
- term : term '*' factor
1803
- | term '/' factor'''
1804
- if p[2] == '+':
1805
- p[0] = p[1] + p[3]
1806
- elif p[2] == '-':
1807
- p[0] = p[1] - p[3]
1808
- elif p[2] == '*':
1809
- p[0] = p[1] * p[3]
1810
- elif p[2] == '/':
1811
- p[0] = p[1] / p[3]
1812
- </pre>
1813
- </blockquote>
1814
-
1815
- A character literal must be enclosed in quotes such as <tt>'+'</tt>. In addition, if literals are used, they must be declared in the
1816
- corresponding <tt>lex</tt> file through the use of a special <tt>literals</tt> declaration.
1817
-
1818
- <blockquote>
1819
- <pre>
1820
- # Literals. Should be placed in module given to lex()
1821
- literals = ['+','-','*','/' ]
1822
- </pre>
1823
- </blockquote>
1824
-
1825
- <b>Character literals are limited to a single character</b>. Thus, it is not legal to specify literals such as <tt>'&lt;='</tt> or <tt>'=='</tt>. For this, use
1826
- the normal lexing rules (e.g., define a rule such as <tt>t_EQ = r'=='</tt>).
1827
-
1828
- <H3><a name="ply_nn26"></a>6.4 Empty Productions</H3>
1829
-
1830
-
1831
- <tt>yacc.py</tt> can handle empty productions by defining a rule like this:
1832
-
1833
- <blockquote>
1834
- <pre>
1835
- def p_empty(p):
1836
- 'empty :'
1837
- pass
1838
- </pre>
1839
- </blockquote>
1840
-
1841
- Now to use the empty production, simply use 'empty' as a symbol. For example:
1842
-
1843
- <blockquote>
1844
- <pre>
1845
- def p_optitem(p):
1846
- 'optitem : item'
1847
- ' | empty'
1848
- ...
1849
- </pre>
1850
- </blockquote>
1851
-
1852
- Note: You can write empty rules anywhere by simply specifying an empty
1853
- right hand side. However, I personally find that writing an "empty"
1854
- rule and using "empty" to denote an empty production is easier to read
1855
- and more clearly states your intentions.
1856
-
1857
- <H3><a name="ply_nn28"></a>6.5 Changing the starting symbol</H3>
1858
-
1859
-
1860
- Normally, the first rule found in a yacc specification defines the starting grammar rule (top level rule). To change this, simply
1861
- supply a <tt>start</tt> specifier in your file. For example:
1862
-
1863
- <blockquote>
1864
- <pre>
1865
- start = 'foo'
1866
-
1867
- def p_bar(p):
1868
- 'bar : A B'
1869
-
1870
- # This is the starting rule due to the start specifier above
1871
- def p_foo(p):
1872
- 'foo : bar X'
1873
- ...
1874
- </pre>
1875
- </blockquote>
1876
-
1877
- The use of a <tt>start</tt> specifier may be useful during debugging
1878
- since you can use it to have yacc build a subset of a larger grammar.
1879
- For this purpose, it is also possible to specify a starting symbol as
1880
- an argument to <tt>yacc()</tt>. For example:
1881
-
1882
- <blockquote>
1883
- <pre>
1884
- yacc.yacc(start='foo')
1885
- </pre>
1886
- </blockquote>
1887
-
1888
- <H3><a name="ply_nn27"></a>6.6 Dealing With Ambiguous Grammars</H3>
1889
-
1890
-
1891
- The expression grammar given in the earlier example has been written
1892
- in a special format to eliminate ambiguity. However, in many
1893
- situations, it is extremely difficult or awkward to write grammars in
1894
- this format. A much more natural way to express the grammar is in a
1895
- more compact form like this:
1896
-
1897
- <blockquote>
1898
- <pre>
1899
- expression : expression PLUS expression
1900
- | expression MINUS expression
1901
- | expression TIMES expression
1902
- | expression DIVIDE expression
1903
- | LPAREN expression RPAREN
1904
- | NUMBER
1905
- </pre>
1906
- </blockquote>
1907
-
1908
- Unfortunately, this grammar specification is ambiguous. For example,
1909
- if you are parsing the string "3 * 4 + 5", there is no way to tell how
1910
- the operators are supposed to be grouped. For example, does the
1911
- expression mean "(3 * 4) + 5" or is it "3 * (4+5)"?
1912
-
1913
- <p>
1914
- When an ambiguous grammar is given to <tt>yacc.py</tt> it will print
1915
- messages about "shift/reduce conflicts" or "reduce/reduce conflicts".
1916
- A shift/reduce conflict is caused when the parser generator can't
1917
- decide whether or not to reduce a rule or shift a symbol on the
1918
- parsing stack. For example, consider the string "3 * 4 + 5" and the
1919
- internal parsing stack:
1920
-
1921
- <blockquote>
1922
- <pre>
1923
- Step Symbol Stack Input Tokens Action
1924
- ---- --------------------- --------------------- -------------------------------
1925
- 1 $ 3 * 4 + 5$ Shift 3
1926
- 2 $ 3 * 4 + 5$ Reduce : expression : NUMBER
1927
- 3 $ expr * 4 + 5$ Shift *
1928
- 4 $ expr * 4 + 5$ Shift 4
1929
- 5 $ expr * 4 + 5$ Reduce: expression : NUMBER
1930
- 6 $ expr * expr + 5$ SHIFT/REDUCE CONFLICT ????
1931
- </pre>
1932
- </blockquote>
1933
-
1934
- In this case, when the parser reaches step 6, it has two options. One
1935
- is to reduce the rule <tt>expr : expr * expr</tt> on the stack. The
1936
- other option is to shift the token <tt>+</tt> on the stack. Both
1937
- options are perfectly legal from the rules of the
1938
- context-free-grammar.
1939
-
1940
- <p>
1941
- By default, all shift/reduce conflicts are resolved in favor of
1942
- shifting. Therefore, in the above example, the parser will always
1943
- shift the <tt>+</tt> instead of reducing. Although this strategy
1944
- works in many cases (for example, the case of
1945
- "if-then" versus "if-then-else"), it is not enough for arithmetic expressions. In fact,
1946
- in the above example, the decision to shift <tt>+</tt> is completely
1947
- wrong---we should have reduced <tt>expr * expr</tt> since
1948
- multiplication has higher mathematical precedence than addition.
1949
-
1950
- <p>To resolve ambiguity, especially in expression
1951
- grammars, <tt>yacc.py</tt> allows individual tokens to be assigned a
1952
- precedence level and associativity. This is done by adding a variable
1953
- <tt>precedence</tt> to the grammar file like this:
1954
-
1955
- <blockquote>
1956
- <pre>
1957
- precedence = (
1958
- ('left', 'PLUS', 'MINUS'),
1959
- ('left', 'TIMES', 'DIVIDE'),
1960
- )
1961
- </pre>
1962
- </blockquote>
1963
-
1964
- This declaration specifies that <tt>PLUS</tt>/<tt>MINUS</tt> have the
1965
- same precedence level and are left-associative and that
1966
- <tt>TIMES</tt>/<tt>DIVIDE</tt> have the same precedence and are
1967
- left-associative. Within the <tt>precedence</tt> declaration, tokens
1968
- are ordered from lowest to highest precedence. Thus, this declaration
1969
- specifies that <tt>TIMES</tt>/<tt>DIVIDE</tt> have higher precedence
1970
- than <tt>PLUS</tt>/<tt>MINUS</tt> (since they appear later in the
1971
- precedence specification).
1972
-
1973
- <p>
1974
- The precedence specification works by associating a numerical
1975
- precedence level value and associativity direction to the listed
1976
- tokens. For example, in the above example you get:
1977
-
1978
- <blockquote>
1979
- <pre>
1980
- PLUS : level = 1, assoc = 'left'
1981
- MINUS : level = 1, assoc = 'left'
1982
- TIMES : level = 2, assoc = 'left'
1983
- DIVIDE : level = 2, assoc = 'left'
1984
- </pre>
1985
- </blockquote>
1986
-
1987
- These values are then used to attach a numerical precedence value and
1988
- associativity direction to each grammar rule. <em>This is always
1989
- determined by looking at the precedence of the right-most terminal
1990
- symbol.</em> For example:
1991
-
1992
- <blockquote>
1993
- <pre>
1994
- expression : expression PLUS expression # level = 1, left
1995
- | expression MINUS expression # level = 1, left
1996
- | expression TIMES expression # level = 2, left
1997
- | expression DIVIDE expression # level = 2, left
1998
- | LPAREN expression RPAREN # level = None (not specified)
1999
- | NUMBER # level = None (not specified)
2000
- </pre>
2001
- </blockquote>
2002
-
2003
- When shift/reduce conflicts are encountered, the parser generator resolves the conflict by
2004
- looking at the precedence rules and associativity specifiers.
2005
-
2006
- <p>
2007
- <ol>
2008
- <li>If the current token has higher precedence than the rule on the stack, it is shifted.
2009
- <li>If the grammar rule on the stack has higher precedence, the rule is reduced.
2010
- <li>If the current token and the grammar rule have the same precedence, the
2011
- rule is reduced for left associativity, whereas the token is shifted for right associativity.
2012
- <li>If nothing is known about the precedence, shift/reduce conflicts are resolved in
2013
- favor of shifting (the default).
2014
- </ol>
2015
-
2016
- For example, if "expression PLUS expression" has been parsed and the
2017
- next token is "TIMES", the action is going to be a shift because
2018
- "TIMES" has a higher precedence level than "PLUS". On the other hand,
2019
- if "expression TIMES expression" has been parsed and the next token is
2020
- "PLUS", the action is going to be reduce because "PLUS" has a lower
2021
- precedence than "TIMES."
2022
-
2023
- <p>
2024
- When shift/reduce conflicts are resolved using the first three
2025
- techniques (with the help of precedence rules), <tt>yacc.py</tt> will
2026
- report no errors or conflicts in the grammar (although it will print
2027
- some information in the <tt>parser.out</tt> debugging file).
2028
-
2029
- <p>
2030
- One problem with the precedence specifier technique is that it is
2031
- sometimes necessary to change the precedence of an operator in certain
2032
- contexts. For example, consider a unary-minus operator in "3 + 4 *
2033
- -5". Mathematically, the unary minus is normally given a very high
2034
- precedence--being evaluated before the multiply. However, in our
2035
- precedence specifier, MINUS has a lower precedence than TIMES. To
2036
- deal with this, precedence rules can be given for so-called "fictitious tokens"
2037
- like this:
2038
-
2039
- <blockquote>
2040
- <pre>
2041
- precedence = (
2042
- ('left', 'PLUS', 'MINUS'),
2043
- ('left', 'TIMES', 'DIVIDE'),
2044
- ('right', 'UMINUS'), # Unary minus operator
2045
- )
2046
- </pre>
2047
- </blockquote>
2048
-
2049
- Now, in the grammar file, we can write our unary minus rule like this:
2050
-
2051
- <blockquote>
2052
- <pre>
2053
- def p_expr_uminus(p):
2054
- 'expression : MINUS expression %prec UMINUS'
2055
- p[0] = -p[2]
2056
- </pre>
2057
- </blockquote>
2058
-
2059
- In this case, <tt>%prec UMINUS</tt> overrides the default rule precedence--setting it to that
2060
- of UMINUS in the precedence specifier.
2061
-
2062
- <p>
2063
- At first, the use of UMINUS in this example may appear very confusing.
2064
- UMINUS is not an input token or a grammer rule. Instead, you should
2065
- think of it as the name of a special marker in the precedence table. When you use the <tt>%prec</tt> qualifier, you're simply
2066
- telling yacc that you want the precedence of the expression to be the same as for this special marker instead of the usual precedence.
2067
-
2068
- <p>
2069
- It is also possible to specify non-associativity in the <tt>precedence</tt> table. This would
2070
- be used when you <em>don't</em> want operations to chain together. For example, suppose
2071
- you wanted to support comparison operators like <tt>&lt;</tt> and <tt>&gt;</tt> but you didn't want to allow
2072
- combinations like <tt>a &lt; b &lt; c</tt>. To do this, simply specify a rule like this:
2073
-
2074
- <blockquote>
2075
- <pre>
2076
- precedence = (
2077
- ('nonassoc', 'LESSTHAN', 'GREATERTHAN'), # Nonassociative operators
2078
- ('left', 'PLUS', 'MINUS'),
2079
- ('left', 'TIMES', 'DIVIDE'),
2080
- ('right', 'UMINUS'), # Unary minus operator
2081
- )
2082
- </pre>
2083
- </blockquote>
2084
-
2085
- <p>
2086
- If you do this, the occurrence of input text such as <tt> a &lt; b &lt; c</tt> will result in a syntax error. However, simple
2087
- expressions such as <tt>a &lt; b</tt> will still be fine.
2088
-
2089
- <p>
2090
- Reduce/reduce conflicts are caused when there are multiple grammar
2091
- rules that can be applied to a given set of symbols. This kind of
2092
- conflict is almost always bad and is always resolved by picking the
2093
- rule that appears first in the grammar file. Reduce/reduce conflicts
2094
- are almost always caused when different sets of grammar rules somehow
2095
- generate the same set of symbols. For example:
2096
-
2097
- <blockquote>
2098
- <pre>
2099
- assignment : ID EQUALS NUMBER
2100
- | ID EQUALS expression
2101
-
2102
- expression : expression PLUS expression
2103
- | expression MINUS expression
2104
- | expression TIMES expression
2105
- | expression DIVIDE expression
2106
- | LPAREN expression RPAREN
2107
- | NUMBER
2108
- </pre>
2109
- </blockquote>
2110
-
2111
- In this case, a reduce/reduce conflict exists between these two rules:
2112
-
2113
- <blockquote>
2114
- <pre>
2115
- assignment : ID EQUALS NUMBER
2116
- expression : NUMBER
2117
- </pre>
2118
- </blockquote>
2119
-
2120
- For example, if you wrote "a = 5", the parser can't figure out if this
2121
- is supposed to be reduced as <tt>assignment : ID EQUALS NUMBER</tt> or
2122
- whether it's supposed to reduce the 5 as an expression and then reduce
2123
- the rule <tt>assignment : ID EQUALS expression</tt>.
2124
-
2125
- <p>
2126
- It should be noted that reduce/reduce conflicts are notoriously
2127
- difficult to spot simply looking at the input grammer. When a
2128
- reduce/reduce conflict occurs, <tt>yacc()</tt> will try to help by
2129
- printing a warning message such as this:
2130
-
2131
- <blockquote>
2132
- <pre>
2133
- WARNING: 1 reduce/reduce conflict
2134
- WARNING: reduce/reduce conflict in state 15 resolved using rule (assignment -> ID EQUALS NUMBER)
2135
- WARNING: rejected rule (expression -> NUMBER)
2136
- </pre>
2137
- </blockquote>
2138
-
2139
- This message identifies the two rules that are in conflict. However,
2140
- it may not tell you how the parser arrived at such a state. To try
2141
- and figure it out, you'll probably have to look at your grammar and
2142
- the contents of the
2143
- <tt>parser.out</tt> debugging file with an appropriately high level of
2144
- caffeination.
2145
-
2146
- <H3><a name="ply_nn28"></a>6.7 The parser.out file</H3>
2147
-
2148
-
2149
- Tracking down shift/reduce and reduce/reduce conflicts is one of the finer pleasures of using an LR
2150
- parsing algorithm. To assist in debugging, <tt>yacc.py</tt> creates a debugging file called
2151
- 'parser.out' when it generates the parsing table. The contents of this file look like the following:
2152
-
2153
- <blockquote>
2154
- <pre>
2155
- Unused terminals:
2156
-
2157
-
2158
- Grammar
2159
-
2160
- Rule 1 expression -> expression PLUS expression
2161
- Rule 2 expression -> expression MINUS expression
2162
- Rule 3 expression -> expression TIMES expression
2163
- Rule 4 expression -> expression DIVIDE expression
2164
- Rule 5 expression -> NUMBER
2165
- Rule 6 expression -> LPAREN expression RPAREN
2166
-
2167
- Terminals, with rules where they appear
2168
-
2169
- TIMES : 3
2170
- error :
2171
- MINUS : 2
2172
- RPAREN : 6
2173
- LPAREN : 6
2174
- DIVIDE : 4
2175
- PLUS : 1
2176
- NUMBER : 5
2177
-
2178
- Nonterminals, with rules where they appear
2179
-
2180
- expression : 1 1 2 2 3 3 4 4 6 0
2181
-
2182
-
2183
- Parsing method: LALR
2184
-
2185
-
2186
- state 0
2187
-
2188
- S' -> . expression
2189
- expression -> . expression PLUS expression
2190
- expression -> . expression MINUS expression
2191
- expression -> . expression TIMES expression
2192
- expression -> . expression DIVIDE expression
2193
- expression -> . NUMBER
2194
- expression -> . LPAREN expression RPAREN
2195
-
2196
- NUMBER shift and go to state 3
2197
- LPAREN shift and go to state 2
2198
-
2199
-
2200
- state 1
2201
-
2202
- S' -> expression .
2203
- expression -> expression . PLUS expression
2204
- expression -> expression . MINUS expression
2205
- expression -> expression . TIMES expression
2206
- expression -> expression . DIVIDE expression
2207
-
2208
- PLUS shift and go to state 6
2209
- MINUS shift and go to state 5
2210
- TIMES shift and go to state 4
2211
- DIVIDE shift and go to state 7
2212
-
2213
-
2214
- state 2
2215
-
2216
- expression -> LPAREN . expression RPAREN
2217
- expression -> . expression PLUS expression
2218
- expression -> . expression MINUS expression
2219
- expression -> . expression TIMES expression
2220
- expression -> . expression DIVIDE expression
2221
- expression -> . NUMBER
2222
- expression -> . LPAREN expression RPAREN
2223
-
2224
- NUMBER shift and go to state 3
2225
- LPAREN shift and go to state 2
2226
-
2227
-
2228
- state 3
2229
-
2230
- expression -> NUMBER .
2231
-
2232
- $ reduce using rule 5
2233
- PLUS reduce using rule 5
2234
- MINUS reduce using rule 5
2235
- TIMES reduce using rule 5
2236
- DIVIDE reduce using rule 5
2237
- RPAREN reduce using rule 5
2238
-
2239
-
2240
- state 4
2241
-
2242
- expression -> expression TIMES . expression
2243
- expression -> . expression PLUS expression
2244
- expression -> . expression MINUS expression
2245
- expression -> . expression TIMES expression
2246
- expression -> . expression DIVIDE expression
2247
- expression -> . NUMBER
2248
- expression -> . LPAREN expression RPAREN
2249
-
2250
- NUMBER shift and go to state 3
2251
- LPAREN shift and go to state 2
2252
-
2253
-
2254
- state 5
2255
-
2256
- expression -> expression MINUS . expression
2257
- expression -> . expression PLUS expression
2258
- expression -> . expression MINUS expression
2259
- expression -> . expression TIMES expression
2260
- expression -> . expression DIVIDE expression
2261
- expression -> . NUMBER
2262
- expression -> . LPAREN expression RPAREN
2263
-
2264
- NUMBER shift and go to state 3
2265
- LPAREN shift and go to state 2
2266
-
2267
-
2268
- state 6
2269
-
2270
- expression -> expression PLUS . expression
2271
- expression -> . expression PLUS expression
2272
- expression -> . expression MINUS expression
2273
- expression -> . expression TIMES expression
2274
- expression -> . expression DIVIDE expression
2275
- expression -> . NUMBER
2276
- expression -> . LPAREN expression RPAREN
2277
-
2278
- NUMBER shift and go to state 3
2279
- LPAREN shift and go to state 2
2280
-
2281
-
2282
- state 7
2283
-
2284
- expression -> expression DIVIDE . expression
2285
- expression -> . expression PLUS expression
2286
- expression -> . expression MINUS expression
2287
- expression -> . expression TIMES expression
2288
- expression -> . expression DIVIDE expression
2289
- expression -> . NUMBER
2290
- expression -> . LPAREN expression RPAREN
2291
-
2292
- NUMBER shift and go to state 3
2293
- LPAREN shift and go to state 2
2294
-
2295
-
2296
- state 8
2297
-
2298
- expression -> LPAREN expression . RPAREN
2299
- expression -> expression . PLUS expression
2300
- expression -> expression . MINUS expression
2301
- expression -> expression . TIMES expression
2302
- expression -> expression . DIVIDE expression
2303
-
2304
- RPAREN shift and go to state 13
2305
- PLUS shift and go to state 6
2306
- MINUS shift and go to state 5
2307
- TIMES shift and go to state 4
2308
- DIVIDE shift and go to state 7
2309
-
2310
-
2311
- state 9
2312
-
2313
- expression -> expression TIMES expression .
2314
- expression -> expression . PLUS expression
2315
- expression -> expression . MINUS expression
2316
- expression -> expression . TIMES expression
2317
- expression -> expression . DIVIDE expression
2318
-
2319
- $ reduce using rule 3
2320
- PLUS reduce using rule 3
2321
- MINUS reduce using rule 3
2322
- TIMES reduce using rule 3
2323
- DIVIDE reduce using rule 3
2324
- RPAREN reduce using rule 3
2325
-
2326
- ! PLUS [ shift and go to state 6 ]
2327
- ! MINUS [ shift and go to state 5 ]
2328
- ! TIMES [ shift and go to state 4 ]
2329
- ! DIVIDE [ shift and go to state 7 ]
2330
-
2331
- state 10
2332
-
2333
- expression -> expression MINUS expression .
2334
- expression -> expression . PLUS expression
2335
- expression -> expression . MINUS expression
2336
- expression -> expression . TIMES expression
2337
- expression -> expression . DIVIDE expression
2338
-
2339
- $ reduce using rule 2
2340
- PLUS reduce using rule 2
2341
- MINUS reduce using rule 2
2342
- RPAREN reduce using rule 2
2343
- TIMES shift and go to state 4
2344
- DIVIDE shift and go to state 7
2345
-
2346
- ! TIMES [ reduce using rule 2 ]
2347
- ! DIVIDE [ reduce using rule 2 ]
2348
- ! PLUS [ shift and go to state 6 ]
2349
- ! MINUS [ shift and go to state 5 ]
2350
-
2351
- state 11
2352
-
2353
- expression -> expression PLUS expression .
2354
- expression -> expression . PLUS expression
2355
- expression -> expression . MINUS expression
2356
- expression -> expression . TIMES expression
2357
- expression -> expression . DIVIDE expression
2358
-
2359
- $ reduce using rule 1
2360
- PLUS reduce using rule 1
2361
- MINUS reduce using rule 1
2362
- RPAREN reduce using rule 1
2363
- TIMES shift and go to state 4
2364
- DIVIDE shift and go to state 7
2365
-
2366
- ! TIMES [ reduce using rule 1 ]
2367
- ! DIVIDE [ reduce using rule 1 ]
2368
- ! PLUS [ shift and go to state 6 ]
2369
- ! MINUS [ shift and go to state 5 ]
2370
-
2371
- state 12
2372
-
2373
- expression -> expression DIVIDE expression .
2374
- expression -> expression . PLUS expression
2375
- expression -> expression . MINUS expression
2376
- expression -> expression . TIMES expression
2377
- expression -> expression . DIVIDE expression
2378
-
2379
- $ reduce using rule 4
2380
- PLUS reduce using rule 4
2381
- MINUS reduce using rule 4
2382
- TIMES reduce using rule 4
2383
- DIVIDE reduce using rule 4
2384
- RPAREN reduce using rule 4
2385
-
2386
- ! PLUS [ shift and go to state 6 ]
2387
- ! MINUS [ shift and go to state 5 ]
2388
- ! TIMES [ shift and go to state 4 ]
2389
- ! DIVIDE [ shift and go to state 7 ]
2390
-
2391
- state 13
2392
-
2393
- expression -> LPAREN expression RPAREN .
2394
-
2395
- $ reduce using rule 6
2396
- PLUS reduce using rule 6
2397
- MINUS reduce using rule 6
2398
- TIMES reduce using rule 6
2399
- DIVIDE reduce using rule 6
2400
- RPAREN reduce using rule 6
2401
- </pre>
2402
- </blockquote>
2403
-
2404
- The different states that appear in this file are a representation of
2405
- every possible sequence of valid input tokens allowed by the grammar.
2406
- When receiving input tokens, the parser is building up a stack and
2407
- looking for matching rules. Each state keeps track of the grammar
2408
- rules that might be in the process of being matched at that point. Within each
2409
- rule, the "." character indicates the current location of the parse
2410
- within that rule. In addition, the actions for each valid input token
2411
- are listed. When a shift/reduce or reduce/reduce conflict arises,
2412
- rules <em>not</em> selected are prefixed with an !. For example:
2413
-
2414
- <blockquote>
2415
- <pre>
2416
- ! TIMES [ reduce using rule 2 ]
2417
- ! DIVIDE [ reduce using rule 2 ]
2418
- ! PLUS [ shift and go to state 6 ]
2419
- ! MINUS [ shift and go to state 5 ]
2420
- </pre>
2421
- </blockquote>
2422
-
2423
- By looking at these rules (and with a little practice), you can usually track down the source
2424
- of most parsing conflicts. It should also be stressed that not all shift-reduce conflicts are
2425
- bad. However, the only way to be sure that they are resolved correctly is to look at <tt>parser.out</tt>.
2426
-
2427
- <H3><a name="ply_nn29"></a>6.8 Syntax Error Handling</H3>
2428
-
2429
-
2430
- If you are creating a parser for production use, the handling of
2431
- syntax errors is important. As a general rule, you don't want a
2432
- parser to simply throw up its hands and stop at the first sign of
2433
- trouble. Instead, you want it to report the error, recover if possible, and
2434
- continue parsing so that all of the errors in the input get reported
2435
- to the user at once. This is the standard behavior found in compilers
2436
- for languages such as C, C++, and Java.
2437
-
2438
- In PLY, when a syntax error occurs during parsing, the error is immediately
2439
- detected (i.e., the parser does not read any more tokens beyond the
2440
- source of the error). However, at this point, the parser enters a
2441
- recovery mode that can be used to try and continue further parsing.
2442
- As a general rule, error recovery in LR parsers is a delicate
2443
- topic that involves ancient rituals and black-magic. The recovery mechanism
2444
- provided by <tt>yacc.py</tt> is comparable to Unix yacc so you may want
2445
- consult a book like O'Reilly's "Lex and Yacc" for some of the finer details.
2446
-
2447
- <p>
2448
- When a syntax error occurs, <tt>yacc.py</tt> performs the following steps:
2449
-
2450
- <ol>
2451
- <li>On the first occurrence of an error, the user-defined <tt>p_error()</tt> function
2452
- is called with the offending token as an argument. However, if the syntax error is due to
2453
- reaching the end-of-file, <tt>p_error()</tt> is called with an argument of <tt>None</tt>.
2454
- Afterwards, the parser enters
2455
- an "error-recovery" mode in which it will not make future calls to <tt>p_error()</tt> until it
2456
- has successfully shifted at least 3 tokens onto the parsing stack.
2457
-
2458
- <p>
2459
- <li>If no recovery action is taken in <tt>p_error()</tt>, the offending lookahead token is replaced
2460
- with a special <tt>error</tt> token.
2461
-
2462
- <p>
2463
- <li>If the offending lookahead token is already set to <tt>error</tt>, the top item of the parsing stack is
2464
- deleted.
2465
-
2466
- <p>
2467
- <li>If the entire parsing stack is unwound, the parser enters a restart state and attempts to start
2468
- parsing from its initial state.
2469
-
2470
- <p>
2471
- <li>If a grammar rule accepts <tt>error</tt> as a token, it will be
2472
- shifted onto the parsing stack.
2473
-
2474
- <p>
2475
- <li>If the top item of the parsing stack is <tt>error</tt>, lookahead tokens will be discarded until the
2476
- parser can successfully shift a new symbol or reduce a rule involving <tt>error</tt>.
2477
- </ol>
2478
-
2479
- <H4><a name="ply_nn30"></a>6.8.1 Recovery and resynchronization with error rules</H4>
2480
-
2481
-
2482
- The most well-behaved approach for handling syntax errors is to write grammar rules that include the <tt>error</tt>
2483
- token. For example, suppose your language had a grammar rule for a print statement like this:
2484
-
2485
- <blockquote>
2486
- <pre>
2487
- def p_statement_print(p):
2488
- 'statement : PRINT expr SEMI'
2489
- ...
2490
- </pre>
2491
- </blockquote>
2492
-
2493
- To account for the possibility of a bad expression, you might write an additional grammar rule like this:
2494
-
2495
- <blockquote>
2496
- <pre>
2497
- def p_statement_print_error(p):
2498
- 'statement : PRINT error SEMI'
2499
- print "Syntax error in print statement. Bad expression"
2500
-
2501
- </pre>
2502
- </blockquote>
2503
-
2504
- In this case, the <tt>error</tt> token will match any sequence of
2505
- tokens that might appear up to the first semicolon that is
2506
- encountered. Once the semicolon is reached, the rule will be
2507
- invoked and the <tt>error</tt> token will go away.
2508
-
2509
- <p>
2510
- This type of recovery is sometimes known as parser resynchronization.
2511
- The <tt>error</tt> token acts as a wildcard for any bad input text and
2512
- the token immediately following <tt>error</tt> acts as a
2513
- synchronization token.
2514
-
2515
- <p>
2516
- It is important to note that the <tt>error</tt> token usually does not appear as the last token
2517
- on the right in an error rule. For example:
2518
-
2519
- <blockquote>
2520
- <pre>
2521
- def p_statement_print_error(p):
2522
- 'statement : PRINT error'
2523
- print "Syntax error in print statement. Bad expression"
2524
- </pre>
2525
- </blockquote>
2526
-
2527
- This is because the first bad token encountered will cause the rule to
2528
- be reduced--which may make it difficult to recover if more bad tokens
2529
- immediately follow.
2530
-
2531
- <H4><a name="ply_nn31"></a>6.8.2 Panic mode recovery</H4>
2532
-
2533
-
2534
- An alternative error recovery scheme is to enter a panic mode recovery in which tokens are
2535
- discarded to a point where the parser might be able to recover in some sensible manner.
2536
-
2537
- <p>
2538
- Panic mode recovery is implemented entirely in the <tt>p_error()</tt> function. For example, this
2539
- function starts discarding tokens until it reaches a closing '}'. Then, it restarts the
2540
- parser in its initial state.
2541
-
2542
- <blockquote>
2543
- <pre>
2544
- def p_error(p):
2545
- print "Whoa. You are seriously hosed."
2546
- # Read ahead looking for a closing '}'
2547
- while 1:
2548
- tok = yacc.token() # Get the next token
2549
- if not tok or tok.type == 'RBRACE': break
2550
- yacc.restart()
2551
- </pre>
2552
- </blockquote>
2553
-
2554
- <p>
2555
- This function simply discards the bad token and tells the parser that the error was ok.
2556
-
2557
- <blockquote>
2558
- <pre>
2559
- def p_error(p):
2560
- print "Syntax error at token", p.type
2561
- # Just discard the token and tell the parser it's okay.
2562
- yacc.errok()
2563
- </pre>
2564
- </blockquote>
2565
-
2566
- <P>
2567
- Within the <tt>p_error()</tt> function, three functions are available to control the behavior
2568
- of the parser:
2569
- <p>
2570
- <ul>
2571
- <li><tt>yacc.errok()</tt>. This resets the parser state so it doesn't think it's in error-recovery
2572
- mode. This will prevent an <tt>error</tt> token from being generated and will reset the internal
2573
- error counters so that the next syntax error will call <tt>p_error()</tt> again.
2574
-
2575
- <p>
2576
- <li><tt>yacc.token()</tt>. This returns the next token on the input stream.
2577
-
2578
- <p>
2579
- <li><tt>yacc.restart()</tt>. This discards the entire parsing stack and resets the parser
2580
- to its initial state.
2581
- </ul>
2582
-
2583
- Note: these functions are only available when invoking <tt>p_error()</tt> and are not available
2584
- at any other time.
2585
-
2586
- <p>
2587
- To supply the next lookahead token to the parser, <tt>p_error()</tt> can return a token. This might be
2588
- useful if trying to synchronize on special characters. For example:
2589
-
2590
- <blockquote>
2591
- <pre>
2592
- def p_error(p):
2593
- # Read ahead looking for a terminating ";"
2594
- while 1:
2595
- tok = yacc.token() # Get the next token
2596
- if not tok or tok.type == 'SEMI': break
2597
- yacc.errok()
2598
-
2599
- # Return SEMI to the parser as the next lookahead token
2600
- return tok
2601
- </pre>
2602
- </blockquote>
2603
-
2604
- <H4><a name="ply_nn35"></a>6.8.3 Signaling an error from a production</H4>
2605
-
2606
-
2607
- If necessary, a production rule can manually force the parser to enter error recovery. This
2608
- is done by raising the <tt>SyntaxError</tt> exception like this:
2609
-
2610
- <blockquote>
2611
- <pre>
2612
- def p_production(p):
2613
- 'production : some production ...'
2614
- raise SyntaxError
2615
- </pre>
2616
- </blockquote>
2617
-
2618
- The effect of raising <tt>SyntaxError</tt> is the same as if the last symbol shifted onto the
2619
- parsing stack was actually a syntax error. Thus, when you do this, the last symbol shifted is popped off
2620
- of the parsing stack and the current lookahead token is set to an <tt>error</tt> token. The parser
2621
- then enters error-recovery mode where it tries to reduce rules that can accept <tt>error</tt> tokens.
2622
- The steps that follow from this point are exactly the same as if a syntax error were detected and
2623
- <tt>p_error()</tt> were called.
2624
-
2625
- <P>
2626
- One important aspect of manually setting an error is that the <tt>p_error()</tt> function will <b>NOT</b> be
2627
- called in this case. If you need to issue an error message, make sure you do it in the production that
2628
- raises <tt>SyntaxError</tt>.
2629
-
2630
- <P>
2631
- Note: This feature of PLY is meant to mimic the behavior of the YYERROR macro in yacc.
2632
-
2633
-
2634
- <H4><a name="ply_nn32"></a>6.8.4 General comments on error handling</H4>
2635
-
2636
-
2637
- For normal types of languages, error recovery with error rules and resynchronization characters is probably the most reliable
2638
- technique. This is because you can instrument the grammar to catch errors at selected places where it is relatively easy
2639
- to recover and continue parsing. Panic mode recovery is really only useful in certain specialized applications where you might want
2640
- to discard huge portions of the input text to find a valid restart point.
2641
-
2642
- <H3><a name="ply_nn33"></a>6.9 Line Number and Position Tracking</H3>
2643
-
2644
-
2645
- Position tracking is often a tricky problem when writing compilers.
2646
- By default, PLY tracks the line number and position of all tokens.
2647
- This information is available using the following functions:
2648
-
2649
- <ul>
2650
- <li><tt>p.lineno(num)</tt>. Return the line number for symbol <em>num</em>
2651
- <li><tt>p.lexpos(num)</tt>. Return the lexing position for symbol <em>num</em>
2652
- </ul>
2653
-
2654
- For example:
2655
-
2656
- <blockquote>
2657
- <pre>
2658
- def p_expression(p):
2659
- 'expression : expression PLUS expression'
2660
- line = p.lineno(2) # line number of the PLUS token
2661
- index = p.lexpos(2) # Position of the PLUS token
2662
- </pre>
2663
- </blockquote>
2664
-
2665
- As an optional feature, <tt>yacc.py</tt> can automatically track line
2666
- numbers and positions for all of the grammar symbols as well.
2667
- However, this extra tracking requires extra processing and can
2668
- significantly slow down parsing. Therefore, it must be enabled by
2669
- passing the
2670
- <tt>tracking=True</tt> option to <tt>yacc.parse()</tt>. For example:
2671
-
2672
- <blockquote>
2673
- <pre>
2674
- yacc.parse(data,tracking=True)
2675
- </pre>
2676
- </blockquote>
2677
-
2678
- Once enabled, the <tt>lineno()</tt> and <tt>lexpos()</tt> methods work
2679
- for all grammar symbols. In addition, two additional methods can be
2680
- used:
2681
-
2682
- <ul>
2683
- <li><tt>p.linespan(num)</tt>. Return a tuple (startline,endline) with the starting and ending line number for symbol <em>num</em>.
2684
- <li><tt>p.lexspan(num)</tt>. Return a tuple (start,end) with the starting and ending positions for symbol <em>num</em>.
2685
- </ul>
2686
-
2687
- For example:
2688
-
2689
- <blockquote>
2690
- <pre>
2691
- def p_expression(p):
2692
- 'expression : expression PLUS expression'
2693
- p.lineno(1) # Line number of the left expression
2694
- p.lineno(2) # line number of the PLUS operator
2695
- p.lineno(3) # line number of the right expression
2696
- ...
2697
- start,end = p.linespan(3) # Start,end lines of the right expression
2698
- starti,endi = p.lexspan(3) # Start,end positions of right expression
2699
-
2700
- </pre>
2701
- </blockquote>
2702
-
2703
- Note: The <tt>lexspan()</tt> function only returns the range of values up to the start of the last grammar symbol.
2704
-
2705
- <p>
2706
- Although it may be convenient for PLY to track position information on
2707
- all grammar symbols, this is often unnecessary. For example, if you
2708
- are merely using line number information in an error message, you can
2709
- often just key off of a specific token in the grammar rule. For
2710
- example:
2711
-
2712
- <blockquote>
2713
- <pre>
2714
- def p_bad_func(p):
2715
- 'funccall : fname LPAREN error RPAREN'
2716
- # Line number reported from LPAREN token
2717
- print "Bad function call at line", p.lineno(2)
2718
- </pre>
2719
- </blockquote>
2720
-
2721
- <p>
2722
- Similarly, you may get better parsing performance if you only
2723
- selectively propagate line number information where it's needed using
2724
- the <tt>p.set_lineno()</tt> method. For example:
2725
-
2726
- <blockquote>
2727
- <pre>
2728
- def p_fname(p):
2729
- 'fname : ID'
2730
- p[0] = p[1]
2731
- p.set_lineno(0,p.lineno(1))
2732
- </pre>
2733
- </blockquote>
2734
-
2735
- PLY doesn't retain line number information from rules that have already been
2736
- parsed. If you are building an abstract syntax tree and need to have line numbers,
2737
- you should make sure that the line numbers appear in the tree itself.
2738
-
2739
- <H3><a name="ply_nn34"></a>6.10 AST Construction</H3>
2740
-
2741
-
2742
- <tt>yacc.py</tt> provides no special functions for constructing an
2743
- abstract syntax tree. However, such construction is easy enough to do
2744
- on your own.
2745
-
2746
- <p>A minimal way to construct a tree is to simply create and
2747
- propagate a tuple or list in each grammar rule function. There
2748
- are many possible ways to do this, but one example would be something
2749
- like this:
2750
-
2751
- <blockquote>
2752
- <pre>
2753
- def p_expression_binop(p):
2754
- '''expression : expression PLUS expression
2755
- | expression MINUS expression
2756
- | expression TIMES expression
2757
- | expression DIVIDE expression'''
2758
-
2759
- p[0] = ('binary-expression',p[2],p[1],p[3])
2760
-
2761
- def p_expression_group(p):
2762
- 'expression : LPAREN expression RPAREN'
2763
- p[0] = ('group-expression',p[2])
2764
-
2765
- def p_expression_number(p):
2766
- 'expression : NUMBER'
2767
- p[0] = ('number-expression',p[1])
2768
- </pre>
2769
- </blockquote>
2770
-
2771
- <p>
2772
- Another approach is to create a set of data structure for different
2773
- kinds of abstract syntax tree nodes and assign nodes to <tt>p[0]</tt>
2774
- in each rule. For example:
2775
-
2776
- <blockquote>
2777
- <pre>
2778
- class Expr: pass
2779
-
2780
- class BinOp(Expr):
2781
- def __init__(self,left,op,right):
2782
- self.type = "binop"
2783
- self.left = left
2784
- self.right = right
2785
- self.op = op
2786
-
2787
- class Number(Expr):
2788
- def __init__(self,value):
2789
- self.type = "number"
2790
- self.value = value
2791
-
2792
- def p_expression_binop(p):
2793
- '''expression : expression PLUS expression
2794
- | expression MINUS expression
2795
- | expression TIMES expression
2796
- | expression DIVIDE expression'''
2797
-
2798
- p[0] = BinOp(p[1],p[2],p[3])
2799
-
2800
- def p_expression_group(p):
2801
- 'expression : LPAREN expression RPAREN'
2802
- p[0] = p[2]
2803
-
2804
- def p_expression_number(p):
2805
- 'expression : NUMBER'
2806
- p[0] = Number(p[1])
2807
- </pre>
2808
- </blockquote>
2809
-
2810
- The advantage to this approach is that it may make it easier to attach more complicated
2811
- semantics, type checking, code generation, and other features to the node classes.
2812
-
2813
- <p>
2814
- To simplify tree traversal, it may make sense to pick a very generic
2815
- tree structure for your parse tree nodes. For example:
2816
-
2817
- <blockquote>
2818
- <pre>
2819
- class Node:
2820
- def __init__(self,type,children=None,leaf=None):
2821
- self.type = type
2822
- if children:
2823
- self.children = children
2824
- else:
2825
- self.children = [ ]
2826
- self.leaf = leaf
2827
-
2828
- def p_expression_binop(p):
2829
- '''expression : expression PLUS expression
2830
- | expression MINUS expression
2831
- | expression TIMES expression
2832
- | expression DIVIDE expression'''
2833
-
2834
- p[0] = Node("binop", [p[1],p[3]], p[2])
2835
- </pre>
2836
- </blockquote>
2837
-
2838
- <H3><a name="ply_nn35"></a>6.11 Embedded Actions</H3>
2839
-
2840
-
2841
- The parsing technique used by yacc only allows actions to be executed at the end of a rule. For example,
2842
- suppose you have a rule like this:
2843
-
2844
- <blockquote>
2845
- <pre>
2846
- def p_foo(p):
2847
- "foo : A B C D"
2848
- print "Parsed a foo", p[1],p[2],p[3],p[4]
2849
- </pre>
2850
- </blockquote>
2851
-
2852
- <p>
2853
- In this case, the supplied action code only executes after all of the
2854
- symbols <tt>A</tt>, <tt>B</tt>, <tt>C</tt>, and <tt>D</tt> have been
2855
- parsed. Sometimes, however, it is useful to execute small code
2856
- fragments during intermediate stages of parsing. For example, suppose
2857
- you wanted to perform some action immediately after <tt>A</tt> has
2858
- been parsed. To do this, write an empty rule like this:
2859
-
2860
- <blockquote>
2861
- <pre>
2862
- def p_foo(p):
2863
- "foo : A seen_A B C D"
2864
- print "Parsed a foo", p[1],p[3],p[4],p[5]
2865
- print "seen_A returned", p[2]
2866
-
2867
- def p_seen_A(p):
2868
- "seen_A :"
2869
- print "Saw an A = ", p[-1] # Access grammar symbol to left
2870
- p[0] = some_value # Assign value to seen_A
2871
-
2872
- </pre>
2873
- </blockquote>
2874
-
2875
- <p>
2876
- In this example, the empty <tt>seen_A</tt> rule executes immediately
2877
- after <tt>A</tt> is shifted onto the parsing stack. Within this
2878
- rule, <tt>p[-1]</tt> refers to the symbol on the stack that appears
2879
- immediately to the left of the <tt>seen_A</tt> symbol. In this case,
2880
- it would be the value of <tt>A</tt> in the <tt>foo</tt> rule
2881
- immediately above. Like other rules, a value can be returned from an
2882
- embedded action by simply assigning it to <tt>p[0]</tt>
2883
-
2884
- <p>
2885
- The use of embedded actions can sometimes introduce extra shift/reduce conflicts. For example,
2886
- this grammar has no conflicts:
2887
-
2888
- <blockquote>
2889
- <pre>
2890
- def p_foo(p):
2891
- """foo : abcd
2892
- | abcx"""
2893
-
2894
- def p_abcd(p):
2895
- "abcd : A B C D"
2896
-
2897
- def p_abcx(p):
2898
- "abcx : A B C X"
2899
- </pre>
2900
- </blockquote>
2901
-
2902
- However, if you insert an embedded action into one of the rules like this,
2903
-
2904
- <blockquote>
2905
- <pre>
2906
- def p_foo(p):
2907
- """foo : abcd
2908
- | abcx"""
2909
-
2910
- def p_abcd(p):
2911
- "abcd : A B C D"
2912
-
2913
- def p_abcx(p):
2914
- "abcx : A B seen_AB C X"
2915
-
2916
- def p_seen_AB(p):
2917
- "seen_AB :"
2918
- </pre>
2919
- </blockquote>
2920
-
2921
- an extra shift-reduce conflict will be introduced. This conflict is
2922
- caused by the fact that the same symbol <tt>C</tt> appears next in
2923
- both the <tt>abcd</tt> and <tt>abcx</tt> rules. The parser can either
2924
- shift the symbol (<tt>abcd</tt> rule) or reduce the empty
2925
- rule <tt>seen_AB</tt> (<tt>abcx</tt> rule).
2926
-
2927
- <p>
2928
- A common use of embedded rules is to control other aspects of parsing
2929
- such as scoping of local variables. For example, if you were parsing C code, you might
2930
- write code like this:
2931
-
2932
- <blockquote>
2933
- <pre>
2934
- def p_statements_block(p):
2935
- "statements: LBRACE new_scope statements RBRACE"""
2936
- # Action code
2937
- ...
2938
- pop_scope() # Return to previous scope
2939
-
2940
- def p_new_scope(p):
2941
- "new_scope :"
2942
- # Create a new scope for local variables
2943
- s = new_scope()
2944
- push_scope(s)
2945
- ...
2946
- </pre>
2947
- </blockquote>
2948
-
2949
- In this case, the embedded action <tt>new_scope</tt> executes
2950
- immediately after a <tt>LBRACE</tt> (<tt>{</tt>) symbol is parsed.
2951
- This might adjust internal symbol tables and other aspects of the
2952
- parser. Upon completion of the rule <tt>statements_block</tt>, code
2953
- might undo the operations performed in the embedded action
2954
- (e.g., <tt>pop_scope()</tt>).
2955
-
2956
- <H3><a name="ply_nn36"></a>6.12 Miscellaneous Yacc Notes</H3>
2957
-
2958
-
2959
- <ul>
2960
- <li>The default parsing method is LALR. To use SLR instead, run yacc() as follows:
2961
-
2962
- <blockquote>
2963
- <pre>
2964
- yacc.yacc(method="SLR")
2965
- </pre>
2966
- </blockquote>
2967
- Note: LALR table generation takes approximately twice as long as SLR table generation. There is no
2968
- difference in actual parsing performance---the same code is used in both cases. LALR is preferred when working
2969
- with more complicated grammars since it is more powerful.
2970
-
2971
- <p>
2972
-
2973
- <li>By default, <tt>yacc.py</tt> relies on <tt>lex.py</tt> for tokenizing. However, an alternative tokenizer
2974
- can be supplied as follows:
2975
-
2976
- <blockquote>
2977
- <pre>
2978
- yacc.parse(lexer=x)
2979
- </pre>
2980
- </blockquote>
2981
- in this case, <tt>x</tt> must be a Lexer object that minimally has a <tt>x.token()</tt> method for retrieving the next
2982
- token. If an input string is given to <tt>yacc.parse()</tt>, the lexer must also have an <tt>x.input()</tt> method.
2983
-
2984
- <p>
2985
- <li>By default, the yacc generates tables in debugging mode (which produces the parser.out file and other output).
2986
- To disable this, use
2987
-
2988
- <blockquote>
2989
- <pre>
2990
- yacc.yacc(debug=0)
2991
- </pre>
2992
- </blockquote>
2993
-
2994
- <p>
2995
- <li>To change the name of the <tt>parsetab.py</tt> file, use:
2996
-
2997
- <blockquote>
2998
- <pre>
2999
- yacc.yacc(tabmodule="foo")
3000
- </pre>
3001
- </blockquote>
3002
-
3003
- <p>
3004
- <li>To change the directory in which the <tt>parsetab.py</tt> file (and other output files) are written, use:
3005
- <blockquote>
3006
- <pre>
3007
- yacc.yacc(tabmodule="foo",outputdir="somedirectory")
3008
- </pre>
3009
- </blockquote>
3010
-
3011
- <p>
3012
- <li>To prevent yacc from generating any kind of parser table file, use:
3013
- <blockquote>
3014
- <pre>
3015
- yacc.yacc(write_tables=0)
3016
- </pre>
3017
- </blockquote>
3018
-
3019
- Note: If you disable table generation, yacc() will regenerate the parsing tables
3020
- each time it runs (which may take awhile depending on how large your grammar is).
3021
-
3022
- <P>
3023
- <li>To print copious amounts of debugging during parsing, use:
3024
-
3025
- <blockquote>
3026
- <pre>
3027
- yacc.parse(debug=1)
3028
- </pre>
3029
- </blockquote>
3030
-
3031
- <p>
3032
- <li>The <tt>yacc.yacc()</tt> function really returns a parser object. If you want to support multiple
3033
- parsers in the same application, do this:
3034
-
3035
- <blockquote>
3036
- <pre>
3037
- p = yacc.yacc()
3038
- ...
3039
- p.parse()
3040
- </pre>
3041
- </blockquote>
3042
-
3043
- Note: The function <tt>yacc.parse()</tt> is bound to the last parser that was generated.
3044
-
3045
- <p>
3046
- <li>Since the generation of the LALR tables is relatively expensive, previously generated tables are
3047
- cached and reused if possible. The decision to regenerate the tables is determined by taking an MD5
3048
- checksum of all grammar rules and precedence rules. Only in the event of a mismatch are the tables regenerated.
3049
-
3050
- <p>
3051
- It should be noted that table generation is reasonably efficient, even for grammars that involve around a 100 rules
3052
- and several hundred states. For more complex languages such as C, table generation may take 30-60 seconds on a slow
3053
- machine. Please be patient.
3054
-
3055
- <p>
3056
- <li>Since LR parsing is driven by tables, the performance of the parser is largely independent of the
3057
- size of the grammar. The biggest bottlenecks will be the lexer and the complexity of the code in your grammar rules.
3058
- </ul>
3059
-
3060
- <H2><a name="ply_nn37"></a>7. Multiple Parsers and Lexers</H2>
3061
-
3062
-
3063
- In advanced parsing applications, you may want to have multiple
3064
- parsers and lexers.
3065
-
3066
- <p>
3067
- As a general rules this isn't a problem. However, to make it work,
3068
- you need to carefully make sure everything gets hooked up correctly.
3069
- First, make sure you save the objects returned by <tt>lex()</tt> and
3070
- <tt>yacc()</tt>. For example:
3071
-
3072
- <blockquote>
3073
- <pre>
3074
- lexer = lex.lex() # Return lexer object
3075
- parser = yacc.yacc() # Return parser object
3076
- </pre>
3077
- </blockquote>
3078
-
3079
- Next, when parsing, make sure you give the <tt>parse()</tt> function a reference to the lexer it
3080
- should be using. For example:
3081
-
3082
- <blockquote>
3083
- <pre>
3084
- parser.parse(text,lexer=lexer)
3085
- </pre>
3086
- </blockquote>
3087
-
3088
- If you forget to do this, the parser will use the last lexer
3089
- created--which is not always what you want.
3090
-
3091
- <p>
3092
- Within lexer and parser rule functions, these objects are also
3093
- available. In the lexer, the "lexer" attribute of a token refers to
3094
- the lexer object that triggered the rule. For example:
3095
-
3096
- <blockquote>
3097
- <pre>
3098
- def t_NUMBER(t):
3099
- r'\d+'
3100
- ...
3101
- print t.lexer # Show lexer object
3102
- </pre>
3103
- </blockquote>
3104
-
3105
- In the parser, the "lexer" and "parser" attributes refer to the lexer
3106
- and parser objects respectively.
3107
-
3108
- <blockquote>
3109
- <pre>
3110
- def p_expr_plus(p):
3111
- 'expr : expr PLUS expr'
3112
- ...
3113
- print p.parser # Show parser object
3114
- print p.lexer # Show lexer object
3115
- </pre>
3116
- </blockquote>
3117
-
3118
- If necessary, arbitrary attributes can be attached to the lexer or parser object.
3119
- For example, if you wanted to have different parsing modes, you could attach a mode
3120
- attribute to the parser object and look at it later.
3121
-
3122
- <H2><a name="ply_nn38"></a>8. Using Python's Optimized Mode</H2>
3123
-
3124
-
3125
- Because PLY uses information from doc-strings, parsing and lexing
3126
- information must be gathered while running the Python interpreter in
3127
- normal mode (i.e., not with the -O or -OO options). However, if you
3128
- specify optimized mode like this:
3129
-
3130
- <blockquote>
3131
- <pre>
3132
- lex.lex(optimize=1)
3133
- yacc.yacc(optimize=1)
3134
- </pre>
3135
- </blockquote>
3136
-
3137
- then PLY can later be used when Python runs in optimized mode. To make this work,
3138
- make sure you first run Python in normal mode. Once the lexing and parsing tables
3139
- have been generated the first time, run Python in optimized mode. PLY will use
3140
- the tables without the need for doc strings.
3141
-
3142
- <p>
3143
- Beware: running PLY in optimized mode disables a lot of error
3144
- checking. You should only do this when your project has stabilized
3145
- and you don't need to do any debugging. One of the purposes of
3146
- optimized mode is to substantially decrease the startup time of
3147
- your compiler (by assuming that everything is already properly
3148
- specified and works).
3149
-
3150
- <H2><a name="ply_nn44"></a>9. Advanced Debugging</H2>
3151
-
3152
-
3153
- <p>
3154
- Debugging a compiler is typically not an easy task. PLY provides some
3155
- advanced diagonistic capabilities through the use of Python's
3156
- <tt>logging</tt> module. The next two sections describe this:
3157
-
3158
- <H3><a name="ply_nn45"></a>9.1 Debugging the lex() and yacc() commands</H3>
3159
-
3160
-
3161
- <p>
3162
- Both the <tt>lex()</tt> and <tt>yacc()</tt> commands have a debugging
3163
- mode that can be enabled using the <tt>debug</tt> flag. For example:
3164
-
3165
- <blockquote>
3166
- <pre>
3167
- lex.lex(debug=True)
3168
- yacc.yacc(debug=True)
3169
- </pre>
3170
- </blockquote>
3171
-
3172
- Normally, the output produced by debugging is routed to either
3173
- standard error or, in the case of <tt>yacc()</tt>, to a file
3174
- <tt>parser.out</tt>. This output can be more carefully controlled
3175
- by supplying a logging object. Here is an example that adds
3176
- information about where different debugging messages are coming from:
3177
-
3178
- <blockquote>
3179
- <pre>
3180
- # Set up a logging object
3181
- import logging
3182
- logging.basicConfig(
3183
- level = logging.DEBUG,
3184
- filename = "parselog.txt",
3185
- filemode = "w",
3186
- format = "%(filename)10s:%(lineno)4d:%(message)s"
3187
- )
3188
- log = logging.getLogger()
3189
-
3190
- lex.lex(debug=True,debuglog=log)
3191
- yacc.yacc(debug=True,debuglog=log)
3192
- </pre>
3193
- </blockquote>
3194
-
3195
- If you supply a custom logger, the amount of debugging
3196
- information produced can be controlled by setting the logging level.
3197
- Typically, debugging messages are either issued at the <tt>DEBUG</tt>,
3198
- <tt>INFO</tt>, or <tt>WARNING</tt> levels.
3199
-
3200
- <p>
3201
- PLY's error messages and warnings are also produced using the logging
3202
- interface. This can be controlled by passing a logging object
3203
- using the <tt>errorlog</tt> parameter.
3204
-
3205
- <blockquote>
3206
- <pre>
3207
- lex.lex(errorlog=log)
3208
- yacc.yacc(errorlog=log)
3209
- </pre>
3210
- </blockquote>
3211
-
3212
- If you want to completely silence warnings, you can either pass in a
3213
- logging object with an appropriate filter level or use the <tt>NullLogger</tt>
3214
- object defined in either <tt>lex</tt> or <tt>yacc</tt>. For example:
3215
-
3216
- <blockquote>
3217
- <pre>
3218
- yacc.yacc(errorlog=yacc.NullLogger())
3219
- </pre>
3220
- </blockquote>
3221
-
3222
- <H3><a name="ply_nn46"></a>9.2 Run-time Debugging</H3>
3223
-
3224
-
3225
- <p>
3226
- To enable run-time debugging of a parser, use the <tt>debug</tt> option to parse. This
3227
- option can either be an integer (which simply turns debugging on or off) or an instance
3228
- of a logger object. For example:
3229
-
3230
- <blockquote>
3231
- <pre>
3232
- log = logging.getLogger()
3233
- parser.parse(input,debug=log)
3234
- </pre>
3235
- </blockquote>
3236
-
3237
- If a logging object is passed, you can use its filtering level to control how much
3238
- output gets generated. The <tt>INFO</tt> level is used to produce information
3239
- about rule reductions. The <tt>DEBUG</tt> level will show information about the
3240
- parsing stack, token shifts, and other details. The <tt>ERROR</tt> level shows information
3241
- related to parsing errors.
3242
-
3243
- <p>
3244
- For very complicated problems, you should pass in a logging object that
3245
- redirects to a file where you can more easily inspect the output after
3246
- execution.
3247
-
3248
- <H2><a name="ply_nn39"></a>10. Where to go from here?</H2>
3249
-
3250
-
3251
- The <tt>examples</tt> directory of the PLY distribution contains several simple examples. Please consult a
3252
- compilers textbook for the theory and underlying implementation details or LR parsing.
3253
-
3254
- </body>
3255
- </html>
3256
-
3257
-
3258
-
3259
-
3260
-
3261
-
3262
-