rufus-lua-win 5.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (459) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +69 -0
  6. data/Rakefile +1 -0
  7. data/lib/rufus/lua/win.rb +18 -0
  8. data/lib/rufus/lua/win/version.rb +7 -0
  9. data/rufus-lua-win.gemspec +23 -0
  10. data/vendor/lua/bin/liblua.dll +0 -0
  11. data/vendor/lua/lib/lua/LuaXml.lua +119 -0
  12. data/vendor/lua/lib/lua/alien.lua +250 -0
  13. data/vendor/lua/lib/lua/alien/core.dll +0 -0
  14. data/vendor/lua/lib/lua/alien/struct.dll +0 -0
  15. data/vendor/lua/lib/lua/base.lua +536 -0
  16. data/vendor/lua/lib/lua/bin.lua +20 -0
  17. data/vendor/lua/lib/lua/bit.dll +0 -0
  18. data/vendor/lua/lib/lua/cdlua.dll +0 -0
  19. data/vendor/lua/lib/lua/cdluacontextplus.dll +0 -0
  20. data/vendor/lua/lib/lua/cdluagl.dll +0 -0
  21. data/vendor/lua/lib/lua/cdluaim.dll +0 -0
  22. data/vendor/lua/lib/lua/cdluapdf.dll +0 -0
  23. data/vendor/lua/lib/lua/copas.lua +543 -0
  24. data/vendor/lua/lib/lua/coxpcall.lua +57 -0
  25. data/vendor/lua/lib/lua/date.lua +745 -0
  26. data/vendor/lua/lib/lua/debug_ext.lua +84 -0
  27. data/vendor/lua/lib/lua/debug_init.lua +2 -0
  28. data/vendor/lua/lib/lua/des56.dll +0 -0
  29. data/vendor/lua/lib/lua/dist/config.lua +109 -0
  30. data/vendor/lua/lib/lua/dist/constraints.lua +271 -0
  31. data/vendor/lua/lib/lua/dist/depends.lua +601 -0
  32. data/vendor/lua/lib/lua/dist/git.lua +307 -0
  33. data/vendor/lua/lib/lua/dist/init.lua +278 -0
  34. data/vendor/lua/lib/lua/dist/manifest.lua +225 -0
  35. data/vendor/lua/lib/lua/dist/package.lua +583 -0
  36. data/vendor/lua/lib/lua/dist/sys.lua +367 -0
  37. data/vendor/lua/lib/lua/dist/utils.lua +130 -0
  38. data/vendor/lua/lib/lua/ex.dll +0 -0
  39. data/vendor/lua/lib/lua/fstable.lua +116 -0
  40. data/vendor/lua/lib/lua/getopt.lua +273 -0
  41. data/vendor/lua/lib/lua/git.lua +5 -0
  42. data/vendor/lua/lib/lua/git/core.dll +0 -0
  43. data/vendor/lua/lib/lua/git/objects.lua +121 -0
  44. data/vendor/lua/lib/lua/git/pack.lua +316 -0
  45. data/vendor/lua/lib/lua/git/protocol.lua +188 -0
  46. data/vendor/lua/lib/lua/git/repo.lua +283 -0
  47. data/vendor/lua/lib/lua/git/util.lua +233 -0
  48. data/vendor/lua/lib/lua/gzio.dll +0 -0
  49. data/vendor/lua/lib/lua/gzip.lua +81 -0
  50. data/vendor/lua/lib/lua/iconv.dll +0 -0
  51. data/vendor/lua/lib/lua/imlua.dll +0 -0
  52. data/vendor/lua/lib/lua/imlua_fftw.dll +0 -0
  53. data/vendor/lua/lib/lua/imlua_jp2.dll +0 -0
  54. data/vendor/lua/lib/lua/imlua_process.dll +0 -0
  55. data/vendor/lua/lib/lua/imlua_process_omp.dll +0 -0
  56. data/vendor/lua/lib/lua/io_ext.lua +115 -0
  57. data/vendor/lua/lib/lua/iuplua.dll +0 -0
  58. data/vendor/lua/lib/lua/iuplua_mglplot.dll +0 -0
  59. data/vendor/lua/lib/lua/iuplua_pplot.dll +0 -0
  60. data/vendor/lua/lib/lua/iupluacd.dll +0 -0
  61. data/vendor/lua/lib/lua/iupluacontrols.dll +0 -0
  62. data/vendor/lua/lib/lua/iupluagl.dll +0 -0
  63. data/vendor/lua/lib/lua/iupluaim.dll +0 -0
  64. data/vendor/lua/lib/lua/iupluaimglib.dll +0 -0
  65. data/vendor/lua/lib/lua/iupluatuio.dll +0 -0
  66. data/vendor/lua/lib/lua/lanes-keeper.lua +302 -0
  67. data/vendor/lua/lib/lua/lanes.lua +591 -0
  68. data/vendor/lua/lib/lua/lanes/core.dll +0 -0
  69. data/vendor/lua/lib/lua/lcs.lua +55 -0
  70. data/vendor/lua/lib/lua/lemock.lua +659 -0
  71. data/vendor/lua/lib/lua/lfs.dll +0 -0
  72. data/vendor/lua/lib/lua/list.lua +375 -0
  73. data/vendor/lua/lib/lua/logging.lua +189 -0
  74. data/vendor/lua/lib/lua/logging/console.lua +22 -0
  75. data/vendor/lua/lib/lua/logging/email.lua +44 -0
  76. data/vendor/lua/lib/lua/logging/file.lua +55 -0
  77. data/vendor/lua/lib/lua/logging/rolling_file.lua +81 -0
  78. data/vendor/lua/lib/lua/logging/socket.lua +35 -0
  79. data/vendor/lua/lib/lua/logging/sql.lua +64 -0
  80. data/vendor/lua/lib/lua/loop/base.lua +68 -0
  81. data/vendor/lua/lib/lua/loop/cached.lua +312 -0
  82. data/vendor/lua/lib/lua/loop/collection/MapWithArrayOfKeys.lua +64 -0
  83. data/vendor/lua/lib/lua/loop/collection/ObjectCache.lua +39 -0
  84. data/vendor/lua/lib/lua/loop/collection/OrderedSet.lua +164 -0
  85. data/vendor/lua/lib/lua/loop/collection/PriorityQueue.lua +86 -0
  86. data/vendor/lua/lib/lua/loop/collection/UnorderedArray.lua +32 -0
  87. data/vendor/lua/lib/lua/loop/collection/UnorderedArraySet.lua +56 -0
  88. data/vendor/lua/lib/lua/loop/compiler/Arguments.lua +108 -0
  89. data/vendor/lua/lib/lua/loop/compiler/Conditional.lua +50 -0
  90. data/vendor/lua/lib/lua/loop/compiler/Expression.lua +215 -0
  91. data/vendor/lua/lib/lua/loop/component/base.lua +221 -0
  92. data/vendor/lua/lib/lua/loop/component/contained.lua +71 -0
  93. data/vendor/lua/lib/lua/loop/component/dynamic.lua +223 -0
  94. data/vendor/lua/lib/lua/loop/component/intercepted.lua +354 -0
  95. data/vendor/lua/lib/lua/loop/component/wrapped.lua +195 -0
  96. data/vendor/lua/lib/lua/loop/debug/Inspector.lua +521 -0
  97. data/vendor/lua/lib/lua/loop/debug/Matcher.lua +192 -0
  98. data/vendor/lua/lib/lua/loop/debug/Verbose.lua +266 -0
  99. data/vendor/lua/lib/lua/loop/debug/Viewer.lua +200 -0
  100. data/vendor/lua/lib/lua/loop/multiple.lua +105 -0
  101. data/vendor/lua/lib/lua/loop/object/Exception.lua +57 -0
  102. data/vendor/lua/lib/lua/loop/object/Publisher.lua +43 -0
  103. data/vendor/lua/lib/lua/loop/object/Wrapper.lua +39 -0
  104. data/vendor/lua/lib/lua/loop/scoped.lua +585 -0
  105. data/vendor/lua/lib/lua/loop/serial/FileStream.lua +48 -0
  106. data/vendor/lua/lib/lua/loop/serial/Serializer.lua +291 -0
  107. data/vendor/lua/lib/lua/loop/serial/SocketStream.lua +51 -0
  108. data/vendor/lua/lib/lua/loop/serial/StringStream.lua +47 -0
  109. data/vendor/lua/lib/lua/loop/simple.lua +75 -0
  110. data/vendor/lua/lib/lua/loop/table.lua +71 -0
  111. data/vendor/lua/lib/lua/loop/thread/CoSocket.lua +416 -0
  112. data/vendor/lua/lib/lua/loop/thread/IOScheduler.lua +170 -0
  113. data/vendor/lua/lib/lua/loop/thread/Scheduler.lua +327 -0
  114. data/vendor/lua/lib/lua/loop/thread/SocketScheduler.lua +88 -0
  115. data/vendor/lua/lib/lua/loop/thread/Timer.lua +54 -0
  116. data/vendor/lua/lib/lua/lpeg.dll +0 -0
  117. data/vendor/lua/lib/lua/ltn12.lua +292 -0
  118. data/vendor/lua/lib/lua/luaXML_lib.dll +0 -0
  119. data/vendor/lua/lib/lua/luacurl.dll +0 -0
  120. data/vendor/lua/lib/lua/luadoc/config.lua +34 -0
  121. data/vendor/lua/lib/lua/luadoc/doclet/debug.lua +46 -0
  122. data/vendor/lua/lib/lua/luadoc/doclet/formatter.lua +84 -0
  123. data/vendor/lua/lib/lua/luadoc/doclet/html.lua +289 -0
  124. data/vendor/lua/lib/lua/luadoc/doclet/html/file.lp +113 -0
  125. data/vendor/lua/lib/lua/luadoc/doclet/html/function.lp +64 -0
  126. data/vendor/lua/lib/lua/luadoc/doclet/html/index.lp +70 -0
  127. data/vendor/lua/lib/lua/luadoc/doclet/html/luadoc.css +286 -0
  128. data/vendor/lua/lib/lua/luadoc/doclet/html/menu.lp +55 -0
  129. data/vendor/lua/lib/lua/luadoc/doclet/html/module.lp +109 -0
  130. data/vendor/lua/lib/lua/luadoc/doclet/html/table.lp +15 -0
  131. data/vendor/lua/lib/lua/luadoc/doclet/raw.lua +12 -0
  132. data/vendor/lua/lib/lua/luadoc/init.lua +58 -0
  133. data/vendor/lua/lib/lua/luadoc/lp.lua +130 -0
  134. data/vendor/lua/lib/lua/luadoc/taglet/standard.lua +495 -0
  135. data/vendor/lua/lib/lua/luadoc/taglet/standard/tags.lua +171 -0
  136. data/vendor/lua/lib/lua/luadoc/util.lua +233 -0
  137. data/vendor/lua/lib/lua/luagl.dll +0 -0
  138. data/vendor/lua/lib/lua/luaglu.dll +0 -0
  139. data/vendor/lua/lib/lua/luaidl.lua +113 -0
  140. data/vendor/lua/lib/lua/luaidl/lex.lua +793 -0
  141. data/vendor/lua/lib/lua/luaidl/pre.lua +149 -0
  142. data/vendor/lua/lib/lua/luaidl/sin.lua +3631 -0
  143. data/vendor/lua/lib/lua/luarocks/add.lua +108 -0
  144. data/vendor/lua/lib/lua/luarocks/admin_remove.lua +87 -0
  145. data/vendor/lua/lib/lua/luarocks/build.lua +330 -0
  146. data/vendor/lua/lib/lua/luarocks/build/builtin.lua +253 -0
  147. data/vendor/lua/lib/lua/luarocks/build/cmake.lua +54 -0
  148. data/vendor/lua/lib/lua/luarocks/build/command.lua +32 -0
  149. data/vendor/lua/lib/lua/luarocks/build/make.lua +92 -0
  150. data/vendor/lua/lib/lua/luarocks/cache.lua +85 -0
  151. data/vendor/lua/lib/lua/luarocks/cfg.lua +449 -0
  152. data/vendor/lua/lib/lua/luarocks/command_line.lua +163 -0
  153. data/vendor/lua/lib/lua/luarocks/deps.lua +654 -0
  154. data/vendor/lua/lib/lua/luarocks/dir.lua +69 -0
  155. data/vendor/lua/lib/lua/luarocks/download.lua +90 -0
  156. data/vendor/lua/lib/lua/luarocks/fetch.lua +321 -0
  157. data/vendor/lua/lib/lua/luarocks/fetch/cvs.lua +44 -0
  158. data/vendor/lua/lib/lua/luarocks/fetch/git.lua +81 -0
  159. data/vendor/lua/lib/lua/luarocks/fetch/git_file.lua +17 -0
  160. data/vendor/lua/lib/lua/luarocks/fetch/hg.lua +54 -0
  161. data/vendor/lua/lib/lua/luarocks/fetch/sscm.lua +42 -0
  162. data/vendor/lua/lib/lua/luarocks/fetch/svn.lua +53 -0
  163. data/vendor/lua/lib/lua/luarocks/fs.lua +40 -0
  164. data/vendor/lua/lib/lua/luarocks/fs/lua.lua +676 -0
  165. data/vendor/lua/lib/lua/luarocks/fs/unix.lua +88 -0
  166. data/vendor/lua/lib/lua/luarocks/fs/unix/tools.lua +325 -0
  167. data/vendor/lua/lib/lua/luarocks/fs/win32.lua +107 -0
  168. data/vendor/lua/lib/lua/luarocks/fs/win32/tools.lua +334 -0
  169. data/vendor/lua/lib/lua/luarocks/help.lua +101 -0
  170. data/vendor/lua/lib/lua/luarocks/index.lua +172 -0
  171. data/vendor/lua/lib/lua/luarocks/install.lua +151 -0
  172. data/vendor/lua/lib/lua/luarocks/list.lua +35 -0
  173. data/vendor/lua/lib/lua/luarocks/loader.lua +228 -0
  174. data/vendor/lua/lib/lua/luarocks/make.lua +71 -0
  175. data/vendor/lua/lib/lua/luarocks/make_manifest.lua +34 -0
  176. data/vendor/lua/lib/lua/luarocks/manif.lua +360 -0
  177. data/vendor/lua/lib/lua/luarocks/manif_core.lua +75 -0
  178. data/vendor/lua/lib/lua/luarocks/new_version.lua +141 -0
  179. data/vendor/lua/lib/lua/luarocks/pack.lua +205 -0
  180. data/vendor/lua/lib/lua/luarocks/path.lua +315 -0
  181. data/vendor/lua/lib/lua/luarocks/persist.lua +173 -0
  182. data/vendor/lua/lib/lua/luarocks/refresh_cache.lua +30 -0
  183. data/vendor/lua/lib/lua/luarocks/remove.lua +135 -0
  184. data/vendor/lua/lib/lua/luarocks/rep.lua +313 -0
  185. data/vendor/lua/lib/lua/luarocks/require.lua +6 -0
  186. data/vendor/lua/lib/lua/luarocks/search.lua +399 -0
  187. data/vendor/lua/lib/lua/luarocks/show.lua +138 -0
  188. data/vendor/lua/lib/lua/luarocks/site_config.lua +23 -0
  189. data/vendor/lua/lib/lua/luarocks/tools/patch.lua +712 -0
  190. data/vendor/lua/lib/lua/luarocks/tools/tar.lua +144 -0
  191. data/vendor/lua/lib/lua/luarocks/tools/zip.lua +245 -0
  192. data/vendor/lua/lib/lua/luarocks/type_check.lua +267 -0
  193. data/vendor/lua/lib/lua/luarocks/unpack.lua +151 -0
  194. data/vendor/lua/lib/lua/luarocks/util.lua +420 -0
  195. data/vendor/lua/lib/lua/luarocks/validate.lua +164 -0
  196. data/vendor/lua/lib/lua/luars232.dll +0 -0
  197. data/vendor/lua/lib/lua/luasql/mysql.dll +0 -0
  198. data/vendor/lua/lib/lua/luasql/postgres.dll +0 -0
  199. data/vendor/lua/lib/lua/luasql/sqlite3.dll +0 -0
  200. data/vendor/lua/lib/lua/luaunit.lua +601 -0
  201. data/vendor/lua/lib/lua/lxp.dll +0 -0
  202. data/vendor/lua/lib/lua/lxp/lom.lua +60 -0
  203. data/vendor/lua/lib/lua/math_ext.lua +27 -0
  204. data/vendor/lua/lib/lua/mbox.lua +53 -0
  205. data/vendor/lua/lib/lua/md5.lua +19 -0
  206. data/vendor/lua/lib/lua/md5/core.dll +0 -0
  207. data/vendor/lua/lib/lua/metalua.lua +0 -0
  208. data/vendor/lua/lib/lua/metalua/ast_to_string.mlua +553 -0
  209. data/vendor/lua/lib/lua/metalua/base.lua +104 -0
  210. data/vendor/lua/lib/lua/metalua/bytecode.lua +0 -0
  211. data/vendor/lua/lib/lua/metalua/clopts.mlua +204 -0
  212. data/vendor/lua/lib/lua/metalua/compiler.lua +3 -0
  213. data/vendor/lua/lib/lua/metalua/dollar.mlua +24 -0
  214. data/vendor/lua/lib/lua/metalua/extension/H-runtime.mlua +216 -0
  215. data/vendor/lua/lib/lua/metalua/extension/H.mlua +22 -0
  216. data/vendor/lua/lib/lua/metalua/extension/anaphoric.mlua +54 -0
  217. data/vendor/lua/lib/lua/metalua/extension/clist.mlua +149 -0
  218. data/vendor/lua/lib/lua/metalua/extension/continue.mlua +53 -0
  219. data/vendor/lua/lib/lua/metalua/extension/localin.mlua +2 -0
  220. data/vendor/lua/lib/lua/metalua/extension/log.mlua +39 -0
  221. data/vendor/lua/lib/lua/metalua/extension/match.mlua +374 -0
  222. data/vendor/lua/lib/lua/metalua/extension/ternary.mlua +10 -0
  223. data/vendor/lua/lib/lua/metalua/extension/trycatch.mlua +189 -0
  224. data/vendor/lua/lib/lua/metalua/extension/types-runtime.mlua +159 -0
  225. data/vendor/lua/lib/lua/metalua/extension/types.mlua +352 -0
  226. data/vendor/lua/lib/lua/metalua/extension/withdo.mlua +30 -0
  227. data/vendor/lua/lib/lua/metalua/extension/xglobal-runtime.lua +41 -0
  228. data/vendor/lua/lib/lua/metalua/extension/xglobal.mlua +20 -0
  229. data/vendor/lua/lib/lua/metalua/extension/xloop.mlua +100 -0
  230. data/vendor/lua/lib/lua/metalua/extension/xmatch.mlua +216 -0
  231. data/vendor/lua/lib/lua/metalua/metaloop.mlua +76 -0
  232. data/vendor/lua/lib/lua/metalua/mlc.lua +0 -0
  233. data/vendor/lua/lib/lua/metalua/mlc_xcall.lua +119 -0
  234. data/vendor/lua/lib/lua/metalua/mlp.lua +0 -0
  235. data/vendor/lua/lib/lua/metalua/package2.lua +101 -0
  236. data/vendor/lua/lib/lua/metalua/runtime.lua +3 -0
  237. data/vendor/lua/lib/lua/metalua/string2.lua +44 -0
  238. data/vendor/lua/lib/lua/metalua/table2.lua +372 -0
  239. data/vendor/lua/lib/lua/metalua/walk.mlua +304 -0
  240. data/vendor/lua/lib/lua/metalua/walk/bindings.mlua +41 -0
  241. data/vendor/lua/lib/lua/metalua/walk/id.mlua +186 -0
  242. data/vendor/lua/lib/lua/metalua/walk/scope.lua +54 -0
  243. data/vendor/lua/lib/lua/mime.lua +87 -0
  244. data/vendor/lua/lib/lua/mime/core.dll +0 -0
  245. data/vendor/lua/lib/lua/mobdebug.lua +1484 -0
  246. data/vendor/lua/lib/lua/modules.lua +16 -0
  247. data/vendor/lua/lib/lua/object.lua +56 -0
  248. data/vendor/lua/lib/lua/oil/Exception.lua +26 -0
  249. data/vendor/lua/lib/lua/oil/arch.lua +27 -0
  250. data/vendor/lua/lib/lua/oil/arch/basic/client.lua +29 -0
  251. data/vendor/lua/lib/lua/oil/arch/basic/common.lua +13 -0
  252. data/vendor/lua/lib/lua/oil/arch/basic/server.lua +27 -0
  253. data/vendor/lua/lib/lua/oil/arch/cooperative/common.lua +10 -0
  254. data/vendor/lua/lib/lua/oil/arch/cooperative/server.lua +16 -0
  255. data/vendor/lua/lib/lua/oil/arch/corba/client.lua +39 -0
  256. data/vendor/lua/lib/lua/oil/arch/corba/common.lua +58 -0
  257. data/vendor/lua/lib/lua/oil/arch/corba/intercepted/client.lua +9 -0
  258. data/vendor/lua/lib/lua/oil/arch/corba/intercepted/server.lua +9 -0
  259. data/vendor/lua/lib/lua/oil/arch/corba/server.lua +35 -0
  260. data/vendor/lua/lib/lua/oil/arch/ludo/byref.lua +18 -0
  261. data/vendor/lua/lib/lua/oil/arch/ludo/client.lua +19 -0
  262. data/vendor/lua/lib/lua/oil/arch/ludo/common.lua +18 -0
  263. data/vendor/lua/lib/lua/oil/arch/ludo/server.lua +19 -0
  264. data/vendor/lua/lib/lua/oil/arch/typed/client.lua +27 -0
  265. data/vendor/lua/lib/lua/oil/arch/typed/common.lua +9 -0
  266. data/vendor/lua/lib/lua/oil/arch/typed/server.lua +18 -0
  267. data/vendor/lua/lib/lua/oil/assert.lua +87 -0
  268. data/vendor/lua/lib/lua/oil/builder.lua +45 -0
  269. data/vendor/lua/lib/lua/oil/builder/basic/client.lua +31 -0
  270. data/vendor/lua/lib/lua/oil/builder/basic/common.lua +11 -0
  271. data/vendor/lua/lib/lua/oil/builder/basic/server.lua +13 -0
  272. data/vendor/lua/lib/lua/oil/builder/cooperative/common.lua +11 -0
  273. data/vendor/lua/lib/lua/oil/builder/cooperative/server.lua +11 -0
  274. data/vendor/lua/lib/lua/oil/builder/corba/client.lua +13 -0
  275. data/vendor/lua/lib/lua/oil/builder/corba/common.lua +24 -0
  276. data/vendor/lua/lib/lua/oil/builder/corba/gencode.lua +13 -0
  277. data/vendor/lua/lib/lua/oil/builder/corba/intercepted/client.lua +11 -0
  278. data/vendor/lua/lib/lua/oil/builder/corba/intercepted/server.lua +11 -0
  279. data/vendor/lua/lib/lua/oil/builder/corba/server.lua +13 -0
  280. data/vendor/lua/lib/lua/oil/builder/lua/client.lua +11 -0
  281. data/vendor/lua/lib/lua/oil/builder/lua/server.lua +12 -0
  282. data/vendor/lua/lib/lua/oil/builder/ludo/byref.lua +13 -0
  283. data/vendor/lua/lib/lua/oil/builder/ludo/client.lua +13 -0
  284. data/vendor/lua/lib/lua/oil/builder/ludo/common.lua +14 -0
  285. data/vendor/lua/lib/lua/oil/builder/ludo/server.lua +13 -0
  286. data/vendor/lua/lib/lua/oil/builder/typed/client.lua +16 -0
  287. data/vendor/lua/lib/lua/oil/builder/typed/server.lua +12 -0
  288. data/vendor/lua/lib/lua/oil/compat.lua +846 -0
  289. data/vendor/lua/lib/lua/oil/component.lua +1 -0
  290. data/vendor/lua/lib/lua/oil/corba/giop.lua +301 -0
  291. data/vendor/lua/lib/lua/oil/corba/giop/Codec.lua +1568 -0
  292. data/vendor/lua/lib/lua/oil/corba/giop/CodecGen.lua +589 -0
  293. data/vendor/lua/lib/lua/oil/corba/giop/Exception.lua +25 -0
  294. data/vendor/lua/lib/lua/oil/corba/giop/Indexer.lua +63 -0
  295. data/vendor/lua/lib/lua/oil/corba/giop/Listener.lua +343 -0
  296. data/vendor/lua/lib/lua/oil/corba/giop/Messenger.lua +228 -0
  297. data/vendor/lua/lib/lua/oil/corba/giop/Referrer.lua +180 -0
  298. data/vendor/lua/lib/lua/oil/corba/giop/Requester.lua +462 -0
  299. data/vendor/lua/lib/lua/oil/corba/idl.lua +597 -0
  300. data/vendor/lua/lib/lua/oil/corba/idl/Compiler.lua +133 -0
  301. data/vendor/lua/lib/lua/oil/corba/idl/Importer.lua +235 -0
  302. data/vendor/lua/lib/lua/oil/corba/idl/Indexer.lua +95 -0
  303. data/vendor/lua/lib/lua/oil/corba/idl/Registry.lua +1821 -0
  304. data/vendor/lua/lib/lua/oil/corba/idl/ir.lua +847 -0
  305. data/vendor/lua/lib/lua/oil/corba/idl/sysex.lua +21 -0
  306. data/vendor/lua/lib/lua/oil/corba/iiop/Profiler.lua +200 -0
  307. data/vendor/lua/lib/lua/oil/corba/intercepted/Listener.lua +158 -0
  308. data/vendor/lua/lib/lua/oil/corba/intercepted/Requester.lua +181 -0
  309. data/vendor/lua/lib/lua/oil/corba/services/event.lua +126 -0
  310. data/vendor/lua/lib/lua/oil/corba/services/event/ConsumerAdmin.lua +50 -0
  311. data/vendor/lua/lib/lua/oil/corba/services/event/EventFactory.lua +15 -0
  312. data/vendor/lua/lib/lua/oil/corba/services/event/EventQueue.lua +37 -0
  313. data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushConsumer.lua +75 -0
  314. data/vendor/lua/lib/lua/oil/corba/services/event/ProxyPushSupplier.lua +62 -0
  315. data/vendor/lua/lib/lua/oil/corba/services/event/SingleDeferredDispatcher.lua +60 -0
  316. data/vendor/lua/lib/lua/oil/corba/services/event/SingleSynchronousDispatcher.lua +39 -0
  317. data/vendor/lua/lib/lua/oil/corba/services/event/SupplierAdmin.lua +50 -0
  318. data/vendor/lua/lib/lua/oil/corba/services/naming.lua +436 -0
  319. data/vendor/lua/lib/lua/oil/kernel/base/Acceptor.lua +268 -0
  320. data/vendor/lua/lib/lua/oil/kernel/base/Channels.lua +121 -0
  321. data/vendor/lua/lib/lua/oil/kernel/base/Connector.lua +147 -0
  322. data/vendor/lua/lib/lua/oil/kernel/base/Dispatcher.lua +99 -0
  323. data/vendor/lua/lib/lua/oil/kernel/base/Proxies.lua +86 -0
  324. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/asynchronous.lua +56 -0
  325. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/protected.lua +17 -0
  326. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/synchronous.lua +17 -0
  327. data/vendor/lua/lib/lua/oil/kernel/base/Proxies/utils.lua +29 -0
  328. data/vendor/lua/lib/lua/oil/kernel/base/Receiver.lua +110 -0
  329. data/vendor/lua/lib/lua/oil/kernel/base/Servants.lua +207 -0
  330. data/vendor/lua/lib/lua/oil/kernel/base/Sockets.lua +44 -0
  331. data/vendor/lua/lib/lua/oil/kernel/cooperative/Receiver.lua +139 -0
  332. data/vendor/lua/lib/lua/oil/kernel/intercepted/Listener.lua +47 -0
  333. data/vendor/lua/lib/lua/oil/kernel/intercepted/Requester.lua +58 -0
  334. data/vendor/lua/lib/lua/oil/kernel/lua/Dispatcher.lua +76 -0
  335. data/vendor/lua/lib/lua/oil/kernel/lua/Proxies.lua +69 -0
  336. data/vendor/lua/lib/lua/oil/kernel/typed/Dispatcher.lua +91 -0
  337. data/vendor/lua/lib/lua/oil/kernel/typed/Proxies.lua +153 -0
  338. data/vendor/lua/lib/lua/oil/kernel/typed/Servants.lua +137 -0
  339. data/vendor/lua/lib/lua/oil/ludo/Codec.lua +66 -0
  340. data/vendor/lua/lib/lua/oil/ludo/CodecByRef.lua +103 -0
  341. data/vendor/lua/lib/lua/oil/ludo/Listener.lua +151 -0
  342. data/vendor/lua/lib/lua/oil/ludo/Referrer.lua +72 -0
  343. data/vendor/lua/lib/lua/oil/ludo/Requester.lua +107 -0
  344. data/vendor/lua/lib/lua/oil/oo.lua +1 -0
  345. data/vendor/lua/lib/lua/oil/port.lua +1 -0
  346. data/vendor/lua/lib/lua/oil/properties.lua +57 -0
  347. data/vendor/lua/lib/lua/oil/verbose.lua +133 -0
  348. data/vendor/lua/lib/lua/package_ext.lua +15 -0
  349. data/vendor/lua/lib/lua/parser.lua +268 -0
  350. data/vendor/lua/lib/lua/pl/Date.lua +555 -0
  351. data/vendor/lua/lib/lua/pl/List.lua +613 -0
  352. data/vendor/lua/lib/lua/pl/Map.lua +113 -0
  353. data/vendor/lua/lib/lua/pl/MultiMap.lua +62 -0
  354. data/vendor/lua/lib/lua/pl/OrderedMap.lua +151 -0
  355. data/vendor/lua/lib/lua/pl/Set.lua +153 -0
  356. data/vendor/lua/lib/lua/pl/app.lua +165 -0
  357. data/vendor/lua/lib/lua/pl/array2d.lua +501 -0
  358. data/vendor/lua/lib/lua/pl/class.lua +180 -0
  359. data/vendor/lua/lib/lua/pl/comprehension.lua +286 -0
  360. data/vendor/lua/lib/lua/pl/config.lua +176 -0
  361. data/vendor/lua/lib/lua/pl/data.lua +606 -0
  362. data/vendor/lua/lib/lua/pl/dir.lua +475 -0
  363. data/vendor/lua/lib/lua/pl/file.lua +70 -0
  364. data/vendor/lua/lib/lua/pl/func.lua +376 -0
  365. data/vendor/lua/lib/lua/pl/init.lua +68 -0
  366. data/vendor/lua/lib/lua/pl/input.lua +173 -0
  367. data/vendor/lua/lib/lua/pl/lapp.lua +407 -0
  368. data/vendor/lua/lib/lua/pl/lexer.lua +456 -0
  369. data/vendor/lua/lib/lua/pl/luabalanced.lua +264 -0
  370. data/vendor/lua/lib/lua/pl/operator.lua +201 -0
  371. data/vendor/lua/lib/lua/pl/path.lua +398 -0
  372. data/vendor/lua/lib/lua/pl/permute.lua +63 -0
  373. data/vendor/lua/lib/lua/pl/platf/luajava.lua +101 -0
  374. data/vendor/lua/lib/lua/pl/pretty.lua +285 -0
  375. data/vendor/lua/lib/lua/pl/seq.lua +551 -0
  376. data/vendor/lua/lib/lua/pl/sip.lua +344 -0
  377. data/vendor/lua/lib/lua/pl/strict.lua +70 -0
  378. data/vendor/lua/lib/lua/pl/stringio.lua +158 -0
  379. data/vendor/lua/lib/lua/pl/stringx.lua +440 -0
  380. data/vendor/lua/lib/lua/pl/tablex.lua +817 -0
  381. data/vendor/lua/lib/lua/pl/template.lua +103 -0
  382. data/vendor/lua/lib/lua/pl/test.lua +135 -0
  383. data/vendor/lua/lib/lua/pl/text.lua +243 -0
  384. data/vendor/lua/lib/lua/pl/utils.lua +550 -0
  385. data/vendor/lua/lib/lua/pl/xml.lua +689 -0
  386. data/vendor/lua/lib/lua/profiler.dll +0 -0
  387. data/vendor/lua/lib/lua/re.lua +248 -0
  388. data/vendor/lua/lib/lua/rex_onig.dll +0 -0
  389. data/vendor/lua/lib/lua/rex_pcre.dll +0 -0
  390. data/vendor/lua/lib/lua/rex_posix.dll +0 -0
  391. data/vendor/lua/lib/lua/rings.dll +0 -0
  392. data/vendor/lua/lib/lua/serialize.lua +193 -0
  393. data/vendor/lua/lib/lua/set.lua +149 -0
  394. data/vendor/lua/lib/lua/socket.lua +133 -0
  395. data/vendor/lua/lib/lua/socket/core.dll +0 -0
  396. data/vendor/lua/lib/lua/socket/ftp.lua +281 -0
  397. data/vendor/lua/lib/lua/socket/http.lua +350 -0
  398. data/vendor/lua/lib/lua/socket/smtp.lua +251 -0
  399. data/vendor/lua/lib/lua/socket/tp.lua +123 -0
  400. data/vendor/lua/lib/lua/socket/url.lua +297 -0
  401. data/vendor/lua/lib/lua/ssl.dll +0 -0
  402. data/vendor/lua/lib/lua/ssl.lua +93 -0
  403. data/vendor/lua/lib/lua/ssl/https.lua +138 -0
  404. data/vendor/lua/lib/lua/stable.lua +28 -0
  405. data/vendor/lua/lib/lua/std.lua +16 -0
  406. data/vendor/lua/lib/lua/strbuf.lua +32 -0
  407. data/vendor/lua/lib/lua/strict.lua +45 -0
  408. data/vendor/lua/lib/lua/string_ext.lua +274 -0
  409. data/vendor/lua/lib/lua/table_ext.lua +117 -0
  410. data/vendor/lua/lib/lua/tar.lua +262 -0
  411. data/vendor/lua/lib/lua/task.dll +0 -0
  412. data/vendor/lua/lib/lua/tree.lua +81 -0
  413. data/vendor/lua/lib/lua/unicode.dll +0 -0
  414. data/vendor/lua/lib/lua/verbose_require.lua +11 -0
  415. data/vendor/lua/lib/lua/vstruct.lua +86 -0
  416. data/vendor/lua/lib/lua/vstruct/ast.lua +192 -0
  417. data/vendor/lua/lib/lua/vstruct/ast/Bitpack.lua +33 -0
  418. data/vendor/lua/lib/lua/vstruct/ast/Generator.lua +174 -0
  419. data/vendor/lua/lib/lua/vstruct/ast/IO.lua +45 -0
  420. data/vendor/lua/lib/lua/vstruct/ast/List.lua +56 -0
  421. data/vendor/lua/lib/lua/vstruct/ast/Name.lua +20 -0
  422. data/vendor/lua/lib/lua/vstruct/ast/Repeat.lua +23 -0
  423. data/vendor/lua/lib/lua/vstruct/ast/Root.lua +19 -0
  424. data/vendor/lua/lib/lua/vstruct/ast/Table.lua +65 -0
  425. data/vendor/lua/lib/lua/vstruct/cursor.lua +81 -0
  426. data/vendor/lua/lib/lua/vstruct/io.lua +45 -0
  427. data/vendor/lua/lib/lua/vstruct/io/a.lua +24 -0
  428. data/vendor/lua/lib/lua/vstruct/io/b.lua +28 -0
  429. data/vendor/lua/lib/lua/vstruct/io/bigendian.lua +21 -0
  430. data/vendor/lua/lib/lua/vstruct/io/c.lua +25 -0
  431. data/vendor/lua/lib/lua/vstruct/io/defaults.lua +24 -0
  432. data/vendor/lua/lib/lua/vstruct/io/endianness.lua +41 -0
  433. data/vendor/lua/lib/lua/vstruct/io/f.lua +129 -0
  434. data/vendor/lua/lib/lua/vstruct/io/hostendian.lua +21 -0
  435. data/vendor/lua/lib/lua/vstruct/io/i.lua +42 -0
  436. data/vendor/lua/lib/lua/vstruct/io/littleendian.lua +21 -0
  437. data/vendor/lua/lib/lua/vstruct/io/m.lua +62 -0
  438. data/vendor/lua/lib/lua/vstruct/io/p.lua +23 -0
  439. data/vendor/lua/lib/lua/vstruct/io/s.lua +27 -0
  440. data/vendor/lua/lib/lua/vstruct/io/seekb.lua +18 -0
  441. data/vendor/lua/lib/lua/vstruct/io/seekf.lua +18 -0
  442. data/vendor/lua/lib/lua/vstruct/io/seekto.lua +18 -0
  443. data/vendor/lua/lib/lua/vstruct/io/u.lua +54 -0
  444. data/vendor/lua/lib/lua/vstruct/io/x.lua +34 -0
  445. data/vendor/lua/lib/lua/vstruct/io/z.lua +63 -0
  446. data/vendor/lua/lib/lua/vstruct/lexer.lua +100 -0
  447. data/vendor/lua/lib/lua/vstruct/pack.lua +142 -0
  448. data/vendor/lua/lib/lua/vstruct/test.lua +47 -0
  449. data/vendor/lua/lib/lua/vstruct/test/basic.lua +73 -0
  450. data/vendor/lua/lib/lua/vstruct/test/common.lua +100 -0
  451. data/vendor/lua/lib/lua/vstruct/test/fp-bigendian.lua +56 -0
  452. data/vendor/lua/lib/lua/vstruct/test/fp-littleendian.lua +56 -0
  453. data/vendor/lua/lib/lua/vstruct/test/struct-test-gen.lua +1230 -0
  454. data/vendor/lua/lib/lua/vstruct/unpack.lua +126 -0
  455. data/vendor/lua/lib/lua/wx.dll +0 -0
  456. data/vendor/lua/lib/lua/xml.lua +75 -0
  457. data/vendor/lua/lib/lua/zip.dll +0 -0
  458. data/vendor/lua/lib/lua/zlib.dll +0 -0
  459. metadata +529 -0
