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,149 @@
1
+ --
2
+ -- Project: LuaIDL
3
+ -- Author: Ricardo Cosme <rcosme@tecgraf.puc-rio.br>
4
+ -- Filename: pre.lua
5
+ --
6
+
7
+ local error = error
8
+ local io = require "io"
9
+ local os = require "os"
10
+ local ipairs = ipairs
11
+ local pairs = pairs
12
+ local string = require "string"
13
+ local table = require "table"
14
+ local type = type
15
+
16
+ module 'luaidl.pre'
17
+
18
+ local tab_macros
19
+ local currNumLine
20
+ local currFilename = ""
21
+ local isProcessing
22
+ local homedir
23
+ local incpath
24
+ local tab_options
25
+
26
+ local scanner
27
+
28
+ ---
29
+ -- Tower of Hanoi
30
+ -------------------------------------------------------------
31
+ local function newStack()
32
+ return {""}
33
+ end
34
+
35
+ local function addString(stack, s)
36
+ table.insert(stack, s)
37
+ for i = (#stack - 1), 1, -1 do
38
+ if (string.len(stack[i]) > string.len(stack[i+1])) then
39
+ break
40
+ end
41
+ stack[i] = stack[i]..table.remove(stack)
42
+ end
43
+ end
44
+ -------------------------------------------------------------
45
+
46
+ local function processDirective(...)
47
+ local directive, macro, value = ...
48
+ if (directive == "endif") then
49
+ isProcessing = true
50
+ return ''
51
+ end
52
+ if (isProcessing) then
53
+ if (directive == "define") then
54
+ tab_macros[macro] = value
55
+ elseif (directive == "include") then
56
+ local incFilename = string.sub(macro, 2, -2)
57
+ local path = homedir..incFilename
58
+ local fh, msg = io.open(path)
59
+ if not fh then
60
+ for _, v in ipairs(incpath) do
61
+ path = v..'/'..incFilename
62
+ fh, msg = io.open(path)
63
+ if fh then
64
+ break
65
+ end
66
+ end
67
+ end
68
+ if not fh then
69
+ error(msg, 2)
70
+ end
71
+ local incSource = fh:read('*a')
72
+ local incENDNumLine = currNumLine + 1
73
+ local OUTFilename = currFilename
74
+ incSource = scanner(incSource, tab_options)
75
+ return string.format('# %d "%s" 1\n%s# %d "%s" 2\n',
76
+ 1, path,
77
+ incSource,
78
+ incENDNumLine, OUTFilename
79
+ )
80
+ elseif (directive == "ifndef") then
81
+ if (tab_macros[macro]) then
82
+ isProcessing = false
83
+ end
84
+ else
85
+ return '#'..table.concat({...}, ' ')
86
+ end
87
+ end
88
+ return ''
89
+ end
90
+
91
+ local function macroExpansion(str)
92
+ for name, value in pairs(tab_macros) do
93
+ str = string.gsub(str, '([^%w])'..name..'([^%w])', '%1'..value..'%2')
94
+ end
95
+ return str
96
+ end
97
+
98
+ function scanner(source, ptab_options)
99
+ local output = newStack()
100
+ local numLine
101
+ if (not homedir) then
102
+ addString(output, '# 1 "'..currFilename..'"\n')
103
+ homedir, numLine = string.gsub(currFilename, '(.*/).*', '%1')
104
+ if (numLine == 0) then
105
+ homedir = ''
106
+ end
107
+ end
108
+ numLine = 1
109
+ -- ugly!
110
+ source = source..'\n'
111
+ for strLine in string.gfind(source, "(.-\n)") do
112
+ strLine = string.gsub(strLine, "^%s*#%s*(%w+)%s*([^%s]*)%s*([^%s]*)", processDirective)
113
+ if (isProcessing) then
114
+ strLine = macroExpansion(strLine)
115
+ addString(output, strLine)
116
+ end
117
+ numLine = numLine + 1
118
+ currNumLine = numLine
119
+ end
120
+ return table.concat(output)
121
+ end
122
+
123
+ function run(source, ptab_options)
124
+ tab_macros = {}
125
+ currNumLine = 1
126
+ isProcessing = true
127
+ homedir = nil
128
+ incpath = nil
129
+ tab_options = ptab_options
130
+ if tab_options then
131
+ currFilename = tab_options.filename
132
+ if currFilename then
133
+ if (type(currFilename) ~= "string") then
134
+ error("Invalid filename", 2)
135
+ end
136
+ else
137
+ currFilename = ""
138
+ end
139
+ incpath = tab_options.incpath
140
+ if incpath then
141
+ if (type(incpath) ~= "table") then
142
+ error("'incpath' must be a table", 2)
143
+ end
144
+ else
145
+ incpath = {}
146
+ end
147
+ end
148
+ return scanner(source, tab_options)
149
+ end
@@ -0,0 +1,3631 @@
1
+ --
2
+ -- Project: LuaIDL
3
+ -- Author: Ricardo Cosme <rcosme@tecgraf.puc-rio.br>
4
+ -- Filename: sin.lua
5
+ --
6
+
7
+ -- OMG IDL Grammar (Corba v3.0)
8
+ -- LL(1)
9
+ --(1) <specification> := <import_l> <definition_l>
10
+ --(2) <import_l> := <import> <import_l>
11
+ --(3) | empty
12
+ --(4) <import> := TK_IMPORT <imported_scope> ";"
13
+ --(5) <imported_scope> := <scoped_name>
14
+ --(6) | TK_STRING_LITERAL
15
+ --(7) <scoped_name> := TK_ID <scoped_name>
16
+ --(8) | ":" ":" TK_ID <scoped_name_l>
17
+ --(9) <scoped_name_l> := ":" ":" TK_ID <scoped_name_l>
18
+ --(10) | empty
19
+ --(11) <definition_l> := <definition> <definition_l_r>
20
+ --(12) <definition_l_r> := <definition> <definition_l_r>
21
+ --(13) | empty
22
+ --(14) <definition> := <type_dcl> ";"
23
+ --(15) | <const_dcl> ";"
24
+ --(16) | <except_dcl> ";"
25
+ --(17) | <inter_value_event> ";"
26
+ --(18) | <module> ";"
27
+ --(19) | <type_id_dcl> ";"
28
+ --(20) | <type_prefix_dcl> ";"
29
+ --(21) | <component> ";"
30
+ --(22) | <home_dcl> ";"
31
+ --(23) <type_dcl> := "typedef" <type_declarator>
32
+ --(24) | <enum_type>
33
+ --(25) | TK_NATIVE TK_ID
34
+ --(26) | <union_or_struct>
35
+ --(27) <type_declarator> := <type_spec> <declarator_l>
36
+ --(28) <type_spec> := <simple_type_spec>
37
+ --(29) | <constr_type_spec>
38
+ --(30) <simple_type_spec> := <base_type_spec>
39
+ --(31) | <template_type_spec>
40
+ --(32) | <scoped_name>
41
+ --(33) <constr_type_spec> := <struct_type>
42
+ --(34) | <union_type>
43
+ --(35) | <enum_type>
44
+ --(36) <base_type_spec> := <float_type_or_int_type>
45
+ --(37) | TK_CHAR
46
+ -- | TK_WCHAR **
47
+ --(38) | TK_BOOLEAN
48
+ --(39) | TK_OCTET
49
+ --(40) | TK_ANY
50
+ --(41) | TK_OBJECT
51
+ --(42) | TK_VALUEBASE
52
+ --(43) <float_type_or_int_type>:= <floating_pt_type>
53
+ --(44) | <integer_type>
54
+ --(45) | TK_LONG <long_or_double>
55
+ --(46) <floating_pt_type> := TK_FLOAT
56
+ --(47) | TK_DOUBLE
57
+ --(48) <integer_type> := TK_SHORT
58
+ --(49) | <unsigned_int>
59
+ --(50) <unsigned_int> := TK_UNSIGNED <unsigned_int_tail>
60
+ --(51) <unsigned_int_tail> := TK_LONG <long_e>
61
+ --(52) | TK_SHORT
62
+ --(53) <long_e> := TK_LONG
63
+ --(54) | empty
64
+ --(55) <long_or_double> := TK_LONG
65
+ --(56) | TK_DOUBLE
66
+ --(57) | empty
67
+ --(58) <template_type_spec> := <sequence_type>
68
+ --(59) | <string_type>
69
+ -- | <wide_string_type> **
70
+ --(60) | <fixed_pt_type>
71
+ --(61) <sequence_type> := TK_SEQUENCE "<" <simple_type_spec> <sequence_type_tail>
72
+ --(69) <sequence_type_tail> := "," <positive_int_const> ">"
73
+ --(70) | ">"
74
+ --(71) <string_type> := TK_STRING <string_type_tail>
75
+ --(72) <string_type_tail> := "<" <positive_int_const> ">"
76
+ --(73) | empty
77
+ -- <wide_string_type> := TK_WSTRING <string_type_tail> **
78
+ --(74) <fixed_pt_type> := TK_FIXED "<" <positive_int_const> "," <positive_int_const> ">"
79
+ --(75) <positive_int_const> := <xor_expr> <or_expr_l>
80
+ --(91) <or_expr_l> := "|" <xor_expr> <or_expr_l>
81
+ --(92) | empty
82
+ --(93) <xor_expr> := <and_expr> <xor_expr_l>
83
+ --(94) <xor_expr_l> := "^" <and_expr> <xor_expr_l>
84
+ --(95) | empty
85
+ --(96) <and_expr> := <shift_expr> <and_expr_l>
86
+ --(97) <and_expr_l> := "&" <shift_expr> <and_expr_l>
87
+ --(98) | empty
88
+ --(99) <shift_expr> := <add_expr> <shift_expr_l>
89
+ --(100) <shift_expr_l> := ">>" <add_expr> <shift_expr_l>
90
+ --(101) | "<<" <add_expr> <shift_expr_l>
91
+ --(102) | empty
92
+ --(103) <add_expr> := <mult_expr> <add_expr_l>
93
+ --(104) <add_expr_l> := "+" <mult_expr> <add_expr_l>
94
+ --(105) | "-" <mult_expr> <add_expr_l>
95
+ --(106) | empty
96
+ --(107) <mult_expr> := <unary_expr> <mult_expr_l>
97
+ --(108) <mult_expr_l> := "*" <unary_expr> <mult_expr_l>
98
+ --(109) | "/" <unary_expr> <mult_expr_l>
99
+ --(110) | "%" <unary_expr> <mult_expr_l>
100
+ --(111) | empty
101
+ --(112) <unary_expr> := <unary_operator> <primary_expr>
102
+ --(113) | <primary_expr>
103
+ --(114) <unary_operator> := "-"
104
+ --(115) | "+"
105
+ --(116) | "~"
106
+ --(117) <primary_expr> := <scoped_name>
107
+ --(118) | <literal>
108
+ --(119) | "(" <positive_int_const3> ")"
109
+ --(120) <literal> := TK_INTEGER_LITERAL
110
+ --(121) | TK_STRING_LITERAL
111
+ -- | TK_WSTRING_LITERAL **
112
+ --(122) | TK_CHAR_LITERAL
113
+ -- | TK_WCHAR_LITERAL **
114
+ --(123) | TK_FIXED_LITERAL
115
+ --(124) | TK_FLOAT_LITERAL
116
+ --(125) | <boolean_literal>
117
+ --(126) <boolean_literal> := TK_TRUE
118
+ --(127) | TK_FALSE
119
+ --(136) <struct_type> := TK_STRUCT TK_ID "{" <member_l> "}"
120
+ --(137) <member_l> := <member> <member_r>
121
+ --(138) <member_r> := <member> <member_r>
122
+ --(139) | empty
123
+ --(140) <member> := <type_spec> <declarator_l> ";"
124
+ --(141) <typedef_dcl_l> := <typedef_dcl> <typedef_l_r>
125
+ --(142) <typedef_l_r> := "," <typedef_dcl> <typedef_l_r>
126
+ --(143) | empty
127
+ --(144) <typedef_dcl> := TK_ID <fixed_array_size_l>
128
+ --(145) <fixed_array_size_l> := <fixed_array_size> <fixed_array_size_l>
129
+ --(146) | empty
130
+ --(147) <fixed_array_size> := "[" <positive_int_const4> "]"
131
+ --(148) <union_type> := TK_UNION TK_ID TK_SWITCH "(" <switch_type_spec> ")"
132
+ -- "{" <case_l> "}"
133
+ --(149) <switch_type_spec> := <integer_type>
134
+ --(150) | TK_LONG <long_e>
135
+ --(151) | TK_CHAR
136
+ --(152) | TK_BOOLEAN
137
+ --(153) | TK_ENUM
138
+ --(154) | <scoped_name>
139
+ --(155) <case_l> := <case> <case_l_r>
140
+ --(156) <case_l_r> := <case> <case_l_r>
141
+ --(157) | empty
142
+ --(158) <case> := <case_label_l> <element_spec> ";"
143
+ --(159) <case_label_l> := <case_label> <case_label_l_r>
144
+ --(160) <case_label_l_r> := <case_label> <case_label_l_r>
145
+ --(161) | empty
146
+ --(162) <case_label> := TK_CASE <positive_int_const5> ":"
147
+ --(163) | TK_DEFAULT ":"
148
+ --(164) <element_spec> := <type_spec> <declarator>
149
+ --(165) <enum_type> := TK_ENUM <enumerator>
150
+ -- "{" <enumerator> <enumerator_l> "}"
151
+ --(166) <enumerator_l> := "," <enumerator> <enumerator_l>
152
+ --(167) | empty
153
+ --(168) <union_or_struct> := TK_STRUCT TK_ID <struct_tail>
154
+ --(169) | TK_UNION TK_ID TK_SWITCH <union_tail>
155
+ --(170) <struct_tail> := "{" <member_l> "}"
156
+ --(171) | empty
157
+ --(172) <union_tail> := TK_SWITCH "(" <switch_type_spec> ")"
158
+ -- "{" <case_l> "}"
159
+ --(173) | empty
160
+ --(174) <const_dcl> := TK_CONST <const_type> TK_ID "=" <positive_int_const>
161
+ --(175) <const_type> := <float_type_or_int_type>
162
+ --(176) | TK_CHAR
163
+ -- | TK_WCHAR **
164
+ --(177) | TK_BOOLEAN
165
+ --(178) | TK_STRING
166
+ -- | TK_WSTRING **
167
+ --(179) | <scoped_name>
168
+ --(180) | TK_OCTET
169
+ --(181) | TK_FIXED
170
+ --(186) <except_dcl> := TK_EXCEPTION TK_ID "{" <member_l_empty> "}"
171
+ --(187) <member_l_empty> := <member> <member_l_empty>
172
+ --(188) | empty
173
+ --(189) <inter_value_event> := TK_ABSTRACT <abstract_tail>
174
+ --(190) | TK_LOCAL TK_INTERFACE TK_ID <interface_tail>
175
+ --(191) | TK_CUSTOM <value_or_event>
176
+ --(192) | TK_INTERFACE TK_ID <interface_tail>
177
+ --(193) | TK_VALUETYPE TK_ID <value_tail>
178
+ --(194) | TK_EVENTTYPE TK_ID <eventtype_tail>
179
+ --(195) <abstract_tail> := TK_INTERFACE TK_ID <interface_tail>
180
+ --(196) | TK_VALUETYPE TK_ID <valueinhe_export_empty>
181
+ --(197) | TK_EVENTTYPE TK_ID <valueinhe_export_empty>
182
+ --(198) <interface_tail> := ":" <scoped_name> <bases> "{" <export_l> "}"
183
+ --(199) | "{" <export_l> "}"
184
+ --(200) | empty
185
+ --(205) <bases> := "," <scoped_name> <bases>
186
+ --(206) | empty
187
+ --(207) <export_l> := <export> <export_l>
188
+ --(208) | empty
189
+ --(209) <export> := <type_dcl> ";"
190
+ --(210) | <const_dcl> ";"
191
+ --(211) | <except_dcl> ";"
192
+ --(212) | <attr_dcl> ";"
193
+ --(213) | <op_dcl> ";"
194
+ --(214) | <type_id_dcl> ";"
195
+ --(215) | <type_prefix_dcl> ";"
196
+ --(216) <attr_dcl> := <readonly_attr_spec>
197
+ --(217) | <attr_spec>
198
+ --(218) <readonly_attr_spec> := TK_READONLY TK_ATTRIBUTE <param_type_spec> <readonly_attr_dec>
199
+ --(219) <param_type_spec> := <base_type_spec>
200
+ --(220) | <string_type>
201
+ -- | <wide_string_type> **
202
+ --(221) | <scoped_name>
203
+ --(226) <readonly_attr_dec> := TK_ID <readonly_attr_dec_tail>
204
+ --(227) <readonly_attr_dec_tail>:= <raises_expr>
205
+ --(228) | <simple_dec_l>
206
+ -- | empty
207
+ --(229) <raises_expr> := TK_RAISES "(" <scoped_name> <inter_name_seq> ")"
208
+ --(230) <simple_dec_l) := "," TK_ID <simple_dec_l>
209
+ --(231) | empty
210
+ --(232) <attr_spec> := TK_ATTRIBUTE <param_type_spec> <attr_declarator>
211
+ --(233) <attr_declarator> := TK_ID <attr_declarator_tail>
212
+ --(234) <attr_declarator_tail> := <attr_raises_expr>
213
+ --(235) | <simple_dec_l>
214
+ -- | empty
215
+ --(236) <attr_raises_expr> := TK_GETRAISES <exception_l> <attr_raises_expr_tail>
216
+ --(237) | TK_SETRAISES <exception_l>
217
+ --(238) <attr_raises_expr_tail> := TK_SETRAISES <exception_l>
218
+ --(239) | empty
219
+ --(240) <exception_l> := "(" <scoped_name> <inter_name_seq> ")"
220
+ --(241) <inter_name_seq> := "," <scoped_name> <inter_name_seq>
221
+ --(242) | empty
222
+ --(243) <op_dcl> := TK_ONEWAY <op_type_spec> TK_ID <parameter_dcls> <raises_expr_e>
223
+ -- <context_expr_e>
224
+ --(244) | <op_type_spec> TK_ID <parameter_dcls> <raises_expr_e>
225
+ -- <context_expr_e>
226
+ --(245) <op_type_spec> := <param_type_spec>
227
+ --(246) | TK_VOID
228
+ --(247) <parameter_dcls> := "(" <parameter_dcls_tail>
229
+ --(248) <parameter_dcls_tail> := <param_dcl> <param_dcl_l>
230
+ --(249) | ")"
231
+ --(250) <param_dcl> := <param_attribute> <param_type_spec> TK_ID
232
+ --(251) <param_attribute> := TK_IN
233
+ --(252) | TK_OUT
234
+ --(253) | TK_INOUT
235
+ --(254) <param_dcl_l> := "," <param_dcl> <param_dcl_l>
236
+ --(255) | empty
237
+ --(256) <context_expr> := TK_CONTEXT "(" <context> <string_literal_l> ")"
238
+ --(257) <string_literal_l> := "," <context> <string_literal_l>
239
+ --(258) | empty
240
+ --(259) <type_id_dcl> := TK_TYPEID <scoped_name> TK_STRING_LITERAL
241
+ --(260) <type_prefix_dcl> := TK_TYPEPREFIX <scoped_name> TK_STRING_LITERAL
242
+ --(265) <valueinhe_export_empty>:= <value_inhe_spec> "{" <export_l> "}
243
+ --(266) | "{" <export_l> "}"
244
+ --(267) | empty
245
+ --(268) <value_inhe_spec> := ":" <truncatable_e> <value_name> <value_name_list>
246
+ -- <supports_e>
247
+ --(269) | <supports_e>
248
+ --(270) | empty
249
+ --(271) <truncatable_e> := TK_TRUNCATABLE
250
+ --(272) | empty
251
+ --(273) <value_name> := TK_ID <value_name_l>
252
+ --(274) | ":" ":" TK_ID <value_name_l>
253
+ --(275) <value_name_l> := ":" ":" TK_ID <value_name_l>
254
+ --(276) | empty
255
+ --(277) <value_name_list> := "," <value_name> <value_name_list>
256
+ --(278) | empty
257
+ --(279) <supports_e> := TK_SUPPORTS <inter_name> <inter_name_seq2>
258
+ --(280) | empty
259
+ --(281) <value_or_event> := TK_VALUETYPE TK_ID <valueinhe_export>
260
+ --(282) | TK_EVENTTYPE TK_ID <valueinhe_export>
261
+ --(283) <valueinhe_export> := <value_inhe_spec> "{" <value_element_l> "}"
262
+ --(284) | "{" <value_element_l> "}"
263
+ --(285) <value_element_l> := <value_element> <value_element_l>
264
+ --(286) | empty
265
+ --(287) <value_element> := <export>
266
+ --(288) | <state_member>
267
+ --(289) | <init_dcl>
268
+ --(290) <state_member> := TK_PUBLIC <type_spec> <declarator_l> ";"
269
+ --(291) | TK_PRIVATE <type_spec> <declarator_l> ";"
270
+ --(292) <init_dcl> := TK_FACTORY TK_ID "(" <init_param_dcl_l_e> ")"
271
+ -- <raises_expr_e> ";"
272
+ --(293) <init_param_dcl_l_e> := <init_param_dcl> <init_param_dcl_l_e_r>
273
+ --(294) | empty
274
+ --(295) <init_param_dcl_l_e_r> := "," <init_param_dcl> <init_param_dcl_l_e_r>
275
+ --(296) | empty
276
+ --(297) <init_param_dcl> := TK_IN <param_type_spec> TK_ID
277
+ --(298) <value_tail> := <value_inhe_spec> "{" <value_element_l> "}"
278
+ --(299) | "{" <value_element_l> "}"
279
+ --(300) | <type_spec>
280
+ --(301) | empty
281
+ --(302) <eventtype_tail> := <value_inhe_spec> "{" <value_element_l> "}"
282
+ --(303) | "{" <value_element_l> "}"
283
+ --(304) | empty
284
+ --(305) <module> := TK_MODULE TK_ID "{" <definition_l> "}"
285
+ --(306) <component> := TK_COMPONENT TK_ID <component_tail>
286
+ --(307) <component_tail> := <component_inh_spec> <supp_inter_spec>
287
+ -- "{" <component_body> "}"
288
+ --(308) | <supp_inter_spec> "{" <component_body> "}"
289
+ --(309) | "{" <component_body> "}"
290
+ --(310) | empty
291
+ --(311) <component_inh_spec> := ":" <component_name>
292
+ --(312) <component_name> := TK_ID <component_name_l>
293
+ --(313) | ":" ":" TK_ID <component_name_l>
294
+ --(314) <component_name_l> := ":" ":" TK_ID <component_name_l>
295
+ --(315) | empty
296
+ --(316) <supp_inter_spec> := TK_SUPPORTS <supp_name> <supp_name_list>
297
+ --(316e) | empty
298
+ --(317) <supp_name> := TK_ID <supp_name_l>
299
+ --(318) | ":" ":" TK_ID <supp_name_l>
300
+ --(319) <supp_name_l> := ":" ":" TK_ID <supp_name_l>
301
+ --(320) | empty
302
+ --(321) <supp_name_list> := "," <supp_name> <supp_name_list>
303
+ --(322) | empty
304
+ --(323) <component_body> := <component_export> <component_body>
305
+ --(324) | empty
306
+ --(325) <component_export> := <provides_dcl> ";"
307
+ --(326) | <uses_dcl> ";"
308
+ --(327) | <emits_dcl> ";"
309
+ --(328) | <publishes_dcl> ";"
310
+ --(329) | <consumes_dcl> ";"
311
+ --(330) | <attr_dcl> ";"
312
+ --(331) <provides_dcl> := TK_PROVIDES <interface_type> TK_ID
313
+ --(332) <interface_type> := <scoped_name>
314
+ --(333) | TK_OBJECT
315
+ --(338) <uses_dcl> := TK_USES <multiple_e> <interface_type> TK_ID
316
+ --(339) <multiple_e> := TK_MULTIPLE
317
+ --(340) | empty
318
+ --(341) <emits_dcl> := TK_EMITS <scoped_name> TK_ID
319
+ --(342) <publishes_dcl> := TK_PUBLISHES <scoped_name> TK_ID
320
+ --(343) <consumes_dcl> := TK_CONSUMES <scoped_name> TK_ID
321
+
322
+ --(344) <home_dcl> := TK_HOME TK_ID <home_dcl_tail>
323
+ --(345) <home_dcl_tail> := <home_inh_spec> <supp_inter_spec>
324
+ -- TK_MANAGES <home_name> <primary_key_spec_e>
325
+ -- "{" <home_export_l> "}"raises_expr>
326
+ --(346) | <supp_inter_spec> TK_MANAGES <home_name> <primary_key_spec_e>
327
+ -- "{" <home_export_l> "}"
328
+ --(347) | TK_MANAGES <home_name> <primary_key_spec_e>
329
+ -- "{" <home_export_l> "}"
330
+ --(348) <home_inh_spec> := ":" <scoped_name>
331
+ --(353) <primary_key_spec_e> := TK_PRIMARYKEY <scoped_name>
332
+ --(354) | empty
333
+ --(359) <home_export_l> := <home_export> <home_export_l>
334
+ --(360) | empty
335
+ --(361) <home_export> := <export>
336
+ --(362) | <factory_dcl> ";"
337
+ --(363) | <finder_dcl> ";"
338
+ --(364) <factory_dcl> := TK_FACTORY TK_ID "(" <init_param_dcls> ")"
339
+ -- <raises_expr_e>
340
+ --(365) <finder_dcl> := TK_FINDER TK_ID "(" <init_param_dcls> ")"
341
+ -- <raises_expr_e>
342
+ --(366) <init_param_dcls> := <init_param_dcl> <init_param_dcl_list>
343
+ --(367) | empty
344
+ --(368) <init_param_dcl_list> := "," <init_param_dcl> <init_param_dcl_list>
345
+ --(369) | empty
346
+ --(370) <raises_expr_e> := <raises_expr>
347
+ --(371) | empty
348
+ --(376) <enumerator> := TK_ID
349
+ --(377) <context_expr_e> := <context_expr>
350
+ --(378) | empty
351
+ --(379) <context> := TK_STRING_LITERAL
352
+
353
+ local type = type
354
+ local pairs = pairs
355
+ local tonumber = tonumber
356
+ local require = require
357
+ local error = error
358
+ local ipairs = ipairs
359
+
360
+ local math = require "math"
361
+ local string = require "string"
362
+ local table = require "table"
363
+
364
+ module 'luaidl.sin'
365
+
366
+ local lex = require 'luaidl.lex'
367
+
368
+ local tab_firsts = {}
369
+ local tab_follow = {}
370
+
371
+ local function set_firsts(firsts)
372
+ local tab = {}
373
+ for _, token in ipairs(firsts) do
374
+ local tokenDcl = lex.tab_tokens[token]
375
+ if tokenDcl then
376
+ tab[tokenDcl] = true
377
+ else
378
+ tab[token] = true
379
+ end
380
+ end
381
+ return tab
382
+ end
383
+
384
+ tab_firsts.rule_1 = set_firsts { 'TK_IMPORT' }
385
+ tab_firsts.rule_11 = set_firsts {
386
+ 'TK_TYPEDEF','TK_ENUM','TK_NATIVE','TK_UNION','TK_STRUCT',
387
+ 'TK_CONST','TK_EXCEPTION','TK_ABSTRACT','TK_LOCAL',
388
+ 'TK_INTERFACE','TK_CUSTOM','TK_VALUETYPE',
389
+ 'TK_EVENTTYPE','TK_MODULE','TK_TYPEID',
390
+ 'TK_TYPEPREFIX','TK_COMPONENT','TK_HOME'
391
+ }
392
+ tab_firsts.rule_12 = tab_firsts.rule_11
393
+ tab_firsts.rule_14 = set_firsts { 'TK_TYPEDEF', 'TK_ENUM', 'TK_NATIVE', 'TK_UNION', 'TK_STRUCT' }
394
+ tab_firsts.rule_15 = set_firsts { 'TK_CONST' }
395
+ tab_firsts.rule_16 = set_firsts { 'TK_EXCEPTION' }
396
+ tab_firsts.rule_17 = set_firsts {
397
+ 'TK_ABSTRACT', 'TK_LOCAL', 'TK_INTERFACE', 'TK_CUSTOM',
398
+ 'TK_VALUETYPE', 'TK_EVENTTYPE'
399
+ }
400
+ tab_firsts.rule_18 = set_firsts { 'TK_MODULE' }
401
+ tab_firsts.rule_19 = set_firsts { 'TK_TYPEID' }
402
+ tab_firsts.rule_20 = set_firsts { 'TK_TYPEPREFIX' }
403
+ tab_firsts.rule_21 = set_firsts { 'TK_COMPONENT' }
404
+ tab_firsts.rule_22 = set_firsts { 'TK_HOME' }
405
+ tab_firsts.rule_23 = set_firsts { 'TK_TYPEDEF' }
406
+ tab_firsts.rule_24 = set_firsts { 'TK_ENUM' }
407
+ tab_firsts.rule_25 = set_firsts { 'TK_NATIVE' }
408
+ tab_firsts.rule_26 = set_firsts { 'TK_STRUCT', 'TK_UNION' }
409
+ tab_firsts.rule_27 = set_firsts {
410
+ 'TK_CHAR', 'TK_BOOLEAN', 'TK_OCTET', 'TK_ANY', 'TK_OBJECT',
411
+ 'TK_VALUEBASE', 'TK_LONG', 'TK_FLOAT', 'TK_DOUBLE', 'TK_SHORT',
412
+ 'TK_UNSIGNED', 'TK_SEQUENCE' , 'TK_STRING', 'TK_FIXED' ,
413
+ 'TK_ID', ":", 'TK_STRUCT', 'TK_UNION', 'TK_ENUM',
414
+ }
415
+ tab_firsts.rule_28 = set_firsts {
416
+ 'TK_CHAR', 'TK_BOOLEAN', 'TK_OCTET', 'TK_ANY', 'TK_OBJECT',
417
+ 'TK_VALUEBASE', 'TK_LONG', 'TK_FLOAT', 'TK_DOUBLE', 'TK_SHORT',
418
+ 'TK_UNSIGNED', 'TK_SEQUENCE' , 'TK_STRING', 'TK_FIXED' ,
419
+ 'TK_ID', ":",
420
+ }
421
+ tab_firsts.rule_29 = set_firsts { 'TK_STRUCT', 'TK_UNION', 'TK_ENUM' }
422
+ tab_firsts.rule_30 = set_firsts {
423
+ 'TK_CHAR', 'TK_BOOLEAN', 'TK_OCTET', 'TK_ANY', 'TK_OBJECT',
424
+ 'TK_VALUEBASE', 'TK_LONG', 'TK_FLOAT', 'TK_DOUBLE', 'TK_SHORT',
425
+ 'TK_UNSIGNED',
426
+ }
427
+ tab_firsts.rule_31 = set_firsts { 'TK_SEQUENCE', 'TK_STRING', 'TK_FIXED' }
428
+ tab_firsts.rule_32 = set_firsts { 'TK_ID', ':' }
429
+
430
+ tab_firsts.rule_33 = set_firsts { 'TK_STRUCT' }
431
+ tab_firsts.rule_34 = set_firsts { 'TK_UNION' }
432
+ tab_firsts.rule_35 = set_firsts { 'TK_ENUM' }
433
+ tab_firsts.rule_36 = set_firsts { 'TK_FLOAT', 'TK_DOUBLE', 'TK_SHORT', 'TK_UNSIGNED', 'TK_LONG' }
434
+ tab_firsts.rule_37 = set_firsts { 'TK_CHAR' }
435
+ tab_firsts.rule_38 = set_firsts { 'TK_BOOLEAN' }
436
+ tab_firsts.rule_39 = set_firsts { 'TK_OCTET' }
437
+ tab_firsts.rule_40 = set_firsts { 'TK_ANY' }
438
+ tab_firsts.rule_41 = set_firsts { 'TK_OBJECT' }
439
+ tab_firsts.rule_42 = set_firsts { 'TK_VALUEBASE' }
440
+
441
+ tab_firsts.rule_43 = set_firsts { 'TK_FLOAT', 'TK_DOUBLE' }
442
+ tab_firsts.rule_44 = set_firsts { 'TK_SHORT', 'TK_UNSIGNED' }
443
+ tab_firsts.rule_45 = set_firsts { 'TK_LONG' }
444
+ tab_firsts.rule_46 = set_firsts { 'TK_FLOAT' }
445
+ tab_firsts.rule_47 = set_firsts { 'TK_DOUBLE' }
446
+ tab_firsts.rule_48 = set_firsts { 'TK_SHORT' }
447
+ tab_firsts.rule_49 = set_firsts { 'TK_UNSIGNED' }
448
+ tab_firsts.rule_50 = tab_firsts.rule_49
449
+ tab_firsts.rule_51 = tab_firsts.rule_45
450
+ tab_firsts.rule_52 = set_firsts { 'TK_SHORT' }
451
+ tab_firsts.rule_53 = set_firsts { 'TK_LONG' }
452
+ tab_firsts.rule_55 = set_firsts { 'TK_LONG' }
453
+ tab_firsts.rule_56 = set_firsts { 'TK_DOUBLE' }
454
+
455
+ tab_firsts.rule_58 = set_firsts { 'TK_SEQUENCE' }
456
+ tab_firsts.rule_59 = set_firsts { 'TK_STRING' }
457
+ tab_firsts.rule_60 = set_firsts { 'TK_FIXED' }
458
+
459
+ tab_firsts.rule_62 = tab_firsts.rule_30
460
+ tab_firsts.rule_63 = tab_firsts.rule_31
461
+ tab_firsts.rule_64 = tab_firsts.rule_32
462
+
463
+ tab_firsts.rule_69 = set_firsts { ',' }
464
+ tab_firsts.rule_70 = set_firsts { '>' }
465
+ tab_firsts.rule_72 = set_firsts { '<' }
466
+ tab_firsts.rule_75 = set_firsts {
467
+ '-', '+', '~', '(', 'TK_ID', ':', 'TK_INTEGER_LITERAL',
468
+ 'TK_STRING_LITERAL', 'TK_CHAR_LITERAL', 'TK_FIXED_LITERAL',
469
+ 'TK_FLOAT_LITERAL', 'TK_TRUE', 'TK_FALSE'
470
+ }
471
+ tab_firsts.rule_93 = tab_firsts.rule_75
472
+ tab_firsts.rule_91 = set_firsts { '|' }
473
+ tab_firsts.rule_94 = set_firsts { '^' }
474
+ tab_firsts.rule_96 = tab_firsts.rule_75
475
+ tab_firsts.rule_97 = set_firsts { '&' }
476
+ tab_firsts.rule_99 = tab_firsts.rule_75
477
+ tab_firsts.rule_100 = set_firsts { '>>' }
478
+ tab_firsts.rule_101 = set_firsts { '<<' }
479
+ tab_firsts.rule_103 = tab_firsts.rule_75
480
+ tab_firsts.rule_104 = set_firsts { '+' }
481
+ tab_firsts.rule_105 = set_firsts { '-' }
482
+ tab_firsts.rule_107 = tab_firsts.rule_75
483
+ tab_firsts.rule_108 = set_firsts { '*' }
484
+ tab_firsts.rule_109 = set_firsts { '/' }
485
+ tab_firsts.rule_110 = set_firsts { '%' }
486
+ tab_firsts.rule_112 = set_firsts { '-', '+', '~' }
487
+ tab_firsts.rule_113 = set_firsts {
488
+ '(', 'TK_ID', ':', 'TK_INTEGER_LITERAL',
489
+ 'TK_STRING_LITERAL', 'TK_CHAR_LITERAL', 'TK_FIXED_LITERAL',
490
+ 'TK_FLOAT_LITERAL', 'TK_TRUE', 'TK_FALSE'
491
+ }
492
+ tab_firsts.rule_114 = set_firsts { '-' }
493
+ tab_firsts.rule_115 = set_firsts { '+' }
494
+ tab_firsts.rule_116 = set_firsts { '~' }
495
+ tab_firsts.rule_117 = set_firsts { 'TK_ID', ':' }
496
+ tab_firsts.rule_118 = set_firsts {
497
+ 'TK_INTEGER_LITERAL', 'TK_STRING_LITERAL', 'TK_CHAR_LITERAL',
498
+ 'TK_FIXED_LITERAL', 'TK_FLOAT_LITERAL', 'TK_TRUE', 'TK_FALSE'
499
+ }
500
+ tab_firsts.rule_119 = set_firsts { '(' }
501
+ tab_firsts.rule_120 = set_firsts { 'TK_INTEGER_LITERAL' }
502
+ tab_firsts.rule_121 = set_firsts { 'TK_STRING_LITERAL' }
503
+ tab_firsts.rule_122 = set_firsts { 'TK_CHAR_LITERAL' }
504
+ tab_firsts.rule_123 = set_firsts { 'TK_FIXED_LITERAL' }
505
+ tab_firsts.rule_124 = set_firsts { 'TK_FLOAT_LITERAL' }
506
+ tab_firsts.rule_125 = set_firsts { 'TK_TRUE', 'TK_FALSE' }
507
+ tab_firsts.rule_126 = set_firsts { 'TK_TRUE' }
508
+ tab_firsts.rule_127 = set_firsts { 'TK_FALSE' }
509
+
510
+ tab_firsts.rule_137 = tab_firsts.rule_27
511
+ tab_firsts.rule_138 = tab_firsts.rule_137
512
+
513
+ tab_firsts.rule_140 = tab_firsts.rule_138
514
+ tab_firsts.rule_141 = set_firsts { 'TK_ID' }
515
+ tab_firsts.rule_142 = set_firsts { "," }
516
+
517
+ tab_firsts.rule_144 = tab_firsts.rule_141
518
+ tab_firsts.rule_145 = set_firsts { "[" }
519
+
520
+ tab_firsts.rule_147 = tab_firsts.rule_145
521
+ tab_firsts.rule_148 = set_firsts { 'TK_UNION' }
522
+ tab_firsts.rule_149 = tab_firsts.rule_44
523
+ tab_firsts.rule_150 = set_firsts { 'TK_LONG' }
524
+ tab_firsts.rule_151 = set_firsts { 'TK_CHAR' }
525
+ tab_firsts.rule_152 = set_firsts { 'TK_BOOLEAN' }
526
+ tab_firsts.rule_153 = set_firsts { 'TK_ENUM' }
527
+ tab_firsts.rule_154 = set_firsts { 'TK_ID', ':' }
528
+ tab_firsts.rule_155 = set_firsts { 'TK_CASE', 'TK_DEFAULT' }
529
+ tab_firsts.rule_156 = set_firsts { 'TK_CASE', 'TK_DEFAULT' }
530
+
531
+ tab_firsts.rule_158 = set_firsts { 'TK_CASE', 'TK_DEFAULT' }
532
+ tab_firsts.rule_159 = set_firsts { 'TK_CASE', 'TK_DEFAULT' }
533
+ tab_firsts.rule_160 = set_firsts { 'TK_CASE', 'TK_DEFAULT' }
534
+
535
+ tab_firsts.rule_162 = set_firsts { 'TK_CASE' }
536
+ tab_firsts.rule_163 = set_firsts { 'TK_DEFAULT' }
537
+ tab_firsts.rule_164 = tab_firsts.rule_27
538
+
539
+ tab_firsts.rule_166 = set_firsts { "," }
540
+
541
+ tab_firsts.rule_168 = set_firsts { 'TK_STRUCT' }
542
+ tab_firsts.rule_169 = set_firsts { 'TK_UNION' }
543
+ tab_firsts.rule_170 = set_firsts { '{' }
544
+
545
+ tab_firsts.rule_172 = set_firsts { 'TK_SWITCH' }
546
+
547
+ tab_firsts.rule_174 = set_firsts { 'TK_CONST' }
548
+ tab_firsts.rule_175 = tab_firsts.rule_36
549
+ tab_firsts.rule_176 = set_firsts { 'TK_CHAR' }
550
+ tab_firsts.rule_177 = set_firsts { 'TK_BOOLEAN' }
551
+ tab_firsts.rule_178 = set_firsts { 'TK_STRING' }
552
+ tab_firsts.rule_179 = set_firsts { 'TK_ID', ':' }
553
+ tab_firsts.rule_180 = set_firsts { 'TK_OCTET' }
554
+ tab_firsts.rule_181 = set_firsts { 'TK_FIXED' }
555
+ tab_firsts.rule_186 = set_firsts { 'TK_EXCEPTION' }
556
+ tab_firsts.rule_187 = tab_firsts.rule_137
557
+
558
+ tab_firsts.rule_189 = set_firsts { 'TK_ABSTRACT' }
559
+ tab_firsts.rule_190 = set_firsts { 'TK_LOCAL' }
560
+ tab_firsts.rule_191 = set_firsts { 'TK_CUSTOM' }
561
+ tab_firsts.rule_192 = set_firsts { 'TK_INTERFACE' }
562
+ tab_firsts.rule_193 = set_firsts { 'TK_VALUETYPE' }
563
+ tab_firsts.rule_194 = set_firsts { 'TK_EVENTTYPE' }
564
+ tab_firsts.rule_195 = set_firsts { 'TK_INTERFACE' }
565
+ tab_firsts.rule_196 = set_firsts { 'TK_VALUETYPE' }
566
+ tab_firsts.rule_198 = set_firsts { ':' }
567
+ tab_firsts.rule_199 = set_firsts { '{' }
568
+
569
+ tab_firsts.rule_207 = set_firsts { 'TK_ONEWAY', 'TK_VOID', 'TK_STRING', 'TK_ID', ':',
570
+ 'TK_CHAR', 'TK_BOOLEAN', 'TK_OCTET', 'TK_ANY',
571
+ 'TK_OBJECT', 'TK_VALUEBASE', 'TK_LONG', 'TK_FLOAT',
572
+ 'TK_DOUBLE', 'TK_SHORT', 'TK_UNSIGNED','TK_TYPEDEF',
573
+ 'TK_ENUM', 'TK_NATIVE', 'TK_UNION', 'TK_STRUCT',
574
+ 'TK_EXCEPTION', 'TK_READONLY', 'TK_ATTRIBUTE', 'TK_CONST', -- 'TK_TYPECODE',
575
+ }
576
+
577
+ tab_firsts.rule_209 = tab_firsts.rule_14
578
+ tab_firsts.rule_210 = set_firsts { 'TK_CONST' }
579
+ tab_firsts.rule_211 = set_firsts { 'TK_EXCEPTION' }
580
+ tab_firsts.rule_212 = set_firsts { 'TK_READONLY', 'TK_ATTRIBUTE' }
581
+ tab_firsts.rule_213 = set_firsts {
582
+ 'TK_ONEWAY', 'TK_VOID', 'TK_STRING', 'TK_ID', ':',
583
+ 'TK_CHAR', 'TK_BOOLEAN', 'TK_OCTET', 'TK_ANY',
584
+ 'TK_OBJECT', 'TK_VALUEBASE', 'TK_LONG', 'TK_FLOAT',
585
+ 'TK_DOUBLE', 'TK_SHORT', 'TK_UNSIGNED',
586
+ }
587
+
588
+ tab_firsts.rule_216 = set_firsts { 'TK_READONLY' }
589
+ tab_firsts.rule_217 = set_firsts { 'TK_ATTRIBUTE' }
590
+
591
+ tab_firsts.rule_219 = tab_firsts.rule_30
592
+ tab_firsts.rule_220 = set_firsts { 'TK_STRING' }
593
+ tab_firsts.rule_221 = tab_firsts.rule_32
594
+
595
+
596
+ tab_firsts.rule_227 = set_firsts { 'TK_RAISES' }
597
+ tab_firsts.rule_228 = set_firsts { ',' }
598
+
599
+ tab_firsts.rule_230 = set_firsts { 'TK_ID' }
600
+ tab_firsts.rule_234 = set_firsts { 'TK_GETRAISES', 'TK_SETRAISES' }
601
+ tab_firsts.rule_235 = set_firsts { ',' }
602
+ tab_firsts.rule_236 = set_firsts { 'TK_GETRAISES' }
603
+ tab_firsts.rule_237 = set_firsts { 'TK_SETRAISES' }
604
+ tab_firsts.rule_238 = tab_firsts.rule_237
605
+
606
+ tab_firsts.rule_243 = set_firsts { 'TK_ONEWAY' }
607
+ tab_firsts.rule_244 = set_firsts {
608
+ 'TK_VOID', 'TK_STRING', 'TK_ID', ':',
609
+ 'TK_CHAR', 'TK_BOOLEAN', 'TK_OCTET', 'TK_ANY',
610
+ 'TK_OBJECT', 'TK_VALUEBASE', 'TK_LONG', 'TK_FLOAT',
611
+ 'TK_DOUBLE', 'TK_SHORT', 'TK_UNSIGNED',
612
+ }
613
+ tab_firsts.rule_245 = set_firsts {
614
+ 'TK_CHAR', 'TK_BOOLEAN', 'TK_OCTET', 'TK_ANY', 'TK_OBJECT',
615
+ 'TK_VALUEBASE', 'TK_LONG', 'TK_FLOAT', 'TK_DOUBLE', 'TK_SHORT',
616
+ 'TK_UNSIGNED', 'TK_STRING', 'TK_ID', ":",
617
+ }
618
+ tab_firsts.rule_246 = set_firsts { 'TK_VOID' }
619
+
620
+ tab_firsts.rule_248 = set_firsts { 'TK_IN', 'TK_OUT', 'TK_INOUT' }
621
+ tab_firsts.rule_249 = set_firsts { ')' }
622
+
623
+ tab_firsts.rule_251 = set_firsts { 'TK_IN' }
624
+ tab_firsts.rule_252 = set_firsts { 'TK_OUT' }
625
+ tab_firsts.rule_253 = set_firsts { 'TK_INOUT' }
626
+ tab_firsts.rule_254 = set_firsts { ',' }
627
+
628
+ tab_firsts.rule_257 = set_firsts { ',' }
629
+
630
+ tab_firsts.rule_268 = set_firsts { ':' }
631
+ tab_firsts.rule_269 = set_firsts { 'TK_SUPPORTS' }
632
+ tab_firsts.rule_271 = set_firsts { 'TK_TRUNCATABLE' }
633
+ tab_firsts.rule_277 = set_firsts { ',' }
634
+ tab_firsts.rule_281 = set_firsts { 'TK_VALUETYPE' }
635
+ tab_firsts.rule_285 = set_firsts {
636
+ 'TK_ONEWAY', 'TK_VOID', 'TK_STRING', 'TK_ID', ':',
637
+ 'TK_CHAR', 'TK_BOOLEAN', 'TK_OCTET', 'TK_ANY',
638
+ 'TK_OBJECT', 'TK_VALUEBASE', 'TK_LONG', 'TK_FLOAT',
639
+ 'TK_DOUBLE', 'TK_SHORT', 'TK_UNSIGNED','TK_TYPEDEF',
640
+ 'TK_ENUM', 'TK_NATIVE', 'TK_UNION', 'TK_STRUCT',
641
+ 'TK_EXCEPTION', 'TK_READONLY', 'TK_ATTRIBUTE',
642
+ 'TK_PUBLIC', 'TK_PRIVATE',
643
+ 'TK_FACTORY'
644
+ }
645
+ tab_firsts.rule_287 = tab_firsts.rule_207
646
+ tab_firsts.rule_288 = set_firsts { 'TK_PUBLIC', 'TK_PRIVATE' }
647
+ tab_firsts.rule_289 = set_firsts { 'TK_FACTORY' }
648
+ tab_firsts.rule_290 = set_firsts { 'TK_PUBLIC' }
649
+ tab_firsts.rule_291 = set_firsts { 'TK_PRIVATE' }
650
+ tab_firsts.rule_292 = tab_firsts.rule_289
651
+ tab_firsts.rule_297 = set_firsts { 'TK_IN' }
652
+ tab_firsts.rule_298 = set_firsts { ':', 'TK_SUPPORTS' }
653
+ tab_firsts.rule_299 = set_firsts { '{' }
654
+ tab_firsts.rule_300 = tab_firsts.rule_27
655
+ tab_firsts.rule_302 = tab_firsts.rule_298
656
+ tab_firsts.rule_303 = set_firsts { '{' }
657
+ tab_firsts.rule_305 = set_firsts { 'TK_MODULE' }
658
+ tab_firsts.rule_306 = set_firsts { 'TK_COMPONENT' }
659
+ tab_firsts.rule_307 = set_firsts { ':' }
660
+ tab_firsts.rule_308 = set_firsts { 'TK_SUPPORTS' }
661
+ tab_firsts.rule_309 = set_firsts { '{' }
662
+ tab_firsts.rule_316 = set_firsts { 'TK_SUPPORTS' }
663
+ tab_firsts.rule_321 = set_firsts { ',' }
664
+ tab_firsts.rule_323 = set_firsts { 'TK_PROVIDES', 'TK_USES', 'TK_EMITS', 'TK_PUBLISHES',
665
+ 'TK_CONSUMES', 'TK_READONLY', 'TK_ATTRIBUTE' }
666
+ tab_firsts.rule_325 = set_firsts { 'TK_PROVIDES' }
667
+ tab_firsts.rule_326 = set_firsts { 'TK_USES' }
668
+ tab_firsts.rule_327 = set_firsts { 'TK_EMITS' }
669
+ tab_firsts.rule_328 = set_firsts { 'TK_PUBLISHES' }
670
+ tab_firsts.rule_329 = set_firsts { 'TK_CONSUMES' }
671
+ tab_firsts.rule_330 = set_firsts { 'TK_READONLY', 'TK_ATTRIBUTE' }
672
+ tab_firsts.rule_332 = set_firsts { 'TK_ID', ':' }
673
+ tab_firsts.rule_333 = set_firsts { 'TK_OBJECT' }
674
+ tab_firsts.rule_339 = set_firsts { 'TK_MULTIPLE' }
675
+ tab_firsts.rule_345 = set_firsts { ':' }
676
+ tab_firsts.rule_346 = set_firsts { 'TK_SUPPORTS' }
677
+ tab_firsts.rule_347 = set_firsts { 'TK_MANAGES' }
678
+ tab_firsts.rule_353 = set_firsts { 'TK_PRIMARYKEY' }
679
+ tab_firsts.rule_359 = set_firsts {
680
+ 'TK_ONEWAY', 'TK_VOID', 'TK_STRING', 'TK_ID', ':',
681
+ 'TK_CHAR', 'TK_BOOLEAN', 'TK_OCTET', 'TK_ANY',
682
+ 'TK_OBJECT', 'TK_VALUEBASE', 'TK_LONG', 'TK_FLOAT',
683
+ 'TK_DOUBLE', 'TK_SHORT', 'TK_UNSIGNED','TK_TYPEDEF',
684
+ 'TK_ENUM', 'TK_NATIVE', 'TK_UNION', 'TK_STRUCT',
685
+ 'TK_EXCEPTION', 'TK_READONLY', 'TK_ATTRIBUTE',
686
+ 'TK_FACTORY', 'TK_FINDER'
687
+ }
688
+ tab_firsts.rule_361 = tab_firsts.rule_207
689
+ tab_firsts.rule_362 = set_firsts { 'TK_FACTORY' }
690
+ tab_firsts.rule_363 = set_firsts { 'TK_FINDER' }
691
+ tab_firsts.rule_364 = tab_firsts.rule_362
692
+ tab_firsts.rule_365 = tab_firsts.rule_363
693
+ tab_firsts.rule_366 = tab_firsts.rule_297
694
+ tab_firsts.rule_368 = set_firsts { ',' }
695
+ tab_firsts.rule_370 = set_firsts { 'TK_RAISES' }
696
+
697
+ tab_firsts.rule_377 = set_firsts { 'TK_CONTEXT' }
698
+
699
+ tab_firsts.rule_400 = set_firsts { 'TK_ID' }
700
+ tab_firsts.rule_401 = set_firsts { ':' }
701
+
702
+ tab_follow.rule_32 = set_firsts { 'TK_ID', ';' }
703
+ tab_follow.rule_54 = set_firsts { 'TK_ID', '>', ';' }
704
+ tab_follow.rule_61 = set_firsts { '>', ',' }
705
+ tab_follow.rule_64 = set_firsts { ',', '>' }
706
+ tab_follow.rule_69 = set_firsts { '>' }
707
+ tab_follow.rule_72 = set_firsts { '>' }
708
+ tab_follow.rule_73 = set_firsts { 'TK_ID' }
709
+ tab_follow.rule_95 = set_firsts { '|', ']', ')' }
710
+ tab_follow.rule_98 = set_firsts { '^', ']', ')' }
711
+ tab_follow.rule_102 = set_firsts { '&', ']', ')' }
712
+ tab_follow.rule_106 = set_firsts { '>>', '<<', '&', '^', '|', ']', ')' }
713
+ tab_follow.rule_111 = set_firsts { '+', '-', '>>', '<<', '&', '^', '|', ']', ')' }
714
+ tab_follow.rule_119 = set_firsts { ')' }
715
+ tab_follow.rule_139 = set_firsts { '}' }
716
+ tab_follow.rule_143 = set_firsts { ';' }
717
+ tab_follow.rule_146 = set_firsts { ',', ';' }
718
+ tab_follow.rule_147 = set_firsts { '*', '/', '%', '+', '-', '>>', '<<', '&', '^', '|', ']', ')' }
719
+ tab_follow.rule_148 = set_firsts { ')' }
720
+ tab_follow.rule_154 = set_firsts { ',', ')' }
721
+ tab_follow.rule_157 = set_firsts { '}' }
722
+ tab_follow.rule_161 = set_firsts {
723
+ 'TK_CHAR', 'TK_BOOLEAN', 'TK_OCTET', 'TK_ANY', 'TK_OBJECT',
724
+ 'TK_VALUEBASE', 'TK_LONG', 'TK_FLOAT', 'TK_DOUBLE', 'TK_SHORT',
725
+ 'TK_UNSIGNED', 'TK_SEQUENCE' , 'TK_STRING', 'TK_FIXED' ,
726
+ 'TK_ID', ":", 'TK_STRUCT', 'TK_UNION', 'TK_ENUM',
727
+ }
728
+ tab_follow.rule_162 = set_firsts { ":" }
729
+ tab_follow.rule_167 = set_firsts { "}" }
730
+ tab_follow.rule_204 = set_firsts { ',', '{' }
731
+ tab_follow.rule_221 = set_firsts { 'TK_ID' }
732
+ tab_follow.rule_229 = set_firsts { ',', ')' }
733
+ tab_follow.rule_268 = set_firsts { ',', 'TK_SUPPORTS', '{' }
734
+ tab_follow.rule_272 = set_firsts { ':', 'TK_ID' }
735
+ tab_follow.rule_278 = set_firsts { 'TK_SUPPORTS', '{' }
736
+ tab_follow.rule_286 = set_firsts { '}' }
737
+ tab_follow.rule_301 = set_firsts { ';' }
738
+ tab_follow.rule_304 = set_firsts { ';' }
739
+ tab_follow.rule_307 = set_firsts { 'TK_SUPPORTS', '{' }
740
+ tab_follow.rule_308 = set_firsts { ',', '{' }
741
+ tab_follow.rule_316 = set_firsts { ',', '{' }
742
+ tab_follow.rule_316e = set_firsts { '{' }
743
+ tab_follow.rule_321 = tab_follow.rule_316
744
+ tab_follow.rule_332 = set_firsts { 'TK_ID' }
745
+ tab_follow.rule_340 = set_firsts { 'TK_MULTIPLE', 'TK_ID', ':', 'TK_OBJECT' }
746
+ tab_follow.rule_341 = set_firsts { 'TK_ID' }
747
+ tab_follow.rule_342 = tab_follow.rule_341
748
+ tab_follow.rule_343 = tab_follow.rule_342
749
+ tab_follow.rule_345 = set_firsts { ',', ':', 'TK_MANAGES' }
750
+ tab_follow.rule_347 = set_firsts { 'TK_PRIMARYKEY', '{' }
751
+ tab_follow.rule_348 = set_firsts { 'TK_SUPPORTS' }
752
+ tab_follow.rule_353 = set_firsts { '{' }
753
+ tab_follow.rule_359 = set_firsts { '}' }
754
+ tab_follow.rule_367 = set_firsts { ',', ')' }
755
+ tab_follow.rule_369 = set_firsts { ')' }
756
+ tab_follow.rule_600 = set_firsts { 'TK_STRING_LITERAL' }
757
+
758
+ local tab_follow_rule_error_msg = {
759
+ [32] = 'identifier',
760
+ [64] = "',' or '>'",
761
+ [154] = "',' or ')'",
762
+ [161] = "'char', 'boolean', 'octet', 'any', 'Object',"..
763
+ "'ValueBase', 'long', 'float', 'double', 'short'"..
764
+ "'unsigned', 'sequence', 'string', 'fixed', identifier,"..
765
+ "'struct', 'union', 'enum'",
766
+ [204] = "',', '{'",
767
+ [221] = "identifier",
768
+ [229] = "',', ')'",
769
+ [268] = "',', 'supports' or '{'",
770
+ [307] = "'{'",
771
+ [308] = "',' or '{'",
772
+ [345] = "':', ',' or 'manages'",
773
+ [316] = "',', '{'",
774
+ [332] = "identifier",
775
+ [600] = 'string literal',
776
+ }
777
+
778
+ local token = lex.token
779
+
780
+ local currentScope
781
+ local namespaces
782
+ -- It is a stack of roots.
783
+ local scopeRoots
784
+ local currentScopeName
785
+ local CORBAVisible
786
+
787
+ local tab_identifiers = {}
788
+
789
+ -- this a list of type declarations
790
+ local TAB_TYPEID = {
791
+ ['CONST'] = 'const',
792
+ ['NATIVE'] = 'native',
793
+ ['CHAR'] = 'char',
794
+ ['BOOLEAN'] = 'boolean',
795
+ ['OCTET'] = 'octet',
796
+ ['ANY'] = 'any',
797
+ ['OBJECT'] = 'Object',
798
+ ['VALUEBASE'] = 'valuebase',
799
+ ['STRUCT'] = 'struct',
800
+ ['FLOAT'] = 'float',
801
+ ['SHORT'] = 'short',
802
+ ['FLOAT'] = 'float',
803
+ ['DOUBLE'] = 'double',
804
+ ['USHORT'] = 'ushort',
805
+ ['ULLONG'] = 'ulonglong',
806
+ ['ULONG'] = 'ulong',
807
+ ['LLONG'] = 'longlong',
808
+ ['LDOUBLE'] = 'longdouble',
809
+ ['LONG'] = 'long',
810
+ ['STRING'] = 'string',
811
+ ['FIXED'] = 'fixed',
812
+ ['EXCEPTION'] = 'except',
813
+ ['INTERFACE'] = 'interface',
814
+ ['VOID'] = 'void',
815
+ ['OPERATION'] = 'operation',
816
+ ['TYPEDEF'] = 'typedef',
817
+ ['ENUM'] = 'enum',
818
+ ['SEQUENCE'] = 'sequence',
819
+ ['ATTRIBUTE'] = 'attribute',
820
+ ['MODULE'] = 'module',
821
+ ['UNION'] = 'union',
822
+ ['TYPECODE'] = 'TypeCode',
823
+ ['COMPONENT'] = 'component',
824
+ ['HOME'] = 'home',
825
+ ['FACTORY'] = 'factory',
826
+ ['FINDER'] = 'finder',
827
+ ['VALUEBOX'] = 'valuebox',
828
+ ['VALUETYPE'] = 'valuetype',
829
+ ['EVENTTYPE'] = 'eventtype',
830
+ }
831
+
832
+ local TAB_BASICTYPE = {
833
+ ['NATIVE'] = { _type = TAB_TYPEID['NATIVE'] },
834
+ ['CHAR'] = { _type = TAB_TYPEID['CHAR'] },
835
+ ['BOOLEAN'] = { _type = TAB_TYPEID['BOOLEAN'] },
836
+ ['OCTET'] = { _type = TAB_TYPEID['OCTET'] },
837
+ ['ANY'] = { _type = TAB_TYPEID['ANY'] },
838
+ ['OBJECT'] = { _type = TAB_TYPEID['OBJECT'],
839
+ repID = 'IDL:omg.org/CORBA/Object:1.0' },
840
+ ['VALUEBASE'] = { _type = TAB_TYPEID['VALUEBASE'] },
841
+ ['FLOAT'] = { _type = TAB_TYPEID['FLOAT'] },
842
+ ['SHORT'] = { _type = TAB_TYPEID['SHORT'] },
843
+ ['FLOAT'] = { _type = TAB_TYPEID['FLOAT'] } ,
844
+ ['DOUBLE'] = { _type = TAB_TYPEID['DOUBLE'] },
845
+ ['USHORT'] = { _type = TAB_TYPEID['USHORT'] },
846
+ ['ULLONG'] = { _type = TAB_TYPEID['ULLONG'] },
847
+ ['ULONG'] = { _type = TAB_TYPEID['ULONG'] },
848
+ ['LLONG'] = { _type = TAB_TYPEID['LLONG'] },
849
+ ['LDOUBLE'] = { _type = TAB_TYPEID['LDOUBLE'] },
850
+ ['LONG'] = { _type = TAB_TYPEID['LONG'] },
851
+ ['FIXED'] = { _type = TAB_TYPEID['FIXED'] },
852
+ ['VOID'] = { _type = TAB_TYPEID['VOID'] },
853
+ ['STRING'] = { _type = TAB_TYPEID['STRING'] },
854
+ }
855
+
856
+ local TAB_IMPLICITTYPE = {
857
+ ['TYPECODE'] = { _type = TAB_TYPEID['TYPECODE'],
858
+ repID = 'IDL:omg.org/CORBA/TypeCode:1.0' },
859
+ }
860
+
861
+ local tab_legal_type = {
862
+ [TAB_TYPEID.TYPEDEF] = true,
863
+ [TAB_TYPEID.STRUCT] = true,
864
+ [TAB_TYPEID.ENUM] = true,
865
+ [TAB_TYPEID.INTERFACE] = true,
866
+ [TAB_TYPEID.NATIVE] = true,
867
+ [TAB_TYPEID.UNION] = true,
868
+ [TAB_TYPEID.CHAR] = true,
869
+ [TAB_TYPEID.BOOLEAN] = true,
870
+ [TAB_TYPEID.OCTET] = true,
871
+ [TAB_TYPEID.ANY] = true,
872
+ [TAB_TYPEID.OBJECT] = true,
873
+ [TAB_TYPEID.VALUEBASE] = true,
874
+ [TAB_TYPEID.FLOAT] = true,
875
+ [TAB_TYPEID.DOUBLE] = true,
876
+ [TAB_TYPEID.SHORT] = true,
877
+ [TAB_TYPEID.USHORT] = true,
878
+ [TAB_TYPEID.ULLONG] = true,
879
+ [TAB_TYPEID.ULONG] = true,
880
+ [TAB_TYPEID.LLONG] = true,
881
+ [TAB_TYPEID.LDOUBLE] = true,
882
+ [TAB_TYPEID.LONG] = true,
883
+ [TAB_TYPEID.FIXED] = true,
884
+ [TAB_TYPEID.VOID] = true,
885
+ [TAB_TYPEID.TYPECODE] = true,
886
+ [TAB_TYPEID.SEQUENCE] = true,
887
+ [TAB_TYPEID.STRING] = true,
888
+ }
889
+
890
+ local tab_accept_definition = {
891
+ [TAB_TYPEID.STRUCT] = true,
892
+ [TAB_TYPEID.EXCEPTION] = true,
893
+ [TAB_TYPEID.INTERFACE] = true,
894
+ [TAB_TYPEID.MODULE] = true,
895
+ [TAB_TYPEID.COMPONENT] = true,
896
+ [TAB_TYPEID.HOME] = true,
897
+ [TAB_TYPEID.VALUETYPE] = true,
898
+ [TAB_TYPEID.EVENTTYPE] = true,
899
+ }
900
+
901
+ local tab_define_scope = {
902
+ [TAB_TYPEID.INTERFACE] = true,
903
+ [TAB_TYPEID.EXCEPTION] = true,
904
+ [TAB_TYPEID.OPERATION] = true,
905
+ [TAB_TYPEID.FACTORY] = true,
906
+ [TAB_TYPEID.STRUCT] = true,
907
+ [TAB_TYPEID.UNION] = true,
908
+ [TAB_TYPEID.MODULE] = true,
909
+ [TAB_TYPEID.COMPONENT] = true,
910
+ [TAB_TYPEID.VALUETYPE] = true,
911
+ }
912
+
913
+ local tab_is_contained = {
914
+ [TAB_TYPEID.ATTRIBUTE] = true,
915
+ [TAB_TYPEID.TYPEDEF] = true,
916
+ [TAB_TYPEID.INTERFACE] = true,
917
+ [TAB_TYPEID.OPERATION] = true,
918
+ [TAB_TYPEID.CONST] = true,
919
+
920
+ [TAB_TYPEID.STRUCT] = true,
921
+ [TAB_TYPEID.EXCEPTION] = true,
922
+ [TAB_TYPEID.MODULE] = true,
923
+ [TAB_TYPEID.ENUM] = true,
924
+ [TAB_TYPEID.UNION] = true,
925
+ [TAB_TYPEID.COMPONENT] = true,
926
+ [TAB_TYPEID.HOME] = true,
927
+ [TAB_TYPEID.VALUETYPE] = true,
928
+ [TAB_TYPEID.VALUEBOX] = true,
929
+ [TAB_TYPEID.EVENTTYPE] = true,
930
+ [TAB_TYPEID.TYPECODE] = true,
931
+ }
932
+
933
+ local TAB_VALUEEXPECTED = {
934
+ [lex.tab_tokens.TK_ID] = "<identifier>",
935
+ [lex.tab_tokens.TK_ABSTRACT] = "abstract",
936
+ [lex.tab_tokens.TK_ANY] = TAB_TYPEID.ANY,
937
+ [lex.tab_tokens.TK_ATTRIBUTE] = TAB_TYPEID.ATTRIBUTE,
938
+ [lex.tab_tokens.TK_BOOLEAN] = TAB_TYPEID.BOOLEAN,
939
+ [lex.tab_tokens.TK_CASE] = "case",
940
+ [lex.tab_tokens.TK_CHAR] = TAB_TYPEID.CHAR,
941
+ [lex.tab_tokens.TK_COMPONENT] = TAB_TYPEID.COMPONENT,
942
+ [lex.tab_tokens.TK_CONST] = TAB_TYPEID.CONST,
943
+ [lex.tab_tokens.TK_CONSUMES] = "consumes",
944
+ [lex.tab_tokens.TK_CONTEXT] = "context",
945
+ [lex.tab_tokens.TK_CUSTOM] = "custom",
946
+ [lex.tab_tokens.TK_DEFAULT] = "default",
947
+ [lex.tab_tokens.TK_DOUBLE] = TAB_TYPEID.DOUBLEF,
948
+ [lex.tab_tokens.TK_EXCEPTION] = TAB_TYPEID.EXCEPTION,
949
+ [lex.tab_tokens.TK_EMITS] = "emits",
950
+ [lex.tab_tokens.TK_ENUM] = TAB_TYPEID.ENUM,
951
+ [lex.tab_tokens.TK_EVENTTYPE] = TAB_TYPEID.EVENTTYPE,
952
+ [lex.tab_tokens.TK_FACTORY] = TAB_TYPEID.FACTORY,
953
+ [lex.tab_tokens.TK_FALSE] = "FALSE",
954
+ [lex.tab_tokens.TK_FINDER] = TAB_TYPEID.FINDER,
955
+ [lex.tab_tokens.TK_FIXED] = TAB_TYPEID.FIXED,
956
+ [lex.tab_tokens.TK_FLOAT] = TAB_TYPEID.FLOAT,
957
+ [lex.tab_tokens.TK_GETRAISES] = "getraises",
958
+ [lex.tab_tokens.TK_HOME] = TAB_TYPEID.HOME,
959
+ [lex.tab_tokens.TK_IMPORT] = "import",
960
+ [lex.tab_tokens.TK_IN] = "in",
961
+ [lex.tab_tokens.TK_INOUT] = "inout",
962
+ [lex.tab_tokens.TK_INTERFACE] = TAB_TYPEID.INTERFACE,
963
+ [lex.tab_tokens.TK_LOCAL] = "local",
964
+ [lex.tab_tokens.TK_LONG] = TAB_TYPEID.LONG,
965
+ [lex.tab_tokens.TK_MODULE] = TAB_TYPEID.MODULE,
966
+ [lex.tab_tokens.TK_MULTIPLE] = "multiple",
967
+ [lex.tab_tokens.TK_NATIVE] = TAB_TYPEID.NATIVE,
968
+ [lex.tab_tokens.TK_OBJECT] = TAB_TYPEID.OBJECT,
969
+ [lex.tab_tokens.TK_OCTET] = TAB_TYPEID.OCTET,
970
+ [lex.tab_tokens.TK_ONEWAY] = "oneway",
971
+ [lex.tab_tokens.TK_OUT] = "out",
972
+ [lex.tab_tokens.TK_PRIMARYKEY] = "primarykey",
973
+ [lex.tab_tokens.TK_PRIVATE] = "private",
974
+ [lex.tab_tokens.TK_PROVIDES] = "provides",
975
+ [lex.tab_tokens.TK_PUBLIC] = "public",
976
+ [lex.tab_tokens.TK_PUBLISHES] = "publishes",
977
+ [lex.tab_tokens.TK_RAISES] = "raises",
978
+ [lex.tab_tokens.TK_READONLY] = "readonly",
979
+ [lex.tab_tokens.TK_SETRAISES] = "setraises",
980
+ [lex.tab_tokens.TK_SEQUENCE] = "sequence",
981
+ [lex.tab_tokens.TK_SHORT] = TAB_TYPEID.SHORT,
982
+ [lex.tab_tokens.TK_STRING] = TAB_TYPEID.STRING,
983
+ [lex.tab_tokens.TK_STRUCT] = TAB_TYPEID.STRUCT,
984
+ [lex.tab_tokens.TK_SUPPORTS] = "supports",
985
+ [lex.tab_tokens.TK_SWITCH] = "switch",
986
+ [lex.tab_tokens.TK_TRUE] = "TRUE",
987
+ [lex.tab_tokens.TK_TRUNCATABLE] = "truncatable",
988
+ [lex.tab_tokens.TK_TYPEDEF] = TAB_TYPEID.TYPEDEF,
989
+ [lex.tab_tokens.TK_TYPEID] = "typeid",
990
+ [lex.tab_tokens.TK_TYPEPREFIX] = "typeprefix",
991
+ [lex.tab_tokens.TK_UNSIGNED] = "unsigned",
992
+ [lex.tab_tokens.TK_UNION] = TAB_TYPEID.UNION,
993
+ [lex.tab_tokens.TK_USES] = "uses",
994
+ [lex.tab_tokens.TK_VALUEBASE] = TAB_TYPEID.VALUEBASE,
995
+ [lex.tab_tokens.TK_VALUETYPE] = TAB_TYPEID.VALUETYPE,
996
+ [lex.tab_tokens.TK_VOID] = TAB_TYPEID.VOID,
997
+ [lex.tab_tokens.TK_WCHAR] = "wchar",
998
+ [lex.tab_tokens.TK_WSTRING] = "wstring",
999
+ [lex.tab_tokens.TK_INTEGER_LITERAL] = "<integer literal>",
1000
+ [lex.tab_tokens.TK_FLOAT_LITERAL] = "<float literal>",
1001
+ [lex.tab_tokens.TK_CHAR_LITERAL] = "<char literal>",
1002
+ [lex.tab_tokens.TK_WCHAR_LITERAL] = "<wchar literal>",
1003
+ [lex.tab_tokens.TK_STRING_LITERAL] = "<string literal>",
1004
+ [lex.tab_tokens.TK_WSTRING_LITERAL] = "<wstring literal>",
1005
+ [lex.tab_tokens.TK_FIXED_LITERAL] = "<fixed literal>",
1006
+ [lex.tab_tokens.TK_PRAGMA_PREFIX] = "<pragma prefix>",
1007
+ [lex.tab_tokens.TK_PRAGMA_ID] = "<pragma id>",
1008
+ [lex.tab_tokens.TK_MANAGES] = "manages",
1009
+ }
1010
+
1011
+ local rules = {}
1012
+
1013
+
1014
+ ---
1015
+ -- Error reporting
1016
+ ---------------------------------------------------------------------------------------------------
1017
+ local ERRMSG_DECLARED = "'%s' has already been declared"
1018
+ local ERRMSG_PARAMDECLARED = "parameter '%s' has already been declared"
1019
+ local ERRMSG_RAISESDECLARED = "raise '%s' has already been declared"
1020
+ local ERRMSG_OPDECLARED = "operation '%s' has already been declared"
1021
+ local ERRMSG_REDEFINITION = "redefinition of '%s'"
1022
+ local ERRMSG_NOTTYPE = "%s is not a legal type"
1023
+ local ERRMSG_UNDECLARED = "%s is an undeclared type"
1024
+ local ERRMSG_FORWARD = "There is a forward reference to %s, but it is not defined"
1025
+
1026
+ local tab_ERRORMSG ={
1027
+ [01] = "definition ('typedef', 'enum', 'native', 'union', 'struct', "..
1028
+ "'const', 'exception', 'abstract', 'local', "..
1029
+ "'interface', 'custom', 'valuetype', 'eventtype', "..
1030
+ "'module', 'typeid', 'typeprefix', 'component' or 'home')",
1031
+ [02] = "type declaration ('typedef', 'struct', 'union', 'enum' or 'native')",
1032
+ [03] = "type specification ('char', 'boolean', 'octet', 'any', 'Object', "..
1033
+ "'ValueBase', 'long', 'float', 'double', 'short', 'unsigned', 'sequence', "..
1034
+ "'string', 'fixed', identifier, 'struct', 'union', 'enum')",
1035
+ [04] = "simple type specification (base type, template type or a scoped name)",
1036
+ [05] = "base type specification ('char', 'boolean', 'octet', 'any', 'Object', "..
1037
+ "'ValueBase', 'long', 'float', 'double', 'short', 'unsigned')",
1038
+ [06] = "'float', 'double', 'short', 'unsigned' or 'long'",
1039
+ [07] = "'float' or 'double'",
1040
+ [08] = "'short' or 'unsigned'",
1041
+ [09] = "'long' or 'short'",
1042
+ --follows!?
1043
+ [10] = "'long'",
1044
+ [11] = "',' or ';'",
1045
+ [12] = "'[', ',' or ';'",
1046
+ [13] = "'-', '+', '~', '(', identifier, ':', <integer literal>,"..
1047
+ "<string literal>, <char literal>, <fixed literal>,"..
1048
+ "<float literal>, 'TRUE' or 'FALSE'",
1049
+ [14] = "'-', '+', '~'",
1050
+ [15] = "'(', identifier, ':', <integer literal>,"..
1051
+ "<string literal>, <char literal>, <fixed literal>,"..
1052
+ "<float literal>, 'TK_TRUE', 'TK_FALSE'",
1053
+ [16] = "<integer literal>, <string literal>, <char literal>,"..
1054
+ "<fixed literal>, <float literal>",
1055
+ [17] = "'TK_TRUE', 'TK_FALSE'",
1056
+ [18] = "'*', '/', '%', '+', '-', ']', ')', '>>', '<<', '&', '^', '|'",
1057
+ [19] = "'+', '-', '>>', '<<'",
1058
+ [20] = "'>>', '<<', '&'",
1059
+ [21] = "'&', '^'",
1060
+ [22] = "'^', '|'",
1061
+ [23] = "'|'",
1062
+ [24] = "you must entry with a positive integer",
1063
+ [25] = "you must entry with a integer",
1064
+ [26] = "'<' or identifier",
1065
+ [27] = "constructed type specification ('struct', 'union' or 'enum')",
1066
+ [28] = "type specification or '}'",
1067
+ [29] = "'short', 'unsigned', 'char', 'boolean', 'enum', identifier, '::'",
1068
+ [30] = "'case', 'default'",
1069
+ [31] = "'case', 'default' or type specification",
1070
+ [32] = "'case', 'default' or '}'",
1071
+ }
1072
+
1073
+ local function sinError(valueExpected)
1074
+ error(string.format("%s(line %i): %s expected, encountered '%s'." ,
1075
+ lex.srcfilename, lex.line, valueExpected, lex.tokenvalue), 2)
1076
+ end
1077
+
1078
+ local function semanticError(error_msg)
1079
+ local scope = currentScope.absolute_name
1080
+ if (scope == '') then
1081
+ scope = 'GLOBAL'
1082
+ end
1083
+ error(string.format("%s(line %i):Scope:'%s': %s.", lex.srcfilename,
1084
+ lex.line, scope, error_msg), 2)
1085
+ end
1086
+ ---------------------------------------------------------------------------------------------------
1087
+
1088
+
1089
+ ---
1090
+ -- Auxiliar functions
1091
+ ---------------------------------------------------------------------------------------------------
1092
+ local function getID()
1093
+ return lex.tokenvalue_previous
1094
+ end
1095
+
1096
+ local function registerID(id)
1097
+ if (string.sub(id, 1, 2) == "::") then
1098
+ id = string.sub(id, 3)
1099
+ end
1100
+ tab_identifiers[string.upper(currentScope.absolute_name.."::"..id)] = true;
1101
+ end
1102
+
1103
+ local function gotoFatherScope()
1104
+ if (scopeRoots[#scopeRoots].scope == currentScope.absolute_name) then
1105
+ table.remove(scopeRoots)
1106
+ end
1107
+ local currentRoot = scopeRoots[#scopeRoots].root
1108
+ if (currentScope._type == TAB_TYPEID.MODULE) then
1109
+ currentRoot = string.gsub(currentRoot, "::[^:]+$", "")
1110
+ scopeRoots[#scopeRoots].root = currentRoot
1111
+ elseif (currentScope._type == TAB_TYPEID.INTERFACE) or
1112
+ (currentScope._type == TAB_TYPEID.STRUCT) or
1113
+ (currentScope._type == TAB_TYPEID.UNION) or
1114
+ (currentScope._type == TAB_TYPEID.EXCEPTION)
1115
+ then
1116
+ currentScopeName = string.gsub(currentScopeName, "::[^:]+$", "")
1117
+ end
1118
+ currentScope = namespaces[currentScope.absolute_name].father_scope
1119
+ end
1120
+
1121
+ local function getAbsolutename(scope, name)
1122
+ return scope.absolute_name..'::'..name
1123
+ end
1124
+
1125
+ local function dclName(name, target, value)
1126
+ local absolutename = getAbsolutename(currentScope, name)
1127
+ if namespaces[absolutename] then
1128
+ semanticError(string.format(ERRMSG_DECLARED, name))
1129
+ else
1130
+ if tab_identifiers[string.upper(absolutename)] then
1131
+ semanticError("collision with '"..name.."'")
1132
+ end
1133
+ namespaces[absolutename] = {namespace = name}
1134
+ if value then
1135
+ value.name = name
1136
+ table.insert(target, value)
1137
+ else
1138
+ table.insert(target, name)
1139
+ end
1140
+ end
1141
+ end
1142
+
1143
+ local recognize
1144
+
1145
+ local function getToken()
1146
+ token = lex.lexer(idl)
1147
+
1148
+ for _, linemark in ipairs(lex.tab_linemarks) do
1149
+ if linemark['1'] then
1150
+ table.insert(scopeRoots, {root = '', scope = currentScope.absolute_name})
1151
+ elseif linemark['2'] then
1152
+ table.remove(scopeRoots)
1153
+ end
1154
+ end
1155
+ lex.tab_linemarks = {}
1156
+
1157
+ -- The ID Pragma
1158
+ -- #pragma ID <name> "<id>"
1159
+ if (token == lex.tab_tokens.TK_PRAGMA_ID) then
1160
+ token = lex.lexer(idl)
1161
+ local definition = rules.scoped_name(600)
1162
+ local repid = lex.tokenvalue
1163
+ recognize(lex.tab_tokens.TK_STRING_LITERAL)
1164
+ local absolutename = definition.absolute_name
1165
+ if namespaces[absolutename].pragmaID then
1166
+ if (definition.repID ~= repid) then
1167
+ semanticError("repository ID ever defined")
1168
+ end
1169
+ else
1170
+ namespaces[absolutename].pragmaID = true
1171
+ definition.repID = repid
1172
+ end
1173
+ -- The Prefix Pragma
1174
+ -- #pragma prefix "<string>"
1175
+ elseif (token == lex.tab_tokens.TK_PRAGMA_PREFIX) then
1176
+ token = lex.lexer(idl)
1177
+ local prefix = lex.tokenvalue
1178
+ if (scopeRoots[#scopeRoots].scope == currentScope.absolute_name) then
1179
+ table.remove(scopeRoots)
1180
+ end
1181
+ table.insert(scopeRoots, {root = prefix, scope = currentScope.absolute_name})
1182
+ recognize(lex.tab_tokens.TK_STRING_LITERAL)
1183
+ end
1184
+ return token
1185
+ end
1186
+
1187
+ function recognize(tokenExpected)
1188
+ if (tokenExpected == token) then
1189
+ token = getToken()
1190
+ else
1191
+ local valueExpected = TAB_VALUEEXPECTED[tokenExpected]
1192
+ if not valueExpected then
1193
+ valueExpected = "'"..tokenExpected.."'"
1194
+ end
1195
+ sinError(valueExpected)
1196
+ end
1197
+ end
1198
+
1199
+ local function updateGlobalName(type, name)
1200
+ local localName = ''
1201
+ local currentRoot = scopeRoots[#scopeRoots].root
1202
+ -- Whenever a module is encountered, the string "::" and the <name> are appended
1203
+ -- to the name of the current root.
1204
+ if (type == TAB_TYPEID.MODULE) then
1205
+ currentRoot = currentRoot..'::'..name
1206
+ -- Whenever a interface, struct, union or exception is encountered,
1207
+ -- the string "::" and the <name> are appended to the name of the current scope.
1208
+ elseif (
1209
+ (type == TAB_TYPEID.INTERFACE) or
1210
+ (type == TAB_TYPEID.STRUCT) or
1211
+ (type == TAB_TYPEID.UNION) or
1212
+ (type == TAB_TYPEID.EXCEPTION)
1213
+ )
1214
+ then
1215
+ currentScopeName = currentScopeName..'::'..name
1216
+ else
1217
+ localName = '::'..name
1218
+ end
1219
+ scopeRoots[#scopeRoots].root = currentRoot
1220
+ return currentRoot, currentScopeName, localName
1221
+ end
1222
+
1223
+ -- Define an OMG IDL definition.
1224
+ local function define(name, type, namespace)
1225
+ local absolutename = getAbsolutename(currentScope, name)
1226
+ local definitions
1227
+
1228
+ -- Esta defini��o j� foi declarada anteriormente?
1229
+ if (namespaces[absolutename]) then
1230
+ -- Um m�dulo est� sendo reaberto?
1231
+ if (
1232
+ (namespaces[absolutename].namespace._type == TAB_TYPEID.MODULE)
1233
+ and
1234
+ (type == TAB_TYPEID.MODULE)
1235
+ )
1236
+ then
1237
+ namespace = namespaces[absolutename].namespace
1238
+ currentScope = namespace
1239
+ updateGlobalName(type, name)
1240
+ return nil, namespace
1241
+ else
1242
+ semanticError(string.format(ERRMSG_REDEFINITION, name))
1243
+ end
1244
+ end
1245
+
1246
+ -- A defini��o j� foi declarada como forward?
1247
+ if forwardDeclarations[absolutename] then
1248
+ namespace = forwardDeclarations[absolutename]
1249
+ forwardDeclarations[absolutename] = nil
1250
+ end
1251
+
1252
+ if (not definitions and tab_accept_definition[type]) then
1253
+ definitions = {}
1254
+ end
1255
+
1256
+ local root, scope, localName = updateGlobalName(type, name)
1257
+ repID = root..scope..localName
1258
+ repID = string.gsub(string.gsub(repID, "^::", ""), "::", "/")
1259
+
1260
+ if (not namespace) then
1261
+ namespace = {}
1262
+ end
1263
+
1264
+ namespace.name = name
1265
+ namespace._type = type
1266
+ namespace.absolute_name = absolutename
1267
+ namespace.repID = "IDL:"..repID..":"..lex.PRAGMA_VERSION
1268
+ namespace.definitions = definitions
1269
+
1270
+ if (tab_is_contained[type] and currentScope ~= output) then
1271
+ table.insert(currentScope.definitions, namespace)
1272
+ elseif (type == TAB_TYPEID.FACTORY) then
1273
+ currentScope.initializers = currentScope.initializers or {}
1274
+ table.insert(currentScope.initializers, namespace)
1275
+ else
1276
+ table.insert(currentScope, namespace)
1277
+ end
1278
+
1279
+ if (tab_define_scope[type]) then
1280
+ namespaces[absolutename] = {
1281
+ father_scope = currentScope,
1282
+ namespace = namespace,
1283
+ }
1284
+ currentScope = namespace
1285
+ else
1286
+ namespaces[absolutename] = {namespace = namespace}
1287
+ end
1288
+ return true, namespace
1289
+ end
1290
+
1291
+ -- This is an auxiliar function for getDefinition().
1292
+ local function getTabDefinition(name)
1293
+ local namespace
1294
+ if namespaces[name] then
1295
+ namespace = namespaces[name].namespace
1296
+ end
1297
+ return namespace or forwardDeclarations[name]
1298
+ end
1299
+
1300
+ local function getDefinition(name, baseScope)
1301
+ local scope = currentScope
1302
+ -- Busca uma defini��o em um escopo previamente fornecido.
1303
+ if baseScope then
1304
+ local definition = getTabDefinition(baseScope..'::'..name)
1305
+ if (definition) then
1306
+ return definition
1307
+ end
1308
+ else
1309
+ while true do
1310
+ local absolutename = getAbsolutename(scope, name)
1311
+ local definition = getTabDefinition(absolutename)
1312
+ if definition then
1313
+ return definition
1314
+ end
1315
+ if (scope._type == TAB_TYPEID.INTERFACE) then
1316
+ -- Busca a defini��o nas interfaces de base.
1317
+ for _, base in ipairs(scope) do
1318
+ absolutename = getAbsolutename(namespaces[base.absolute_name].namespace, name)
1319
+ local definition = getTabDefinition(absolutename)
1320
+ if definition then
1321
+ return definition
1322
+ end
1323
+ end
1324
+ end
1325
+ -- Se a defini��o n�o foi encontrada no escopo atual, ent�o a busca continua
1326
+ -- no escopo *pai*.
1327
+ if (scope ~= output) then
1328
+ scope = namespaces[scope.absolute_name].father_scope
1329
+ else
1330
+ if (currentScope._type == TAB_TYPEID.UNION) then
1331
+ if (currentScope.switch._type == TAB_TYPEID.ENUM) then
1332
+ return namespaces[getAbsolutename(currentScope.switch, scope)].namespace
1333
+ end
1334
+ end
1335
+ break
1336
+ end
1337
+ end
1338
+ end
1339
+ semanticError(string.format(ERRMSG_UNDECLARED, name))
1340
+ end
1341
+
1342
+ -- Define uma declara��o forward.
1343
+ local function dclForward(name, type)
1344
+ local absolute_name = getAbsolutename(currentScope, name)
1345
+ local definition = namespaces[absolute_name] or
1346
+ forwardDeclarations[absolute_name]
1347
+ if not definition then
1348
+ definition = {name = name, _type = type, absolute_name = absolute_name}
1349
+ forwardDeclarations[absolute_name] = definition
1350
+ end
1351
+ return definition
1352
+ end
1353
+ ---------------------------------------------------------------------------------------------------
1354
+
1355
+
1356
+ ---
1357
+ -- GRAMMAR RULES
1358
+ --------------------------------------------------------------------------
1359
+
1360
+ rules.specification = function ()
1361
+ -- import_l()
1362
+ if (callbacks.start) then
1363
+ callbacks.start()
1364
+ end
1365
+ rules.definition_l()
1366
+ -- Is there any forward reference without definition?
1367
+ for definition, _ in pairs(forwardDeclarations) do
1368
+ semanticError(string.format(ERRMSG_FORWARD, definition))
1369
+ end
1370
+ if (callbacks.finish) then
1371
+ callbacks.finish()
1372
+ end
1373
+ end
1374
+
1375
+ rules.definition_l = function ()
1376
+ if (tab_firsts.rule_11[token]) then
1377
+ rules.definition()
1378
+ rules.definition_l_r()
1379
+ else
1380
+ sinError(tab_ERRORMSG[01])
1381
+ end
1382
+ end
1383
+
1384
+ rules.definition_l_r = function ()
1385
+ if (tab_firsts.rule_12[token]) then
1386
+ rules.definition()
1387
+ rules.definition_l_r()
1388
+ elseif (not token) then
1389
+ --empty
1390
+ else
1391
+ sinError(tab_ERRORMSG[01])
1392
+ end
1393
+ end
1394
+
1395
+ rules.definition = function ()
1396
+ if (tab_firsts.rule_14[token]) then
1397
+ rules.type_dcl()
1398
+ elseif (tab_firsts.rule_15[token]) then
1399
+ rules.const_dcl()
1400
+ elseif (tab_firsts.rule_16[token]) then
1401
+ rules.except_dcl()
1402
+ elseif (tab_firsts.rule_17[token]) then
1403
+ rules.inter_value_event()
1404
+ elseif (tab_firsts.rule_18[token]) then
1405
+ rules.module()
1406
+ elseif (tab_firsts.rule_19[token]) then
1407
+ rules.type_id_dcl()
1408
+ elseif (tab_firsts.rule_20[token]) then
1409
+ rules.type_prefix_dcl()
1410
+ elseif (tab_firsts.rule_21[token]) then
1411
+ rules.component()
1412
+ elseif (tab_firsts.rule_22[token]) then
1413
+ rules.home_dcl()
1414
+ end
1415
+ recognize(";")
1416
+ end
1417
+
1418
+ rules.const_dcl = function ()
1419
+ if (tab_firsts.rule_174[token]) then
1420
+ recognize(lex.tab_tokens.TK_CONST)
1421
+ local type = rules.const_type()
1422
+ recognize(lex.tab_tokens.TK_ID)
1423
+ local name = getID()
1424
+ recognize("=")
1425
+ local value = rules.positive_int_const(143)
1426
+ local const = {type = type, value = value}
1427
+ define(name, TAB_TYPEID.CONST, const)
1428
+ if (callbacks.const) then
1429
+ callbacks.const(const)
1430
+ end
1431
+ end
1432
+ end
1433
+
1434
+ rules.const_type = function ()
1435
+ if (tab_firsts.rule_175[token]) then
1436
+ return rules.float_type_or_int_type()
1437
+ elseif (tab_firsts.rule_176[token]) then
1438
+ recognize(lex.tab_tokens.TK_CHAR)
1439
+ return TAB_BASICTYPE.CHAR
1440
+ elseif (tab_firsts.rule_177[token]) then
1441
+ recognize(lex.tab_tokens.TK_BOOLEAN)
1442
+ return TAB_BASICTYPE.BOOLEAN
1443
+ elseif (tab_firsts.rule_178[token]) then
1444
+ recognize(lex.tab_tokens.TK_STRING)
1445
+ return TAB_BASICTYPE.STRING
1446
+ elseif (tab_firsts.rule_179[token]) then
1447
+ return rules.scoped_name(32)
1448
+ elseif (tab_firsts.rule_180[token]) then
1449
+ recognize(lex.tab_tokens.TK_OCTET)
1450
+ return TAB_BASICTYPE.OCTET
1451
+ elseif (tab_firsts.rule_181[token]) then
1452
+ recognize(lex.tab_tokens.TK_FIXED)
1453
+ return TAB_BASICTYPE.FIXED
1454
+ end
1455
+ end
1456
+
1457
+ rules.type_dcl = function ()
1458
+ if (tab_firsts.rule_23[token]) then
1459
+ recognize(lex.tab_tokens.TK_TYPEDEF)
1460
+ rules.type_declarator()
1461
+ elseif (tab_firsts.rule_24[token]) then
1462
+ rules.enum_type()
1463
+ elseif (tab_firsts.rule_25[token]) then
1464
+ recognize(lex.tab_tokens.TK_NATIVE)
1465
+ recognize(lex.tab_tokens.TK_ID)
1466
+ define(getID(), TAB_TYPEID.NATIVE)
1467
+ elseif (tab_firsts.rule_26[token]) then
1468
+ rules.union_or_struct()
1469
+ else
1470
+ sinError(tab_ERRORMSG[02])
1471
+ end
1472
+ end
1473
+
1474
+ rules.type_declarator = function ()
1475
+ local type = rules.type_spec()
1476
+ if (not tab_legal_type[type._type]) then
1477
+ semanticError(string.format(ERRMSG_NOTTYPE, type._type))
1478
+ end
1479
+ rules.type_dcl_name_l(type)
1480
+ end
1481
+
1482
+ rules.type_spec = function (numrule)
1483
+ if (tab_firsts.rule_28[token]) then
1484
+ return rules.simple_type_spec(numrule)
1485
+ elseif (tab_firsts.rule_29[token]) then
1486
+ return rules.constr_type_spec()
1487
+ else
1488
+ sinError(tab_ERRORMSG[03])
1489
+ end
1490
+ end
1491
+
1492
+ rules.simple_type_spec = function (numrule)
1493
+ if (tab_firsts.rule_30[token]) then
1494
+ return rules.base_type_spec()
1495
+ elseif (tab_firsts.rule_31[token]) then
1496
+ return rules.template_type_spec()
1497
+ elseif (tab_firsts.rule_32[token]) then
1498
+ tab = rules.scoped_name(numrule or 32)
1499
+ return tab
1500
+ else
1501
+ sinError(tab_ERRORMSG[04])
1502
+ end
1503
+ end
1504
+
1505
+ rules.base_type_spec = function ()
1506
+ if (tab_firsts.rule_36[token]) then
1507
+ return rules.float_type_or_int_type()
1508
+ elseif (tab_firsts.rule_37[token]) then
1509
+ recognize(lex.tab_tokens.TK_CHAR)
1510
+ return TAB_BASICTYPE.CHAR
1511
+ elseif (tab_firsts.rule_38[token]) then
1512
+ recognize(lex.tab_tokens.TK_BOOLEAN)
1513
+ return TAB_BASICTYPE.BOOLEAN
1514
+ elseif (tab_firsts.rule_39[token]) then
1515
+ recognize(lex.tab_tokens.TK_OCTET)
1516
+ return TAB_BASICTYPE.OCTET
1517
+ elseif (tab_firsts.rule_40[token]) then
1518
+ recognize(lex.tab_tokens.TK_ANY)
1519
+ return TAB_BASICTYPE.ANY
1520
+ elseif (tab_firsts.rule_41[token]) then
1521
+ recognize(lex.tab_tokens.TK_OBJECT)
1522
+ return TAB_BASICTYPE.OBJECT
1523
+ elseif (tab_firsts.rule_42[token]) then
1524
+ recognize(lex.tab_tokens.TK_VALUEBASE)
1525
+ return TAB_BASICTYPE.VALUEBASE
1526
+ -- else
1527
+ -- sinError(tab_ERRORMSG[05])
1528
+ end
1529
+ end
1530
+
1531
+ rules.float_type_or_int_type = function ()
1532
+ if (tab_firsts.rule_43[token]) then
1533
+ return rules.floating_pt_type()
1534
+ elseif (tab_firsts.rule_44[token]) then
1535
+ return rules.integer_type(54)
1536
+ elseif (tab_firsts.rule_45[token]) then
1537
+ recognize(lex.tab_tokens.TK_LONG)
1538
+ return rules.long_or_double()
1539
+ else
1540
+ sinError(tab_ERRORMSG[06])
1541
+ end
1542
+ end
1543
+
1544
+ rules.floating_pt_type = function ()
1545
+ if (tab_firsts.rule_46[token]) then
1546
+ recognize(lex.tab_tokens.TK_FLOAT)
1547
+ return TAB_BASICTYPE.FLOAT
1548
+ elseif (tab_firsts.rule_47[token]) then
1549
+ recognize(lex.tab_tokens.TK_DOUBLE)
1550
+ return TAB_BASICTYPE.DOUBLE
1551
+ -- else
1552
+ -- sinError(tab_ERRORMSG[07])
1553
+ end
1554
+ end
1555
+
1556
+ rules.integer_type = function (numrule)
1557
+ if (tab_firsts.rule_48[token]) then
1558
+ recognize(lex.tab_tokens.TK_SHORT)
1559
+ return TAB_BASICTYPE.SHORT
1560
+ elseif (tab_firsts.rule_49[token]) then
1561
+ return rules.unsigned_int(numrule)
1562
+ -- else
1563
+ -- sinError(tab_ERRORMSG[08])
1564
+ end
1565
+ end
1566
+
1567
+ rules.unsigned_int = function (numrule)
1568
+ recognize(lex.tab_tokens.TK_UNSIGNED)
1569
+ return rules.unsigned_int_tail(numrule)
1570
+ end
1571
+
1572
+ rules.unsigned_int_tail = function (numrule)
1573
+ if (tab_firsts.rule_51[token]) then
1574
+ recognize(lex.tab_tokens.TK_LONG)
1575
+ return rules.ulong_e(numrule)
1576
+ elseif (tab_firsts.rule_52[token]) then
1577
+ recognize(lex.tab_tokens.TK_SHORT)
1578
+ return TAB_BASICTYPE.USHORT
1579
+ else
1580
+ sinError(tab_ERRORMSG[09])
1581
+ end
1582
+ end
1583
+
1584
+ rules.long_e = function (numrule)
1585
+ if (tab_firsts.rule_53[token]) then
1586
+ recognize(lex.tab_tokens.TK_LONG)
1587
+ return TAB_BASICTYPE.LLONG
1588
+ elseif (tab_follow['rule_'..numrule][token]) then
1589
+ return TAB_BASICTYPE.LONG
1590
+ --empty
1591
+ else
1592
+ sinError(tab_ERRORMSG[10])
1593
+ end
1594
+ end
1595
+
1596
+ rules.ulong_e = function (numrule)
1597
+ if (tab_firsts.rule_53[token]) then
1598
+ recognize(lex.tab_tokens.TK_LONG)
1599
+ return TAB_BASICTYPE.ULLONG
1600
+ elseif (tab_follow['rule_'..numrule][token]) then
1601
+ return TAB_BASICTYPE.ULONG
1602
+ --empty
1603
+ else
1604
+ sinError(tab_ERRORMSG[10])
1605
+ end
1606
+ end
1607
+
1608
+ rules.type_dcl_name_l = function (type)
1609
+ rules.type_dcl_name(type)
1610
+ rules.type_dcl_name_l_r(type)
1611
+ end
1612
+
1613
+ rules.type_dcl_name_l_r = function (type)
1614
+ if (tab_firsts.rule_142[token]) then
1615
+ recognize(",")
1616
+ rules.type_dcl_name(type)
1617
+ rules.type_dcl_name_l_r(type)
1618
+ elseif (tab_follow.rule_143 [token]) then
1619
+ --empty
1620
+ else
1621
+ sinError(tab_ERRORMSG[11])
1622
+ end
1623
+ end
1624
+
1625
+ rules.type_dcl_name = function (type)
1626
+ recognize(lex.tab_tokens.TK_ID)
1627
+ local name = getID()
1628
+ local typedef = {original_type = rules.fixed_array_size_l(type)}
1629
+ define(name, TAB_TYPEID.TYPEDEF, typedef)
1630
+ if (callbacks.typedef) then
1631
+ callbacks.typedef(typedef)
1632
+ end
1633
+ end
1634
+
1635
+ -- without revision
1636
+ rules.fixed_array_size_l = function (tab_type_spec)
1637
+ if (tab_firsts.rule_145[token]) then
1638
+ local array = {
1639
+ length = rules.fixed_array_size(tab_type_spec),
1640
+ elementtype = rules.fixed_array_size_l(tab_type_spec),
1641
+ _type = 'array'
1642
+ }
1643
+ if callbacks.array then
1644
+ callbacks.array(array)
1645
+ end
1646
+ return array
1647
+ elseif (tab_follow.rule_146[token]) then
1648
+ --empty
1649
+ return tab_type_spec
1650
+ else
1651
+ sinError(tab_ERRORMSG[12])
1652
+ end
1653
+ end
1654
+
1655
+ rules.fixed_array_size = function (tab_type_spec)
1656
+ recognize("[")
1657
+ local const = rules.positive_int_const(147)
1658
+ recognize("]")
1659
+ return const
1660
+ end
1661
+
1662
+ -- without revision
1663
+ --without revision
1664
+ --without bitwise logical operations
1665
+ rules.positive_int_const = function (numrule)
1666
+ if tab_firsts.rule_75[token] then
1667
+ local const1 = rules.xor_expr(numrule)
1668
+ rules.or_expr_l(numrule)
1669
+ if type(const1) == "string" and string.find(const1, '[%d]') then
1670
+ const1 = tonumber(const1)
1671
+ if const1 < 0 then
1672
+ semanticError(tab_ERRORMSG[24])
1673
+ end
1674
+ end
1675
+ return const1
1676
+ else
1677
+ sinError(tab_ERRORMSG[13])
1678
+ end
1679
+ end
1680
+
1681
+
1682
+ rules.xor_expr = function (numrule)
1683
+ if tab_firsts.rule_93[token] then
1684
+ local exp1 = rules.and_expr(numrule)
1685
+ rules.xor_expr_l(numrule)
1686
+ return exp1
1687
+ -- else
1688
+ -- sinError(tab_ERRORMSG[13])
1689
+ end
1690
+ end
1691
+
1692
+
1693
+ rules.and_expr = function (numrule)
1694
+ if tab_firsts.rule_96[token] then
1695
+ local const1 = rules.shift_expr(numrule)
1696
+ return rules.and_expr_l(const1, numrule)
1697
+ -- else
1698
+ -- sinError(tab_ERRORMSG[13])
1699
+ end
1700
+ end
1701
+
1702
+
1703
+ rules.shift_expr = function (numrule)
1704
+ if tab_firsts.rule_99[token] then
1705
+ local const1 = rules.add_expr(numrule)
1706
+ return rules.shift_expr_l(const1, numrule)
1707
+ -- else
1708
+ -- sinError(tab_ERRORMSG[13])
1709
+ end
1710
+ end
1711
+
1712
+
1713
+ rules.add_expr = function (numrule)
1714
+ if tab_firsts.rule_103[token] then
1715
+ local const1 = rules.mult_expr(numrule)
1716
+ return rules.add_expr_l(const1, numrule)
1717
+ -- else
1718
+ -- sinError(tab_ERRORMSG[13])
1719
+ end
1720
+ end
1721
+
1722
+
1723
+ rules.mult_expr = function (numrule)
1724
+ if tab_firsts.rule_107[token] then
1725
+ local const = rules.unary_expr()
1726
+ --[[ if not is_num(const) then
1727
+ semanticError(tab_ERRORMSG[25])
1728
+ end
1729
+ ]]
1730
+ const = rules.mult_expr_l(const, numrule)
1731
+ return const
1732
+ -- else
1733
+ -- sinError(tab_ERRORMSG[13])
1734
+ end
1735
+ end
1736
+
1737
+
1738
+ --semantic of '~' operator ???!!
1739
+ rules.unary_expr = function ()
1740
+ if tab_firsts.rule_112[token] then
1741
+ local op = rules.unary_operator()
1742
+ local exp = rules.primary_expr()
1743
+ if tonumber(exp) then
1744
+ if op == '-' then
1745
+ exp = tonumber('-'..exp)
1746
+ elseif op == '+' then
1747
+ exp = tonumber('+'..exp)
1748
+ end
1749
+ end
1750
+ return exp
1751
+ elseif tab_firsts.rule_113[token] then
1752
+ return rules.primary_expr()
1753
+ -- else
1754
+ -- sinError(tab_ERRORMSG[13])
1755
+ end
1756
+ end
1757
+
1758
+ rules.unary_operator = function ()
1759
+ if tab_firsts.rule_114[token] then
1760
+ recognize("-")
1761
+ return '-'
1762
+ elseif tab_firsts.rule_115[token] then
1763
+ recognize("+")
1764
+ return '+'
1765
+ elseif tab_firsts.rule_116[token] then
1766
+ recognize("~")
1767
+ return '~'
1768
+ -- else
1769
+ -- sinError(tab_ERRORMSG[14])
1770
+ end
1771
+ end
1772
+
1773
+
1774
+ rules.primary_expr = function ()
1775
+ if tab_firsts.rule_117[token] then
1776
+ local value = rules.case_label_aux()
1777
+ if type(value) == 'table' then
1778
+ sinError("The <scoped_name> in the <const_type> production must be a previously \
1779
+ defined name of an <integer_type>, <char_type>, <wide_char_type>, \
1780
+ <boolean_type>, <floating_pt_type>, \
1781
+ <string_type>, <wide_string_type>, <octet_type>, or <enum_type> constant.")
1782
+ end
1783
+ return value
1784
+ elseif tab_firsts.rule_118[token] then
1785
+ local value = rules.literal()
1786
+ if (currentScope._type == TAB_TYPEID.UNION) then
1787
+ recognize(":")
1788
+ end
1789
+ return value
1790
+ elseif tab_firsts.rule_119[token] then
1791
+ recognize("(")
1792
+ local const = rules.positive_int_const(119)
1793
+ recognize(")")
1794
+ return const
1795
+ else
1796
+ sinError(tab_ERRORMSG[15])
1797
+ end
1798
+ end
1799
+
1800
+ rules.literal = function ()
1801
+ if tab_firsts.rule_120[token] then
1802
+ recognize(lex.tab_tokens.TK_INTEGER_LITERAL)
1803
+ return getID()
1804
+ elseif tab_firsts.rule_121[token] then
1805
+ recognize(lex.tab_tokens.TK_STRING_LITERAL)
1806
+ return getID()
1807
+ elseif tab_firsts.rule_122[token] then
1808
+ recognize(lex.tab_tokens.TK_CHAR_LITERAL)
1809
+ return getID()
1810
+ elseif tab_firsts.rule_123[token] then
1811
+ recognize(lex.tab_tokens.TK_FIXED_LITERAL)
1812
+ return getID()
1813
+ elseif tab_firsts.rule_124[token] then
1814
+ recognize(lex.tab_tokens.TK_FLOAT_LITERAL)
1815
+ return getID()
1816
+ elseif tab_firsts.rule_125[token] then
1817
+ return rules.boolean_literal()
1818
+ -- else
1819
+ -- sinError(tab_ERRORMSG[16])
1820
+ end
1821
+ end
1822
+
1823
+
1824
+ rules.boolean_literal = function ()
1825
+ if tab_firsts.rule_126[token] then
1826
+ recognize(lex.tab_tokens.TK_TRUE)
1827
+ return true
1828
+ elseif tab_firsts.rule_127[token] then
1829
+ recognize(lex.tab_tokens.TK_FALSE)
1830
+ return false
1831
+ -- else
1832
+ -- sinError(tab_ERRORMSG[17])
1833
+ end
1834
+ end
1835
+
1836
+
1837
+ rules.mult_expr_l = function (const1, numrule)
1838
+ if tab_firsts.rule_108[token] then
1839
+ recognize("*")
1840
+ local const2 = rules.unary_expr()
1841
+ if not tonumber(const2) then
1842
+ semanticError(tab_ERRORMSG[25])
1843
+ end
1844
+ local const = const1 * const2
1845
+ return rules.mult_expr_l(const, numrule)
1846
+ elseif tab_firsts.rule_109[token] then
1847
+ recognize("/")
1848
+ local const2 = rules.unary_expr()
1849
+ if not tonumber(const2) then
1850
+ semanticError(tab_ERRORMSG[25])
1851
+ end
1852
+ local const = const1 / const2
1853
+ return rules.mult_expr_l(const, numrule)
1854
+ elseif tab_firsts.rule_110[token] then
1855
+ recognize("%")
1856
+ local const2 = rules.unary_expr()
1857
+ if not tonumber(const2) then
1858
+ semanticError(tab_ERRORMSG[25])
1859
+ end
1860
+ local const = math.mod(const1, const2)
1861
+ return rules.mult_expr_l(const, numrule)
1862
+ elseif (
1863
+ tab_follow.rule_111[token] or
1864
+ tab_follow['rule_'..numrule][token] or
1865
+ (getID() == ':')
1866
+ )
1867
+ then
1868
+ --empty
1869
+ return const1
1870
+ else
1871
+ sinError(tab_ERRORMSG[18])
1872
+ end
1873
+ end
1874
+
1875
+ rules.add_expr_l = function (const1, numrule)
1876
+ if tab_firsts.rule_104[token] then
1877
+ recognize("+")
1878
+ if not tonumber(const1) then
1879
+ semanticError(tab_ERRORMSG[25])
1880
+ end
1881
+ local const2 = rules.mult_expr(numrule)
1882
+ local const = const1 + const2
1883
+ return rules.add_expr_l(const, numrule)
1884
+ elseif tab_firsts.rule_105[token] then
1885
+ recognize("-")
1886
+ if not tonumber(const1) then
1887
+ semanticError(tab_ERRORMSG[25])
1888
+ end
1889
+ local const2 = rules.mult_expr(numrule)
1890
+ local const = const1 - const2
1891
+ return rules.add_expr_l(const, numrule)
1892
+ elseif (
1893
+ tab_follow.rule_106[token] or
1894
+ tab_follow['rule_'..numrule][token] or
1895
+ (getID() == ':')
1896
+ )
1897
+ then
1898
+ --empty
1899
+ return const1
1900
+ else
1901
+ sinError(tab_ERRORMSG[19])
1902
+ end
1903
+ end
1904
+
1905
+ rules.shift_expr_l = function (const1, numrule)
1906
+ if tab_firsts.rule_100[token] then
1907
+ recognize(">>")
1908
+ rules.add_expr(numrule)
1909
+ rules.shift_expr_l(numrule)
1910
+ elseif tab_firsts.rule_101[token] then
1911
+ recognize("<<")
1912
+ rules.add_expr(numrule)
1913
+ rules.shift_expr_l(numrule)
1914
+ elseif (
1915
+ tab_follow.rule_102[token] or
1916
+ tab_follow['rule_'..numrule][token] or
1917
+ (getID() == ':')
1918
+ )
1919
+ then
1920
+ --empty
1921
+ return const1
1922
+ else
1923
+ sinError(tab_ERRORMSG[20])
1924
+ end
1925
+ end
1926
+
1927
+ rules.and_expr_l = function (const1, numrule)
1928
+ if tab_firsts.rule_97[token] then
1929
+ recognize("&")
1930
+ --[[ if not is_num(const1) then
1931
+ semanticError(tab_ERRORMSG[25])
1932
+ end]]
1933
+ local const2 = rulesshift_expr(numrule)
1934
+ -- local const = const1 and const2
1935
+ return rules.and_expr_l(const, numrule)
1936
+ elseif (
1937
+ tab_follow.rule_98[token] or
1938
+ tab_follow['rule_'..numrule][token] or
1939
+ (getID() == ':')
1940
+ )
1941
+ then
1942
+ --empty
1943
+ return const1
1944
+ else
1945
+ sinError(tab_ERRORMSG[21])
1946
+ end
1947
+ end
1948
+
1949
+ rules.xor_expr_l = function (numrule)
1950
+ if tab_firsts.rule_94[token] then
1951
+ recognize("^")
1952
+ rules.and_expr(numrule)
1953
+ rules.xor_expr_l(numrule)
1954
+ elseif (
1955
+ tab_follow.rule_95[token] or
1956
+ tab_follow['rule_'..numrule][token] or
1957
+ (getID() == ':')
1958
+ )
1959
+ then
1960
+ --empty
1961
+ else
1962
+ sinError(tab_ERRORMSG[22])
1963
+ end
1964
+ end
1965
+
1966
+ rules.or_expr_l = function (numrule)
1967
+ if tab_firsts.rule_91[token] then
1968
+ recognize("|")
1969
+ rules.xor_expr(numrule)
1970
+ rules.or_expr_l(numrule)
1971
+ elseif (
1972
+ tab_follow['rule_'..numrule][token] or
1973
+ (getID() == ':')
1974
+ )
1975
+ then
1976
+ --empty
1977
+ else
1978
+ sinError(tab_ERRORMSG[23])
1979
+ end
1980
+ end
1981
+
1982
+ rules.template_type_spec = function ()
1983
+ if tab_firsts.rule_58[token] then
1984
+ return rules.sequence_type()
1985
+ elseif tab_firsts.rule_59[token] then
1986
+ return rules.string_type()
1987
+ elseif tab_firsts.rule_60[token] then
1988
+ return rules.fixed_pt_type()
1989
+ end
1990
+ end
1991
+
1992
+ rules.sequence_type = function ()
1993
+ recognize(lex.tab_tokens.TK_SEQUENCE, "'sequence'")
1994
+ recognize("<")
1995
+ local tab_type_spec = rules.simple_type_spec(61)
1996
+ tab_type_spec = rules.sequence_type_tail(tab_type_spec)
1997
+ if callbacks.sequence then
1998
+ callbacks.sequence(tab_type_spec)
1999
+ end
2000
+ return tab_type_spec
2001
+ end
2002
+
2003
+ rules.sequence_type_tail = function (tab_type_spec)
2004
+ if tab_firsts.rule_69[token] then
2005
+ recognize(",")
2006
+ local const = rules.positive_int_const(69)
2007
+ recognize(">")
2008
+ return { _type = TAB_TYPEID.SEQUENCE, elementtype = tab_type_spec, maxlength = const }
2009
+ elseif tab_firsts.rule_70[token] then
2010
+ recognize(">")
2011
+ --maxlength??
2012
+ return { _type = TAB_TYPEID.SEQUENCE, elementtype = tab_type_spec, maxlength = 0 }
2013
+ else
2014
+ sinError("',' or '>'")
2015
+ end
2016
+ end
2017
+
2018
+ rules.string_type = function ()
2019
+ recognize(lex.tab_tokens.TK_STRING)
2020
+ --maxlength??
2021
+ return TAB_BASICTYPE.STRING
2022
+ end
2023
+
2024
+
2025
+ rules.string_type_tail = function ()
2026
+ if tab_firsts.rule_72[token] then
2027
+ recognize("<")
2028
+ local const = positive_int_const(72)
2029
+ recognize(">")
2030
+ return const
2031
+ elseif tab_follow.rule_73[token] then
2032
+ return nil
2033
+ --empty
2034
+ else
2035
+ sinError(tab_ERRORMSG[26])
2036
+ end
2037
+ end
2038
+
2039
+ rules.fixed_pt_type = function ()
2040
+ recognize(lex.tab_tokens.TK_FIXED)
2041
+ recognize("<")
2042
+ local const1 = rules.positive_int_const(74)
2043
+ recognize(",")
2044
+ local const2 = rules.positive_int_const(74)
2045
+ recognize(">")
2046
+ return TAB_BASICTYPE.FIXED
2047
+ end
2048
+
2049
+ rules.constr_type_spec = function ()
2050
+ if tab_firsts.rule_33[token] then
2051
+ return rules.struct_type()
2052
+ elseif tab_firsts.rule_34[token] then
2053
+ return rules.union_type()
2054
+ elseif tab_firsts.rule_35[token] then
2055
+ return rules.enum_type()
2056
+ else
2057
+ sinError(tab_ERRORMSG[27])
2058
+ end
2059
+ end
2060
+
2061
+ rules.struct_type = function ()
2062
+ recognize(lex.tab_tokens.TK_STRUCT)
2063
+ recognize(lex.tab_tokens.TK_ID)
2064
+ define(getID(), TAB_TYPEID.STRUCT)
2065
+ recognize("{")
2066
+ rules.member_l()
2067
+ local struct = currentScope
2068
+ gotoFatherScope()
2069
+ recognize("}")
2070
+ if callbacks.struct then
2071
+ callbacks.struct(struct)
2072
+ end
2073
+ return struct
2074
+ end
2075
+
2076
+ rules.union_type = function ()
2077
+ if tab_firsts.rule_148[token] then
2078
+ recognize(lex.tab_tokens.TK_UNION)
2079
+ recognize(lex.tab_tokens.TK_ID)
2080
+ local union_name = getID()
2081
+ recognize(lex.tab_tokens.TK_SWITCH)
2082
+ define(union_name, TAB_TYPEID.UNION)
2083
+ recognize("(")
2084
+ currentScope.switch = rules.switch_type_spec()
2085
+ recognize(")")
2086
+ recognize("{")
2087
+ currentScope.default = -1
2088
+ rules.case_l()
2089
+ recognize("}")
2090
+ local union = currentScope
2091
+ gotoFatherScope()
2092
+ if callbacks.union then
2093
+ callbacks.union(union)
2094
+ end
2095
+ return tab_union
2096
+ else
2097
+ sinError(tab_ERRORMSG[29])
2098
+ end
2099
+ end
2100
+
2101
+ rules.switch_type_spec = function ()
2102
+ if tab_firsts.rule_149[token] then
2103
+ return rules.integer_type(148)
2104
+ elseif tab_firsts.rule_150[token] then
2105
+ recognize(lex.tab_tokens.TK_LONG)
2106
+ return rules.long_e(148)
2107
+ elseif tab_firsts.rule_151[token] then
2108
+ recognize(lex.tab_tokens.TK_CHAR)
2109
+ return TAB_BASICTYPE.CHAR
2110
+ elseif tab_firsts.rule_152[token] then
2111
+ recognize(lex.tab_tokens.TK_BOOLEAN)
2112
+ return TAB_BASICTYPE.BOOLEAN
2113
+ elseif tab_firsts.rule_153[token] then
2114
+ recognize(lex.tab_tokens.TK_ENUM)
2115
+ return TAB_BASICTYPE.ENUM
2116
+ elseif tab_firsts.rule_154[token] then
2117
+ return rules.scoped_name(154)
2118
+ else
2119
+ sinError(tab_ERRORMSG[30])
2120
+ end
2121
+ end
2122
+
2123
+ rules.case_l = function ()
2124
+ if tab_firsts.rule_155[token] then
2125
+ rules.case()
2126
+ rules.case_l_r()
2127
+ else
2128
+ sinError(tab_ERRORMSG[31])
2129
+ end
2130
+ end
2131
+
2132
+ rules.case_l_r = function ()
2133
+ if tab_firsts.rule_156[token] then
2134
+ rules.case()
2135
+ rules.case_l_r()
2136
+ elseif tab_follow.rule_157[token] then
2137
+ --empty
2138
+ else
2139
+ sinError(tab_ERRORMSG[33])
2140
+ end
2141
+ end
2142
+
2143
+ rules.case = function ()
2144
+ if tab_firsts.rule_158[token] then
2145
+ local cases = rules.case_label_l()
2146
+ local tab_type_spec, name = rules.element_spec(cases)
2147
+ for i, case in pairs(cases) do
2148
+ if i == 1 then
2149
+ dclName(name, currentScope, {type = tab_type_spec, label = case})
2150
+ registerID(name);
2151
+ else
2152
+ table.insert(currentScope, {name = name, type = tab_type_spec, label = case})
2153
+ end
2154
+ if case == 'none' then
2155
+ currentScope.default = table.getn(currentScope)
2156
+ end
2157
+ end
2158
+ recognize(";")
2159
+ else
2160
+ sinError(tab_ERRORMSG[31])
2161
+ end
2162
+ end
2163
+
2164
+ rules.case_label_l = function ()
2165
+ local cases = {}
2166
+ if tab_firsts.rule_159[token] then
2167
+ rules.case_label(cases)
2168
+ rules.case_label_l_r(cases)
2169
+ else
2170
+ sinError(tab_ERRORMSG[31])
2171
+ end
2172
+ return cases
2173
+ end
2174
+
2175
+ rules.case_label_l_r = function (cases)
2176
+ if tab_firsts.rule_160[token] then
2177
+ rules.case_label(cases)
2178
+ rules.case_label_l_r(cases)
2179
+ elseif tab_follow.rule_161[token] then
2180
+ --empty
2181
+ else
2182
+ sinError(tab_ERRORMSG[32])
2183
+ end
2184
+ end
2185
+
2186
+ rules.case_label = function (cases)
2187
+ if (tab_firsts.rule_162[token]) then
2188
+ recognize(lex.tab_tokens.TK_CASE)
2189
+ local value = rules.positive_int_const(162)
2190
+ table.insert(cases, value)
2191
+ elseif (tab_firsts.rule_163[token]) then
2192
+ recognize(lex.tab_tokens.TK_DEFAULT)
2193
+ recognize(":")
2194
+ if (currentScope.default ~= -1) then
2195
+ semanticError("A default case can appear at most once.")
2196
+ else
2197
+ table.insert(cases, 'none')
2198
+ currentScope.default = 1
2199
+ end
2200
+ else
2201
+ sinError(tab_ERRORMSG[31])
2202
+ end
2203
+ end
2204
+
2205
+ rules.case_label_aux = function ()
2206
+ if (token == lex.tab_tokens.TK_ID) then
2207
+ recognize(lex.tab_tokens.TK_ID)
2208
+ tab_scope = getDefinition(getID())
2209
+ recognize(":")
2210
+ return rules.case_label_tail(tab_scope)
2211
+ elseif (token == ':') then
2212
+ recognize(":")
2213
+ recognize(":")
2214
+ recognize(lex.tab_tokens.TK_ID, "identifier")
2215
+ tab_scope = getDefinition(getID())
2216
+ recognize(":")
2217
+ return rules.case_label_tail(tab_scope)
2218
+ end
2219
+ end
2220
+
2221
+ rules.case_label_tail = function (tab_scope)
2222
+ if (token == ':') then
2223
+ recognize(":")
2224
+ return rules.case_label_tail_aux(tab_scope)
2225
+ elseif (tab_firsts.rule_28[token] or tab_firsts.rule_29[token]) then
2226
+ --empty
2227
+ return tab_scope
2228
+ end
2229
+ end
2230
+
2231
+ rules.case_label_tail_aux = function (tab_scope)
2232
+ if (token == ':') then
2233
+ recognize(":")
2234
+ elseif (token == lex.tab_tokens.TK_ID) then
2235
+ recognize(lex.tab_tokens.TK_ID)
2236
+ local namespace = getID()
2237
+ tab_scope = getDefinition(namespace, tab_scope.absolute_name)
2238
+ tab_scope = rules.case_label_tail_aux(tab_scope)
2239
+ end
2240
+ return tab_scope
2241
+ end
2242
+
2243
+ rules.element_spec = function (cases)
2244
+ if (tab_firsts.rule_164[token]) then
2245
+ local tab_type_spec = rules.type_spec(221)
2246
+ recognize(lex.tab_tokens.TK_ID)
2247
+ local name = getID()
2248
+ return tab_type_spec, name
2249
+ else
2250
+ sinError(tab_ERRORMSG[03])
2251
+ end
2252
+ end
2253
+
2254
+ rules.enum_type = function ()
2255
+ recognize(lex.tab_tokens.TK_ENUM)
2256
+ recognize(lex.tab_tokens.TK_ID)
2257
+ local _, tab_enum = define(getID(), TAB_TYPEID.ENUM)
2258
+ recognize("{")
2259
+ rules.enumerator(tab_enum)
2260
+ rules.enumerator_l(tab_enum)
2261
+ recognize("}")
2262
+ if callbacks.enum then
2263
+ callbacks.enum(tab_enum)
2264
+ end
2265
+ return tab_enum
2266
+ end
2267
+
2268
+ rules.enumerator = function (tab_enum)
2269
+ recognize(lex.tab_tokens.TK_ID)
2270
+ local name = getID()
2271
+ dclName(name, tab_enum)
2272
+ registerID(name);
2273
+ end
2274
+
2275
+ rules.enumerator_l = function (tab_enum)
2276
+ if (tab_firsts.rule_166[token]) then
2277
+ recognize(",")
2278
+ rules.enumerator(tab_enum)
2279
+ rules.enumerator_l(tab_enum)
2280
+ elseif (tab_follow.rule_167[token]) then
2281
+ -- empty
2282
+ else
2283
+ sinError("',' or '}'")
2284
+ end
2285
+ end
2286
+
2287
+ rules.module = function ()
2288
+ if (tab_firsts.rule_305[token]) then
2289
+ recognize(lex.tab_tokens.TK_MODULE)
2290
+ recognize(lex.tab_tokens.TK_ID)
2291
+ local name = getID()
2292
+ if (name == 'CORBA') then
2293
+ CORBAVisible = true
2294
+ end
2295
+ local status, _module = define(name, TAB_TYPEID.MODULE)
2296
+ recognize("{")
2297
+ rules.definition_l_module()
2298
+ local module = currentScope
2299
+ gotoFatherScope()
2300
+ recognize("}")
2301
+ if callbacks.module then
2302
+ callbacks.module(module)
2303
+ end
2304
+ end
2305
+ end
2306
+
2307
+ rules.long_or_double = function ()
2308
+ if tab_firsts.rule_55[token] then
2309
+ recognize(lex.tab_tokens.TK_LONG)
2310
+ return TAB_BASICTYPE.LLONG
2311
+ elseif tab_firsts.rule_56[token] then
2312
+ recognize(lex.tab_tokens.TK_DOUBLE)
2313
+ return TAB_BASICTYPE.LDOUBLE
2314
+ else
2315
+ return TAB_BASICTYPE.LONG
2316
+ end
2317
+ end
2318
+
2319
+ rules.scoped_name_l = function (tab_scope, full_namespace, num_follow_rule)
2320
+ if (token == ":") then
2321
+ recognize(":")
2322
+ recognize(":")
2323
+ recognize(lex.tab_tokens.TK_ID)
2324
+ local namespace = getID()
2325
+ full_namespace = tab_scope.absolute_name..'::'..namespace
2326
+ tab_scope = getDefinition(namespace, tab_scope.absolute_name)
2327
+ tab_scope = rules.scoped_name_l(tab_scope, full_namespace, num_follow_rule)
2328
+ elseif (tab_follow['rule_'..num_follow_rule][token]) then
2329
+ -- empty
2330
+ else
2331
+ sinError("':' or "..tab_follow_rule_error_msg[num_follow_rule])
2332
+ end
2333
+ return tab_scope
2334
+ end
2335
+
2336
+ rules.scoped_name = function (num_follow_rule)
2337
+ local name = ''
2338
+ local tab_scope = {}
2339
+ if (token == lex.tab_tokens.TK_ID) then
2340
+ recognize(lex.tab_tokens.TK_ID)
2341
+ name = getID()
2342
+ tab_scope = getDefinition(name)
2343
+ tab_scope = rules.scoped_name_l(tab_scope, name, num_follow_rule)
2344
+ elseif (token == ":") then
2345
+ recognize(":")
2346
+ recognize(":")
2347
+ recognize(lex.tab_tokens.TK_ID)
2348
+ name = getID()
2349
+ tab_scope = getDefinition(name)
2350
+ tab_scope = rules.scoped_name_l(tab_scope, name, num_follow_rule)
2351
+ end
2352
+ local absolute_name
2353
+ if (tab_scope.absolute_name) then
2354
+ absolute_name = tab_scope.absolute_name
2355
+ registerID(tab_scope.absolute_name)
2356
+ else
2357
+ end
2358
+ return tab_scope
2359
+ end
2360
+
2361
+ rules.union_or_struct = function ()
2362
+ if (tab_firsts.rule_168[token]) then
2363
+ recognize(lex.tab_tokens.TK_STRUCT)
2364
+ recognize(lex.tab_tokens.TK_ID)
2365
+ local name = getID()
2366
+ return rules.struct_tail(name)
2367
+ elseif (tab_firsts.rule_169[token]) then
2368
+ recognize(lex.tab_tokens.TK_UNION)
2369
+ recognize(lex.tab_tokens.TK_ID)
2370
+ define(getID(), TAB_TYPEID.UNION)
2371
+ rules.union_tail()
2372
+ local union = currentScope
2373
+ gotoFatherScope()
2374
+ if callbacks.union then
2375
+ callbacks.union(union)
2376
+ end
2377
+ return union
2378
+ else
2379
+ sinError("'struct' or 'union'")
2380
+ end
2381
+ end
2382
+
2383
+ rules.struct_tail = function (name)
2384
+ if (tab_firsts.rule_170[token]) then
2385
+ define(name, TAB_TYPEID.STRUCT)
2386
+ recognize("{")
2387
+ rules.member_l()
2388
+ recognize("}")
2389
+ local struct = currentScope
2390
+ gotoFatherScope()
2391
+ if callbacks.struct then
2392
+ callbacks.struct(struct)
2393
+ end
2394
+ return struct
2395
+ elseif (token == ";") then
2396
+ return dclForward(name, TAB_TYPEID.STRUCT)
2397
+ else
2398
+ sinError(" '{' or ';' ")
2399
+ end
2400
+ end
2401
+
2402
+ rules.member_l = function ()
2403
+ if (tab_firsts.rule_137[token]) then
2404
+ rules.member()
2405
+ rules.member_r()
2406
+ else
2407
+ sinError(tab_ERRORMSG[03])
2408
+ end
2409
+ end
2410
+
2411
+ rules.member = function ()
2412
+ if (tab_firsts.rule_140[token]) then
2413
+ rules.declarator_l(rules.type_spec())
2414
+ recognize(";")
2415
+ else
2416
+ sinError(tab_ERRORMSG[03])
2417
+ end
2418
+ end
2419
+
2420
+ rules.member_r = function ()
2421
+ if tab_firsts.rule_138[token] then
2422
+ rules.member()
2423
+ rules.member_r()
2424
+ elseif tab_follow.rule_139[token] then
2425
+ -- empty
2426
+ else
2427
+ sinError(tab_ERRORMSG[28])
2428
+ end
2429
+ end
2430
+
2431
+ rules.declarator_l = function (type, access)
2432
+ rules.declarator(type, access)
2433
+ rules.declarator_l_r(type, access)
2434
+ end
2435
+
2436
+ rules.declarator_l_r = function (type, access)
2437
+ if (tab_firsts.rule_142[token]) then
2438
+ recognize(",")
2439
+ rules.declarator(type, access)
2440
+ rules.declarator_l_r(type, access)
2441
+ elseif (tab_follow.rule_143[token]) then
2442
+ --empty
2443
+ else
2444
+ sinError(tab_ERRORMSG[11])
2445
+ end
2446
+ end
2447
+
2448
+ rules.declarator = function (type, access)
2449
+ recognize(lex.tab_tokens.TK_ID)
2450
+ local name = getID()
2451
+ dclName(name, currentScope,
2452
+ {
2453
+ type = rules.fixed_array_size_l(type),
2454
+ access = access,
2455
+ })
2456
+ registerID(name);
2457
+ end
2458
+
2459
+ rules.union_tail = function ()
2460
+ if (tab_firsts.rule_172[token]) then
2461
+ recognize(lex.tab_tokens.TK_SWITCH)
2462
+ recognize("(")
2463
+ currentScope.switch = rules.switch_type_spec()
2464
+ recognize(")")
2465
+ recognize("{")
2466
+ currentScope.default = -1
2467
+ rules.case_l()
2468
+ recognize("}")
2469
+ else
2470
+ sinError("'switch'")
2471
+ end
2472
+ end
2473
+
2474
+ rules.except_dcl = function ()
2475
+ recognize(lex.tab_tokens.TK_EXCEPTION)
2476
+ recognize(lex.tab_tokens.TK_ID)
2477
+ local name = getID()
2478
+ define(name, TAB_TYPEID.EXCEPTION)
2479
+ recognize("{")
2480
+ rules.member_l_empty()
2481
+ local except = currentScope
2482
+ gotoFatherScope()
2483
+ recognize("}")
2484
+ if callbacks.except then
2485
+ callbacks.except(except)
2486
+ end
2487
+ end
2488
+
2489
+ rules.member_l_empty = function ()
2490
+ if (tab_firsts.rule_187[token]) then
2491
+ rules.member()
2492
+ rules.member_l_empty()
2493
+ elseif (token == "}") then
2494
+ -- empty
2495
+ else
2496
+ sinError("member list { ... } or '}'")
2497
+ end
2498
+ end
2499
+
2500
+ rules.definition_l_r_module = function ()
2501
+ if (tab_firsts.rule_12[token]) then
2502
+ rules.definition()
2503
+ rules.definition_l_r_module()
2504
+ elseif (token == '}') then
2505
+ -- empty
2506
+ else
2507
+ sinError("definition")
2508
+ end
2509
+ end
2510
+
2511
+ rules.definition_l_module = function ()
2512
+ if (tab_firsts.rule_11[token]) then
2513
+ rules.definition()
2514
+ rules.definition_l_r_module()
2515
+ else
2516
+ sinError("definition")
2517
+ end
2518
+ end
2519
+
2520
+
2521
+ ---
2522
+ -- INTERFACE DECLARATION
2523
+ --------------------------------------------------------------------------
2524
+
2525
+ rules.inter_value_event = function ()
2526
+ if (tab_firsts.rule_192[token]) then
2527
+ recognize(lex.tab_tokens.TK_INTERFACE)
2528
+ recognize(lex.tab_tokens.TK_ID)
2529
+ local name = getID()
2530
+ local interface = rules.interface_tail(name)
2531
+ if callbacks.interface then
2532
+ callbacks.interface(interface)
2533
+ end
2534
+ elseif (tab_firsts.rule_189[token]) then
2535
+ recognize(lex.tab_tokens.TK_ABSTRACT)
2536
+ rules.abstract_tail()
2537
+ elseif (tab_firsts.rule_190[token]) then
2538
+ recognize(lex.tab_tokens.TK_LOCAL)
2539
+ recognize(lex.tab_tokens.TK_INTERFACE)
2540
+ recognize(lex.tab_tokens.TK_ID)
2541
+ local name = getID()
2542
+ local interface = rules.interface_tail(name, 'local')
2543
+ if callbacks.interface and interface then
2544
+ callbacks.interface(interface)
2545
+ end
2546
+ elseif (tab_firsts.rule_193[token]) then
2547
+ recognize(lex.tab_tokens.TK_VALUETYPE)
2548
+ recognize(lex.tab_tokens.TK_ID)
2549
+ local name = getID()
2550
+ rules.value_tail(name)
2551
+ elseif (tab_firsts.rule_191[token]) then
2552
+ recognize(lex.tab_tokens.TK_CUSTOM)
2553
+ rules.value_or_event()
2554
+ elseif tab_firsts.rule_194[token] then
2555
+ recognize(lex.tab_tokens.TK_EVENTTYPE)
2556
+ recognize(lex.tab_tokens.TK_ID)
2557
+ local name = getID()
2558
+ local tab_eventtypescope = rules.eventtype_tail(name)
2559
+ if callbacks.eventtype then
2560
+ callbacks.eventtype(tab_eventtypescope)
2561
+ end
2562
+ else
2563
+ sinError("'interface', 'abstract', 'local' or 'valuetype'")
2564
+ end
2565
+ end
2566
+
2567
+ rules.abstract_tail = function ()
2568
+ if (tab_firsts.rule_195[token]) then
2569
+ recognize(lex.tab_tokens.TK_INTERFACE)
2570
+ recognize(lex.tab_tokens.TK_ID)
2571
+ local name = getID()
2572
+ local interface = rules.interface_tail(name, 'abstract')
2573
+ if callbacks.interface then
2574
+ callbacks.interface(interface)
2575
+ end
2576
+ elseif (tab_firsts.rule_196[token]) then
2577
+ recognize(lex.tab_tokens.TK_VALUETYPE)
2578
+ recognize(lex.tab_tokens.TK_ID)
2579
+ local name = getID()
2580
+ rules.value_tail(name, "abstract")
2581
+ elseif tab_firsts.rule_197[token] then
2582
+ recognize(lex.tab_tokens.TK_EVENTTYPE)
2583
+ recognize(lex.tab_tokens.TK_ID)
2584
+ local name = getID()
2585
+ local tab_eventtypescope = rules.eventtype_tail(name, "abstract")
2586
+ if callbacks.eventtype then
2587
+ callbacks.eventtype(tab_eventtypescope)
2588
+ end
2589
+ else
2590
+ sinError("'interface', 'valuetype' or 'event'")
2591
+ end
2592
+ end
2593
+
2594
+ rules.interface_tail = function (name, header)
2595
+ if (tab_firsts.rule_198[token]) then
2596
+ recognize(":")
2597
+ local base = rules.scoped_name(204)
2598
+ define(name, TAB_TYPEID.INTERFACE)
2599
+ table.insert(currentScope, base)
2600
+ rules.bases()
2601
+ recognize("{")
2602
+ rules.export_l()
2603
+ recognize("}")
2604
+ local interface = currentScope
2605
+ rules.verifyHeader(header)
2606
+ gotoFatherScope()
2607
+ return interface
2608
+ elseif (tab_firsts.rule_199[token]) then
2609
+ recognize("{")
2610
+ define(name, TAB_TYPEID.INTERFACE)
2611
+ rules.export_l()
2612
+ recognize("}")
2613
+ local interface = currentScope
2614
+ rules.verifyHeader(header)
2615
+ gotoFatherScope()
2616
+ return interface
2617
+ elseif (token == ';') then
2618
+ return dclForward(name, TAB_TYPEID.INTERFACE)
2619
+ else
2620
+ sinError("'{', ':' or ';'")
2621
+ end
2622
+ end
2623
+
2624
+ rules.bases = function ()
2625
+ if (tab_firsts.rule_254[token]) then
2626
+ recognize(",")
2627
+ local base = rules.scoped_name(204)
2628
+ table.insert(currentScope, base)
2629
+ rules.bases()
2630
+ elseif (token == '{') then
2631
+ -- empty
2632
+ else
2633
+ sinError("',' or '{'")
2634
+ end
2635
+ end
2636
+
2637
+ rules.verifyHeader = function (header)
2638
+ if (header == 'local') then
2639
+ currentScope['header'] = true
2640
+ elseif (header == 'abstract') then
2641
+ currentScope['abstract'] = true
2642
+ end
2643
+ end
2644
+
2645
+ rules.export_l = function ()
2646
+ if (tab_firsts.rule_207[token]) then
2647
+ rules.export()
2648
+ rules.export_l()
2649
+ elseif (token == "}") then
2650
+ --empty
2651
+ else
2652
+ sinError("empty interface, a declaration or '}'")
2653
+ end
2654
+ end
2655
+
2656
+ rules.export = function ()
2657
+ if (tab_firsts.rule_209[token]) then
2658
+ rules.type_dcl()
2659
+ recognize(";")
2660
+ elseif (tab_firsts.rule_210[token]) then
2661
+ rules.const_dcl()
2662
+ recognize(";")
2663
+ elseif (tab_firsts.rule_211[token]) then
2664
+ rules.except_dcl()
2665
+ recognize(";")
2666
+ elseif (tab_firsts.rule_212[token]) then
2667
+ rules.attr_dcl()
2668
+ recognize(";")
2669
+ elseif (tab_firsts.rule_213[token]) then
2670
+ rules.op_dcl()
2671
+ recognize(";")
2672
+ else
2673
+ sinError("constant, type, exception, attribute or operation declaration")
2674
+ end
2675
+ end
2676
+
2677
+
2678
+ ---
2679
+ -- OPERATION DECLARATION
2680
+ --------------------------------------------------------------------------
2681
+
2682
+ rules.op_dcl = function ()
2683
+ if (tab_firsts.rule_243[token]) then
2684
+ recognize(lex.tab_tokens.TK_ONEWAY)
2685
+ local result = rules.op_type_spec()
2686
+ if (result._type ~= 'void') then
2687
+ semanticError("An operation with the oneway attribute must specify a 'void' return type.")
2688
+ end
2689
+ recognize(lex.tab_tokens.TK_ID)
2690
+ local name = getID()
2691
+ define(name, TAB_TYPEID.OPERATION)
2692
+ currentScope.name = name
2693
+ currentScope.oneway = true
2694
+ rules.parameter_dcls()
2695
+ rules.raises_expr_e(currentScope)
2696
+ rules.context_expr_e()
2697
+ local operation = currentScope
2698
+ gotoFatherScope()
2699
+ if (callbacks.operation) then
2700
+ callbacks.operation(operation)
2701
+ end
2702
+ elseif tab_firsts.rule_244[token] then
2703
+ local result = rules.op_type_spec()
2704
+ recognize(lex.tab_tokens.TK_ID)
2705
+ local name = getID()
2706
+ define(name, TAB_TYPEID.OPERATION)
2707
+ currentScope.name = name
2708
+ currentScope.result = result
2709
+ rules.parameter_dcls()
2710
+ rules.raises_expr_e(currentScope)
2711
+ rules.context_expr_e()
2712
+ local operation = currentScope
2713
+ gotoFatherScope()
2714
+ if callbacks.operation then
2715
+ callbacks.operation(operation)
2716
+ end
2717
+ else
2718
+ sinError("'oneway' or type specification")
2719
+ end
2720
+ end
2721
+
2722
+ rules.op_type_spec = function ()
2723
+ if (tab_firsts.rule_245[token]) then
2724
+ return rules.param_type_spec()
2725
+ elseif (tab_firsts.rule_246[token]) then
2726
+ recognize(lex.tab_tokens.TK_VOID)
2727
+ return TAB_BASICTYPE.VOID
2728
+ else
2729
+ sinError("type return")
2730
+ end
2731
+ end
2732
+
2733
+ rules.parameter_dcls = function ()
2734
+ recognize("(")
2735
+ rules.parameter_dcls_tail()
2736
+ end
2737
+
2738
+ rules.parameter_dcls_tail = function ()
2739
+ if (tab_firsts.rule_248[token]) then
2740
+ currentScope.parameters = {}
2741
+ rules.param_dcl()
2742
+ rules.param_dcl_l()
2743
+ recognize(")")
2744
+ elseif (tab_firsts.rule_249[token]) then
2745
+ recognize(")")
2746
+ else
2747
+ sinError("'in', 'out', 'inout' or ')'")
2748
+ end
2749
+ end
2750
+
2751
+ rules.param_dcl = function ()
2752
+ local attribute = rules.param_attribute()
2753
+ local type = rules.param_type_spec()
2754
+ recognize(lex.tab_tokens.TK_ID)
2755
+ local name = getID()
2756
+ dclName(name, currentScope.parameters, {mode = attribute, type = type})
2757
+ registerID(name);
2758
+ end
2759
+
2760
+ rules.param_dcl_l = function ()
2761
+ if (tab_firsts.rule_254[token]) then
2762
+ recognize(",")
2763
+ rules.param_dcl()
2764
+ rules.param_dcl_l()
2765
+ elseif token == lex.tab_tokens.TK_RAISES or
2766
+ token == lex.tab_tokens.TK_CONTEXT or
2767
+ token == ')' then
2768
+ -- empty
2769
+ else
2770
+ sinError("',', ')', 'raises' or 'context'")
2771
+ end
2772
+ end
2773
+
2774
+ rules.param_attribute = function ()
2775
+ if (tab_firsts.rule_251[token]) then
2776
+ recognize(lex.tab_tokens.TK_IN)
2777
+ return 'PARAM_IN'
2778
+ elseif (tab_firsts.rule_252[token]) then
2779
+ recognize(lex.tab_tokens.TK_OUT)
2780
+ return 'PARAM_OUT'
2781
+ elseif (tab_firsts.rule_253[token]) then
2782
+ recognize(lex.tab_tokens.TK_INOUT)
2783
+ return 'PARAM_INOUT'
2784
+ end
2785
+ end
2786
+
2787
+ rules.param_type_spec = function ()
2788
+ if (tab_firsts.rule_219[token]) then
2789
+ return rules.base_type_spec()
2790
+ elseif (tab_firsts.rule_220[token]) then
2791
+ return rules.string_type()
2792
+ elseif (tab_firsts.rule_221[token]) then
2793
+ return rules.scoped_name(221)
2794
+ else
2795
+ sinError('type specification')
2796
+ end
2797
+ end
2798
+
2799
+ rules.raises_expr = function (tab)
2800
+ recognize(lex.tab_tokens.TK_RAISES)
2801
+ recognize("(")
2802
+ tab.exceptions = {}
2803
+ rules.raises(tab.exceptions)
2804
+ rules.inter_name_seq(tab.exceptions)
2805
+ recognize(")")
2806
+ end
2807
+
2808
+ rules.raises = function (raises)
2809
+ local exception = rules.scoped_name(229)
2810
+ if (exception._type ~= TAB_TYPEID.EXCEPTION) then
2811
+ semanticError(string.format("The type of '%s' is %s, but it should be exception.",
2812
+ exception.absolute_name, exception._type))
2813
+ end
2814
+ table.insert(raises, exception)
2815
+ end
2816
+
2817
+ rules.inter_name_seq = function (_raises)
2818
+ if (tab_firsts.rule_254[token]) then
2819
+ recognize(",")
2820
+ rules.raises(_raises)
2821
+ rules.inter_name_seq(_raises)
2822
+ elseif (token == ')') then
2823
+ -- empty
2824
+ else
2825
+ sinError("')'")
2826
+ end
2827
+ end
2828
+
2829
+ rules.raises_expr_e = function (tab)
2830
+ if (tab_firsts.rule_370[token]) then
2831
+ rules.raises_expr(tab)
2832
+ elseif (token == ';' or token == lex.tab_tokens.TK_CONTEXT) then
2833
+ -- empty
2834
+ else
2835
+ sinError("'raises', 'context', ';'")
2836
+ end
2837
+ end
2838
+
2839
+ rules.context_expr_e = function ()
2840
+ if (tab_firsts.rule_377[token]) then
2841
+ rules.context_expr()
2842
+ elseif (token == ';') then
2843
+ -- empty
2844
+ else
2845
+ sinError("'context' or ';'")
2846
+ end
2847
+ end
2848
+
2849
+ rules.context_expr = function ()
2850
+ recognize(lex.tab_tokens.TK_CONTEXT)
2851
+ recognize("(")
2852
+ currentScope.contexts = {}
2853
+ rules.context()
2854
+ rules.string_literal_l()
2855
+ recognize(")")
2856
+ end
2857
+
2858
+ rules.context = function ()
2859
+ recognize(lex.tab_tokens.TK_STRING_LITERAL)
2860
+ local name = getID()
2861
+ dclName(name, currentScope.contexts, {})
2862
+ registerID(name);
2863
+ end
2864
+
2865
+ rules.string_literal_l = function ()
2866
+ if (tab_firsts.rule_257[token]) then
2867
+ recognize(",")
2868
+ rules.context()
2869
+ rules.string_literal_l()
2870
+ elseif (token == ')') then
2871
+ -- empty
2872
+ else
2873
+ sinError("',' or ')'")
2874
+ end
2875
+ end
2876
+
2877
+
2878
+ ---
2879
+ -- ATTRIBUTE
2880
+ --------------------------------------------------------------------------
2881
+
2882
+ rules.attr_dcl = function ()
2883
+ if (tab_firsts.rule_216[token]) then
2884
+ rules.readonly_attr_spec()
2885
+ elseif (tab_firsts.rule_217[token]) then
2886
+ rules.attr_spec()
2887
+ else
2888
+ sinError("'readonly' or 'attribute'")
2889
+ end
2890
+ end
2891
+
2892
+ rules.readonly_attr_spec = function ()
2893
+ recognize(lex.tab_tokens.TK_READONLY)
2894
+ recognize(lex.tab_tokens.TK_ATTRIBUTE)
2895
+ local type = rules.param_type_spec()
2896
+ rules.readonly_attr_spec_dec(type)
2897
+ end
2898
+
2899
+ rules.attr_spec = function ()
2900
+ recognize(lex.tab_tokens.TK_ATTRIBUTE)
2901
+ local type = rules.param_type_spec()
2902
+ rules.attr_declarator(type)
2903
+ end
2904
+
2905
+ rules.readonly_attr_spec_dec = function (type)
2906
+ local attribute = {type = type, readonly = true}
2907
+ local name = rules.simple_dcl()
2908
+ define(name, TAB_TYPEID.ATTRIBUTE, attribute)
2909
+ rules.readonly_attr_spec_dec_tail(attribute)
2910
+ if callbacks.attribute then
2911
+ callbacks.attribute(attribute)
2912
+ end
2913
+ end
2914
+
2915
+ rules.attr_declarator = function (type)
2916
+ local attribute = {type = type}
2917
+ local name = rules.simple_dcl()
2918
+ define(name, TAB_TYPEID.ATTRIBUTE, attribute)
2919
+ rules.attr_declarator_tail(attribute)
2920
+ if callbacks.attribute then
2921
+ callbacks.attribute(attribute)
2922
+ end
2923
+ end
2924
+
2925
+ rules.readonly_attr_spec_dec_tail = function (attribute)
2926
+ if (tab_firsts.rule_227[token]) then
2927
+ rules.raises_expr(attribute)
2928
+ elseif (tab_firsts.rule_228[token]) then
2929
+ rules.simple_dcl_l(type, true)
2930
+ elseif (token == ';') then
2931
+ -- empty
2932
+ else
2933
+ sinError("'raises', ',' or ';'")
2934
+ end
2935
+ end
2936
+
2937
+ rules.attr_declarator_tail = function (attribute)
2938
+ if (tab_firsts.rule_234[token]) then
2939
+ rules.attr_raises_expr(attribute)
2940
+ elseif (tab_firsts.rule_235[token]) then
2941
+ rules.simple_dcl_l(attribute.type)
2942
+ elseif (token == ';') then
2943
+ -- empty
2944
+ else
2945
+ sinError("'getraises', 'setraises', ',' or ';'")
2946
+ end
2947
+ end
2948
+
2949
+ rules.simple_dcl = function ()
2950
+ recognize(lex.tab_tokens.TK_ID)
2951
+ return getID()
2952
+ end
2953
+
2954
+ rules.simple_dcl_l = function (type, readonly)
2955
+ if (tab_firsts.rule_142[token]) then
2956
+ recognize(",")
2957
+ local attribute = {type = type, readonly = readonly}
2958
+ local name = rules.simple_dcl()
2959
+ define(name, TAB_TYPEID.ATTRIBUTE, attribute)
2960
+ rules.simple_dcl_l(type)
2961
+ elseif (token == ';') then
2962
+ -- empty
2963
+ end
2964
+ end
2965
+
2966
+ rules.attr_raises_expr = function (attribute)
2967
+ if (tab_firsts.rule_236[token]) then
2968
+ recognize(lex.tab_tokens.TK_GETRAISES)
2969
+ attribute.raises = {}
2970
+ rules.exception_l(attribute, 'getraises')
2971
+ rules.attr_raises_expr_tail(attribute)
2972
+ elseif (tab_firsts.rule_237[token]) then
2973
+ recognize(lex.tab_tokens.TK_SETRAISES)
2974
+ attribute.raises = {}
2975
+ rules.exception_l(attribute, 'setraises')
2976
+ end
2977
+ end
2978
+
2979
+ rules.attr_raises_expr_tail = function (attribute)
2980
+ if (tab_firsts.rule_238[token]) then
2981
+ recognize(lex.tab_tokens.TK_SETRAISES)
2982
+ rules.exception_l(attribute, 'setraises')
2983
+ elseif (token == ';') then
2984
+ --empty
2985
+ else
2986
+ sinError("'setraises' or ';'")
2987
+ end
2988
+ end
2989
+
2990
+ rules.exception = function (attribute, raises_type)
2991
+ local exception = {type = raises_type, exception = rules.scoped_name(229)}
2992
+ table.insert(attribute.raises, exception)
2993
+ end
2994
+
2995
+ rules.exception_l = function (attribute, raises_type)
2996
+ recognize("(")
2997
+ rules.exception(attribute, raises_type)
2998
+ rules.exception_l_seq(attribute, raises_type)
2999
+ recognize(")")
3000
+ end
3001
+
3002
+ rules.exception_l_seq = function (attribute, raises_type)
3003
+ if (tab_firsts.rule_142[token]) then
3004
+ recognize(",")
3005
+ rules.exception(attribute, raises_type)
3006
+ rules.exception_l_seq(attribute, raises_type)
3007
+ elseif (token == ';') then
3008
+ -- empty
3009
+ end
3010
+ end
3011
+
3012
+
3013
+ ---
3014
+ -- COMPONENT DECLARATION
3015
+ --------------------------------------------------------------------------
3016
+
3017
+ rules.component = function ()
3018
+ recognize(lex.tab_tokens.TK_COMPONENT)
3019
+ recognize(lex.tab_tokens.TK_ID)
3020
+ local name = getID()
3021
+ define(name, TAB_TYPEID.COMPONENT)
3022
+ currentScope.declarations = {}
3023
+ rules.component_tail(name)
3024
+ gotoFatherScope()
3025
+ end
3026
+
3027
+ rules.component_tail = function (name)
3028
+ if (tab_firsts.rule_307[token]) then
3029
+ recognize(":", "':'")
3030
+ local component = rules.scoped_name(307)
3031
+ if component._type ~= TAB_TYPEID.COMPONENT then
3032
+ semanticError("The previously-defined type is not a COMPONENT")
3033
+ end
3034
+ currentScope.component_base = component
3035
+ rules.supp_inter_spec(308)
3036
+ recognize("{")
3037
+ rules.component_body()
3038
+ recognize("}")
3039
+ elseif (tab_firsts.rule_308[token]) then
3040
+ rules.supp_inter_spec(308)
3041
+ recognize("{")
3042
+ rules.component_body()
3043
+ recognize("}")
3044
+ elseif (tab_firsts.rule_309[token]) then
3045
+ recognize("{")
3046
+ rules.component_body()
3047
+ recognize("}")
3048
+ elseif (token == ';') then
3049
+ dclForward(name, TAB_TYPEID.COMPONENT)
3050
+ --empty
3051
+ else
3052
+ sinError("':', 'supports' or '{'")
3053
+ end
3054
+ end
3055
+
3056
+ rules.supp_inter_spec = function (num_follow_rule)
3057
+ if tab_firsts.rule_316[token] then
3058
+ recognize(lex.tab_tokens.TK_SUPPORTS)
3059
+ currentScope.supports = {}
3060
+ local interface = rules.scoped_name(num_follow_rule)
3061
+ if (interface._type ~= TAB_TYPEID.INTERFACE) then
3062
+ semanticError("The 'SUPPORTS' construction must be reference to an interface")
3063
+ end
3064
+ table.insert(currentScope.supports, interface)
3065
+ rules.supp_name_list(num_follow_rule)
3066
+ elseif (tab_follow['rule_'..num_follow_rule][token]) then
3067
+ -- empty
3068
+ else
3069
+ sinError("':', ',', or "..tab_follow_rule_error_msg[num_follow_rule])
3070
+ end
3071
+ end
3072
+
3073
+ rules.supp_name_list = function (num_follow_rule)
3074
+ if (tab_firsts.rule_321[token]) then
3075
+ recognize(',')
3076
+ local interface = rules.scoped_name(num_follow_rule)
3077
+ if (interface._type ~= TAB_TYPEID.INTERFACE) then
3078
+ semanticError("The 'SUPPORTS' construction must be reference to an interface")
3079
+ end
3080
+ table.insert(currentScope.supports, interface)
3081
+ rules.supp_name_list(num_follow_rule)
3082
+ elseif (tab_follow['rule_'..num_follow_rule][token]) then
3083
+ --empty
3084
+ else
3085
+ sinError("',' or '{'")
3086
+ end
3087
+ end
3088
+
3089
+ rules.component_body = function ()
3090
+ if (tab_firsts.rule_323[token]) then
3091
+ rules.component_export()
3092
+ rules.component_body()
3093
+ elseif (token == '}') then
3094
+ --empty
3095
+ else
3096
+ sinError("'provides', 'uses', 'emits', 'publishes', 'consumes', 'readonly' 'attribute' or '}'")
3097
+ end
3098
+ end
3099
+
3100
+ rules.component_export = function ()
3101
+ if (tab_firsts.rule_325[token]) then
3102
+ rules.provides_dcl()
3103
+ recognize(';')
3104
+ elseif (tab_firsts.rule_326[token]) then
3105
+ rules.uses_dcl()
3106
+ recognize(';')
3107
+ elseif (tab_firsts.rule_327[token]) then
3108
+ rules.emits_dcl()
3109
+ recognize(';')
3110
+ elseif (tab_firsts.rule_328[token]) then
3111
+ rules.publishes_dcl()
3112
+ recognize(';')
3113
+ elseif (tab_firsts.rule_329[token]) then
3114
+ rules.consumes_dcl()
3115
+ recognize(';')
3116
+ elseif (tab_firsts.rule_330[token]) then
3117
+ rules.attr_dcl()
3118
+ recognize(';')
3119
+ end
3120
+ end
3121
+
3122
+ rules.provides_dcl = function ()
3123
+ recognize(lex.tab_tokens.TK_PROVIDES, 'provides')
3124
+ local tab_provides = { _type = 'provides' }
3125
+ tab_provides.interface_type = rules.interface_type()
3126
+ recognize(lex.tab_tokens.TK_ID, '<identifier>')
3127
+ local name = getID()
3128
+ -- new_name(name, name, currentScope.declarations, tab_provides, ERRMSG_DECLARED, name)
3129
+ end
3130
+
3131
+ rules.interface_type = function ()
3132
+ if (tab_firsts.rule_332[token]) then
3133
+ local scope = rules.scoped_name(332)
3134
+ if (scope._type ~= TAB_TYPEID.INTERFACE) then
3135
+ semanticError("The interface type of this provides declaration shall be either the keyword \
3136
+ Object or a scoped name that denotes a previously-declared interface type")
3137
+ end
3138
+ return scope
3139
+ elseif (tab_firsts.rule_333[token]) then
3140
+ recognize(lex.tab_tokens.TK_OBJECT)
3141
+ return TAB_BASICTYPE.OBJECT
3142
+ else
3143
+ sinError("<identifier> or 'Object'")
3144
+ end
3145
+ end
3146
+
3147
+ rules.uses_dcl = function ()
3148
+ recognize(lex.tab_tokens.TK_USES)
3149
+ local tab_uses = { _type = 'uses' }
3150
+ tab_uses.multiple = rules.multiple_e()
3151
+ tab_uses.interface_type = rules.interface_type()
3152
+ recognize(lex.tab_tokens.TK_ID)
3153
+ local name = getID()
3154
+ -- new_name(name, name, currentScope.declarations, tab_uses, ERRMSG_DECLARED, name)
3155
+ end
3156
+
3157
+ rules.multiple_e = function ()
3158
+ if (tab_firsts.rule_339[token]) then
3159
+ recognize(lex.tab_tokens.TK_MULTIPLE)
3160
+ return true
3161
+ elseif (tab_follow.rule_340[token]) then
3162
+ return nil
3163
+ --empty
3164
+ else
3165
+ sinError("'multiple', <identifier>, ':' or 'Object'")
3166
+ end
3167
+ end
3168
+
3169
+ rules.emits_dcl = function ()
3170
+ recognize(lex.tab_tokens.TK_EMITS)
3171
+ local name = getID()
3172
+ local tab_uses = { _type = 'emits' }
3173
+ -- new_name(name, name, currentScope.declarations, tab_emits, ERRMSG_DECLARED, name)
3174
+ tab_uses.event_type = rules.scoped_name(341)
3175
+ recognize(lex.tab_tokens.TK_ID)
3176
+ tab_uses.evtsrc = getID()
3177
+ end
3178
+
3179
+ rules.publishes_dcl = function ()
3180
+ recognize(lex.tab_tokens.TK_PUBLISHES)
3181
+ local name = getID()
3182
+ local tab_publishes = { _type = 'publishes' }
3183
+ -- new_name(name, name, currentScope.declarations, tab_publishes, ERRMSG_DECLARED, name)
3184
+ tab_uses.event_type = rules.scoped_name(342)
3185
+ recognize(lex.tab_tokens.TK_ID)
3186
+ tab_uses.evtsrc = getID()
3187
+ end
3188
+
3189
+ rules.consumes_dcl = function ()
3190
+ recognize(lex.tab_tokens.TK_CONSUMES)
3191
+ local name = getID()
3192
+ local tab_publishes = { _type = 'consumes' }
3193
+ -- new_name(name, name, currentScope.declarations, tab_consumes, ERRMSG_DECLARED, name)
3194
+ tab_uses.event_type = rules.scoped_name(343)
3195
+ recognize(lex.tab_tokens.TK_ID)
3196
+ tab_uses.evtsink = getID()
3197
+ end
3198
+
3199
+
3200
+ ---
3201
+ -- HOME DECLARATION
3202
+ --------------------------------------------------------------------------
3203
+
3204
+ rules.home_dcl = function ()
3205
+ recognize(lex.tab_tokens.TK_HOME)
3206
+ recognize(lex.tab_tokens.TK_ID)
3207
+ local name = getID()
3208
+ define(name, TAB_TYPEID.HOME)
3209
+ rules.home_dcl_tail(name)
3210
+ gotoFatherScope()
3211
+ end
3212
+
3213
+ rules.home_dcl_tail = function (name)
3214
+ if (tab_firsts.rule_345[token])then
3215
+ rules.home_inh_spec()
3216
+ rules.supp_inter_spec(345)
3217
+ recognize(lex.tab_tokens.TK_MANAGES)
3218
+ local component = rules.scoped_name(347)
3219
+ currentScope.manages = component
3220
+ rules.primary_key_spec_e()
3221
+ recognize("{")
3222
+ rules.home_export_l()
3223
+ recognize("}")
3224
+ elseif (tab_firsts.rule_346[token]) then
3225
+ rules.supp_inter_spec(345)
3226
+ recognize(lex.tab_tokens.TK_MANAGES)
3227
+ local component = rules.scoped_name(347)
3228
+ currentScope.manages = component
3229
+ rules.primary_key_spec_e()
3230
+ recognize("{")
3231
+ rules.home_export_l()
3232
+ recognize("}")
3233
+ elseif (tab_firsts.rule_347[token]) then
3234
+ recognize(lex.tab_tokens.TK_MANAGES)
3235
+ currentScope.component = rules.scoped_name(347)
3236
+ rules.primary_key_spec_e()
3237
+ recognize("{")
3238
+ rules.home_export_l()
3239
+ recognize("}")
3240
+ else
3241
+ sin.error("'supports', 'manages', ':'")
3242
+ end
3243
+ end
3244
+
3245
+ rules.home_inh_spec = function ()
3246
+ if (tab_firsts.rule_348[token]) then
3247
+ recognize(":")
3248
+ local home = rules.scoped_name(348)
3249
+ if (home._type ~= TAB_TYPEID.HOME) then
3250
+ semanticError("The previously-defined type is not a HOME")
3251
+ end
3252
+ currentScope.home_base = home
3253
+ end
3254
+ end
3255
+
3256
+ --(353) <primary_key_spec_e> := TK_PRIMARYKEY <scoped_name>
3257
+ --(354) | empty
3258
+ rules.primary_key_spec_e = function ()
3259
+ if tab_firsts.rule_353[token] then
3260
+ recognize(lex.tab_tokens.TK_PRIMARYKEY, 'primarykey')
3261
+ rules.scoped_name(353)
3262
+ elseif tab_follow.rule_353[token] then
3263
+ --empty
3264
+ end
3265
+ end
3266
+
3267
+ rules.home_export_l = function ()
3268
+ if tab_firsts.rule_359[token] then
3269
+ rules.home_export()
3270
+ rules.home_export_l()
3271
+ elseif tab_follow.rule_359[token] then
3272
+ --empty
3273
+ end
3274
+ end
3275
+
3276
+ rules.home_export = function ()
3277
+ if tab_firsts.rule_361[token] then
3278
+ rules.export()
3279
+ elseif tab_firsts.rule_362[token] then
3280
+ rules.factory_dcl()
3281
+ recognize(";")
3282
+ elseif tab_firsts.rule_363[token] then
3283
+ rules.finder_dcl()
3284
+ recognize(";")
3285
+ else
3286
+ sinError("error")
3287
+ end
3288
+ end
3289
+
3290
+ rules.factory_dcl = function ()
3291
+ if tab_firsts.rule_364[token] then
3292
+ recognize(lex.tab_tokens.TK_FACTORY)
3293
+ recognize(lex.tab_tokens.TK_ID)
3294
+ local name = getID()
3295
+ define(name, TAB_TYPEID.FACTORY)
3296
+ recognize("(")
3297
+ rules.init_param_dcls()
3298
+ recognize(")")
3299
+ rules.raises_expr_e()
3300
+ end
3301
+ end
3302
+
3303
+ rules.init_param_dcls = function ()
3304
+ if tab_firsts.rule_366[token] then
3305
+ currentScope.members = {}
3306
+ rules.init_param_dcl()
3307
+ rules.init_param_dcl_list()
3308
+ elseif tab_follow.rule_367[token] then
3309
+ --empty
3310
+ end
3311
+ end
3312
+
3313
+ rules.init_param_dcl = function ()
3314
+ if tab_firsts.rule_297[token] then
3315
+ recognize(lex.tab_tokens.TK_IN)
3316
+ local tab_type_spec = rules.param_type_spec()
3317
+ recognize(lex.tab_tokens.TK_ID)
3318
+ local param_name = getID()
3319
+ dclName(param_name, currentScope.members,
3320
+ {
3321
+ type = tab_type_spec,
3322
+ name = param_name,
3323
+ })
3324
+ else
3325
+ sinError("'in'")
3326
+ end
3327
+ end
3328
+
3329
+ rules.init_param_dcl_list = function ()
3330
+ if tab_firsts.rule_368[token] then
3331
+ recognize(",")
3332
+ rules.init_param_dcl()
3333
+ rules.init_param_dcl_list()
3334
+ elseif tab_follow.rule_369[token] then
3335
+ --empty
3336
+ end
3337
+ end
3338
+
3339
+ rules.finder_dcl = function ()
3340
+ if tab_firsts.rule_365[token] then
3341
+ recognize(lex.tab_tokens.TK_FINDER)
3342
+ recognize(lex.tab_tokens.TK_ID)
3343
+ local name = getID()
3344
+ local tab_finder = { _type = TAB_TYPEID.FINDER, name = name }
3345
+ -- new_name(name, name,
3346
+ -- currentScope.members, tab_finder, ERRMSG_OPDECLARED, name)
3347
+ recognize("(")
3348
+ rules.init_param_dcls(tab_finder)
3349
+ recognize(")")
3350
+ rules.raises_expr_e(tab_finder)
3351
+ else
3352
+ sinError("'finder'")
3353
+ end
3354
+ end
3355
+
3356
+ rules.value_or_event = function ()
3357
+ if (tab_firsts.rule_281[token]) then
3358
+ recognize(lex.tab_tokens.TK_VALUETYPE)
3359
+ recognize(lex.tab_tokens.TK_ID)
3360
+ local name = getID()
3361
+ rules.value_tail(name, "custom")
3362
+ elseif (tab_firsts.rule_282[token]) then
3363
+ recognize(lex.tab_tokens.TK_EVENTTYPE)
3364
+ recognize(lex.tab_tokens.TK_ID)
3365
+ local name = getID()
3366
+ local tab_eventtypescope = rules.eventtype_tail(name, "custom")
3367
+ if callbacks.eventtype then
3368
+ callbacks.eventtype(tab_eventtypescope)
3369
+ end
3370
+ else
3371
+ sinError("'valuetype' or 'eventtype'")
3372
+ end
3373
+ end
3374
+
3375
+
3376
+ ---
3377
+ -- VALUE DECLARATION
3378
+ --------------------------------------------------------------------------
3379
+
3380
+ rules.value_tail = function (name, modifier)
3381
+ if (tab_firsts.rule_299[token]) then
3382
+ define(name, TAB_TYPEID.VALUETYPE)
3383
+ if modifier then
3384
+ currentScope[modifier] = true
3385
+ end
3386
+ local tab_valuetypescope = rules.value_tail_aux(name)
3387
+ if callbacks.valuetype then
3388
+ callbacks.valuetype(tab_valuetypescope)
3389
+ end
3390
+ return tab_valuetypescope
3391
+ elseif (tab_firsts.rule_298[token]) then
3392
+ define(name, TAB_TYPEID.VALUETYPE)
3393
+ if modifier then
3394
+ currentScope[modifier] = true
3395
+ end
3396
+ rules.value_inhe_spec()
3397
+ local tab_valuetypescope = rules.value_tail_aux(name)
3398
+ if callbacks.valuetype then
3399
+ callbacks.valuetype(tab_valuetypescope)
3400
+ end
3401
+ return tab_valuetypescope
3402
+ elseif tab_firsts.rule_300[token] then
3403
+ local _, nameSpace = define(name, TAB_TYPEID.VALUEBOX)
3404
+ if modifier then
3405
+ nameSpace[modifier] = true
3406
+ end
3407
+ nameSpace.original_type = rules.type_spec()
3408
+ if callbacks.valuebox then
3409
+ callbacks.valuebox(nameSpace)
3410
+ end
3411
+ return nameSpace
3412
+ elseif tab_follow.rule_301[token] then
3413
+ return dclForward(name, TAB_TYPEID.VALUETYPE)
3414
+ end
3415
+ end
3416
+
3417
+ rules.value_tail_aux = function (name)
3418
+ recognize("{")
3419
+ rules.value_element_l()
3420
+ recognize("}")
3421
+ local tab_valuetypescope = currentScope
3422
+ gotoFatherScope()
3423
+ return tab_valuetypescope
3424
+ end
3425
+
3426
+ rules.value_inhe_spec = function ()
3427
+ if tab_firsts.rule_268[token] then
3428
+ recognize(":")
3429
+ local truncatable = rules.truncatable_e()
3430
+ local value = rules.scoped_name(268)
3431
+ if (value._type ~= TAB_TYPEID.VALUETYPE and value._type ~= TAB_TYPEID.INTERFACE) then
3432
+ semanticError("The previously-defined type is not a VALUETYPE or INTERFACE")
3433
+ end
3434
+ currentScope.truncatable = truncatable
3435
+ if (not value.abstract) then
3436
+ currentScope.base_value = value
3437
+ else
3438
+ currentScope.abstract_base_values = {}
3439
+ table.insert(currentScope.abstract_base_values, value)
3440
+ end
3441
+ rules.value_name_list()
3442
+ rules.supp_inter_spec(308)
3443
+ elseif tab_firsts.rule_269[token] then
3444
+ rules.supp_inter_spec(308)
3445
+ else
3446
+ sinError("':', 'supports'")
3447
+ end
3448
+ end
3449
+
3450
+ rules.value_name_list = function ()
3451
+ if tab_firsts.rule_277[token] then
3452
+ recognize(",")
3453
+ local value = rules.scoped_name(268)
3454
+ if (not value.abstract) then
3455
+ if (currentScope.base_value) then
3456
+ sinError("The single base concrete has been declared.")
3457
+ else
3458
+ sinError("The single base concrete must be the first element specified in the inheritance list.")
3459
+ end
3460
+ else
3461
+ currentScope.abstract_base_values = currentScope.abstract_base_values or {}
3462
+ table.insert(currentScope.abstract_base_values, value)
3463
+ end
3464
+ rules.value_name_list()
3465
+ elseif tab_follow.rule_278[token] then
3466
+ --empty
3467
+ end
3468
+ end
3469
+
3470
+ rules.truncatable_e = function ()
3471
+ if tab_firsts.rule_271[token] then
3472
+ recognize(lex.tab_tokens.TK_TRUNCATABLE)
3473
+ return true
3474
+ elseif tab_follow.rule_272[token] then
3475
+ --empty
3476
+ end
3477
+ end
3478
+
3479
+ rules.value_element_l = function ()
3480
+ if (tab_firsts.rule_285[token]) then
3481
+ rules.value_element()
3482
+ rules.value_element_l()
3483
+ elseif (tab_follow.rule_286[token]) then
3484
+ --empty
3485
+ end
3486
+ end
3487
+
3488
+ rules.value_element = function ()
3489
+ if (tab_firsts.rule_287[token]) then
3490
+ rules.export()
3491
+ elseif (tab_firsts.rule_288[token]) then
3492
+ rules.state_member()
3493
+ elseif (tab_firsts.rule_289[token]) then
3494
+ rules.init_dcl()
3495
+ end
3496
+ end
3497
+
3498
+ rules.state_member = function ()
3499
+ if (tab_firsts.rule_290[token]) then
3500
+ recognize(lex.tab_tokens.TK_PUBLIC)
3501
+ rules.state_member_tail("public")
3502
+ elseif (tab_firsts.rule_291[token]) then
3503
+ recognize(lex.tab_tokens.TK_PRIVATE)
3504
+ rules.state_member_tail("private")
3505
+ end
3506
+ end
3507
+
3508
+ rules.state_member_tail = function (access)
3509
+ rules.declarator_l(rules.type_spec(), access)
3510
+ recognize(";")
3511
+ end
3512
+
3513
+ rules.init_dcl = function ()
3514
+ if (tab_firsts.rule_292[token]) then
3515
+ recognize(lex.tab_tokens.TK_FACTORY)
3516
+ recognize(lex.tab_tokens.TK_ID)
3517
+ local name = getID()
3518
+ define(name, TAB_TYPEID.FACTORY)
3519
+ recognize("(")
3520
+ rules.init_param_dcls()
3521
+ recognize(")")
3522
+ rules.raises_expr_e()
3523
+ recognize(";")
3524
+ gotoFatherScope()
3525
+ end
3526
+ end
3527
+
3528
+
3529
+ ---
3530
+ -- EVENT DECLARATION
3531
+ --------------------------------------------------------------------------
3532
+
3533
+ rules.eventtype_tail = function (name)
3534
+ if tab_firsts.rule_302[token] then
3535
+ define(name, TAB_TYPEID.EVENTTYPE)
3536
+ rules.value_inhe_spec()
3537
+ recognize("{")
3538
+ rules.value_element_l()
3539
+ recognize("}")
3540
+ local tab_eventtypescope = currentScope
3541
+ gotoFatherScope()
3542
+ return tab_eventtypescope
3543
+ elseif tab_firsts.rule_303[token] then
3544
+ define(name, TAB_TYPEID.EVENTTYPE)
3545
+ recognize("{")
3546
+ rules.value_element_l()
3547
+ recognize("}")
3548
+ local tab_eventtypescope = currentScope
3549
+ gotoFatherScope()
3550
+ return tab_eventtypescope
3551
+ elseif tab_follow.rule_304[token] then
3552
+ return dclForward(name, TAB_TYPEID.EVENTTYPE)
3553
+ end
3554
+ end
3555
+
3556
+ --[[function type_prefix_dcl()
3557
+ if tab_firsts.rule_260[token] then
3558
+ recognize(lex.tab_tokens.TK_TYPEPREFIX)
3559
+ rules.scoped_name()
3560
+ recognize(lex.tab_tokens.TK_STRING_LITERAL)
3561
+ else
3562
+ sinError("'typeprefix'")
3563
+ end
3564
+ end
3565
+ ]]
3566
+
3567
+
3568
+ ---
3569
+ -- API
3570
+ --------------------------------------------------------------------------
3571
+
3572
+ function parse(stridl, options)
3573
+ if not options then
3574
+ options = {}
3575
+ end
3576
+
3577
+ if options.callbacks then
3578
+ callbacks = options.callbacks
3579
+ for type, tab in pairs(TAB_BASICTYPE) do
3580
+ local callback = callbacks[type]
3581
+ if callback then
3582
+ if (type == 'TYPECODE') then
3583
+ else
3584
+ TAB_BASICTYPE[type] = callback
3585
+ end
3586
+ end
3587
+ end
3588
+
3589
+ for type, tab in pairs(TAB_IMPLICITTYPE) do
3590
+ local callback = callbacks[type]
3591
+ if callback then
3592
+ TAB_IMPLICITTYPE[type] = callback
3593
+ end
3594
+ end
3595
+ else
3596
+ callbacks = {}
3597
+ end
3598
+
3599
+ -- Estrutura que armazena o grafo de sa�da.
3600
+ -- A tabela � inicializada com o escopo 'GLOBAL'.
3601
+ output = {absolute_name = ''}
3602
+ currentScope = output
3603
+
3604
+ -- Estrutura que armazena informa��es pertinentes a cada identificador mapeado.
3605
+ -- Auxilia o processo de gera��o do grafo de sa�da.
3606
+ -- A tabela � indexada por *absolute name*.
3607
+ namespaces = {[''] = {namespace = output}}
3608
+ forwardDeclarations = {}
3609
+ idl = stridl
3610
+ CORBAVisible = nil
3611
+ currentScopeName = ''
3612
+ tab_identifiers = {}
3613
+ scopeRoots = {}
3614
+ table.insert(scopeRoots, {root = '', scope = ''})
3615
+ lex.init()
3616
+ token = getToken()
3617
+ --Implicit definitions
3618
+ -- CORBA::TypeCode
3619
+ if not options.notypecode then
3620
+ define('CORBA', TAB_TYPEID.MODULE)
3621
+ define('TypeCode', TAB_TYPEID.TYPECODE, TAB_IMPLICITTYPE.TYPECODE)
3622
+ gotoFatherScope()
3623
+ end
3624
+ -- Starts parsing with the first grammar rule.
3625
+ rules.specification()
3626
+ -- Removing CORBA::TypeCode implicit definition.
3627
+ if (not options.notypecode) and (not CORBAVisible) then
3628
+ table.remove(output, 1)
3629
+ end
3630
+ return output
3631
+ end