@@ -0,0 +1,15 @@
1
+ -- Additions to the package module.
2
+ module ("package", package.seeall)
3
+
4
+
5
+ --- Make named constants for <code>package.config</code> (undocumented
6
+ -- in 5.1; see luaconf.h for C equivalents).
7
+ -- @class table
8
+ -- @name package
9
+ -- @field dirsep directory separator
10
+ -- @field pathsep path separator
11
+ -- @field path_mark string that marks substitution points in a path template
12
+ -- @field execdir (Windows only) replaced by the executable's directory in a path
13
+ -- @field igmark Mark to ignore all before it when building <code>luaopen_</code> function name.
14
+ dirsep, pathsep, path_mark, execdir, igmark =
15
+ string.match (package.config, "^([^\n]+)\n([^\n]+)\n([^\n]+)\n([^\n]+)\n([^\n]+)")
@@ -0,0 +1,268 @@
1
+ --- Parser generator.
2
+ -- <p>A parser is created by</p>
3
+ -- <blockquote>
4
+ -- <p><code>p = Parser {grammar}</code></p>
5
+ -- </blockquote>
6
+ -- <p>and called with</p>
7
+ -- <blockquote>
8
+ -- <p><code>result = p:parse (start_token, token_list[,
9
+ -- from])</code></p>
10
+ -- </blockquote>
11
+ -- <p>where start_token is the non-terminal at which to start parsing
12
+ -- in the grammar, token_list is a list of tokens of the form</p>
13
+ -- <blockquote>
14
+ -- <p><code>{ty = "token_type", tok = "token_text"}</code></p>
15
+ -- </blockquote>
16
+ -- <p>and from is the token in the list from which to start (the
17
+ -- default value is 1).</p>
18
+ -- <p>The output of the parser is a tree, each of whose
19
+ -- nodes is of the form:</p>
20
+ -- <blockquote>
21
+ -- <p><code>{ty = symbol, node<sub>1</sub> = tree<sub>1</sub>,
22
+ -- node<sub>2</sub> = tree<sub>2</sub>, ... [, list]}</code></p>
23
+ -- </blockquote>
24
+ -- <p>where each <code>node<sub>i</sub></code> is a symbolic name, and
25
+ -- list is the list of trees returned if the corresponding token was a
26
+ -- list token.</p>
27
+ -- <p>A grammar is a table of rules of the form</p>
28
+ -- <blockquote>
29
+ -- <p><code>non-terminal = {production<sub>1</sub>,
30
+ -- production<sub>2</sub>, ...}</code></p>
31
+ -- </blockquote>
32
+ -- <p>plus a special item</p>
33
+ -- <blockquote>
34
+ -- <p><code>lexemes = Set {"class<sub>1</sub>", "class<sub>2</sub>",
35
+ -- ...}</code></p>
36
+ -- </blockquote>
37
+ -- <p>Each production gives a form that a non-terminal may take. A
38
+ -- production has the form</p>
39
+ -- <blockquote>
40
+ -- <p><code>production = {"token<sub>1</sub>", "token<sub>2</sub>",
41
+ -- ..., [action][,abstract]}</code></p>
42
+ -- </blockquote>
43
+ -- <p>A production</p>
44
+ -- <ul>
45
+ -- <li>must not start with the non-terminal being defined (it must not
46
+ -- be left-recursive)</li>
47
+ -- <li>must not be a prefix of a later production in the same
48
+ -- non-terminal</li>
49
+ -- </ul>
50
+ -- <p>Each token may be</p>
51
+ -- <ul>
52
+ -- <li>a non-terminal, i.e. a token defined by the grammar</li>
53
+ -- <ul>
54
+ -- <li>an optional symbol is indicated by the suffix <code>_opt</code></li>
55
+ -- <li>a list is indicated by the suffix <code>_list</code>, and may be
56
+ -- followed by <code>_&le;separator-symbol&gt;</code> (default is no separator)</li>
57
+ -- </ul>
58
+ -- <li>a lexeme class</li>
59
+ -- <li>a string to match literally</li>
60
+ -- </ul>
61
+ -- <p>The parse tree for a literal string or lexeme class is the string
62
+ -- that was matched. The parse tree for a non-terminal is a table of
63
+ -- the form</p>
64
+ -- <blockquote>
65
+ -- <p><code>{ty = "non_terminal_name", tree<sub>1</sub>,
66
+ -- tree<sub>2</sub>, ...}</code></p>
67
+ -- </blockquote>
68
+ -- <p>where the <code>tree<sub>i</sub></code> are the parse trees for the
69
+ -- corresponding terminals and non-terminals.</p>
70
+ -- <p>An action is of the form</p>
71
+ -- <blockquote>
72
+ -- <p><code>action = function (tree, token, pos) ... return tree_
73
+ -- end</code></p>
74
+ -- </blockquote>
75
+ -- <p>It is passed the parse tree for the current node, the token list,
76
+ -- and the current position in the token list, and returns a new parse
77
+ -- tree.</p>
78
+ -- <p>An abstract syntax rule is of the form</p>
79
+ -- <blockquote>
80
+ -- <p><code>name = {i<sub>1</sub>, i<sub>2</sub>, ...}</code></p>
81
+ -- </blockquote>
82
+ -- <p>where <code>i<sub>1</sub></code>, <code>i<sub>2</sub></code>,
83
+ -- ... are numbers. This results in a parse tree of the form</p>
84
+ -- <blockquote>
85
+ -- <p><code>{ty = "name"; tree<sub>i<sub>1</sub></sub>,
86
+ -- tree<sub>i<sub>2</sub></sub>, ...}</code></p>
87
+ -- </blockquote>
88
+ -- <p>If a production has no abstract syntax rule, the result is the
89
+ -- parse node for the current node.</p>
90
+ -- <p>FIXME: Give lexemes as an extra argument to <code>Parser</code>?
91
+ -- <br>FIXME: Rename second argument to parse method to "tokens"?
92
+ -- <br>FIXME: Make start_token an optional argument to parse? (swap with
93
+ -- token list) and have it default to the first non-terminal?</p>
94
+ module ("parser", package.seeall)
95
+
96
+ require "object"
97
+
98
+
99
+ Parser = Object {_init = {"grammar"}}
100
+
101
+
102
+ --- Parser constructor
103
+ -- @param grammar parser grammar
104
+ -- @return parser
105
+ function Parser:_init (grammar)
106
+ local init = table.clone_rename (self._init, grammar)
107
+ -- Reformat the abstract syntax rules
108
+ for rname, rule in pairs (init.grammar) do
109
+ if name ~= "lexemes" then
110
+ for pnum, prod in ipairs (rule) do
111
+ local abstract
112
+ for i, v in pairs (prod) do
113
+ if type (i) == "string" and i ~= "action" then
114
+ if abstract then
115
+ print (prod)
116
+ die ("more than one abstract rule for " .. rname .. "."
117
+ .. tostring (pnum))
118
+ else
119
+ if type (v) ~= "table" then
120
+ die ("bad abstract syntax rule of type " .. type (v))
121
+ end
122
+ abstract = {ty = i, template = v}
123
+ prod[i] = nil
124
+ end
125
+ end
126
+ end
127
+ if abstract then
128
+ prod.abstract = abstract
129
+ end
130
+ end
131
+ end
132
+ end
133
+ return table.merge (self, init)
134
+ end
135
+
136
+ --- Parse a token list.
137
+ -- @param start the token at which to start
138
+ -- @param token the list of tokens
139
+ -- @param from the index of the token to start from (default: 1)
140
+ -- @return parse tree
141
+ function Parser:parse (start, token, from)
142
+
143
+ local grammar = self.grammar -- for consistency and brevity
144
+ local rule, symbol -- functions called before they are defined
145
+
146
+ -- Try to parse an optional symbol.
147
+ -- @param sym the symbol being tried
148
+ -- @param from the index of the token to start from
149
+ -- @return the resulting parse tree, or false if empty
150
+ -- @return the index of the first unused token, or false to
151
+ -- indicate failure
152
+ local function optional (sym, from)
153
+ local tree, to = symbol (sym, from)
154
+ if to then
155
+ return tree, to
156
+ else
157
+ return false, from
158
+ end
159
+ end
160
+
161
+ -- Try to parse a list of symbols.
162
+ -- @param sym the symbol being tried
163
+ -- @param sep the list separator
164
+ -- @param from the index of the token to start from
165
+ -- @return the resulting parse tree, or false if empty
166
+ -- @return the index of the first unused token, or false to
167
+ -- indicate failure
168
+ local function list (sym, sep, from)
169
+ local tree, to
170
+ tree, from = symbol (sym, from)
171
+ local list = {tree}
172
+ if from == false then
173
+ return list, false
174
+ end
175
+ to = from
176
+ repeat
177
+ if sep ~= "" then
178
+ tree, from = symbol (sep, from)
179
+ end
180
+ if from then
181
+ tree, from = symbol (sym, from)
182
+ if from then
183
+ table.insert (list, tree)
184
+ to = from
185
+ end
186
+ end
187
+ until from == false
188
+ return list, to
189
+ end
190
+
191
+ -- Try to parse a given symbol.
192
+ -- @param sym the symbol being tried
193
+ -- @param from the index of the token to start from
194
+ -- @return tree the resulting parse tree, or false if empty
195
+ -- @return the index of the first unused token, or false to
196
+ -- indicate failure
197
+ symbol = function (sym, from) -- declared at the top
198
+ if string.sub (sym, -4, -1) == "_opt" then -- optional symbol
199
+ return optional (string.sub (sym, 1, -5), from)
200
+ elseif string.find (sym, "_list.-$") then -- list
201
+ local _, _, subsym, sep = string.find (sym, "^(.*)_list_?(.-)$")
202
+ return list (subsym, sep, from)
203
+ elseif grammar[sym] then -- non-terminal
204
+ return rule (sym, from)
205
+ elseif token[from] and -- not end of token list
206
+ ((grammar.lexemes[sym] and sym == token[from].ty) or
207
+ -- lexeme
208
+ sym == token[from].tok) -- literal terminal
209
+ then
210
+ return token[from].tok, from + 1 -- advance to next token
211
+ else
212
+ return false, false
213
+ end
214
+ end
215
+
216
+ -- Try a production.
217
+ -- @param name the name of the current rule
218
+ -- @param prod the production (list of symbols) being tried
219
+ -- @param from the index of the token to start from
220
+ -- @return the parse tree (incomplete if to is false)
221
+ -- @return the index of the first unused token, or false to
222
+ -- indicate failure
223
+ local function production (name, prod, from)
224
+ local tree = {ty = name}
225
+ local to = from
226
+ for prod in list.elems (prod) do
227
+ local sym
228
+ sym, to = symbol (prod, to)
229
+ if to then
230
+ table.insert (tree, sym)
231
+ else
232
+ return tree, false
233
+ end
234
+ end
235
+ if prod.action then
236
+ tree = prod.action (tree, token, to)
237
+ end
238
+ if prod.abstract then
239
+ local ntree = {}
240
+ ntree.ty = prod.abstract.ty
241
+ for i, n in prod.abstract.template do
242
+ ntree[i] = tree[n]
243
+ end
244
+ tree = ntree
245
+ end
246
+ return tree, to
247
+ end
248
+
249
+ -- Parse according to a particular rule.
250
+ -- @param name the name of the rule to try
251
+ -- @param from the index of the token to start from
252
+ -- @return parse tree
253
+ -- @return the index of the first unused token, or false to
254
+ -- indicate failure
255
+ rule = function (name, from) -- declared at the top
256
+ local alt = grammar[name]
257
+ local tree, to
258
+ for alt in list.elems (alt) do
259
+ tree, to = production (name, alt, from)
260
+ if to then
261
+ return tree, to
262
+ end
263
+ end
264
+ return tree, false
265
+ end
266
+
267
+ return rule (start, 1, from or 1)
268
+ end
@@ -0,0 +1,555 @@
1
+ --- Date and Date Format classes.
2
+ -- See @{05-dates.md|the Guide}.
3
+ --
4
+ -- Dependencies: `pl.class`, `pl.stringx`
5
+ -- @module pl.Date
6
+ -- @pragma nostrip
7
+
8
+ local class = require 'pl.class'
9
+ local os_time, os_date = os.time, os.date
10
+ local stringx = require 'pl.stringx'
11
+ local utils = require 'pl.utils'
12
+ local assert_arg,assert_string,raise = utils.assert_arg,utils.assert_string,utils.raise
13
+
14
+ local Date = class()
15
+ Date.Format = class()
16
+
17
+ --- Date constructor.
18
+ -- @param t this can be either
19
+ --
20
+ -- * `nil` or empty - use current date and time
21
+ -- * number - seconds since epoch (as returned by @{os.time})
22
+ -- * `Date` - copy constructor
23
+ -- * table - table containing year, month, etc as for `os.time`. You may leave out year, month or day,
24
+ -- in which case current values will be used.
25
+ -- *three to six numbers: year, month, day, hour, min, sec
26
+ --
27
+ -- @function Date
28
+ function Date:_init(t,...)
29
+ local time
30
+ if select('#',...) > 2 then
31
+ local extra = {...}
32
+ local year = t
33
+ t = {
34
+ year = year,
35
+ month = extra[1],
36
+ day = extra[2],
37
+ hour = extra[3],
38
+ min = extra[4],
39
+ sec = extra[5]
40
+ }
41
+ end
42
+ if t == nil then
43
+ time = os_time()
44
+ elseif type(t) == 'number' then
45
+ time = t
46
+ local next = ...
47
+ self.interval = next == true or next == 'interval'
48
+ elseif type(t) == 'table' then
49
+ if getmetatable(t) == Date then -- copy ctor
50
+ time = t.time
51
+ else
52
+ if not (t.year and t.month and t.year) then
53
+ local lt = os.date('*t')
54
+ if not t.year and not t.month and not t.day then
55
+ t.year = lt.year
56
+ t.month = lt.month
57
+ t.day = lt.day
58
+ else
59
+ t.year = t.year or lt.year
60
+ t.month = t.month or (t.day and lt.month or 1)
61
+ t.day = t.day or 1
62
+ end
63
+ end
64
+ time = os_time(t)
65
+ end
66
+ end
67
+ self:set(time)
68
+ end
69
+
70
+ local tzone_
71
+
72
+ --- get the time zone offset from UTC.
73
+ -- @return seconds ahead of UTC
74
+ function Date.tzone ()
75
+ if not tzone_ then
76
+ local now = os.time()
77
+ local utc = os.date('!*t',now)
78
+ local lcl = os.date('*t',now)
79
+ local unow = os.time(utc)
80
+ tzone_ = os.difftime(now,unow)
81
+ if lcl.isdst then
82
+ if tzone_ > 0 then
83
+ tzone_ = tzone_ - 3600
84
+ else
85
+ tzone_ = tzone_ + 3600
86
+ end
87
+ end
88
+ end
89
+ return tzone_
90
+ end
91
+
92
+ --- convert this date to UTC.
93
+ function Date:toUTC ()
94
+ self:add { sec = -Date.tzone() }
95
+ end
96
+
97
+ --- convert this UTC date to local.
98
+ function Date:toLocal ()
99
+ self:add { sec = Date.tzone() }
100
+ end
101
+
102
+ --- set the current time of this Date object.
103
+ -- @param t seconds since epoch
104
+ function Date:set(t)
105
+ self.time = t
106
+ if self.interval then
107
+ self.tab = os_date('!*t',self.time)
108
+ else
109
+ self.tab = os_date('*t',self.time)
110
+ end
111
+ end
112
+
113
+ --- set the year.
114
+ -- @param y Four-digit year
115
+ -- @class function
116
+ -- @name Date:year
117
+
118
+ --- set the month.
119
+ -- @param m month
120
+ -- @class function
121
+ -- @name Date:month
122
+
123
+ --- set the day.
124
+ -- @param d day
125
+ -- @class function
126
+ -- @name Date:day
127
+
128
+ --- set the hour.
129
+ -- @param h hour
130
+ -- @class function
131
+ -- @name Date:hour
132
+
133
+ --- set the minutes.
134
+ -- @param min minutes
135
+ -- @class function
136
+ -- @name Date:min
137
+
138
+ --- set the seconds.
139
+ -- @param sec seconds
140
+ -- @class function
141
+ -- @name Date:sec
142
+
143
+ --- set the day of year.
144
+ -- @class function
145
+ -- @param yday day of year
146
+ -- @name Date:yday
147
+
148
+ --- get the year.
149
+ -- @param y Four-digit year
150
+ -- @class function
151
+ -- @name Date:year
152
+
153
+ --- get the month.
154
+ -- @class function
155
+ -- @name Date:month
156
+
157
+ --- get the day.
158
+ -- @class function
159
+ -- @name Date:day
160
+
161
+ --- get the hour.
162
+ -- @class function
163
+ -- @name Date:hour
164
+
165
+ --- get the minutes.
166
+ -- @class function
167
+ -- @name Date:min
168
+
169
+ --- get the seconds.
170
+ -- @class function
171
+ -- @name Date:sec
172
+
173
+ --- get the day of year.
174
+ -- @class function
175
+ -- @name Date:yday
176
+
177
+
178
+ for _,c in ipairs{'year','month','day','hour','min','sec','yday'} do
179
+ Date[c] = function(self,val)
180
+ if val then
181
+ assert_arg(1,val,"number")
182
+ self.tab[c] = val
183
+ self:set(os_time(self.tab))
184
+ return self
185
+ else
186
+ return self.tab[c]
187
+ end
188
+ end
189
+ end
190
+
191
+ --- name of day of week.
192
+ -- @param full abbreviated if true, full otherwise.
193
+ -- @return string name
194
+ function Date:weekday_name(full)
195
+ return os_date(full and '%A' or '%a',self.time)
196
+ end
197
+
198
+ --- name of month.
199
+ -- @param full abbreviated if true, full otherwise.
200
+ -- @return string name
201
+ function Date:month_name(full)
202
+ return os_date(full and '%B' or '%b',self.time)
203
+ end
204
+
205
+ --- is this day on a weekend?.
206
+ function Date:is_weekend()
207
+ return self.tab.wday == 0 or self.tab.wday == 6
208
+ end
209
+
210
+ --- add to a date object.
211
+ -- @param t a table containing one of the following keys and a value:<br>
212
+ -- year,month,day,hour,min,sec
213
+ -- @return this date
214
+ function Date:add(t)
215
+ local key,val = next(t)
216
+ self.tab[key] = self.tab[key] + val
217
+ self:set(os_time(self.tab))
218
+ return self
219
+ end
220
+
221
+ --- last day of the month.
222
+ -- @return int day
223
+ function Date:last_day()
224
+ local d = 28
225
+ local m = self.tab.month
226
+ while self.tab.month == m do
227
+ d = d + 1
228
+ self:add{day=1}
229
+ end
230
+ self:add{day=-1}
231
+ return self
232
+ end
233
+
234
+ --- difference between two Date objects.
235
+ -- Note: currently the result is a regular @{Date} object,
236
+ -- but also has `interval` field set, which means a more
237
+ -- appropriate string rep is used.
238
+ -- @param other Date object
239
+ -- @return a Date object
240
+ function Date:diff(other)
241
+ local dt = self.time - other.time
242
+ if dt < 0 then error("date difference is negative!",2) end
243
+ return Date(dt,true)
244
+ end
245
+
246
+ --- long numerical ISO data format version of this date.
247
+ -- If it's an interval then the format is '2 hours 29 sec' etc.
248
+ function Date:__tostring()
249
+ if not self.interval then
250
+ return os_date('%Y-%m-%d %H:%M:%S',self.time)
251
+ else
252
+ local t, res = self.tab, ''
253
+ local y,m,d = t.year - 1970, t.month - 1, t.day - 1
254
+ if y > 0 then res = res .. y .. ' years ' end
255
+ if m > 0 then res = res .. m .. ' months ' end
256
+ if d > 0 then res = res .. d .. ' days ' end
257
+ if y == 0 and m == 0 then
258
+ local h = t.hour
259
+ if h > 0 then res = res .. h .. ' hours ' end
260
+ if t.min > 0 then res = res .. t.min .. ' min ' end
261
+ if t.sec > 0 then res = res .. t.sec .. ' sec ' end
262
+ end
263
+ return res
264
+ end
265
+ end
266
+
267
+ --- equality between Date objects.
268
+ function Date:__eq(other)
269
+ return self.time == other.time
270
+ end
271
+
272
+ --- equality between Date objects.
273
+ function Date:__lt(other)
274
+ return self.time < other.time
275
+ end
276
+
277
+
278
+ ------------ Date.Format class: parsing and renderinig dates ------------
279
+
280
+ -- short field names, explicit os.date names, and a mask for allowed field repeats
281
+ local formats = {
282
+ d = {'day',{true,true}},
283
+ y = {'year',{false,true,false,true}},
284
+ m = {'month',{true,true}},
285
+ H = {'hour',{true,true}},
286
+ M = {'min',{true,true}},
287
+ S = {'sec',{true,true}},
288
+ }
289
+
290
+ --
291
+
292
+ --- Date.Format constructor.
293
+ -- @param fmt. A string where the following fields are significant: <ul>
294
+ -- <li>d day (either d or dd)</li>
295
+ -- <li>y year (either yy or yyy)</li>
296
+ -- <li>m month (either m or mm)</li>
297
+ -- <li>H hour (either H or HH)</li>
298
+ -- <li>M minute (either M or MM)</li>
299
+ -- <li>S second (either S or SS)</li>
300
+ -- </ul>
301
+ -- Alternatively, if fmt is nil then this returns a flexible date parser
302
+ -- that tries various date/time schemes in turn:
303
+ -- <ol>
304
+ -- <li> <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a>,
305
+ -- like 2010-05-10 12:35:23Z or 2008-10-03T14:30+02<li>
306
+ -- <li> times like 15:30 or 8.05pm (assumed to be today's date)</li>
307
+ -- <li> dates like 28/10/02 (European order!) or 5 Feb 2012 </li>
308
+ -- <li> month name like march or Mar (case-insensitive, first 3 letters);
309
+ -- here the day will be 1 and the year this current year </li>
310
+ -- </ol>
311
+ -- A date in format 3 can be optionally followed by a time in format 2.
312
+ -- Please see test-date.lua in the tests folder for more examples.
313
+ -- @usage df = Date.Format("yyyy-mm-dd HH:MM:SS")
314
+ -- @class function
315
+ -- @name Date.Format
316
+ function Date.Format:_init(fmt)
317
+ if not fmt then return end
318
+ local append = table.insert
319
+ local D,PLUS,OPENP,CLOSEP = '\001','\002','\003','\004'
320
+ local vars,used = {},{}
321
+ local patt,outf = {},{}
322
+ local i = 1
323
+ while i < #fmt do
324
+ local ch = fmt:sub(i,i)
325
+ local df = formats[ch]
326
+ if df then
327
+ if used[ch] then error("field appeared twice: "..ch,2) end
328
+ used[ch] = true
329
+ -- this field may be repeated
330
+ local _,inext = fmt:find(ch..'+',i+1)
331
+ local cnt = not _ and 1 or inext-i+1
332
+ if not df[2][cnt] then error("wrong number of fields: "..ch,2) end
333
+ -- single chars mean 'accept more than one digit'
334
+ local p = cnt==1 and (D..PLUS) or (D):rep(cnt)
335
+ append(patt,OPENP..p..CLOSEP)
336
+ append(vars,ch)
337
+ if ch == 'y' then
338
+ append(outf,cnt==2 and '%y' or '%Y')
339
+ else
340
+ append(outf,'%'..ch)
341
+ end
342
+ i = i + cnt
343
+ else
344
+ append(patt,ch)
345
+ append(outf,ch)
346
+ i = i + 1
347
+ end
348
+ end
349
+ -- escape any magic characters
350
+ fmt = table.concat(patt):gsub('[%-%.%+%[%]%(%)%$%^%%%?%*]','%%%1')
351
+ -- replace markers with their magic equivalents
352
+ fmt = fmt:gsub(D,'%%d'):gsub(PLUS,'+'):gsub(OPENP,'('):gsub(CLOSEP,')')
353
+ self.fmt = fmt
354
+ self.outf = table.concat(outf)
355
+ self.vars = vars
356
+
357
+ end
358
+
359
+ local parse_date
360
+
361
+ --- parse a string into a Date object.
362
+ -- @param str a date string
363
+ -- @return date object
364
+ function Date.Format:parse(str)
365
+ assert_string(1,str)
366
+ if not self.fmt then
367
+ return parse_date(str,self.us)
368
+ end
369
+ local res = {str:match(self.fmt)}
370
+ if #res==0 then return nil, 'cannot parse '..str end
371
+ local tab = {}
372
+ for i,v in ipairs(self.vars) do
373
+ local name = formats[v][1] -- e.g. 'y' becomes 'year'
374
+ tab[name] = tonumber(res[i])
375
+ end
376
+ -- os.date() requires these fields; if not present, we assume
377
+ -- that the time set is for the current day.
378
+ if not (tab.year and tab.month and tab.year) then
379
+ local today = Date()
380
+ tab.year = tab.year or today:year()
381
+ tab.month = tab.month or today:month()
382
+ tab.day = tab.day or today:month()
383
+ end
384
+ local Y = tab.year
385
+ if Y < 100 then -- classic Y2K pivot
386
+ tab.year = Y + (Y < 35 and 2000 or 1999)
387
+ elseif not Y then
388
+ tab.year = 1970
389
+ end
390
+ --dump(tab)
391
+ return Date(tab)
392
+ end
393
+
394
+ --- convert a Date object into a string.
395
+ -- @param d a date object, or a time value as returned by @{os.time}
396
+ -- @return string
397
+ function Date.Format:tostring(d)
398
+ local tm = type(d) == 'number' and d or d.time
399
+ if self.outf then
400
+ return os.date(self.outf,tm)
401
+ else
402
+ return tostring(Date(d))
403
+ end
404
+ end
405
+
406
+ function Date.Format:US_order(yesno)
407
+ self.us = yesno
408
+ end
409
+
410
+ local months = {jan=1,feb=2,mar=3,apr=4,may=5,jun=6,jul=7,aug=8,sep=9,oct=10,nov=11,dec=12}
411
+
412
+ --[[
413
+ Allowed patterns:
414
+ - [day] [monthname] [year] [time]
415
+ - [day]/[month][/year] [time]
416
+
417
+ ]]
418
+
419
+
420
+ local is_word = stringx.isalpha
421
+ local is_number = stringx.isdigit
422
+ local function tonum(s,l1,l2,kind)
423
+ kind = kind or ''
424
+ local n = tonumber(s)
425
+ if not n then error(("%snot a number: '%s'"):format(kind,s)) end
426
+ if n < l1 or n > l2 then
427
+ error(("%s out of range: %s is not between %d and %d"):format(kind,s,l1,l2))
428
+ end
429
+ return n
430
+ end
431
+
432
+ local function parse_iso_end(p,ns,sec)
433
+ -- may be fractional part of seconds
434
+ local _,nfrac,secfrac = p:find('^%.%d+',ns+1)
435
+ if secfrac then
436
+ sec = sec .. secfrac
437
+ p = p:sub(nfrac+1)
438
+ else
439
+ p = p:sub(ns+1)
440
+ end
441
+ -- ISO 8601 dates may end in Z (for UTC) or [+-][isotime]
442
+ -- (we're working with the date as lower case, hence 'z')
443
+ if p:match 'z$' then return sec, {h=0,m=0} end -- we're UTC!
444
+ p = p:gsub(':','') -- turn 00:30 to 0030
445
+ local _,_,sign,offs = p:find('^([%+%-])(%d+)')
446
+ if not sign then return sec, nil end -- not UTC
447
+
448
+ if #offs == 2 then offs = offs .. '00' end -- 01 to 0100
449
+ local tz = { h = tonumber(offs:sub(1,2)), m = tonumber(offs:sub(3,4)) }
450
+ if sign == '-' then tz.h = -tz.h; tz.m = -tz.m end
451
+ return sec, tz
452
+ end
453
+
454
+ local function parse_date_unsafe (s,US)
455
+ s = s:gsub('T',' ') -- ISO 8601
456
+ local parts = stringx.split(s:lower())
457
+ local i,p = 1,parts[1]
458
+ local function nextp() i = i + 1; p = parts[i] end
459
+ local year,min,hour,sec,apm
460
+ local tz
461
+ local _,nxt,day, month = p:find '^(%d+)/(%d+)'
462
+ if day then
463
+ -- swop for US case
464
+ if US then
465
+ day, month = month, day
466
+ end
467
+ _,_,year = p:find('^/(%d+)',nxt+1)
468
+ nextp()
469
+ else -- ISO
470
+ year,month,day = p:match('^(%d+)%-(%d+)%-(%d+)')
471
+ if year then
472
+ nextp()
473
+ end
474
+ end
475
+ if p and not year and is_number(p) then -- has to be date
476
+ day = p
477
+ nextp()
478
+ end
479
+ if p and is_word(p) then
480
+ p = p:sub(1,3)
481
+ local mon = months[p]
482
+ if mon then
483
+ month = mon
484
+ else error("not a month: " .. p) end
485
+ nextp()
486
+ end
487
+ if p and not year and is_number(p) then
488
+ year = p
489
+ nextp()
490
+ end
491
+
492
+ if p then -- time is hh:mm[:ss], hhmm[ss] or H.M[am|pm]
493
+ _,nxt,hour,min = p:find '^(%d+):(%d+)'
494
+ local ns
495
+ if nxt then -- are there seconds?
496
+ _,ns,sec = p:find ('^:(%d+)',nxt+1)
497
+ --if ns then
498
+ sec,tz = parse_iso_end(p,ns or nxt,sec)
499
+ --end
500
+ else -- might be h.m
501
+ _,ns,hour,min = p:find '^(%d+)%.(%d+)'
502
+ if ns then
503
+ apm = p:match '[ap]m$'
504
+ else -- or hhmm[ss]
505
+ local hourmin
506
+ _,nxt,hourmin = p:find ('^(%d+)')
507
+ if nxt then
508
+ hour = hourmin:sub(1,2)
509
+ min = hourmin:sub(3,4)
510
+ sec = hourmin:sub(5,6)
511
+ if #sec == 0 then sec = nil end
512
+ sec,tz = parse_iso_end(p,nxt,sec)
513
+ end
514
+ end
515
+ end
516
+ end
517
+ local today
518
+ if not (year and month and day) then
519
+ today = Date()
520
+ end
521
+ day = day and tonum(day,1,31,'day') or (month and 1 or today:day())
522
+ month = month and tonum(month,1,12,'month') or today:month()
523
+ year = year and tonumber(year) or today:year()
524
+ if year < 100 then -- two-digit year pivot around year < 2035
525
+ year = year + (year < 35 and 2000 or 1900)
526
+ end
527
+ hour = hour and tonum(hour,0,apm and 12 or 24,'hour') or 12
528
+ if apm == 'pm' then
529
+ hour = hour + 12
530
+ end
531
+ min = min and tonum(min,0,59) or 0
532
+ sec = sec and tonum(sec,0,60) or 0 --60 used to indicate leap second
533
+ local res = Date {year = year, month = month, day = day, hour = hour, min = min, sec = sec}
534
+ if tz then -- ISO 8601 UTC time
535
+ res:add {hour = -tz.h}
536
+ if tz.m ~= 0 then res:add {min = -tz.m} end
537
+ -- we're in UTC, so let's go local...
538
+ res:toLocal()
539
+ end
540
+ return res
541
+ end
542
+
543
+ function parse_date (s)
544
+ local ok, d = pcall(parse_date_unsafe,s)
545
+ if not ok then -- error
546
+ d = d:gsub('.-:%d+: ','')
547
+ return nil, d
548
+ else
549
+ return d
550
+ end
551
+ end
552
+
553
+
554
+ return Date
555
+