expressir 0.2.5-x64-mingw32 → 0.2.7-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (526) hide show
  1. checksums.yaml +5 -5
  2. data/.cross_rubies +30 -0
  3. data/.github/workflows/rake.yml +45 -46
  4. data/.github/workflows/release.yml +84 -75
  5. data/.gitignore +17 -15
  6. data/.gitmodules +3 -3
  7. data/.rspec +2 -2
  8. data/.rubocop.yml +508 -508
  9. data/Gemfile +4 -6
  10. data/README.adoc +147 -147
  11. data/Rakefile +11 -17
  12. data/bin/console +12 -12
  13. data/bin/rspec +29 -29
  14. data/bin/setup +8 -8
  15. data/demo.rb +18 -18
  16. data/docs/development.md +90 -90
  17. data/exe/expressir +20 -20
  18. data/exe/generate-parser +47 -47
  19. data/expressir.gemspec +43 -40
  20. data/lib/expressir/cli/ui.rb +36 -36
  21. data/lib/expressir/cli.rb +27 -27
  22. data/lib/expressir/config.rb +23 -23
  23. data/lib/expressir/express/aggregate_dimension.rb +38 -38
  24. data/lib/expressir/express/attribute.rb +15 -15
  25. data/lib/expressir/express/comment.rb +7 -7
  26. data/lib/expressir/express/defined_type.rb +36 -36
  27. data/lib/expressir/express/derived.rb +65 -65
  28. data/lib/expressir/express/derived_aggregate.rb +43 -43
  29. data/lib/expressir/express/entity.rb +137 -137
  30. data/lib/expressir/express/explicit.rb +70 -70
  31. data/lib/expressir/express/explicit_aggregate.rb +46 -46
  32. data/lib/expressir/express/explicit_or_derived.rb +16 -16
  33. data/lib/expressir/express/global_rule.rb +44 -44
  34. data/lib/expressir/express/interface_specification.rb +51 -51
  35. data/lib/expressir/express/interfaced_item.rb +38 -38
  36. data/lib/expressir/express/inverse.rb +46 -46
  37. data/lib/expressir/express/inverse_aggregate.rb +37 -37
  38. data/lib/expressir/express/model_element.rb +7 -7
  39. data/lib/expressir/express/named_type.rb +19 -19
  40. data/lib/expressir/express/remark.rb +8 -8
  41. data/lib/expressir/express/repository.rb +306 -306
  42. data/lib/expressir/express/schema_definition.rb +96 -96
  43. data/lib/expressir/express/subtype_constraint.rb +14 -14
  44. data/lib/expressir/express/type.rb +26 -26
  45. data/lib/expressir/express/type_aggregate.rb +42 -42
  46. data/lib/expressir/express/type_enum.rb +29 -29
  47. data/lib/expressir/express/type_parser.rb +45 -45
  48. data/lib/expressir/express/type_select.rb +82 -82
  49. data/lib/expressir/express/unique_rule.rb +35 -35
  50. data/lib/expressir/express/where_rule.rb +32 -32
  51. data/lib/expressir/express.rb +11 -11
  52. data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
  53. data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
  54. data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
  55. data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
  56. data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
  57. data/lib/expressir/express_exp/formatter.rb +1449 -1449
  58. data/lib/expressir/express_exp/parser.rb +40 -35
  59. data/lib/expressir/express_exp/visitor.rb +2463 -2450
  60. data/lib/expressir/express_parser.rb +30 -30
  61. data/lib/expressir/model/attribute.rb +26 -26
  62. data/lib/expressir/model/constant.rb +16 -16
  63. data/lib/expressir/model/entity.rb +45 -45
  64. data/lib/expressir/model/enumeration_item.rb +10 -10
  65. data/lib/expressir/model/expressions/aggregate_initializer.rb +12 -12
  66. data/lib/expressir/model/expressions/aggregate_item.rb +14 -14
  67. data/lib/expressir/model/expressions/attribute_reference.rb +14 -14
  68. data/lib/expressir/model/expressions/binary_expression.rb +39 -39
  69. data/lib/expressir/model/expressions/call.rb +14 -14
  70. data/lib/expressir/model/expressions/entity_constructor.rb +14 -14
  71. data/lib/expressir/model/expressions/group_reference.rb +14 -14
  72. data/lib/expressir/model/expressions/index_reference.rb +16 -16
  73. data/lib/expressir/model/expressions/interval.rb +20 -20
  74. data/lib/expressir/model/expressions/query_expression.rb +25 -25
  75. data/lib/expressir/model/expressions/simple_reference.rb +12 -12
  76. data/lib/expressir/model/expressions/unary_expression.rb +18 -18
  77. data/lib/expressir/model/function.rb +61 -61
  78. data/lib/expressir/model/identifier.rb +9 -8
  79. data/lib/expressir/model/interface.rb +17 -17
  80. data/lib/expressir/model/literals/binary.rb +12 -12
  81. data/lib/expressir/model/literals/integer.rb +12 -12
  82. data/lib/expressir/model/literals/logical.rb +16 -16
  83. data/lib/expressir/model/literals/real.rb +12 -12
  84. data/lib/expressir/model/literals/string.rb +14 -14
  85. data/lib/expressir/model/parameter.rb +16 -16
  86. data/lib/expressir/model/procedure.rb +59 -59
  87. data/lib/expressir/model/renamed_ref.rb +12 -12
  88. data/lib/expressir/model/repository.rb +18 -18
  89. data/lib/expressir/model/rule.rb +61 -61
  90. data/lib/expressir/model/schema.rb +66 -66
  91. data/lib/expressir/model/scope.rb +16 -16
  92. data/lib/expressir/model/statements/alias.rb +25 -25
  93. data/lib/expressir/model/statements/assignment.rb +14 -14
  94. data/lib/expressir/model/statements/call.rb +14 -14
  95. data/lib/expressir/model/statements/case.rb +16 -16
  96. data/lib/expressir/model/statements/case_action.rb +14 -14
  97. data/lib/expressir/model/statements/compound.rb +12 -12
  98. data/lib/expressir/model/statements/escape.rb +7 -7
  99. data/lib/expressir/model/statements/if.rb +16 -16
  100. data/lib/expressir/model/statements/null.rb +7 -7
  101. data/lib/expressir/model/statements/repeat.rb +33 -33
  102. data/lib/expressir/model/statements/return.rb +12 -12
  103. data/lib/expressir/model/statements/skip.rb +7 -7
  104. data/lib/expressir/model/subtype_constraint.rb +26 -26
  105. data/lib/expressir/model/type.rb +23 -23
  106. data/lib/expressir/model/types/aggregate.rb +16 -16
  107. data/lib/expressir/model/types/array.rb +20 -20
  108. data/lib/expressir/model/types/bag.rb +16 -16
  109. data/lib/expressir/model/types/binary.rb +14 -14
  110. data/lib/expressir/model/types/boolean.rb +7 -7
  111. data/lib/expressir/model/types/enumeration.rb +18 -18
  112. data/lib/expressir/model/types/generic.rb +12 -12
  113. data/lib/expressir/model/types/generic_entity.rb +12 -12
  114. data/lib/expressir/model/types/integer.rb +7 -7
  115. data/lib/expressir/model/types/list.rb +18 -18
  116. data/lib/expressir/model/types/logical.rb +7 -7
  117. data/lib/expressir/model/types/number.rb +7 -7
  118. data/lib/expressir/model/types/real.rb +12 -12
  119. data/lib/expressir/model/types/select.rb +20 -20
  120. data/lib/expressir/model/types/set.rb +16 -16
  121. data/lib/expressir/model/types/string.rb +14 -14
  122. data/lib/expressir/model/unique.rb +14 -14
  123. data/lib/expressir/model/variable.rb +16 -16
  124. data/lib/expressir/model/where.rb +14 -14
  125. data/lib/expressir/model.rb +64 -64
  126. data/lib/expressir/parser/owl_parser.rb +8 -8
  127. data/lib/expressir/parser.rb +6 -6
  128. data/lib/expressir/version.rb +3 -3
  129. data/lib/expressir.rb +21 -21
  130. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +9589 -9589
  131. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +36619 -36619
  132. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +13293 -13293
  133. data/original/examples/employment/eclipse/.project +17 -17
  134. data/original/examples/employment/eclipse/Express/employment_schema.exp +33 -33
  135. data/original/examples/employment/eclipse/Express/employment_schema.xmi +77 -77
  136. data/original/examples/employment/eclipse/Express/employment_schema.xml +92 -92
  137. data/original/examples/employment/eclipse/Models/Employment.uml +4 -4
  138. data/original/examples/employment/eclipse/Models/Employment.umldi +240 -240
  139. data/original/examples/employment/eclipse/readme.txt +6 -6
  140. data/original/examples/employment/employment_schema.exp +33 -33
  141. data/original/examples/employment/employment_schema.rb +232 -232
  142. data/original/examples/employment/employment_schema.xml +92 -92
  143. data/original/examples/employment/employment_schema___module.rb +46 -46
  144. data/original/examples/employment/employment_schema___p28attr.rb +126 -126
  145. data/original/examples/employment/employment_schema___p28inst.rb +26 -26
  146. data/original/examples/employment/example_employment_data.xml +1 -1
  147. data/original/examples/employment/example_employment_data_copy.xml +1 -1
  148. data/original/examples/employment/example_employment_reader.rb +30 -30
  149. data/original/examples/employment/example_employment_writer.rb +51 -51
  150. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +3710 -3710
  151. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +35880 -35880
  152. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +15357 -15357
  153. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +9467 -9467
  154. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +8404 -8404
  155. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +43147 -43147
  156. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +18341 -18341
  157. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +11631 -11631
  158. data/original/examples/syntax/remark.exp +146 -145
  159. data/original/examples/syntax/remark_formatted.exp +174 -173
  160. data/original/examples/syntax/syntax.exp +311 -310
  161. data/original/examples/syntax/syntax_formatted.exp +1190 -1186
  162. data/original/exp2ruby.rb +525 -525
  163. data/original/expsm.rb +34 -34
  164. data/original/mapping_owl.rb +1018 -1018
  165. data/original/mapping_sysml.rb +2281 -2281
  166. data/original/mapping_uml2.rb +598 -598
  167. data/original/mapping_uml2_eclipse.rb +433 -433
  168. data/original/reeper.rb +134 -134
  169. data/rakelib/cross-ruby.rake +308 -0
  170. data/spec/acceptance/express_to_owl_spec.rb +18 -18
  171. data/spec/acceptance/version_spec.rb +12 -12
  172. data/spec/expressir/express/repository_spec.rb +25 -25
  173. data/spec/expressir/express_exp/ap233_spec.rb +22 -22
  174. data/spec/expressir/express_exp/format_remark_spec.rb +28 -28
  175. data/spec/expressir/express_exp/format_syntax_spec.rb +28 -28
  176. data/spec/expressir/express_exp/parse_remark_spec.rb +346 -345
  177. data/spec/expressir/express_exp/parse_syntax_spec.rb +3003 -2998
  178. data/spec/expressir/model/find_spec.rb +110 -110
  179. data/spec/expressr_spec.rb +5 -5
  180. data/spec/spec_helper.rb +17 -17
  181. data/spec/support/console_helper.rb +29 -29
  182. metadata +32 -370
  183. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +0 -118
  184. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +0 -637
  185. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -984
  186. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +0 -652
  187. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -990
  188. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +0 -652
  189. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -990
  190. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +0 -652
  191. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -990
  192. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/Info.plist +0 -26
  193. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/antlrcpp_ios.h +0 -17
  194. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +0 -3024
  195. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  196. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  197. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +0 -76
  198. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +0 -80
  199. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +0 -80
  200. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.cpp +0 -10
  201. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.h +0 -167
  202. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.cpp +0 -10
  203. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.h +0 -121
  204. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -34
  205. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +0 -27
  206. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +0 -155
  207. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +0 -69
  208. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.cpp +0 -61
  209. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.h +0 -59
  210. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.cpp +0 -25
  211. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.h +0 -36
  212. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.cpp +0 -414
  213. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.h +0 -200
  214. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.cpp +0 -11
  215. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.h +0 -37
  216. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +0 -195
  217. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.h +0 -158
  218. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +0 -39
  219. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +0 -74
  220. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.cpp +0 -78
  221. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.h +0 -79
  222. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp +0 -15
  223. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.h +0 -35
  224. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +0 -333
  225. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.h +0 -466
  226. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp +0 -84
  227. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.h +0 -80
  228. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +0 -64
  229. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +0 -99
  230. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +0 -51
  231. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +0 -32
  232. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.cpp +0 -18
  233. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.h +0 -24
  234. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.cpp +0 -12
  235. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -218
  236. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.cpp +0 -19
  237. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.h +0 -45
  238. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -295
  239. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -196
  240. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -75
  241. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +0 -52
  242. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.cpp +0 -36
  243. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.h +0 -31
  244. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +0 -92
  245. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +0 -88
  246. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.cpp +0 -46
  247. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.h +0 -42
  248. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +0 -648
  249. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -467
  250. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +0 -306
  251. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +0 -179
  252. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +0 -141
  253. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +0 -147
  254. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +0 -53
  255. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.h +0 -38
  256. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -66
  257. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.h +0 -98
  258. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +0 -167
  259. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +0 -164
  260. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +0 -143
  261. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +0 -137
  262. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.cpp +0 -27
  263. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.h +0 -32
  264. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +0 -53
  265. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.h +0 -155
  266. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.cpp +0 -9
  267. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -92
  268. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenFactory.h +0 -30
  269. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.cpp +0 -9
  270. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +0 -85
  271. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.cpp +0 -11
  272. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.h +0 -137
  273. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +0 -425
  274. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +0 -293
  275. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +0 -211
  276. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +0 -123
  277. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp +0 -270
  278. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.h +0 -115
  279. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +0 -104
  280. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +0 -193
  281. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.cpp +0 -9
  282. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.h +0 -23
  283. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +0 -137
  284. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +0 -167
  285. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +0 -209
  286. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +0 -112
  287. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +0 -113
  288. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +0 -148
  289. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +0 -228
  290. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +0 -110
  291. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +0 -64
  292. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +0 -50
  293. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +0 -758
  294. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +0 -85
  295. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
  296. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
  297. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +0 -63
  298. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +0 -87
  299. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +0 -72
  300. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +0 -133
  301. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNType.h +0 -20
  302. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
  303. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
  304. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +0 -33
  305. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +0 -33
  306. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.cpp +0 -16
  307. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.h +0 -68
  308. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +0 -82
  309. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +0 -43
  310. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +0 -31
  311. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +0 -30
  312. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
  313. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +0 -22
  314. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
  315. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +0 -21
  316. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
  317. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +0 -24
  318. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
  319. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +0 -21
  320. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.cpp +0 -14
  321. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.h +0 -47
  322. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.cpp +0 -14
  323. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.h +0 -70
  324. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.cpp +0 -25
  325. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +0 -227
  326. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -17
  327. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +0 -30
  328. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
  329. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
  330. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +0 -35
  331. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +0 -39
  332. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.cpp +0 -15
  333. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.h +0 -43
  334. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +0 -158
  335. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +0 -109
  336. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +0 -84
  337. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +0 -44
  338. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +0 -628
  339. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +0 -210
  340. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +0 -9
  341. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +0 -66
  342. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +0 -107
  343. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +0 -115
  344. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +0 -55
  345. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +0 -55
  346. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +0 -63
  347. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +0 -62
  348. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +0 -87
  349. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +0 -63
  350. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +0 -82
  351. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +0 -56
  352. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +0 -61
  353. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +0 -47
  354. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +0 -57
  355. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +0 -47
  356. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +0 -57
  357. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +0 -56
  358. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +0 -61
  359. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +0 -47
  360. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +0 -55
  361. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +0 -56
  362. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +0 -55
  363. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.cpp +0 -16
  364. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.h +0 -42
  365. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
  366. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +0 -22
  367. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
  368. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +0 -27
  369. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +0 -25
  370. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +0 -12
  371. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +0 -20
  372. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.cpp +0 -102
  373. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.h +0 -102
  374. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +0 -1366
  375. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +0 -904
  376. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
  377. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +0 -25
  378. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
  379. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +0 -22
  380. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +0 -32
  381. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +0 -29
  382. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +0 -17
  383. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +0 -62
  384. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +0 -34
  385. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +0 -39
  386. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +0 -662
  387. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +0 -254
  388. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +0 -201
  389. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +0 -436
  390. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +0 -179
  391. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +0 -60
  392. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +0 -30
  393. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +0 -29
  394. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
  395. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +0 -25
  396. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
  397. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +0 -25
  398. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +0 -37
  399. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +0 -40
  400. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +0 -377
  401. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +0 -222
  402. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +0 -32
  403. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +0 -30
  404. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +0 -81
  405. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +0 -36
  406. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
  407. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +0 -21
  408. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
  409. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +0 -35
  410. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +0 -19
  411. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +0 -21
  412. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
  413. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +0 -21
  414. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +0 -44
  415. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +0 -76
  416. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +0 -25
  417. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +0 -25
  418. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +0 -127
  419. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +0 -91
  420. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +0 -67
  421. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +0 -32
  422. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +0 -100
  423. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +0 -144
  424. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +0 -20
  425. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +0 -23
  426. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +0 -124
  427. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +0 -31
  428. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +0 -89
  429. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +0 -84
  430. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +0 -521
  431. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +0 -198
  432. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +0 -134
  433. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +0 -76
  434. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.cpp +0 -4
  435. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.h +0 -21
  436. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -13
  437. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +0 -170
  438. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +0 -43
  439. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +0 -110
  440. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +0 -76
  441. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +0 -248
  442. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +0 -78
  443. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -163
  444. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +0 -36
  445. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +0 -54
  446. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
  447. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
  448. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +0 -128
  449. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
  450. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +0 -19
  451. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +0 -23
  452. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +0 -33
  453. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +0 -71
  454. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.h +0 -53
  455. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -15
  456. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +0 -102
  457. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.cpp +0 -9
  458. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.h +0 -39
  459. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeProperty.h +0 -50
  460. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.cpp +0 -9
  461. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +0 -57
  462. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +0 -49
  463. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +0 -31
  464. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
  465. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +0 -32
  466. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +0 -57
  467. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +0 -33
  468. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +0 -241
  469. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.h +0 -78
  470. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.cpp +0 -9
  471. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.h +0 -44
  472. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.cpp +0 -69
  473. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h +0 -132
  474. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +0 -64
  475. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h +0 -105
  476. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +0 -371
  477. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h +0 -185
  478. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp +0 -77
  479. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.h +0 -117
  480. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.cpp +0 -39
  481. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h +0 -86
  482. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.cpp +0 -28
  483. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h +0 -51
  484. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp +0 -36
  485. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.h +0 -80
  486. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +0 -154
  487. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.h +0 -86
  488. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.cpp +0 -31
  489. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.h +0 -40
  490. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +0 -173
  491. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.g4 +0 -64
  492. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +0 -56
  493. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.tokens +0 -12
  494. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.cpp +0 -13
  495. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.h +0 -22
  496. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.cpp +0 -20
  497. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.h +0 -27
  498. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +0 -30
  499. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.h +0 -26
  500. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.cpp +0 -20
  501. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.h +0 -25
  502. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +0 -33
  503. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.h +0 -26
  504. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.cpp +0 -23
  505. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.h +0 -23
  506. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.cpp +0 -24
  507. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.h +0 -23
  508. data/ext/express-parser/antlrgen/Express.interp +0 -532
  509. data/ext/express-parser/antlrgen/Express.tokens +0 -190
  510. data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +0 -7
  511. data/ext/express-parser/antlrgen/ExpressBaseListener.h +0 -623
  512. data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +0 -7
  513. data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +0 -816
  514. data/ext/express-parser/antlrgen/ExpressLexer.cpp +0 -1169
  515. data/ext/express-parser/antlrgen/ExpressLexer.h +0 -85
  516. data/ext/express-parser/antlrgen/ExpressLexer.interp +0 -534
  517. data/ext/express-parser/antlrgen/ExpressLexer.tokens +0 -190
  518. data/ext/express-parser/antlrgen/ExpressListener.cpp +0 -7
  519. data/ext/express-parser/antlrgen/ExpressListener.h +0 -616
  520. data/ext/express-parser/antlrgen/ExpressParser.cpp +0 -17284
  521. data/ext/express-parser/antlrgen/ExpressParser.h +0 -3696
  522. data/ext/express-parser/antlrgen/ExpressVisitor.cpp +0 -7
  523. data/ext/express-parser/antlrgen/ExpressVisitor.h +0 -422
  524. data/ext/express-parser/express_parser.cpp +0 -17931
  525. data/ext/express-parser/extconf.rb +0 -34
  526. data/lib/express_parser.so +0 -0
@@ -1,2451 +1,2464 @@
1
- require 'express_parser'
2
- require 'expressir/model'
3
-
4
- # static shorthands are unwrapped
5
- # - entity attributes, function/procedure parameters, local variables
6
- #
7
- # reference type is not recognized
8
- # see note in A.1.5 Interpreted identifiers
9
- # > It is expected that identifiers matching these syntax rules are known to an implementation.
10
- # > How the implementation obtains this information is of no concern to the definition of the language. One
11
- # > method of gaining this information is multi-pass parsing: the first pass collects the identifiers from their
12
- # > declarations, so that subsequent passes are then able to distinguish a veriable_ref from a function_ref,
13
- # > for example.
14
- #
15
- # - xxxRef - merged to SimpleReference
16
- # - entityConstructor, functionCall - merged to Call
17
- #
18
- # difference between generalized and instantiable types is not recognized
19
- # see note in 8.6.2 Parameter data types
20
- # > A syntactic construct such as ARRAY[1:3] OF REAL satisfies two syntactic productions —
21
- # > aggregation_type and general_aggregation_type. It is considered to be instantiable no matter which
22
- # > production it is required to satisfy in the syntax.
23
-
24
- module Expressir
25
- module ExpressExp
26
- class Visitor < ::ExpressParser::Visitor
27
- REMARK_CHANNEL = 2
28
-
29
- def initialize(tokens)
30
- @tokens = tokens
31
- @attached_remarks = Set.new
32
-
33
- super()
34
- end
35
-
36
- def visit(ctx)
37
- result = super(ctx)
38
- attach_parent(ctx, result)
39
- attach_remarks(ctx, result)
40
- result
41
- end
42
-
43
- def visit_if(ctx)
44
- visit(ctx) if ctx
45
- end
46
-
47
- def visit_if_map(ctx)
48
- ctx.map{|ctx2| visit(ctx2)} if ctx
49
- end
50
-
51
- def visit_if_map_flatten(ctx)
52
- ctx.map{|ctx2| visit(ctx2)}.flatten if ctx
53
- end
54
-
55
- def attach_parent(ctx, node)
56
- if node.class.method_defined? :children
57
- node.children.each do |child_node|
58
- if child_node.class.method_defined? :parent
59
- child_node.parent = node
60
- end
61
- end
62
- end
63
- end
64
-
65
- def attach_remarks(ctx, node)
66
- # get remark tokens
67
- start_index, stop_index = if ctx.instance_of? ::ExpressParser::SyntaxContext
68
- [0, @tokens.size - 1]
69
- else
70
- [ctx.start.token_index, ctx.stop.token_index]
71
- end
72
- # puts [start_index, stop_index, ctx.class].inspect
73
-
74
- remark_tokens = @tokens[start_index..stop_index].select{|x| x.channel == REMARK_CHANNEL}
75
- if remark_tokens
76
- remark_tokens.each do |remark_token|
77
- remark_text = remark_token.text
78
-
79
- # check if it is tagged remark
80
- match = if remark_text.start_with?('--')
81
- remark_text[2..-1].match(/^"([^"]*)"(.*)$/)
82
- elsif remark_text.start_with?('(*') and remark_text.end_with?('*)')
83
- remark_text[2..-3].match(/^"([^"]*)"(.*)$/m)
84
- end
85
- if !match
86
- next
87
- end
88
-
89
- # don't attach already attached tagged remark
90
- if @attached_remarks.include? remark_token
91
- next
92
- end
93
-
94
- # attach tagged remark
95
- remark_tag = match[1]
96
- remark_content = match[2].strip
97
-
98
- target_node = nil
99
- current_node = node
100
- if current_node.class.method_defined? :find
101
- target_node = current_node.find(remark_tag)
102
- end
103
- while !target_node and current_node.class.method_defined? :parent and current_node.parent.class.method_defined? :find
104
- current_node = current_node.parent
105
- target_node = current_node.find(remark_tag)
106
- end
107
-
108
- if target_node
109
- target_node.remarks ||= []
110
- target_node.remarks << remark_content
111
-
112
- # mark remark as attached, so that it is not attached again at higher nesting level
113
- @attached_remarks << remark_token
114
- end
115
- end
116
- end
117
- end
118
-
119
- def visit_attribute_ref(ctx)
120
- ctx__attribute_id = ctx.attribute_id
121
-
122
- id = visit_if(ctx__attribute_id)
123
-
124
- Model::Expressions::SimpleReference.new({
125
- id: id
126
- })
127
- end
128
-
129
- def visit_constant_ref(ctx)
130
- ctx__constant_id = ctx.constant_id
131
-
132
- id = visit_if(ctx__constant_id)
133
-
134
- Model::Expressions::SimpleReference.new({
135
- id: id
136
- })
137
- end
138
-
139
- def visit_entity_ref(ctx)
140
- ctx__entity_id = ctx.entity_id
141
-
142
- id = visit_if(ctx__entity_id)
143
-
144
- Model::Expressions::SimpleReference.new({
145
- id: id
146
- })
147
- end
148
-
149
- def visit_enumeration_ref(ctx)
150
- ctx__enumeration_id = ctx.enumeration_id
151
-
152
- id = visit_if(ctx__enumeration_id)
153
-
154
- Model::Expressions::SimpleReference.new({
155
- id: id
156
- })
157
- end
158
-
159
- def visit_function_ref(ctx)
160
- ctx__function_id = ctx.function_id
161
-
162
- id = visit_if(ctx__function_id)
163
-
164
- Model::Expressions::SimpleReference.new({
165
- id: id
166
- })
167
- end
168
-
169
- def visit_parameter_ref(ctx)
170
- ctx__parameter_id = ctx.parameter_id
171
-
172
- id = visit_if(ctx__parameter_id)
173
-
174
- Model::Expressions::SimpleReference.new({
175
- id: id
176
- })
177
- end
178
-
179
- def visit_procedure_ref(ctx)
180
- ctx__procedure_id = ctx.procedure_id
181
-
182
- id = visit_if(ctx__procedure_id)
183
-
184
- Model::Expressions::SimpleReference.new({
185
- id: id
186
- })
187
- end
188
-
189
- def visit_rule_label_ref(ctx)
190
- ctx__rule_label_id = ctx.rule_label_id
191
-
192
- id = visit_if(ctx__rule_label_id)
193
-
194
- Model::Expressions::SimpleReference.new({
195
- id: id
196
- })
197
- end
198
-
199
- def visit_rule_ref(ctx)
200
- ctx__rule_id = ctx.rule_id
201
-
202
- id = visit_if(ctx__rule_id)
203
-
204
- Model::Expressions::SimpleReference.new({
205
- id: id
206
- })
207
- end
208
-
209
- def visit_schema_ref(ctx)
210
- ctx__schema_id = ctx.schema_id
211
-
212
- id = visit_if(ctx__schema_id)
213
-
214
- Model::Expressions::SimpleReference.new({
215
- id: id
216
- })
217
- end
218
-
219
- def visit_subtype_constraint_ref(ctx)
220
- ctx__subtype_constraint_id = ctx.subtype_constraint_id
221
-
222
- id = visit_if(ctx__subtype_constraint_id)
223
-
224
- Model::Expressions::SimpleReference.new({
225
- id: id
226
- })
227
- end
228
-
229
- def visit_type_label_ref(ctx)
230
- ctx__type_label_id = ctx.type_label_id
231
-
232
- id = visit_if(ctx__type_label_id)
233
-
234
- Model::Expressions::SimpleReference.new({
235
- id: id
236
- })
237
- end
238
-
239
- def visit_type_ref(ctx)
240
- ctx__type_id = ctx.type_id
241
-
242
- id = visit_if(ctx__type_id)
243
-
244
- Model::Expressions::SimpleReference.new({
245
- id: id
246
- })
247
- end
248
-
249
- def visit_variable_ref(ctx)
250
- ctx__variable_id = ctx.variable_id
251
-
252
- id = visit_if(ctx__variable_id)
253
-
254
- Model::Expressions::SimpleReference.new({
255
- id: id
256
- })
257
- end
258
-
259
- def visit_abstract_entity_declaration(ctx)
260
- raise 'Invalid state'
261
- end
262
-
263
- def visit_abstract_supertype(ctx)
264
- raise 'Invalid state'
265
- end
266
-
267
- def visit_abstract_supertype_declaration(ctx)
268
- ctx__subtype_constraint = ctx.subtype_constraint
269
-
270
- visit_if(ctx__subtype_constraint)
271
- end
272
-
273
- def visit_actual_parameter_list(ctx)
274
- ctx__parameter = ctx.parameter
275
-
276
- visit_if_map(ctx__parameter)
277
- end
278
-
279
- def visit_add_like_op(ctx)
280
- ctx__text = ctx.text
281
- ctx__ADDITION = ctx__text == '+'
282
- ctx__SUBTRACTION = ctx__text == '-'
283
- ctx__OR = ctx.OR
284
- ctx__XOR = ctx.XOR
285
-
286
- if ctx__ADDITION
287
- Model::Expressions::BinaryExpression::ADDITION
288
- elsif ctx__SUBTRACTION
289
- Model::Expressions::BinaryExpression::SUBTRACTION
290
- elsif ctx__OR
291
- Model::Expressions::BinaryExpression::OR
292
- elsif ctx__XOR
293
- Model::Expressions::BinaryExpression::XOR
294
- else
295
- raise 'Invalid state'
296
- end
297
- end
298
-
299
- def visit_aggregate_initializer(ctx)
300
- ctx__element = ctx.element
301
-
302
- items = visit_if_map(ctx__element)
303
-
304
- Model::Expressions::AggregateInitializer.new({
305
- items: items
306
- })
307
- end
308
-
309
- def visit_aggregate_source(ctx)
310
- ctx__simple_expression = ctx.simple_expression
311
-
312
- visit_if(ctx__simple_expression)
313
- end
314
-
315
- def visit_aggregate_type(ctx)
316
- ctx__type_label = ctx.type_label
317
- ctx__parameter_type = ctx.parameter_type
318
-
319
- id = visit_if(ctx__type_label)
320
- base_type = visit_if(ctx__parameter_type)
321
-
322
- Model::Types::Aggregate.new({
323
- id: id,
324
- base_type: base_type
325
- })
326
- end
327
-
328
- def visit_aggregation_types(ctx)
329
- ctx__array_type = ctx.array_type
330
- ctx__bag_type = ctx.bag_type
331
- ctx__list_type = ctx.list_type
332
- ctx__set_type = ctx.set_type
333
-
334
- visit_if(ctx__array_type || ctx__bag_type || ctx__list_type || ctx__set_type)
335
- end
336
-
337
- def visit_algorithm_head(ctx)
338
- raise 'Invalid state'
339
- end
340
-
341
- def visit_alias_stmt(ctx)
342
- ctx__variable_id = ctx.variable_id
343
- ctx__general_ref = ctx.general_ref
344
- ctx__qualifier = ctx.qualifier
345
- ctx__stmt = ctx.stmt
346
-
347
- id = visit_if(ctx__variable_id)
348
- expression = handle_qualified_ref(visit_if(ctx__general_ref), ctx__qualifier)
349
- statements = visit_if_map(ctx__stmt)
350
-
351
- Model::Statements::Alias.new({
352
- id: id,
353
- expression: expression,
354
- statements: statements
355
- })
356
- end
357
-
358
- def visit_array_type(ctx)
359
- ctx__bound_spec = ctx.bound_spec
360
- ctx__OPTIONAL = ctx.OPTIONAL
361
- ctx__UNIQUE = ctx.UNIQUE
362
- ctx__instantiable_type = ctx.instantiable_type
363
- ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
364
- ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
365
-
366
- bound1 = visit_if(ctx__bound_spec__bound1)
367
- bound2 = visit_if(ctx__bound_spec__bound2)
368
- optional = !!ctx__OPTIONAL
369
- unique = !!ctx__UNIQUE
370
- base_type = visit_if(ctx__instantiable_type)
371
-
372
- Model::Types::Array.new({
373
- bound1: bound1,
374
- bound2: bound2,
375
- optional: optional,
376
- unique: unique,
377
- base_type: base_type
378
- })
379
- end
380
-
381
- def visit_assignment_stmt(ctx)
382
- ctx__general_ref = ctx.general_ref
383
- ctx__qualifier = ctx.qualifier
384
- ctx__expression = ctx.expression
385
-
386
- ref = handle_qualified_ref(visit_if(ctx__general_ref), ctx__qualifier)
387
- expression = visit_if(ctx__expression)
388
-
389
- Model::Statements::Assignment.new({
390
- ref: ref,
391
- expression: expression
392
- })
393
- end
394
-
395
- def visit_attribute_decl(ctx)
396
- ctx__attribute_id = ctx.attribute_id
397
- ctx__redeclared_attribute = ctx.redeclared_attribute
398
- ctx__redeclared_attribute__qualified_attribute = ctx__redeclared_attribute&.qualified_attribute
399
- ctx__redeclared_attribute__attribute_id = ctx__redeclared_attribute&.attribute_id
400
-
401
- id = visit_if(ctx__attribute_id || ctx__redeclared_attribute__attribute_id)
402
- supertype_attribute = visit_if(ctx__redeclared_attribute__qualified_attribute)
403
-
404
- Model::Attribute.new({
405
- id: id,
406
- supertype_attribute: supertype_attribute
407
- })
408
- end
409
-
410
- def visit_attribute_id(ctx)
411
- ctx__SimpleId = ctx.SimpleId
412
-
413
- handle_simple_id(ctx__SimpleId)
414
- end
415
-
416
- def visit_attribute_qualifier(ctx)
417
- ctx__attribute_ref = ctx.attribute_ref
418
-
419
- attribute = visit_if(ctx__attribute_ref)
420
-
421
- Model::Expressions::AttributeReference.new({
422
- attribute: attribute
423
- })
424
- end
425
-
426
- def visit_attribute_reference(ctx)
427
- raise 'Invalid state'
428
- end
429
-
430
- def visit_bag_type(ctx)
431
- ctx__bound_spec = ctx.bound_spec
432
- ctx__instantiable_type = ctx.instantiable_type
433
- ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
434
- ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
435
-
436
- bound1 = visit_if(ctx__bound_spec__bound1)
437
- bound2 = visit_if(ctx__bound_spec__bound2)
438
- base_type = visit_if(ctx__instantiable_type)
439
-
440
- Model::Types::Bag.new({
441
- bound1: bound1,
442
- bound2: bound2,
443
- base_type: base_type
444
- })
445
- end
446
-
447
- def visit_binary_type(ctx)
448
- ctx__width_spec = ctx.width_spec
449
- ctx__width_spec__width = ctx__width_spec&.width
450
- ctx__width_spec__FIXED = ctx__width_spec&.FIXED
451
-
452
- width = visit_if(ctx__width_spec__width)
453
- fixed = !!ctx__width_spec__FIXED
454
-
455
- Model::Types::Binary.new({
456
- width: width,
457
- fixed: fixed
458
- })
459
- end
460
-
461
- def visit_boolean_type(ctx)
462
- Model::Types::Boolean.new
463
- end
464
-
465
- def visit_bound1(ctx)
466
- ctx__numeric_expression = ctx.numeric_expression
467
-
468
- visit_if(ctx__numeric_expression)
469
- end
470
-
471
- def visit_bound2(ctx)
472
- ctx__numeric_expression = ctx.numeric_expression
473
-
474
- visit_if(ctx__numeric_expression)
475
- end
476
-
477
- def visit_bound_spec(ctx)
478
- raise 'Invalid state'
479
- end
480
-
481
- def visit_built_in_constant(ctx)
482
- ctx__text = ctx.text
483
-
484
- id = ctx__text
485
-
486
- Model::Expressions::SimpleReference.new({
487
- id: id
488
- })
489
- end
490
-
491
- def visit_built_in_function(ctx)
492
- ctx__text = ctx.text
493
-
494
- id = ctx__text
495
-
496
- Model::Expressions::SimpleReference.new({
497
- id: id
498
- })
499
- end
500
-
501
- def visit_built_in_procedure(ctx)
502
- ctx__text = ctx.text
503
-
504
- id = ctx__text
505
-
506
- Model::Expressions::SimpleReference.new({
507
- id: id
508
- })
509
- end
510
-
511
- def visit_case_action(ctx)
512
- ctx__case_label = ctx.case_label
513
- ctx__stmt = ctx.stmt
514
-
515
- labels = visit_if_map(ctx__case_label)
516
- statement = visit_if(ctx__stmt)
517
-
518
- Model::Statements::CaseAction.new({
519
- labels: labels,
520
- statement: statement
521
- })
522
- end
523
-
524
- def visit_case_label(ctx)
525
- ctx__expression = ctx.expression
526
-
527
- visit_if(ctx__expression)
528
- end
529
-
530
- def visit_case_stmt(ctx)
531
- ctx__selector = ctx.selector
532
- ctx__case_action = ctx.case_action
533
- ctx__stmt = ctx.stmt
534
- ctx__selector__expression = ctx__selector&.expression
535
-
536
- expression = visit_if(ctx__selector__expression)
537
- actions = visit_if_map_flatten(ctx__case_action)
538
- otherwise_statement = visit_if(ctx__stmt)
539
-
540
- Model::Statements::Case.new({
541
- expression: expression,
542
- actions: actions,
543
- otherwise_statement: otherwise_statement
544
- })
545
- end
546
-
547
- def visit_compound_stmt(ctx)
548
- ctx__stmt = ctx.stmt
549
-
550
- statements = visit_if_map(ctx__stmt)
551
-
552
- Model::Statements::Compound.new({
553
- statements: statements
554
- })
555
- end
556
-
557
- def visit_concrete_types(ctx)
558
- ctx__aggregation_types = ctx.aggregation_types
559
- ctx__simple_types = ctx.simple_types
560
- ctx__type_ref = ctx.type_ref
561
-
562
- visit_if(ctx__aggregation_types || ctx__simple_types || ctx__type_ref)
563
- end
564
-
565
- def visit_constant_body(ctx)
566
- ctx__constant_id = ctx.constant_id
567
- ctx__instantiable_type = ctx.instantiable_type
568
- ctx__expression = ctx.expression
569
-
570
- id = visit_if(ctx__constant_id)
571
- type = visit_if(ctx__instantiable_type)
572
- expression = visit_if(ctx__expression)
573
-
574
- Model::Constant.new({
575
- id: id,
576
- type: type,
577
- expression: expression
578
- })
579
- end
580
-
581
- def visit_constant_decl(ctx)
582
- ctx__constant_body = ctx.constant_body
583
-
584
- visit_if_map(ctx__constant_body)
585
- end
586
-
587
- def visit_constant_factor(ctx)
588
- ctx__built_in_constant = ctx.built_in_constant
589
- ctx__constant_ref = ctx.constant_ref
590
-
591
- visit_if(ctx__built_in_constant || ctx__constant_ref)
592
- end
593
-
594
- def visit_constant_id(ctx)
595
- ctx__SimpleId = ctx.SimpleId
596
-
597
- handle_simple_id(ctx__SimpleId)
598
- end
599
-
600
- def visit_constructed_types(ctx)
601
- ctx__enumeration_type = ctx.enumeration_type
602
- ctx__select_type = ctx.select_type
603
-
604
- visit_if(ctx__enumeration_type || ctx__select_type)
605
- end
606
-
607
- def visit_declaration(ctx)
608
- ctx__entity_decl = ctx.entity_decl
609
- ctx__function_decl = ctx.function_decl
610
- ctx__procedure_decl = ctx.procedure_decl
611
- ctx__subtype_constraint_decl = ctx.subtype_constraint_decl
612
- ctx__type_decl = ctx.type_decl
613
-
614
- visit_if(ctx__entity_decl || ctx__function_decl || ctx__procedure_decl || ctx__subtype_constraint_decl || ctx__type_decl)
615
- end
616
-
617
- def visit_derived_attr(ctx)
618
- ctx__attribute_decl = ctx.attribute_decl
619
- ctx__parameter_type = ctx.parameter_type
620
- ctx__expression = ctx.expression
621
-
622
- attribute = visit_if(ctx__attribute_decl)
623
- type = visit_if(ctx__parameter_type)
624
- expression = visit_if(ctx__expression)
625
-
626
- Model::Attribute.new({
627
- id: attribute.id,
628
- kind: Model::Attribute::DERIVED,
629
- supertype_attribute: attribute.supertype_attribute,
630
- type: type,
631
- expression: expression
632
- })
633
- end
634
-
635
- def visit_derive_clause(ctx)
636
- ctx__derived_attr = ctx.derived_attr
637
-
638
- visit_if_map(ctx__derived_attr)
639
- end
640
-
641
- def visit_domain_rule(ctx)
642
- ctx__rule_label_id = ctx.rule_label_id
643
- ctx__expression = ctx.expression
644
-
645
- id = visit_if(ctx__rule_label_id)
646
- expression = visit_if(ctx__expression)
647
-
648
- Model::Where.new({
649
- id: id,
650
- expression: expression
651
- })
652
- end
653
-
654
- def visit_element(ctx)
655
- ctx__expression = ctx.expression
656
- ctx__repetition = ctx.repetition
657
-
658
- if ctx__repetition
659
- expression = visit_if(ctx__expression)
660
- repetition = visit_if(ctx__repetition)
661
-
662
- Model::Expressions::AggregateItem.new({
663
- expression: expression,
664
- repetition: repetition
665
- })
666
- else
667
- visit_if(ctx__expression)
668
- end
669
- end
670
-
671
- def visit_entity_body(ctx)
672
- raise 'Invalid state'
673
- end
674
-
675
- def visit_entity_constructor(ctx)
676
- ctx__entity_ref = ctx.entity_ref
677
- ctx__expression = ctx.expression
678
-
679
- ref = visit_if(ctx__entity_ref)
680
- parameters = visit_if_map(ctx__expression)
681
-
682
- Model::Expressions::Call.new({
683
- ref: ref,
684
- parameters: parameters
685
- })
686
- end
687
-
688
- def visit_entity_decl(ctx)
689
- ctx__entity_head = ctx.entity_head
690
- ctx__entity_body = ctx.entity_body
691
- ctx__entity_head__entity_id = ctx__entity_head&.entity_id
692
- ctx__entity_head__subsuper = ctx__entity_head&.subsuper
693
- ctx__entity_head__subsuper__supertype_constraint = ctx__entity_head__subsuper&.supertype_constraint
694
- ctx__entity_head__subsuper__supertype_constraint__abstract_entity_declaration = ctx__entity_head__subsuper__supertype_constraint&.abstract_entity_declaration
695
- ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration = ctx__entity_head__subsuper__supertype_constraint&.abstract_supertype_declaration
696
- ctx__entity_head__subsuper__supertype_constraint__supertype_rule = ctx__entity_head__subsuper__supertype_constraint&.supertype_rule
697
- ctx__entity_head__subsuper__subtype_declaration = ctx__entity_head__subsuper&.subtype_declaration
698
- ctx__entity_body__explicit_attr = ctx__entity_body&.explicit_attr
699
- ctx__entity_body__derive_clause = ctx__entity_body&.derive_clause
700
- ctx__entity_body__inverse_clause = ctx__entity_body&.inverse_clause
701
- ctx__entity_body__unique_clause = ctx__entity_body&.unique_clause
702
- ctx__entity_body__where_clause = ctx__entity_body&.where_clause
703
-
704
- id = visit_if(ctx__entity_head__entity_id)
705
- abstract = !!(ctx__entity_head__subsuper__supertype_constraint__abstract_entity_declaration || ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration)
706
- supertype_expression = visit_if(ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration || ctx__entity_head__subsuper__supertype_constraint__supertype_rule)
707
- subtype_of = visit_if(ctx__entity_head__subsuper__subtype_declaration)
708
- attributes = [
709
- *visit_if_map_flatten(ctx__entity_body__explicit_attr),
710
- *visit_if(ctx__entity_body__derive_clause),
711
- *visit_if(ctx__entity_body__inverse_clause)
712
- ]
713
- unique = visit_if(ctx__entity_body__unique_clause)
714
- where = visit_if(ctx__entity_body__where_clause)
715
-
716
- Model::Entity.new({
717
- id: id,
718
- abstract: abstract,
719
- supertype_expression: supertype_expression,
720
- subtype_of: subtype_of,
721
- attributes: attributes,
722
- unique: unique,
723
- where: where
724
- })
725
- end
726
-
727
- def visit_entity_head(ctx)
728
- raise 'Invalid state'
729
- end
730
-
731
- def visit_entity_id(ctx)
732
- ctx__SimpleId = ctx.SimpleId
733
-
734
- handle_simple_id(ctx__SimpleId)
735
- end
736
-
737
- def visit_enumeration_extension(ctx)
738
- raise 'Invalid state'
739
- end
740
-
741
- def visit_enumeration_id(ctx)
742
- ctx__SimpleId = ctx.SimpleId
743
-
744
- handle_simple_id(ctx__SimpleId)
745
- end
746
-
747
- def visit_enumeration_items(ctx)
748
- ctx__enumeration_item = ctx.enumeration_item
749
-
750
- visit_if_map(ctx__enumeration_item)
751
- end
752
-
753
- def visit_enumeration_item(ctx)
754
- ctx__enumeration_id = ctx.enumeration_id
755
-
756
- id = visit_if(ctx__enumeration_id)
757
-
758
- Model::EnumerationItem.new({
759
- id: id
760
- })
761
- end
762
-
763
- def visit_enumeration_reference(ctx)
764
- ctx__type_ref = ctx.type_ref
765
- ctx__enumeration_ref = ctx.enumeration_ref
766
-
767
- if ctx__type_ref
768
- ref = visit_if(ctx__type_ref)
769
- attribute = visit_if(ctx__enumeration_ref)
770
-
771
- Model::Expressions::AttributeReference.new({
772
- ref: ref,
773
- attribute: attribute
774
- })
775
- else
776
- visit_if(ctx__enumeration_ref)
777
- end
778
- end
779
-
780
- def visit_enumeration_type(ctx)
781
- ctx__EXTENSIBLE = ctx.EXTENSIBLE
782
- ctx__enumeration_items = ctx.enumeration_items
783
- ctx__enumeration_extension = ctx.enumeration_extension
784
- ctx__enumeration_extension__type_ref = ctx__enumeration_extension&.type_ref
785
- ctx__enumeration_extension__enumeration_items = ctx__enumeration_extension&.enumeration_items
786
-
787
- extensible = !!ctx__EXTENSIBLE
788
- items = visit_if(ctx__enumeration_items)
789
- extension_type = visit_if(ctx__enumeration_extension__type_ref)
790
- extension_items = visit_if(ctx__enumeration_extension__enumeration_items)
791
-
792
- Model::Types::Enumeration.new({
793
- extensible: extensible,
794
- items: items,
795
- extension_type: extension_type,
796
- extension_items: extension_items
797
- })
798
- end
799
-
800
- def visit_escape_stmt(ctx)
801
- Model::Statements::Escape.new
802
- end
803
-
804
- def visit_explicit_attr(ctx)
805
- ctx__attribute_decl = ctx.attribute_decl
806
- ctx__OPTIONAL = ctx.OPTIONAL
807
- ctx__parameter_type = ctx.parameter_type
808
-
809
- attributes = visit_if_map(ctx__attribute_decl)
810
- optional = !!ctx__OPTIONAL
811
- type = visit_if(ctx__parameter_type)
812
-
813
- attributes.map do |attribute|
814
- Model::Attribute.new({
815
- id: attribute.id,
816
- kind: Model::Attribute::EXPLICIT,
817
- supertype_attribute: attribute.supertype_attribute,
818
- optional: optional,
819
- type: type
820
- })
821
- end
822
- end
823
-
824
- def visit_expression(ctx)
825
- ctx__simple_expression = ctx.simple_expression
826
- ctx__rel_op_extended = ctx.rel_op_extended
827
-
828
- if ctx__simple_expression.length == 2
829
- operator = visit_if(ctx__rel_op_extended)
830
- operand1 = visit_if(ctx__simple_expression[0])
831
- operand2 = visit_if(ctx__simple_expression[1])
832
-
833
- Model::Expressions::BinaryExpression.new({
834
- operator: operator,
835
- operand1: operand1,
836
- operand2: operand2
837
- })
838
- else
839
- visit_if(ctx__simple_expression[0])
840
- end
841
- end
842
-
843
- def visit_factor(ctx)
844
- ctx__simple_factor = ctx.simple_factor
845
-
846
- if ctx__simple_factor.length == 2
847
- operator = Model::Expressions::BinaryExpression::EXPONENTIATION
848
- operand1 = visit(ctx__simple_factor[0])
849
- operand2 = visit(ctx__simple_factor[1])
850
-
851
- Model::Expressions::BinaryExpression.new({
852
- operator: operator,
853
- operand1: operand1,
854
- operand2: operand2
855
- })
856
- elsif ctx__simple_factor.length == 1
857
- visit_if(ctx__simple_factor[0])
858
- else
859
- raise 'Invalid state'
860
- end
861
- end
862
-
863
- def visit_formal_parameter(ctx)
864
- ctx__parameter_id = ctx.parameter_id
865
- ctx__parameter_type = ctx.parameter_type
866
-
867
- ids = visit_if_map(ctx__parameter_id)
868
- type = visit_if(ctx__parameter_type)
869
-
870
- ids.map do |id|
871
- Model::Parameter.new({
872
- id: id,
873
- type: type
874
- })
875
- end
876
- end
877
-
878
- def visit_function_call(ctx)
879
- ctx__built_in_function = ctx.built_in_function
880
- ctx__function_ref = ctx.function_ref
881
- ctx__actual_parameter_list = ctx.actual_parameter_list
882
-
883
- ref = visit_if(ctx__built_in_function || ctx__function_ref)
884
- parameters = visit_if(ctx__actual_parameter_list)
885
-
886
- Model::Expressions::Call.new({
887
- ref: ref,
888
- parameters: parameters
889
- })
890
- end
891
-
892
- def visit_function_decl(ctx)
893
- ctx__function_head = ctx.function_head
894
- ctx__algorithm_head = ctx.algorithm_head
895
- ctx__stmt = ctx.stmt
896
- ctx__function_head__function_id = ctx__function_head&.function_id
897
- ctx__function_head__formal_parameter = ctx__function_head&.formal_parameter
898
- ctx__function_head__parameter_type = ctx__function_head&.parameter_type
899
- ctx__algorithm_head__declaration = ctx__algorithm_head&.declaration
900
- ctx__algorithm_head__constant_decl = ctx__algorithm_head&.constant_decl
901
- ctx__algorithm_head__local_decl = ctx__algorithm_head&.local_decl
902
-
903
- id = visit_if(ctx__function_head__function_id)
904
- parameters = visit_if_map_flatten(ctx__function_head__formal_parameter)
905
- return_type = visit_if(ctx__function_head__parameter_type)
906
- declarations = visit_if_map(ctx__algorithm_head__declaration)
907
- constants = visit_if(ctx__algorithm_head__constant_decl)
908
- variables = visit_if(ctx__algorithm_head__local_decl)
909
- statements = visit_if_map(ctx__stmt)
910
-
911
- Model::Function.new({
912
- id: id,
913
- parameters: parameters,
914
- return_type: return_type,
915
- declarations: declarations,
916
- constants: constants,
917
- variables: variables,
918
- statements: statements
919
- })
920
- end
921
-
922
- def visit_function_head(ctx)
923
- raise 'Invalid state'
924
- end
925
-
926
- def visit_function_id(ctx)
927
- ctx__SimpleId = ctx.SimpleId
928
-
929
- handle_simple_id(ctx__SimpleId)
930
- end
931
-
932
- def visit_generalized_types(ctx)
933
- ctx__aggregate_type = ctx.aggregate_type
934
- ctx__general_aggregation_types = ctx.general_aggregation_types
935
- ctx__generic_entity_type = ctx.generic_entity_type
936
- ctx__generic_type = ctx.generic_type
937
-
938
- visit_if(ctx__aggregate_type || ctx__general_aggregation_types || ctx__generic_entity_type || ctx__generic_type)
939
- end
940
-
941
- def visit_general_aggregation_types(ctx)
942
- ctx__general_array_type = ctx.general_array_type
943
- ctx__general_bag_type = ctx.general_bag_type
944
- ctx__general_list_type = ctx.general_list_type
945
- ctx__general_set_type = ctx.general_set_type
946
-
947
- visit_if(ctx__general_array_type || ctx__general_bag_type || ctx__general_list_type || ctx__general_set_type)
948
- end
949
-
950
- def visit_general_array_type(ctx)
951
- ctx__bound_spec = ctx.bound_spec
952
- ctx__OPTIONAL = ctx.OPTIONAL
953
- ctx__UNIQUE = ctx.UNIQUE
954
- ctx__parameter_type = ctx.parameter_type
955
- ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
956
- ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
957
-
958
- bound1 = visit_if(ctx__bound_spec__bound1)
959
- bound2 = visit_if(ctx__bound_spec__bound2)
960
- optional = !!ctx__OPTIONAL
961
- unique = !!ctx__UNIQUE
962
- base_type = visit_if(ctx__parameter_type)
963
-
964
- Model::Types::Array.new({
965
- bound1: bound1,
966
- bound2: bound2,
967
- optional: optional,
968
- unique: unique,
969
- base_type: base_type
970
- })
971
- end
972
-
973
- def visit_general_bag_type(ctx)
974
- ctx__bound_spec = ctx.bound_spec
975
- ctx__parameter_type = ctx.parameter_type
976
- ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
977
- ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
978
-
979
- bound1 = visit_if(ctx__bound_spec__bound1)
980
- bound2 = visit_if(ctx__bound_spec__bound2)
981
- base_type = visit_if(ctx__parameter_type)
982
-
983
- Model::Types::Bag.new({
984
- bound1: bound1,
985
- bound2: bound2,
986
- base_type: base_type
987
- })
988
- end
989
-
990
- def visit_general_list_type(ctx)
991
- ctx__bound_spec = ctx.bound_spec
992
- ctx__UNIQUE = ctx.UNIQUE
993
- ctx__parameter_type = ctx.parameter_type
994
- ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
995
- ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
996
-
997
- bound1 = visit_if(ctx__bound_spec__bound1)
998
- bound2 = visit_if(ctx__bound_spec__bound2)
999
- unique = !!ctx__UNIQUE
1000
- base_type = visit_if(ctx__parameter_type)
1001
-
1002
- Model::Types::List.new({
1003
- bound1: bound1,
1004
- bound2: bound2,
1005
- unique: unique,
1006
- base_type: base_type
1007
- })
1008
- end
1009
-
1010
- def visit_general_ref(ctx)
1011
- ctx__parameter_ref = ctx.parameter_ref
1012
- ctx__variable_id = ctx.variable_id
1013
-
1014
- visit_if(ctx__parameter_ref || ctx__variable_id)
1015
- end
1016
-
1017
- def visit_general_set_type(ctx)
1018
- ctx__bound_spec = ctx.bound_spec
1019
- ctx__parameter_type = ctx.parameter_type
1020
- ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
1021
- ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
1022
-
1023
- bound1 = visit_if(ctx__bound_spec__bound1)
1024
- bound2 = visit_if(ctx__bound_spec__bound2)
1025
- base_type = visit_if(ctx__parameter_type)
1026
-
1027
- Model::Types::Set.new({
1028
- bound1: bound1,
1029
- bound2: bound2,
1030
- base_type: base_type
1031
- })
1032
- end
1033
-
1034
- def visit_generic_entity_type(ctx)
1035
- ctx__type_label = ctx.type_label
1036
-
1037
- id = visit_if(ctx__type_label)
1038
-
1039
- Model::Types::GenericEntity.new({
1040
- id: id
1041
- })
1042
- end
1043
-
1044
- def visit_generic_type(ctx)
1045
- ctx__type_label = ctx.type_label
1046
-
1047
- id = visit_if(ctx__type_label)
1048
-
1049
- Model::Types::Generic.new({
1050
- id: id
1051
- })
1052
- end
1053
-
1054
- def visit_group_qualifier(ctx)
1055
- ctx__entity_ref = ctx.entity_ref
1056
-
1057
- entity = visit_if(ctx__entity_ref)
1058
-
1059
- Model::Expressions::GroupReference.new({
1060
- entity: entity
1061
- })
1062
- end
1063
-
1064
- def visit_group_reference(ctx)
1065
- raise 'Invalid state'
1066
- end
1067
-
1068
- def visit_if_stmt(ctx)
1069
- ctx__logical_expression = ctx.logical_expression
1070
- ctx__if_stmt_statements = ctx.if_stmt_statements
1071
- ctx__if_stmt_else_statements = ctx.if_stmt_else_statements
1072
-
1073
- expression = visit_if(ctx__logical_expression)
1074
- statements = visit_if(ctx__if_stmt_statements)
1075
- else_statements = visit_if(ctx__if_stmt_else_statements)
1076
-
1077
- Model::Statements::If.new({
1078
- expression: expression,
1079
- statements: statements,
1080
- else_statements: else_statements
1081
- })
1082
- end
1083
-
1084
- def visit_if_stmt_statements(ctx)
1085
- ctx__stmt = ctx.stmt
1086
-
1087
- visit_if_map(ctx__stmt)
1088
- end
1089
-
1090
- def visit_if_stmt_else_statements(ctx)
1091
- ctx__stmt = ctx.stmt
1092
-
1093
- visit_if_map(ctx__stmt)
1094
- end
1095
-
1096
- def visit_increment(ctx)
1097
- ctx__numeric_expression = ctx.numeric_expression
1098
-
1099
- visit_if(ctx__numeric_expression)
1100
- end
1101
-
1102
- def visit_increment_control(ctx)
1103
- raise 'Invalid state'
1104
- end
1105
-
1106
- def visit_index(ctx)
1107
- ctx__numeric_expression = ctx.numeric_expression
1108
-
1109
- visit_if(ctx__numeric_expression)
1110
- end
1111
-
1112
- def visit_index1(ctx)
1113
- ctx__index = ctx.index
1114
-
1115
- visit_if(ctx__index)
1116
- end
1117
-
1118
- def visit_index2(ctx)
1119
- ctx__index = ctx.index
1120
-
1121
- visit_if(ctx__index)
1122
- end
1123
-
1124
- def visit_index_qualifier(ctx)
1125
- ctx__index1 = ctx.index1
1126
- ctx__index2 = ctx.index2
1127
-
1128
- index1 = visit_if(ctx__index1)
1129
- index2 = visit_if(ctx__index2)
1130
-
1131
- Model::Expressions::IndexReference.new({
1132
- index1: index1,
1133
- index2: index2
1134
- })
1135
- end
1136
-
1137
- def visit_index_reference(ctx)
1138
- raise 'Invalid state'
1139
- end
1140
-
1141
- def visit_instantiable_type(ctx)
1142
- ctx__concrete_types = ctx.concrete_types
1143
- ctx__entity_ref = ctx.entity_ref
1144
-
1145
- visit_if(ctx__concrete_types || ctx__entity_ref)
1146
- end
1147
-
1148
- def visit_integer_type(ctx)
1149
- Model::Types::Integer.new
1150
- end
1151
-
1152
- def visit_interface_specification(ctx)
1153
- ctx__reference_clause = ctx.reference_clause
1154
- ctx__use_clause = ctx.use_clause
1155
-
1156
- visit_if(ctx__reference_clause || ctx__use_clause)
1157
- end
1158
-
1159
- def visit_interval(ctx)
1160
- ctx__interval_low = ctx.interval_low
1161
- ctx__interval_op = ctx.interval_op
1162
- ctx__interval_item = ctx.interval_item
1163
- ctx__interval_high = ctx.interval_high
1164
-
1165
- low = visit_if(ctx__interval_low)
1166
- operator1 = visit_if(ctx__interval_op[0])
1167
- item = visit_if(ctx__interval_item)
1168
- operator2 = visit_if(ctx__interval_op[1])
1169
- high = visit_if(ctx__interval_high)
1170
-
1171
- Model::Expressions::Interval.new({
1172
- low: low,
1173
- operator1: operator1,
1174
- item: item,
1175
- operator2: operator2,
1176
- high: high
1177
- })
1178
- end
1179
-
1180
- def visit_interval_high(ctx)
1181
- ctx__simple_expression = ctx.simple_expression
1182
-
1183
- visit_if(ctx__simple_expression)
1184
- end
1185
-
1186
- def visit_interval_item(ctx)
1187
- ctx__simple_expression = ctx.simple_expression
1188
-
1189
- visit_if(ctx__simple_expression)
1190
- end
1191
-
1192
- def visit_interval_low(ctx)
1193
- ctx__simple_expression = ctx.simple_expression
1194
-
1195
- visit_if(ctx__simple_expression)
1196
- end
1197
-
1198
- def visit_interval_op(ctx)
1199
- ctx__text = ctx.text
1200
- ctx__LESS_THAN = ctx__text == '<'
1201
- ctx__LESS_THAN_OR_EQUAL = ctx__text == '<='
1202
-
1203
- if ctx__LESS_THAN
1204
- Model::Expressions::BinaryExpression::LESS_THAN
1205
- elsif ctx__LESS_THAN_OR_EQUAL
1206
- Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL
1207
- else
1208
- raise 'Invalid state'
1209
- end
1210
- end
1211
-
1212
- def visit_inverse_attr(ctx)
1213
- ctx__attribute_decl = ctx.attribute_decl
1214
- ctx__inverse_attr_type = ctx.inverse_attr_type
1215
- ctx__entity_ref = ctx.entity_ref
1216
- ctx__attribute_ref = ctx.attribute_ref
1217
-
1218
- attribute = visit_if(ctx__attribute_decl)
1219
- type = visit_if(ctx__inverse_attr_type)
1220
- expression = if ctx__entity_ref
1221
- ref = visit(ctx__entity_ref)
1222
- attribute_ref = visit(ctx__attribute_ref)
1223
-
1224
- Model::Expressions::AttributeReference.new({
1225
- ref: ref,
1226
- attribute: attribute_ref
1227
- })
1228
- else
1229
- visit(ctx__attribute_ref)
1230
- end
1231
-
1232
- Model::Attribute.new({
1233
- id: attribute.id,
1234
- kind: Model::Attribute::INVERSE,
1235
- supertype_attribute: attribute.supertype_attribute,
1236
- type: type,
1237
- expression: expression
1238
- })
1239
- end
1240
-
1241
- def visit_inverse_attr_type(ctx)
1242
- ctx__SET = ctx.SET
1243
- ctx__BAG = ctx.BAG
1244
- ctx__bound_spec = ctx.bound_spec
1245
- ctx__entity_ref = ctx.entity_ref
1246
- ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
1247
- ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
1248
-
1249
- if ctx__SET
1250
- bound1 = visit_if(ctx__bound_spec__bound1)
1251
- bound2 = visit_if(ctx__bound_spec__bound2)
1252
- base_type = visit_if(ctx__entity_ref)
1253
-
1254
- Model::Types::Set.new({
1255
- bound1: bound1,
1256
- bound2: bound2,
1257
- base_type: base_type
1258
- })
1259
- elsif ctx__BAG
1260
- bound1 = visit_if(ctx__bound_spec__bound1)
1261
- bound2 = visit_if(ctx__bound_spec__bound2)
1262
- base_type = visit_if(ctx__entity_ref)
1263
-
1264
- Model::Types::Bag.new({
1265
- bound1: bound1,
1266
- bound2: bound2,
1267
- base_type: base_type
1268
- })
1269
- else
1270
- visit_if(ctx__entity_ref)
1271
- end
1272
- end
1273
-
1274
- def visit_inverse_clause(ctx)
1275
- ctx__inverse_attr = ctx.inverse_attr
1276
-
1277
- visit_if_map(ctx__inverse_attr)
1278
- end
1279
-
1280
- def visit_list_type(ctx)
1281
- ctx__bound_spec = ctx.bound_spec
1282
- ctx__UNIQUE = ctx.UNIQUE
1283
- ctx__instantiable_type = ctx.instantiable_type
1284
- ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
1285
- ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
1286
-
1287
- bound1 = visit_if(ctx__bound_spec__bound1)
1288
- bound2 = visit_if(ctx__bound_spec__bound2)
1289
- unique = !!ctx__UNIQUE
1290
- base_type = visit_if(ctx__instantiable_type)
1291
-
1292
- Model::Types::List.new({
1293
- bound1: bound1,
1294
- bound2: bound2,
1295
- unique: unique,
1296
- base_type: base_type
1297
- })
1298
- end
1299
-
1300
- def visit_literal(ctx)
1301
- ctx__BinaryLiteral = ctx.BinaryLiteral
1302
- ctx__IntegerLiteral = ctx.IntegerLiteral
1303
- ctx__logical_literal = ctx.logical_literal
1304
- ctx__RealLiteral = ctx.RealLiteral
1305
- ctx__string_literal = ctx.string_literal
1306
-
1307
- if ctx__BinaryLiteral
1308
- handle_binary_literal(ctx__BinaryLiteral)
1309
- elsif ctx__IntegerLiteral
1310
- handle_integer_literal(ctx__IntegerLiteral)
1311
- elsif ctx__logical_literal
1312
- visit(ctx__logical_literal)
1313
- elsif ctx__RealLiteral
1314
- handle_real_literal(ctx__RealLiteral)
1315
- elsif ctx__string_literal
1316
- visit(ctx__string_literal)
1317
- else
1318
- raise 'Invalid state'
1319
- end
1320
- end
1321
-
1322
- def visit_local_decl(ctx)
1323
- ctx__local_variable = ctx.local_variable
1324
-
1325
- visit_if_map_flatten(ctx__local_variable)
1326
- end
1327
-
1328
- def visit_local_variable(ctx)
1329
- ctx__variable_id = ctx.variable_id
1330
- ctx__parameter_type = ctx.parameter_type
1331
- ctx__expression = ctx.expression
1332
-
1333
- ids = visit_if_map(ctx__variable_id)
1334
- type = visit_if(ctx__parameter_type)
1335
- expression = visit_if(ctx__expression)
1336
-
1337
- ids.map do |id|
1338
- Model::Variable.new({
1339
- id: id,
1340
- type: type,
1341
- expression: expression
1342
- })
1343
- end
1344
- end
1345
-
1346
- def visit_logical_expression(ctx)
1347
- ctx__expression = ctx.expression
1348
-
1349
- visit_if(ctx__expression)
1350
- end
1351
-
1352
- def visit_logical_literal(ctx)
1353
- ctx__TRUE = ctx.TRUE
1354
- ctx__FALSE = ctx.FALSE
1355
- ctx__UNKNOWN = ctx.UNKNOWN
1356
-
1357
- value = if ctx__TRUE
1358
- Model::Literals::Logical::TRUE
1359
- elsif ctx__FALSE
1360
- Model::Literals::Logical::FALSE
1361
- elsif ctx__UNKNOWN
1362
- Model::Literals::Logical::UNKNOWN
1363
- else
1364
- raise 'Invalid state'
1365
- end
1366
-
1367
- Model::Literals::Logical.new({
1368
- value: value
1369
- })
1370
- end
1371
-
1372
- def visit_logical_type(ctx)
1373
- Model::Types::Logical.new
1374
- end
1375
-
1376
- def visit_multiplication_like_op(ctx)
1377
- ctx__text = ctx.text
1378
- ctx__MULTIPLICATION = ctx__text == '*'
1379
- ctx__REAL_DIVISION = ctx__text == '/'
1380
- ctx__INTEGER_DIVISION = ctx.DIV
1381
- ctx__MODULO = ctx.MOD
1382
- ctx__AND = ctx.AND
1383
- ctx__COMBINE = ctx__text == '||'
1384
-
1385
- if ctx__MULTIPLICATION
1386
- Model::Expressions::BinaryExpression::MULTIPLICATION
1387
- elsif ctx__REAL_DIVISION
1388
- Model::Expressions::BinaryExpression::REAL_DIVISION
1389
- elsif ctx__INTEGER_DIVISION
1390
- Model::Expressions::BinaryExpression::INTEGER_DIVISION
1391
- elsif ctx__MODULO
1392
- Model::Expressions::BinaryExpression::MODULO
1393
- elsif ctx__AND
1394
- Model::Expressions::BinaryExpression::AND
1395
- elsif ctx__COMBINE
1396
- Model::Expressions::BinaryExpression::COMBINE
1397
- else
1398
- raise 'Invalid state'
1399
- end
1400
- end
1401
-
1402
- def visit_named_types(ctx)
1403
- ctx__entity_ref = ctx.entity_ref
1404
- ctx__type_ref = ctx.type_ref
1405
-
1406
- visit_if(ctx__entity_ref || ctx__type_ref)
1407
- end
1408
-
1409
- def visit_named_type_or_rename(ctx)
1410
- ctx__named_types = ctx.named_types
1411
- ctx__entity_id = ctx.entity_id
1412
- ctx__type_id = ctx.type_id
1413
-
1414
- ref = visit_if(ctx__named_types)
1415
- id = visit_if(ctx__entity_id || ctx__type_id)
1416
-
1417
- if id
1418
- Model::RenamedRef.new({
1419
- ref: ref,
1420
- id: id
1421
- })
1422
- else
1423
- ref
1424
- end
1425
- end
1426
-
1427
- def visit_null_stmt(ctx)
1428
- Model::Statements::Null.new
1429
- end
1430
-
1431
- def visit_number_type(ctx)
1432
- Model::Types::Number.new
1433
- end
1434
-
1435
- def visit_numeric_expression(ctx)
1436
- ctx__simple_expression = ctx.simple_expression
1437
-
1438
- visit_if(ctx__simple_expression)
1439
- end
1440
-
1441
- def visit_one_of(ctx)
1442
- ctx__supertype_expression = ctx.supertype_expression
1443
-
1444
- ref = Model::Expressions::SimpleReference.new({ id: 'ONEOF' })
1445
- parameters = visit_if_map(ctx__supertype_expression)
1446
-
1447
- Model::Expressions::Call.new({
1448
- ref: ref,
1449
- parameters: parameters
1450
- })
1451
- end
1452
-
1453
- def visit_parameter(ctx)
1454
- ctx__expression = ctx.expression
1455
-
1456
- visit_if(ctx__expression)
1457
- end
1458
-
1459
- def visit_parameter_id(ctx)
1460
- ctx__SimpleId = ctx.SimpleId
1461
-
1462
- handle_simple_id(ctx__SimpleId)
1463
- end
1464
-
1465
- def visit_parameter_type(ctx)
1466
- ctx__generalized_types = ctx.generalized_types
1467
- ctx__named_types = ctx.named_types
1468
- ctx__simple_types = ctx.simple_types
1469
-
1470
- visit_if(ctx__generalized_types || ctx__named_types || ctx__simple_types)
1471
- end
1472
-
1473
- def visit_population(ctx)
1474
- ctx__entity_ref = ctx.entity_ref
1475
-
1476
- visit_if(ctx__entity_ref)
1477
- end
1478
-
1479
- def visit_precision_spec(ctx)
1480
- ctx__numeric_expression = ctx.numeric_expression
1481
-
1482
- visit_if(ctx__numeric_expression)
1483
- end
1484
-
1485
- def visit_primary(ctx)
1486
- ctx__literal = ctx.literal
1487
- ctx__qualifiable_factor = ctx.qualifiable_factor
1488
- ctx__qualifier = ctx.qualifier
1489
-
1490
- if ctx__literal
1491
- visit(ctx__literal)
1492
- elsif ctx__qualifiable_factor
1493
- handle_qualified_ref(visit(ctx__qualifiable_factor), ctx__qualifier)
1494
- else
1495
- raise 'Invalid state'
1496
- end
1497
- end
1498
-
1499
- def visit_procedure_call_stmt(ctx)
1500
- ctx__built_in_procedure = ctx.built_in_procedure
1501
- ctx__procedure_ref = ctx.procedure_ref
1502
- ctx__actual_parameter_list = ctx.actual_parameter_list
1503
-
1504
- ref = visit_if(ctx__built_in_procedure || ctx__procedure_ref)
1505
- parameters = visit_if(ctx__actual_parameter_list)
1506
-
1507
- Model::Statements::Call.new({
1508
- ref: ref,
1509
- parameters: parameters
1510
- })
1511
- end
1512
-
1513
- def visit_procedure_decl(ctx)
1514
- ctx__procedure_head = ctx.procedure_head
1515
- ctx__algorithm_head = ctx.algorithm_head
1516
- ctx__stmt = ctx.stmt
1517
- ctx__procedure_head__procedure_id = ctx__procedure_head&.procedure_id
1518
- ctx__procedure_head__procedure_head_parameter = ctx__procedure_head&.procedure_head_parameter
1519
- ctx__algorithm_head__declaration = ctx__algorithm_head&.declaration
1520
- ctx__algorithm_head__constant_decl = ctx__algorithm_head&.constant_decl
1521
- ctx__algorithm_head__local_decl = ctx__algorithm_head&.local_decl
1522
-
1523
- id = visit_if(ctx__procedure_head__procedure_id)
1524
- parameters = visit_if_map_flatten(ctx__procedure_head__procedure_head_parameter)
1525
- declarations = visit_if_map(ctx__algorithm_head__declaration)
1526
- constants = visit_if(ctx__algorithm_head__constant_decl)
1527
- variables = visit_if(ctx__algorithm_head__local_decl)
1528
- statements = visit_if_map(ctx__stmt)
1529
-
1530
- Model::Procedure.new({
1531
- id: id,
1532
- parameters: parameters,
1533
- declarations: declarations,
1534
- constants: constants,
1535
- variables: variables,
1536
- statements: statements
1537
- })
1538
- end
1539
-
1540
- def visit_procedure_head(ctx)
1541
- raise 'Invalid state'
1542
- end
1543
-
1544
- def visit_procedure_head_parameter(ctx)
1545
- ctx__formal_parameter = ctx.formal_parameter
1546
- ctx__VAR = ctx.VAR
1547
-
1548
- parameters = visit(ctx__formal_parameter)
1549
-
1550
- if ctx.VAR
1551
- parameters.map do |parameter|
1552
- Model::Parameter.new({
1553
- id: parameter.id,
1554
- var: true,
1555
- type: parameter.type
1556
- })
1557
- end
1558
- else
1559
- parameters
1560
- end
1561
- end
1562
-
1563
- def visit_procedure_id(ctx)
1564
- ctx__SimpleId = ctx.SimpleId
1565
-
1566
- handle_simple_id(ctx__SimpleId)
1567
- end
1568
-
1569
- def visit_qualifiable_factor(ctx)
1570
- ctx__attribute_ref = ctx.attribute_ref
1571
- ctx__constant_factor = ctx.constant_factor
1572
- ctx__function_call = ctx.function_call
1573
- ctx__general_ref = ctx.general_ref
1574
- ctx__population = ctx.population
1575
-
1576
- visit_if(ctx__attribute_ref || ctx__constant_factor || ctx__function_call || ctx__general_ref || ctx__population)
1577
- end
1578
-
1579
- def visit_qualified_attribute(ctx)
1580
- ctx__group_qualifier = ctx.group_qualifier
1581
- ctx__attribute_qualifier = ctx.attribute_qualifier
1582
-
1583
- id = 'SELF'
1584
- group_reference = visit_if(ctx__group_qualifier)
1585
- attribute_reference = visit_if(ctx__attribute_qualifier)
1586
-
1587
- Model::Expressions::AttributeReference.new({
1588
- ref: Model::Expressions::GroupReference.new({
1589
- ref: Model::Expressions::SimpleReference.new({
1590
- id: id
1591
- }),
1592
- entity: group_reference.entity
1593
- }),
1594
- attribute: attribute_reference.attribute
1595
- })
1596
- end
1597
-
1598
- def visit_qualifier(ctx)
1599
- ctx__attribute_qualifier = ctx.attribute_qualifier
1600
- ctx__group_qualifier = ctx.group_qualifier
1601
- ctx__index_qualifier = ctx.index_qualifier
1602
-
1603
- visit_if(ctx__attribute_qualifier || ctx__group_qualifier || ctx__index_qualifier)
1604
- end
1605
-
1606
- def visit_query_expression(ctx)
1607
- ctx__variable_id = ctx.variable_id
1608
- ctx__aggregate_source = ctx.aggregate_source
1609
- ctx__logical_expression = ctx.logical_expression
1610
-
1611
- id = visit_if(ctx__variable_id)
1612
- source = visit_if(ctx__aggregate_source)
1613
- expression = visit_if(ctx__logical_expression)
1614
-
1615
- Model::Expressions::QueryExpression.new({
1616
- id: id,
1617
- source: source,
1618
- expression: expression
1619
- })
1620
- end
1621
-
1622
- def visit_real_type(ctx)
1623
- ctx__precision_spec = ctx.precision_spec
1624
-
1625
- precision = visit_if(ctx__precision_spec)
1626
-
1627
- Model::Types::Real.new({
1628
- precision: precision
1629
- })
1630
- end
1631
-
1632
- def visit_redeclared_attribute(ctx)
1633
- raise 'Invalid state'
1634
- end
1635
-
1636
- def visit_referenced_attribute(ctx)
1637
- ctx__attribute_ref = ctx.attribute_ref
1638
- ctx__qualified_attribute = ctx.qualified_attribute
1639
-
1640
- visit_if(ctx__attribute_ref || ctx__qualified_attribute)
1641
- end
1642
-
1643
- def visit_reference_clause(ctx)
1644
- ctx__schema_ref = ctx.schema_ref
1645
- ctx__resource_or_rename = ctx.resource_or_rename
1646
-
1647
- schema = visit_if(ctx__schema_ref)
1648
- items = visit_if_map(ctx__resource_or_rename)
1649
-
1650
- Model::Interface.new({
1651
- kind: Model::Interface::REFERENCE,
1652
- schema: schema,
1653
- items: items
1654
- })
1655
- end
1656
-
1657
- def visit_rel_op(ctx)
1658
- ctx__text = ctx.text
1659
- ctx__LESS_THAN = ctx__text == '<'
1660
- ctx__GREATER_THAN = ctx__text == '>'
1661
- ctx__LESS_THAN_OR_EQUAL = ctx__text == '<='
1662
- ctx__GREATER_THAN_OR_EQUAL = ctx__text == '>='
1663
- ctx__NOT_EQUAL = ctx__text == '<>'
1664
- ctx__EQUAL = ctx__text == '='
1665
- ctx__INSTANCE_NOT_EQUAL = ctx__text == ':<>:'
1666
- ctx__INSTANCE_EQUAL = ctx__text == ':=:'
1667
-
1668
- if ctx__LESS_THAN
1669
- Model::Expressions::BinaryExpression::LESS_THAN
1670
- elsif ctx__GREATER_THAN
1671
- Model::Expressions::BinaryExpression::GREATER_THAN
1672
- elsif ctx__LESS_THAN_OR_EQUAL
1673
- Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL
1674
- elsif ctx__GREATER_THAN_OR_EQUAL
1675
- Model::Expressions::BinaryExpression::GREATER_THAN_OR_EQUAL
1676
- elsif ctx__NOT_EQUAL
1677
- Model::Expressions::BinaryExpression::NOT_EQUAL
1678
- elsif ctx__EQUAL
1679
- Model::Expressions::BinaryExpression::EQUAL
1680
- elsif ctx__INSTANCE_NOT_EQUAL
1681
- Model::Expressions::BinaryExpression::INSTANCE_NOT_EQUAL
1682
- elsif ctx__INSTANCE_EQUAL
1683
- Model::Expressions::BinaryExpression::INSTANCE_EQUAL
1684
- else
1685
- raise 'Invalid state'
1686
- end
1687
- end
1688
-
1689
- def visit_rel_op_extended(ctx)
1690
- ctx__rel_op = ctx.rel_op
1691
- ctx__IN = ctx.IN
1692
- ctx__LIKE = ctx.LIKE
1693
-
1694
- if ctx__rel_op
1695
- visit(ctx__rel_op)
1696
- elsif ctx__IN
1697
- Model::Expressions::BinaryExpression::IN
1698
- elsif ctx__LIKE
1699
- Model::Expressions::BinaryExpression::LIKE
1700
- else
1701
- raise 'Invalid state'
1702
- end
1703
- end
1704
-
1705
- def visit_rename_id(ctx)
1706
- ctx__constant_id = ctx.constant_id
1707
- ctx__entity_id = ctx.entity_id
1708
- ctx__function_id = ctx.function_id
1709
- ctx__procedure_id = ctx.procedure_id
1710
- ctx__type_id = ctx.type_id
1711
-
1712
- visit_if(ctx__constant_id || ctx__entity_id || ctx__function_id || ctx__procedure_id || ctx__type_id)
1713
- end
1714
-
1715
- def visit_repeat_control(ctx)
1716
- raise 'Invalid state'
1717
- end
1718
-
1719
- def visit_repeat_stmt(ctx)
1720
- ctx__repeat_control = ctx.repeat_control
1721
- ctx__stmt = ctx.stmt
1722
- ctx__repeat_control__increment_control = ctx__repeat_control&.increment_control
1723
- ctx__repeat_control__increment_control__variable_id = ctx__repeat_control__increment_control&.variable_id
1724
- ctx__repeat_control__increment_control__bound1 = ctx__repeat_control__increment_control&.bound1
1725
- ctx__repeat_control__increment_control__bound2 = ctx__repeat_control__increment_control&.bound2
1726
- ctx__repeat_control__increment_control__increment = ctx__repeat_control__increment_control&.increment
1727
- ctx__repeat_control__while_control = ctx__repeat_control&.while_control
1728
- ctx__repeat_control__until_control = ctx__repeat_control&.until_control
1729
-
1730
- id = visit_if(ctx__repeat_control__increment_control__variable_id)
1731
- bound1 = visit_if(ctx__repeat_control__increment_control__bound1)
1732
- bound2 = visit_if(ctx__repeat_control__increment_control__bound2)
1733
- increment = visit_if(ctx__repeat_control__increment_control__increment)
1734
- while_expression = visit_if(ctx__repeat_control__while_control)
1735
- until_expression = visit_if(ctx__repeat_control__until_control)
1736
- statements = visit_if_map(ctx__stmt)
1737
-
1738
- Model::Statements::Repeat.new({
1739
- id: id,
1740
- bound1: bound1,
1741
- bound2: bound2,
1742
- increment: increment,
1743
- while_expression: while_expression,
1744
- until_expression: until_expression,
1745
- statements: statements
1746
- })
1747
- end
1748
-
1749
- def visit_repetition(ctx)
1750
- ctx__numeric_expression = ctx.numeric_expression
1751
-
1752
- visit_if(ctx__numeric_expression)
1753
- end
1754
-
1755
- def visit_resource_or_rename(ctx)
1756
- ctx__resource_ref = ctx.resource_ref
1757
- ctx__rename_id = ctx.rename_id
1758
-
1759
- if ctx__resource_ref
1760
- if ctx__rename_id
1761
- ref = visit(ctx__resource_ref)
1762
- id = visit(ctx__rename_id)
1763
-
1764
- Model::RenamedRef.new({
1765
- ref: ref,
1766
- id: id
1767
- })
1768
- else
1769
- visit(ctx__resource_ref)
1770
- end
1771
- else
1772
- raise 'Invalid state'
1773
- end
1774
- end
1775
-
1776
- def visit_resource_ref(ctx)
1777
- ctx__constant_ref = ctx.constant_ref
1778
- ctx__entity_ref = ctx.entity_ref
1779
- ctx__function_ref = ctx.function_ref
1780
- ctx__procedure_ref = ctx.procedure_ref
1781
- ctx__type_ref = ctx.type_ref
1782
-
1783
- visit_if(ctx__constant_ref || ctx__entity_ref || ctx__function_ref || ctx__procedure_ref || ctx__type_ref)
1784
- end
1785
-
1786
- def visit_return_stmt(ctx)
1787
- ctx__expression = ctx.expression
1788
-
1789
- expression = visit_if(ctx__expression)
1790
-
1791
- Model::Statements::Return.new({
1792
- expression: expression
1793
- })
1794
- end
1795
-
1796
- def visit_rule_decl(ctx)
1797
- ctx__rule_head = ctx.rule_head
1798
- ctx__algorithm_head = ctx.algorithm_head
1799
- ctx__stmt = ctx.stmt
1800
- ctx__where_clause = ctx.where_clause
1801
- ctx__rule_head__rule_id = ctx__rule_head&.rule_id
1802
- ctx__rule_head__entity_ref = ctx__rule_head&.entity_ref
1803
- ctx__algorithm_head__declaration = ctx__algorithm_head&.declaration
1804
- ctx__algorithm_head__constant_decl = ctx__algorithm_head&.constant_decl
1805
- ctx__algorithm_head__local_decl = ctx__algorithm_head&.local_decl
1806
-
1807
- id = visit_if(ctx__rule_head__rule_id)
1808
- applies_to = visit_if_map(ctx__rule_head__entity_ref)
1809
- declarations = visit_if_map(ctx__algorithm_head__declaration)
1810
- constants = visit_if(ctx__algorithm_head__constant_decl)
1811
- variables = visit_if(ctx__algorithm_head__local_decl)
1812
- statements = visit_if_map(ctx__stmt)
1813
- where = visit_if(ctx__where_clause)
1814
-
1815
- Model::Rule.new({
1816
- id: id,
1817
- applies_to: applies_to,
1818
- declarations: declarations,
1819
- constants: constants,
1820
- variables: variables,
1821
- statements: statements,
1822
- where: where
1823
- })
1824
- end
1825
-
1826
- def visit_rule_head(ctx)
1827
- raise 'Invalid state'
1828
- end
1829
-
1830
- def visit_rule_id(ctx)
1831
- ctx__SimpleId = ctx.SimpleId
1832
-
1833
- handle_simple_id(ctx__SimpleId)
1834
- end
1835
-
1836
- def visit_rule_label_id(ctx)
1837
- ctx__SimpleId = ctx.SimpleId
1838
-
1839
- handle_simple_id(ctx__SimpleId)
1840
- end
1841
-
1842
- def visit_schema_body(ctx)
1843
- raise 'Invalid state'
1844
- end
1845
-
1846
- def visit_schema_body_declaration(ctx)
1847
- ctx__declaration = ctx.declaration
1848
- ctx__rule_decl = ctx.rule_decl
1849
-
1850
- visit_if(ctx__declaration || ctx__rule_decl)
1851
- end
1852
-
1853
- def visit_schema_decl(ctx)
1854
- ctx__schema_id = ctx.schema_id
1855
- ctx__schema_version_id = ctx.schema_version_id
1856
- ctx__schema_body = ctx.schema_body
1857
- ctx__schema_body__interface_specification = ctx__schema_body&.interface_specification
1858
- ctx__schema_body__constant_decl = ctx__schema_body&.constant_decl
1859
- ctx__schema_body__schema_body_declaration = ctx__schema_body&.schema_body_declaration
1860
-
1861
- id = visit_if(ctx__schema_id)
1862
- version = visit_if(ctx__schema_version_id)
1863
- interfaces = visit_if_map(ctx__schema_body__interface_specification)
1864
- constants = visit_if(ctx__schema_body__constant_decl)
1865
- declarations = visit_if_map(ctx__schema_body__schema_body_declaration)
1866
-
1867
- Model::Schema.new({
1868
- id: id,
1869
- version: version,
1870
- interfaces: interfaces,
1871
- constants: constants,
1872
- declarations: declarations
1873
- })
1874
- end
1875
-
1876
- def visit_schema_id(ctx)
1877
- ctx__SimpleId = ctx.SimpleId
1878
-
1879
- handle_simple_id(ctx__SimpleId)
1880
- end
1881
-
1882
- def visit_schema_version_id(ctx)
1883
- ctx__string_literal = ctx.string_literal
1884
-
1885
- visit_if(ctx__string_literal)
1886
- end
1887
-
1888
- def visit_selector(ctx)
1889
- raise 'Invalid state'
1890
- end
1891
-
1892
- def visit_select_extension(ctx)
1893
- ctx__named_types = ctx.named_types
1894
-
1895
- visit_if_map(ctx__named_types)
1896
- end
1897
-
1898
- def visit_select_list(ctx)
1899
- ctx__named_types = ctx.named_types
1900
-
1901
- visit_if_map(ctx__named_types)
1902
- end
1903
-
1904
- def visit_select_type(ctx)
1905
- ctx__EXTENSIBLE = ctx.EXTENSIBLE
1906
- ctx__GENERIC_ENTITY = ctx.GENERIC_ENTITY
1907
- ctx__select_list = ctx.select_list
1908
- ctx__select_extension = ctx.select_extension
1909
- ctx__select_extension__type_ref = ctx.select_extension&.type_ref
1910
- ctx__select_extension__select_list = ctx__select_extension&.select_list
1911
-
1912
- extensible = !!ctx__EXTENSIBLE
1913
- generic_entity = !!ctx__GENERIC_ENTITY
1914
- items = visit_if(ctx__select_list)
1915
- extension_type = visit_if(ctx__select_extension__type_ref)
1916
- extension_items = visit_if(ctx__select_extension__select_list)
1917
-
1918
- Model::Types::Select.new({
1919
- extensible: extensible,
1920
- generic_entity: generic_entity,
1921
- items: items,
1922
- extension_type: extension_type,
1923
- extension_items: extension_items
1924
- })
1925
- end
1926
-
1927
- def visit_set_type(ctx)
1928
- ctx__bound_spec = ctx.bound_spec
1929
- ctx__instantiable_type = ctx.instantiable_type
1930
- ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
1931
- ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
1932
-
1933
- bound1 = visit_if(ctx__bound_spec__bound1)
1934
- bound2 = visit_if(ctx__bound_spec__bound2)
1935
- base_type = visit_if(ctx__instantiable_type)
1936
-
1937
- Model::Types::Set.new({
1938
- bound1: bound1,
1939
- bound2: bound2,
1940
- base_type: base_type
1941
- })
1942
- end
1943
-
1944
- def visit_simple_expression(ctx)
1945
- ctx__term = ctx.term
1946
- ctx__add_like_op = ctx.add_like_op
1947
-
1948
- if ctx__term
1949
- if ctx__term.length >= 2
1950
- if ctx__add_like_op and ctx__add_like_op.length == ctx__term.length - 1
1951
- operands = ctx__term.map(&self.method(:visit))
1952
- operators = ctx__add_like_op.map(&self.method(:visit))
1953
-
1954
- handle_binary_expression(operands, operators)
1955
- else
1956
- raise 'Invalid state'
1957
- end
1958
- elsif ctx__term.length == 1
1959
- visit(ctx__term[0])
1960
- else
1961
- raise 'Invalid state'
1962
- end
1963
- end
1964
- end
1965
-
1966
- def visit_simple_factor(ctx)
1967
- ctx__aggregate_initializer = ctx.aggregate_initializer
1968
- ctx__entity_constructor = ctx.entity_constructor
1969
- ctx__enumeration_reference = ctx.enumeration_reference
1970
- ctx__interval = ctx.interval
1971
- ctx__query_expression = ctx.query_expression
1972
- ctx__simple_factor_expression = ctx.simple_factor_expression
1973
- ctx__simple_factor_unary_expression = ctx.simple_factor_unary_expression
1974
-
1975
- visit_if(ctx__aggregate_initializer || ctx__entity_constructor || ctx__enumeration_reference || ctx__interval || ctx__query_expression || ctx__simple_factor_expression || ctx__simple_factor_unary_expression)
1976
- end
1977
-
1978
- def visit_simple_factor_expression(ctx)
1979
- ctx__expression = ctx.expression
1980
- ctx__primary = ctx.primary
1981
-
1982
- visit_if(ctx__expression || ctx__primary)
1983
- end
1984
-
1985
- def visit_simple_factor_unary_expression(ctx)
1986
- ctx__unary_op = ctx.unary_op
1987
- ctx__simple_factor_expression = ctx.simple_factor_expression
1988
-
1989
- operator = visit_if(ctx__unary_op)
1990
- operand = visit_if(ctx__simple_factor_expression)
1991
-
1992
- Model::Expressions::UnaryExpression.new({
1993
- operator: operator,
1994
- operand: operand
1995
- })
1996
- end
1997
-
1998
- def visit_simple_types(ctx)
1999
- ctx__binary_type = ctx.binary_type
2000
- ctx__boolean_type = ctx.boolean_type
2001
- ctx__integer_type = ctx.integer_type
2002
- ctx__logical_type = ctx.logical_type
2003
- ctx__number_type = ctx.number_type
2004
- ctx__real_type = ctx.real_type
2005
- ctx__string_type = ctx.string_type
2006
-
2007
- visit_if(ctx__binary_type || ctx__boolean_type || ctx__integer_type || ctx__logical_type || ctx__number_type || ctx__real_type || ctx__string_type)
2008
- end
2009
-
2010
- def visit_skip_stmt(ctx)
2011
- Model::Statements::Skip.new
2012
- end
2013
-
2014
- def visit_stmt(ctx)
2015
- ctx__alias_stmt = ctx.alias_stmt
2016
- ctx__assignment_stmt = ctx.assignment_stmt
2017
- ctx__case_stmt = ctx.case_stmt
2018
- ctx__compound_stmt = ctx.compound_stmt
2019
- ctx__escape_stmt = ctx.escape_stmt
2020
- ctx__if_stmt = ctx.if_stmt
2021
- ctx__null_stmt = ctx.null_stmt
2022
- ctx__procedure_call_stmt = ctx.procedure_call_stmt
2023
- ctx__repeat_stmt = ctx.repeat_stmt
2024
- ctx__return_stmt = ctx.return_stmt
2025
- ctx__skip_stmt = ctx.skip_stmt
2026
-
2027
- visit_if(ctx__alias_stmt || ctx__assignment_stmt || ctx__case_stmt || ctx__compound_stmt || ctx__escape_stmt || ctx__if_stmt || ctx__null_stmt || ctx__procedure_call_stmt || ctx__repeat_stmt || ctx__return_stmt || ctx__skip_stmt)
2028
- end
2029
-
2030
- def visit_string_literal(ctx)
2031
- ctx__SimpleStringLiteral = ctx.SimpleStringLiteral
2032
- ctx__EncodedStringLiteral = ctx.EncodedStringLiteral
2033
-
2034
- if ctx__SimpleStringLiteral
2035
- handle_simple_string_literal(ctx__SimpleStringLiteral)
2036
- elsif ctx__EncodedStringLiteral
2037
- handle_encoded_string_literal(ctx__EncodedStringLiteral)
2038
- else
2039
- raise 'Invalid state'
2040
- end
2041
- end
2042
-
2043
- def visit_string_type(ctx)
2044
- ctx__width_spec = ctx.width_spec
2045
- ctx__width_spec__width = ctx__width_spec&.width
2046
- ctx__width_spec__FIXED = ctx__width_spec&.FIXED
2047
-
2048
- width = visit_if(ctx__width_spec__width)
2049
- fixed = !!ctx__width_spec__FIXED
2050
-
2051
- Model::Types::String.new({
2052
- width: width,
2053
- fixed: fixed
2054
- })
2055
- end
2056
-
2057
- def visit_subsuper(ctx)
2058
- raise 'Invalid state'
2059
- end
2060
-
2061
- def visit_subtype_constraint(ctx)
2062
- ctx__supertype_expression = ctx.supertype_expression
2063
-
2064
- visit_if(ctx__supertype_expression)
2065
- end
2066
-
2067
- def visit_subtype_constraint_body(ctx)
2068
- raise 'Invalid state'
2069
- end
2070
-
2071
- def visit_subtype_constraint_decl(ctx)
2072
- ctx__subtype_constraint_head = ctx.subtype_constraint_head
2073
- ctx__subtype_constraint_body = ctx.subtype_constraint_body
2074
- ctx__subtype_constraint_head__subtype_constraint_id = ctx__subtype_constraint_head&.subtype_constraint_id
2075
- ctx__subtype_constraint_head__entity_ref = ctx__subtype_constraint_head&.entity_ref
2076
- ctx__subtype_constraint_body__abstract_supertype = ctx__subtype_constraint_body&.abstract_supertype
2077
- ctx__subtype_constraint_body__total_over = ctx__subtype_constraint_body&.total_over
2078
- ctx__subtype_constraint_body__supertype_expression = ctx__subtype_constraint_body&.supertype_expression
2079
-
2080
- id = visit_if(ctx__subtype_constraint_head__subtype_constraint_id)
2081
- applies_to = visit_if(ctx__subtype_constraint_head__entity_ref)
2082
- abstract = !!ctx__subtype_constraint_body__abstract_supertype
2083
- total_over = visit_if(ctx__subtype_constraint_body__total_over)
2084
- supertype_expression = visit_if(ctx__subtype_constraint_body__supertype_expression)
2085
-
2086
- Model::SubtypeConstraint.new({
2087
- id: id,
2088
- applies_to: applies_to,
2089
- abstract: abstract,
2090
- total_over: total_over,
2091
- supertype_expression: supertype_expression
2092
- })
2093
- end
2094
-
2095
- def visit_subtype_constraint_head(ctx)
2096
- raise 'Invalid state'
2097
- end
2098
-
2099
- def visit_subtype_constraint_id(ctx)
2100
- ctx__SimpleId = ctx.SimpleId
2101
-
2102
- handle_simple_id(ctx__SimpleId)
2103
- end
2104
-
2105
- def visit_subtype_declaration(ctx)
2106
- ctx__entity_ref = ctx.entity_ref
2107
-
2108
- visit_if_map(ctx__entity_ref)
2109
- end
2110
-
2111
- def visit_supertype_constraint(ctx)
2112
- raise 'Invalid state'
2113
- end
2114
-
2115
- def visit_supertype_expression(ctx)
2116
- ctx__supertype_factor = ctx.supertype_factor
2117
- ctx__ANDOR = ctx.ANDOR
2118
-
2119
- if ctx__supertype_factor
2120
- if ctx__supertype_factor.length >= 2
2121
- if ctx__ANDOR and ctx__ANDOR.length == ctx__supertype_factor.length - 1
2122
- operands = ctx__supertype_factor.map(&self.method(:visit))
2123
- operators = ctx__ANDOR.map{Model::Expressions::BinaryExpression::ANDOR}
2124
-
2125
- handle_binary_expression(operands, operators)
2126
- else
2127
- raise 'Invalid state'
2128
- end
2129
- elsif ctx__supertype_factor.length == 1
2130
- visit(ctx__supertype_factor[0])
2131
- else
2132
- raise 'Invalid state'
2133
- end
2134
- end
2135
- end
2136
-
2137
- def visit_supertype_factor(ctx)
2138
- ctx__supertype_term = ctx.supertype_term
2139
- ctx__AND = ctx.AND
2140
-
2141
- if ctx__supertype_term
2142
- if ctx__supertype_term.length >= 2
2143
- if ctx__AND and ctx__AND.length == ctx__supertype_term.length - 1
2144
- operands = ctx__supertype_term.map(&self.method(:visit))
2145
- operators = ctx__AND.map{Model::Expressions::BinaryExpression::AND}
2146
-
2147
- handle_binary_expression(operands, operators)
2148
- else
2149
- raise 'Invalid state'
2150
- end
2151
- elsif ctx__supertype_term.length == 1
2152
- visit(ctx__supertype_term[0])
2153
- else
2154
- raise 'Invalid state'
2155
- end
2156
- end
2157
- end
2158
-
2159
- def visit_supertype_rule(ctx)
2160
- ctx__subtype_constraint = ctx.subtype_constraint
2161
-
2162
- visit_if(ctx__subtype_constraint)
2163
- end
2164
-
2165
- def visit_supertype_term(ctx)
2166
- ctx__entity_ref = ctx.entity_ref
2167
- ctx__one_of = ctx.one_of
2168
- ctx__supertype_expression = ctx.supertype_expression
2169
-
2170
- visit_if(ctx__entity_ref || ctx__one_of || ctx__supertype_expression)
2171
- end
2172
-
2173
- def visit_syntax(ctx)
2174
- ctx__schema_decl = ctx.schema_decl
2175
-
2176
- schemas = visit_if_map(ctx__schema_decl)
2177
-
2178
- Model::Repository.new({
2179
- schemas: schemas
2180
- })
2181
- end
2182
-
2183
- def visit_term(ctx)
2184
- ctx__factor = ctx.factor
2185
- ctx__multiplication_like_op = ctx.multiplication_like_op
2186
-
2187
- if ctx__factor
2188
- if ctx__factor.length >= 2
2189
- if ctx__multiplication_like_op and ctx__multiplication_like_op.length == ctx__factor.length - 1
2190
- operands = ctx__factor.map(&self.method(:visit))
2191
- operators = ctx__multiplication_like_op.map(&self.method(:visit))
2192
-
2193
- handle_binary_expression(operands, operators)
2194
- else
2195
- raise 'Invalid state'
2196
- end
2197
- elsif ctx__factor.length == 1
2198
- visit(ctx__factor[0])
2199
- else
2200
- raise 'Invalid state'
2201
- end
2202
- end
2203
- end
2204
-
2205
- def visit_total_over(ctx)
2206
- ctx__entity_ref = ctx.entity_ref
2207
-
2208
- visit_if_map(ctx__entity_ref)
2209
- end
2210
-
2211
- def visit_type_decl(ctx)
2212
- ctx__type_id = ctx.type_id
2213
- ctx__underlying_type = ctx.underlying_type
2214
- ctx__where_clause = ctx.where_clause
2215
-
2216
- id = visit_if(ctx__type_id)
2217
- type = visit_if(ctx__underlying_type)
2218
- where = visit_if(ctx__where_clause)
2219
-
2220
- Model::Type.new({
2221
- id: id,
2222
- type: type,
2223
- where: where
2224
- })
2225
- end
2226
-
2227
- def visit_type_id(ctx)
2228
- ctx__SimpleId = ctx.SimpleId
2229
-
2230
- handle_simple_id(ctx__SimpleId)
2231
- end
2232
-
2233
- def visit_type_label(ctx)
2234
- ctx__type_label_id = ctx.type_label_id
2235
- ctx__type_label_ref = ctx.type_label_ref
2236
-
2237
- visit_if(ctx__type_label_id || ctx__type_label_ref)
2238
- end
2239
-
2240
- def visit_type_label_id(ctx)
2241
- ctx__SimpleId = ctx.SimpleId
2242
-
2243
- handle_simple_id(ctx__SimpleId)
2244
- end
2245
-
2246
- def visit_unary_op(ctx)
2247
- ctx__text = ctx.text
2248
- ctx__PLUS = ctx__text == '+'
2249
- ctx__MINUS = ctx__text == '-'
2250
- ctx__NOT = ctx.NOT
2251
-
2252
- if ctx__PLUS
2253
- Model::Expressions::UnaryExpression::PLUS
2254
- elsif ctx__MINUS
2255
- Model::Expressions::UnaryExpression::MINUS
2256
- elsif ctx__NOT
2257
- Model::Expressions::UnaryExpression::NOT
2258
- else
2259
- raise 'Invalid state'
2260
- end
2261
- end
2262
-
2263
- def visit_underlying_type(ctx)
2264
- ctx__concrete_types = ctx.concrete_types
2265
- ctx__constructed_types = ctx.constructed_types
2266
-
2267
- visit_if(ctx__concrete_types || ctx__constructed_types)
2268
- end
2269
-
2270
- def visit_unique_clause(ctx)
2271
- ctx__unique_rule = ctx.unique_rule
2272
-
2273
- visit_if_map(ctx__unique_rule)
2274
- end
2275
-
2276
- def visit_unique_rule(ctx)
2277
- ctx__rule_label_id = ctx.rule_label_id
2278
- ctx__referenced_attribute = ctx.referenced_attribute
2279
-
2280
- id = visit_if(ctx__rule_label_id)
2281
- attributes = visit_if_map(ctx__referenced_attribute)
2282
-
2283
- Model::Unique.new({
2284
- id: id,
2285
- attributes: attributes
2286
- })
2287
- end
2288
-
2289
- def visit_until_control(ctx)
2290
- ctx__logical_expression = ctx.logical_expression
2291
-
2292
- visit_if(ctx__logical_expression)
2293
- end
2294
-
2295
- def visit_use_clause(ctx)
2296
- ctx__schema_ref = ctx.schema_ref
2297
- ctx__named_type_or_rename = ctx.named_type_or_rename
2298
-
2299
- schema = visit_if(ctx__schema_ref)
2300
- items = visit_if_map(ctx__named_type_or_rename)
2301
-
2302
- Model::Interface.new({
2303
- kind: Model::Interface::USE,
2304
- schema: schema,
2305
- items: items
2306
- })
2307
- end
2308
-
2309
- def visit_variable_id(ctx)
2310
- ctx__SimpleId = ctx.SimpleId
2311
-
2312
- handle_simple_id(ctx__SimpleId)
2313
- end
2314
-
2315
- def visit_where_clause(ctx)
2316
- ctx__domain_rule = ctx.domain_rule
2317
-
2318
- visit_if_map(ctx__domain_rule)
2319
- end
2320
-
2321
- def visit_while_control(ctx)
2322
- ctx__logical_expression = ctx.logical_expression
2323
-
2324
- visit_if(ctx__logical_expression)
2325
- end
2326
-
2327
- def visit_width(ctx)
2328
- ctx__numeric_expression = ctx.numeric_expression
2329
-
2330
- visit_if(ctx__numeric_expression)
2331
- end
2332
-
2333
- def visit_width_spec(ctx)
2334
- raise 'Invalid state'
2335
- end
2336
-
2337
- private
2338
-
2339
- def handle_binary_expression(operands, operators)
2340
- if operands.length != operators.length + 1
2341
- raise 'Invalid state'
2342
- end
2343
-
2344
- expression = Model::Expressions::BinaryExpression.new({
2345
- operator: operators[0],
2346
- operand1: operands[0],
2347
- operand2: operands[1]
2348
- })
2349
- operators[1..(operators.length - 1)].each_with_index do |operator, i|
2350
- expression = Model::Expressions::BinaryExpression.new({
2351
- operator: operator,
2352
- operand1: expression,
2353
- operand2: operands[i + 2]
2354
- })
2355
- end
2356
- expression
2357
- end
2358
-
2359
- def handle_qualified_ref(ref, qualifiers)
2360
- qualifiers.reduce(ref) do |ref, ctx|
2361
- ctx__attribute_qualifier = ctx.attribute_qualifier
2362
- ctx__group_qualifier = ctx.group_qualifier
2363
- ctx__index_qualifier = ctx.index_qualifier
2364
-
2365
- if ctx__attribute_qualifier
2366
- attribute_reference = visit_if(ctx__attribute_qualifier)
2367
-
2368
- Model::Expressions::AttributeReference.new({
2369
- ref: ref,
2370
- attribute: attribute_reference.attribute
2371
- })
2372
- elsif ctx__group_qualifier
2373
- group_reference = visit_if(ctx__group_qualifier)
2374
-
2375
- Model::Expressions::GroupReference.new({
2376
- ref: ref,
2377
- entity: group_reference.entity
2378
- })
2379
- elsif ctx__index_qualifier
2380
- index_reference = visit_if(ctx__index_qualifier)
2381
-
2382
- Model::Expressions::IndexReference.new({
2383
- ref: ref,
2384
- index1: index_reference.index1,
2385
- index2: index_reference.index2
2386
- })
2387
- else
2388
- raise 'Invalid state'
2389
- end
2390
- end
2391
- end
2392
-
2393
- def handle_binary_literal(ctx)
2394
- ctx__text = ctx.text
2395
-
2396
- value = ctx__text[1..(ctx__text.length - 1)]
2397
-
2398
- Model::Literals::Binary.new({
2399
- value: value
2400
- })
2401
- end
2402
-
2403
- def handle_integer_literal(ctx)
2404
- ctx__text = ctx.text
2405
-
2406
- value = ctx__text
2407
-
2408
- Model::Literals::Integer.new({
2409
- value: value
2410
- })
2411
- end
2412
-
2413
- def handle_real_literal(ctx)
2414
- ctx__text = ctx.text
2415
-
2416
- value = ctx__text
2417
-
2418
- Model::Literals::Real.new({
2419
- value: value
2420
- })
2421
- end
2422
-
2423
- def handle_simple_id(ctx)
2424
- ctx__text = ctx.text
2425
-
2426
- ctx__text
2427
- end
2428
-
2429
- def handle_simple_string_literal(ctx)
2430
- ctx__text = ctx.text
2431
-
2432
- value = ctx__text[1..(ctx__text.length - 2)]
2433
-
2434
- Model::Literals::String.new({
2435
- value: value
2436
- })
2437
- end
2438
-
2439
- def handle_encoded_string_literal(ctx)
2440
- ctx__text = ctx.text
2441
-
2442
- value = ctx__text[1..(ctx__text.length - 2)]
2443
-
2444
- Model::Literals::String.new({
2445
- value: value,
2446
- encoded: true
2447
- })
2448
- end
2449
- end
2450
- end
1
+ begin
2
+ RUBY_VERSION =~ /(\d+\.\d+)/
3
+ require_relative "#{$1}/express_parser"
4
+ rescue LoadError
5
+ require_relative "express_parser"
6
+ end
7
+ require "expressir/model"
8
+
9
+ # static shorthands are unwrapped
10
+ # - entity attributes, function/procedure parameters, local variables
11
+ #
12
+ # reference type is not recognized
13
+ # see note in A.1.5 Interpreted identifiers
14
+ # > It is expected that identifiers matching these syntax rules are known to an implementation.
15
+ # > How the implementation obtains this information is of no concern to the definition of the language. One
16
+ # > method of gaining this information is multi-pass parsing: the first pass collects the identifiers from their
17
+ # > declarations, so that subsequent passes are then able to distinguish a veriable_ref from a function_ref,
18
+ # > for example.
19
+ #
20
+ # - xxxRef - merged to SimpleReference
21
+ # - entityConstructor, functionCall - merged to Call
22
+ #
23
+ # difference between generalized and instantiable types is not recognized
24
+ # see note in 8.6.2 Parameter data types
25
+ # > A syntactic construct such as ARRAY[1:3] OF REAL satisfies two syntactic productions —
26
+ # > aggregation_type and general_aggregation_type. It is considered to be instantiable no matter which
27
+ # > production it is required to satisfy in the syntax.
28
+
29
+ module Expressir
30
+ module ExpressExp
31
+ class Visitor < ::ExpressParser::Visitor
32
+ REMARK_CHANNEL = 2
33
+
34
+ def initialize(tokens)
35
+ @tokens = tokens
36
+ @attached_remarks = Set.new
37
+
38
+ super()
39
+ end
40
+
41
+ def visit(ctx)
42
+ result = super(ctx)
43
+ attach_source(ctx, result)
44
+ attach_parent(ctx, result)
45
+ attach_remarks(ctx, result)
46
+ result
47
+ end
48
+
49
+ def visit_if(ctx)
50
+ visit(ctx) if ctx
51
+ end
52
+
53
+ def visit_if_map(ctx)
54
+ ctx.map{|ctx2| visit(ctx2)} if ctx
55
+ end
56
+
57
+ def visit_if_map_flatten(ctx)
58
+ ctx.map{|ctx2| visit(ctx2)}.flatten if ctx
59
+ end
60
+
61
+ def attach_source(ctx, node)
62
+ if node.class.method_defined? :source
63
+ start_index, stop_index = [ctx.start.token_index, ctx.stop.token_index]
64
+ node.source = @tokens[start_index..stop_index].map{|x| x.text}.join('').force_encoding('UTF-8')
65
+ end
66
+ end
67
+
68
+ def attach_parent(ctx, node)
69
+ if node.class.method_defined? :children
70
+ node.children.each do |child_node|
71
+ if child_node.class.method_defined? :parent
72
+ child_node.parent = node
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ def attach_remarks(ctx, node)
79
+ # get remark tokens
80
+ start_index, stop_index = if ctx.instance_of? ::ExpressParser::SyntaxContext
81
+ [0, @tokens.size - 1]
82
+ else
83
+ [ctx.start.token_index, ctx.stop.token_index]
84
+ end
85
+ # puts [start_index, stop_index, ctx.class].inspect
86
+
87
+ remark_tokens = @tokens[start_index..stop_index].select{|x| x.channel == REMARK_CHANNEL}
88
+ if remark_tokens
89
+ remark_tokens.each do |remark_token|
90
+ remark_text = remark_token.text
91
+
92
+ # check if it is tagged remark
93
+ match = if remark_text.start_with?('--')
94
+ remark_text[2..-1].match(/^"([^"]*)"(.*)$/)
95
+ elsif remark_text.start_with?('(*') and remark_text.end_with?('*)')
96
+ remark_text[2..-3].match(/^"([^"]*)"(.*)$/m)
97
+ end
98
+ if !match
99
+ next
100
+ end
101
+
102
+ # don't attach already attached tagged remark
103
+ if @attached_remarks.include? remark_token
104
+ next
105
+ end
106
+
107
+ # attach tagged remark
108
+ remark_tag = match[1]
109
+ remark_content = match[2].strip.force_encoding('UTF-8')
110
+
111
+ target_node = nil
112
+ current_node = node
113
+ if current_node.class.method_defined? :find
114
+ target_node = current_node.find(remark_tag)
115
+ end
116
+ while !target_node and current_node.class.method_defined? :parent and current_node.parent.class.method_defined? :find
117
+ current_node = current_node.parent
118
+ target_node = current_node.find(remark_tag)
119
+ end
120
+
121
+ if target_node
122
+ target_node.remarks ||= []
123
+ target_node.remarks << remark_content
124
+
125
+ # mark remark as attached, so that it is not attached again at higher nesting level
126
+ @attached_remarks << remark_token
127
+ end
128
+ end
129
+ end
130
+ end
131
+
132
+ def visit_attribute_ref(ctx)
133
+ ctx__attribute_id = ctx.attribute_id
134
+
135
+ id = visit_if(ctx__attribute_id)
136
+
137
+ Model::Expressions::SimpleReference.new({
138
+ id: id
139
+ })
140
+ end
141
+
142
+ def visit_constant_ref(ctx)
143
+ ctx__constant_id = ctx.constant_id
144
+
145
+ id = visit_if(ctx__constant_id)
146
+
147
+ Model::Expressions::SimpleReference.new({
148
+ id: id
149
+ })
150
+ end
151
+
152
+ def visit_entity_ref(ctx)
153
+ ctx__entity_id = ctx.entity_id
154
+
155
+ id = visit_if(ctx__entity_id)
156
+
157
+ Model::Expressions::SimpleReference.new({
158
+ id: id
159
+ })
160
+ end
161
+
162
+ def visit_enumeration_ref(ctx)
163
+ ctx__enumeration_id = ctx.enumeration_id
164
+
165
+ id = visit_if(ctx__enumeration_id)
166
+
167
+ Model::Expressions::SimpleReference.new({
168
+ id: id
169
+ })
170
+ end
171
+
172
+ def visit_function_ref(ctx)
173
+ ctx__function_id = ctx.function_id
174
+
175
+ id = visit_if(ctx__function_id)
176
+
177
+ Model::Expressions::SimpleReference.new({
178
+ id: id
179
+ })
180
+ end
181
+
182
+ def visit_parameter_ref(ctx)
183
+ ctx__parameter_id = ctx.parameter_id
184
+
185
+ id = visit_if(ctx__parameter_id)
186
+
187
+ Model::Expressions::SimpleReference.new({
188
+ id: id
189
+ })
190
+ end
191
+
192
+ def visit_procedure_ref(ctx)
193
+ ctx__procedure_id = ctx.procedure_id
194
+
195
+ id = visit_if(ctx__procedure_id)
196
+
197
+ Model::Expressions::SimpleReference.new({
198
+ id: id
199
+ })
200
+ end
201
+
202
+ def visit_rule_label_ref(ctx)
203
+ ctx__rule_label_id = ctx.rule_label_id
204
+
205
+ id = visit_if(ctx__rule_label_id)
206
+
207
+ Model::Expressions::SimpleReference.new({
208
+ id: id
209
+ })
210
+ end
211
+
212
+ def visit_rule_ref(ctx)
213
+ ctx__rule_id = ctx.rule_id
214
+
215
+ id = visit_if(ctx__rule_id)
216
+
217
+ Model::Expressions::SimpleReference.new({
218
+ id: id
219
+ })
220
+ end
221
+
222
+ def visit_schema_ref(ctx)
223
+ ctx__schema_id = ctx.schema_id
224
+
225
+ id = visit_if(ctx__schema_id)
226
+
227
+ Model::Expressions::SimpleReference.new({
228
+ id: id
229
+ })
230
+ end
231
+
232
+ def visit_subtype_constraint_ref(ctx)
233
+ ctx__subtype_constraint_id = ctx.subtype_constraint_id
234
+
235
+ id = visit_if(ctx__subtype_constraint_id)
236
+
237
+ Model::Expressions::SimpleReference.new({
238
+ id: id
239
+ })
240
+ end
241
+
242
+ def visit_type_label_ref(ctx)
243
+ ctx__type_label_id = ctx.type_label_id
244
+
245
+ id = visit_if(ctx__type_label_id)
246
+
247
+ Model::Expressions::SimpleReference.new({
248
+ id: id
249
+ })
250
+ end
251
+
252
+ def visit_type_ref(ctx)
253
+ ctx__type_id = ctx.type_id
254
+
255
+ id = visit_if(ctx__type_id)
256
+
257
+ Model::Expressions::SimpleReference.new({
258
+ id: id
259
+ })
260
+ end
261
+
262
+ def visit_variable_ref(ctx)
263
+ ctx__variable_id = ctx.variable_id
264
+
265
+ id = visit_if(ctx__variable_id)
266
+
267
+ Model::Expressions::SimpleReference.new({
268
+ id: id
269
+ })
270
+ end
271
+
272
+ def visit_abstract_entity_declaration(ctx)
273
+ raise 'Invalid state'
274
+ end
275
+
276
+ def visit_abstract_supertype(ctx)
277
+ raise 'Invalid state'
278
+ end
279
+
280
+ def visit_abstract_supertype_declaration(ctx)
281
+ ctx__subtype_constraint = ctx.subtype_constraint
282
+
283
+ visit_if(ctx__subtype_constraint)
284
+ end
285
+
286
+ def visit_actual_parameter_list(ctx)
287
+ ctx__parameter = ctx.parameter
288
+
289
+ visit_if_map(ctx__parameter)
290
+ end
291
+
292
+ def visit_add_like_op(ctx)
293
+ ctx__text = ctx.text
294
+ ctx__ADDITION = ctx__text == '+'
295
+ ctx__SUBTRACTION = ctx__text == '-'
296
+ ctx__OR = ctx.OR
297
+ ctx__XOR = ctx.XOR
298
+
299
+ if ctx__ADDITION
300
+ Model::Expressions::BinaryExpression::ADDITION
301
+ elsif ctx__SUBTRACTION
302
+ Model::Expressions::BinaryExpression::SUBTRACTION
303
+ elsif ctx__OR
304
+ Model::Expressions::BinaryExpression::OR
305
+ elsif ctx__XOR
306
+ Model::Expressions::BinaryExpression::XOR
307
+ else
308
+ raise 'Invalid state'
309
+ end
310
+ end
311
+
312
+ def visit_aggregate_initializer(ctx)
313
+ ctx__element = ctx.element
314
+
315
+ items = visit_if_map(ctx__element)
316
+
317
+ Model::Expressions::AggregateInitializer.new({
318
+ items: items
319
+ })
320
+ end
321
+
322
+ def visit_aggregate_source(ctx)
323
+ ctx__simple_expression = ctx.simple_expression
324
+
325
+ visit_if(ctx__simple_expression)
326
+ end
327
+
328
+ def visit_aggregate_type(ctx)
329
+ ctx__type_label = ctx.type_label
330
+ ctx__parameter_type = ctx.parameter_type
331
+
332
+ id = visit_if(ctx__type_label)
333
+ base_type = visit_if(ctx__parameter_type)
334
+
335
+ Model::Types::Aggregate.new({
336
+ id: id,
337
+ base_type: base_type
338
+ })
339
+ end
340
+
341
+ def visit_aggregation_types(ctx)
342
+ ctx__array_type = ctx.array_type
343
+ ctx__bag_type = ctx.bag_type
344
+ ctx__list_type = ctx.list_type
345
+ ctx__set_type = ctx.set_type
346
+
347
+ visit_if(ctx__array_type || ctx__bag_type || ctx__list_type || ctx__set_type)
348
+ end
349
+
350
+ def visit_algorithm_head(ctx)
351
+ raise 'Invalid state'
352
+ end
353
+
354
+ def visit_alias_stmt(ctx)
355
+ ctx__variable_id = ctx.variable_id
356
+ ctx__general_ref = ctx.general_ref
357
+ ctx__qualifier = ctx.qualifier
358
+ ctx__stmt = ctx.stmt
359
+
360
+ id = visit_if(ctx__variable_id)
361
+ expression = handle_qualified_ref(visit_if(ctx__general_ref), ctx__qualifier)
362
+ statements = visit_if_map(ctx__stmt)
363
+
364
+ Model::Statements::Alias.new({
365
+ id: id,
366
+ expression: expression,
367
+ statements: statements
368
+ })
369
+ end
370
+
371
+ def visit_array_type(ctx)
372
+ ctx__bound_spec = ctx.bound_spec
373
+ ctx__OPTIONAL = ctx.OPTIONAL
374
+ ctx__UNIQUE = ctx.UNIQUE
375
+ ctx__instantiable_type = ctx.instantiable_type
376
+ ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
377
+ ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
378
+
379
+ bound1 = visit_if(ctx__bound_spec__bound1)
380
+ bound2 = visit_if(ctx__bound_spec__bound2)
381
+ optional = !!ctx__OPTIONAL
382
+ unique = !!ctx__UNIQUE
383
+ base_type = visit_if(ctx__instantiable_type)
384
+
385
+ Model::Types::Array.new({
386
+ bound1: bound1,
387
+ bound2: bound2,
388
+ optional: optional,
389
+ unique: unique,
390
+ base_type: base_type
391
+ })
392
+ end
393
+
394
+ def visit_assignment_stmt(ctx)
395
+ ctx__general_ref = ctx.general_ref
396
+ ctx__qualifier = ctx.qualifier
397
+ ctx__expression = ctx.expression
398
+
399
+ ref = handle_qualified_ref(visit_if(ctx__general_ref), ctx__qualifier)
400
+ expression = visit_if(ctx__expression)
401
+
402
+ Model::Statements::Assignment.new({
403
+ ref: ref,
404
+ expression: expression
405
+ })
406
+ end
407
+
408
+ def visit_attribute_decl(ctx)
409
+ ctx__attribute_id = ctx.attribute_id
410
+ ctx__redeclared_attribute = ctx.redeclared_attribute
411
+ ctx__redeclared_attribute__qualified_attribute = ctx__redeclared_attribute&.qualified_attribute
412
+ ctx__redeclared_attribute__attribute_id = ctx__redeclared_attribute&.attribute_id
413
+
414
+ id = visit_if(ctx__attribute_id || ctx__redeclared_attribute__attribute_id)
415
+ supertype_attribute = visit_if(ctx__redeclared_attribute__qualified_attribute)
416
+
417
+ Model::Attribute.new({
418
+ id: id,
419
+ supertype_attribute: supertype_attribute
420
+ })
421
+ end
422
+
423
+ def visit_attribute_id(ctx)
424
+ ctx__SimpleId = ctx.SimpleId
425
+
426
+ handle_simple_id(ctx__SimpleId)
427
+ end
428
+
429
+ def visit_attribute_qualifier(ctx)
430
+ ctx__attribute_ref = ctx.attribute_ref
431
+
432
+ attribute = visit_if(ctx__attribute_ref)
433
+
434
+ Model::Expressions::AttributeReference.new({
435
+ attribute: attribute
436
+ })
437
+ end
438
+
439
+ def visit_attribute_reference(ctx)
440
+ raise 'Invalid state'
441
+ end
442
+
443
+ def visit_bag_type(ctx)
444
+ ctx__bound_spec = ctx.bound_spec
445
+ ctx__instantiable_type = ctx.instantiable_type
446
+ ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
447
+ ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
448
+
449
+ bound1 = visit_if(ctx__bound_spec__bound1)
450
+ bound2 = visit_if(ctx__bound_spec__bound2)
451
+ base_type = visit_if(ctx__instantiable_type)
452
+
453
+ Model::Types::Bag.new({
454
+ bound1: bound1,
455
+ bound2: bound2,
456
+ base_type: base_type
457
+ })
458
+ end
459
+
460
+ def visit_binary_type(ctx)
461
+ ctx__width_spec = ctx.width_spec
462
+ ctx__width_spec__width = ctx__width_spec&.width
463
+ ctx__width_spec__FIXED = ctx__width_spec&.FIXED
464
+
465
+ width = visit_if(ctx__width_spec__width)
466
+ fixed = !!ctx__width_spec__FIXED
467
+
468
+ Model::Types::Binary.new({
469
+ width: width,
470
+ fixed: fixed
471
+ })
472
+ end
473
+
474
+ def visit_boolean_type(ctx)
475
+ Model::Types::Boolean.new
476
+ end
477
+
478
+ def visit_bound1(ctx)
479
+ ctx__numeric_expression = ctx.numeric_expression
480
+
481
+ visit_if(ctx__numeric_expression)
482
+ end
483
+
484
+ def visit_bound2(ctx)
485
+ ctx__numeric_expression = ctx.numeric_expression
486
+
487
+ visit_if(ctx__numeric_expression)
488
+ end
489
+
490
+ def visit_bound_spec(ctx)
491
+ raise 'Invalid state'
492
+ end
493
+
494
+ def visit_built_in_constant(ctx)
495
+ ctx__text = ctx.text
496
+
497
+ id = ctx__text
498
+
499
+ Model::Expressions::SimpleReference.new({
500
+ id: id
501
+ })
502
+ end
503
+
504
+ def visit_built_in_function(ctx)
505
+ ctx__text = ctx.text
506
+
507
+ id = ctx__text
508
+
509
+ Model::Expressions::SimpleReference.new({
510
+ id: id
511
+ })
512
+ end
513
+
514
+ def visit_built_in_procedure(ctx)
515
+ ctx__text = ctx.text
516
+
517
+ id = ctx__text
518
+
519
+ Model::Expressions::SimpleReference.new({
520
+ id: id
521
+ })
522
+ end
523
+
524
+ def visit_case_action(ctx)
525
+ ctx__case_label = ctx.case_label
526
+ ctx__stmt = ctx.stmt
527
+
528
+ labels = visit_if_map(ctx__case_label)
529
+ statement = visit_if(ctx__stmt)
530
+
531
+ Model::Statements::CaseAction.new({
532
+ labels: labels,
533
+ statement: statement
534
+ })
535
+ end
536
+
537
+ def visit_case_label(ctx)
538
+ ctx__expression = ctx.expression
539
+
540
+ visit_if(ctx__expression)
541
+ end
542
+
543
+ def visit_case_stmt(ctx)
544
+ ctx__selector = ctx.selector
545
+ ctx__case_action = ctx.case_action
546
+ ctx__stmt = ctx.stmt
547
+ ctx__selector__expression = ctx__selector&.expression
548
+
549
+ expression = visit_if(ctx__selector__expression)
550
+ actions = visit_if_map_flatten(ctx__case_action)
551
+ otherwise_statement = visit_if(ctx__stmt)
552
+
553
+ Model::Statements::Case.new({
554
+ expression: expression,
555
+ actions: actions,
556
+ otherwise_statement: otherwise_statement
557
+ })
558
+ end
559
+
560
+ def visit_compound_stmt(ctx)
561
+ ctx__stmt = ctx.stmt
562
+
563
+ statements = visit_if_map(ctx__stmt)
564
+
565
+ Model::Statements::Compound.new({
566
+ statements: statements
567
+ })
568
+ end
569
+
570
+ def visit_concrete_types(ctx)
571
+ ctx__aggregation_types = ctx.aggregation_types
572
+ ctx__simple_types = ctx.simple_types
573
+ ctx__type_ref = ctx.type_ref
574
+
575
+ visit_if(ctx__aggregation_types || ctx__simple_types || ctx__type_ref)
576
+ end
577
+
578
+ def visit_constant_body(ctx)
579
+ ctx__constant_id = ctx.constant_id
580
+ ctx__instantiable_type = ctx.instantiable_type
581
+ ctx__expression = ctx.expression
582
+
583
+ id = visit_if(ctx__constant_id)
584
+ type = visit_if(ctx__instantiable_type)
585
+ expression = visit_if(ctx__expression)
586
+
587
+ Model::Constant.new({
588
+ id: id,
589
+ type: type,
590
+ expression: expression
591
+ })
592
+ end
593
+
594
+ def visit_constant_decl(ctx)
595
+ ctx__constant_body = ctx.constant_body
596
+
597
+ visit_if_map(ctx__constant_body)
598
+ end
599
+
600
+ def visit_constant_factor(ctx)
601
+ ctx__built_in_constant = ctx.built_in_constant
602
+ ctx__constant_ref = ctx.constant_ref
603
+
604
+ visit_if(ctx__built_in_constant || ctx__constant_ref)
605
+ end
606
+
607
+ def visit_constant_id(ctx)
608
+ ctx__SimpleId = ctx.SimpleId
609
+
610
+ handle_simple_id(ctx__SimpleId)
611
+ end
612
+
613
+ def visit_constructed_types(ctx)
614
+ ctx__enumeration_type = ctx.enumeration_type
615
+ ctx__select_type = ctx.select_type
616
+
617
+ visit_if(ctx__enumeration_type || ctx__select_type)
618
+ end
619
+
620
+ def visit_declaration(ctx)
621
+ ctx__entity_decl = ctx.entity_decl
622
+ ctx__function_decl = ctx.function_decl
623
+ ctx__procedure_decl = ctx.procedure_decl
624
+ ctx__subtype_constraint_decl = ctx.subtype_constraint_decl
625
+ ctx__type_decl = ctx.type_decl
626
+
627
+ visit_if(ctx__entity_decl || ctx__function_decl || ctx__procedure_decl || ctx__subtype_constraint_decl || ctx__type_decl)
628
+ end
629
+
630
+ def visit_derived_attr(ctx)
631
+ ctx__attribute_decl = ctx.attribute_decl
632
+ ctx__parameter_type = ctx.parameter_type
633
+ ctx__expression = ctx.expression
634
+
635
+ attribute = visit_if(ctx__attribute_decl)
636
+ type = visit_if(ctx__parameter_type)
637
+ expression = visit_if(ctx__expression)
638
+
639
+ Model::Attribute.new({
640
+ id: attribute.id,
641
+ kind: Model::Attribute::DERIVED,
642
+ supertype_attribute: attribute.supertype_attribute,
643
+ type: type,
644
+ expression: expression
645
+ })
646
+ end
647
+
648
+ def visit_derive_clause(ctx)
649
+ ctx__derived_attr = ctx.derived_attr
650
+
651
+ visit_if_map(ctx__derived_attr)
652
+ end
653
+
654
+ def visit_domain_rule(ctx)
655
+ ctx__rule_label_id = ctx.rule_label_id
656
+ ctx__expression = ctx.expression
657
+
658
+ id = visit_if(ctx__rule_label_id)
659
+ expression = visit_if(ctx__expression)
660
+
661
+ Model::Where.new({
662
+ id: id,
663
+ expression: expression
664
+ })
665
+ end
666
+
667
+ def visit_element(ctx)
668
+ ctx__expression = ctx.expression
669
+ ctx__repetition = ctx.repetition
670
+
671
+ if ctx__repetition
672
+ expression = visit_if(ctx__expression)
673
+ repetition = visit_if(ctx__repetition)
674
+
675
+ Model::Expressions::AggregateItem.new({
676
+ expression: expression,
677
+ repetition: repetition
678
+ })
679
+ else
680
+ visit_if(ctx__expression)
681
+ end
682
+ end
683
+
684
+ def visit_entity_body(ctx)
685
+ raise 'Invalid state'
686
+ end
687
+
688
+ def visit_entity_constructor(ctx)
689
+ ctx__entity_ref = ctx.entity_ref
690
+ ctx__expression = ctx.expression
691
+
692
+ ref = visit_if(ctx__entity_ref)
693
+ parameters = visit_if_map(ctx__expression)
694
+
695
+ Model::Expressions::Call.new({
696
+ ref: ref,
697
+ parameters: parameters
698
+ })
699
+ end
700
+
701
+ def visit_entity_decl(ctx)
702
+ ctx__entity_head = ctx.entity_head
703
+ ctx__entity_body = ctx.entity_body
704
+ ctx__entity_head__entity_id = ctx__entity_head&.entity_id
705
+ ctx__entity_head__subsuper = ctx__entity_head&.subsuper
706
+ ctx__entity_head__subsuper__supertype_constraint = ctx__entity_head__subsuper&.supertype_constraint
707
+ ctx__entity_head__subsuper__supertype_constraint__abstract_entity_declaration = ctx__entity_head__subsuper__supertype_constraint&.abstract_entity_declaration
708
+ ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration = ctx__entity_head__subsuper__supertype_constraint&.abstract_supertype_declaration
709
+ ctx__entity_head__subsuper__supertype_constraint__supertype_rule = ctx__entity_head__subsuper__supertype_constraint&.supertype_rule
710
+ ctx__entity_head__subsuper__subtype_declaration = ctx__entity_head__subsuper&.subtype_declaration
711
+ ctx__entity_body__explicit_attr = ctx__entity_body&.explicit_attr
712
+ ctx__entity_body__derive_clause = ctx__entity_body&.derive_clause
713
+ ctx__entity_body__inverse_clause = ctx__entity_body&.inverse_clause
714
+ ctx__entity_body__unique_clause = ctx__entity_body&.unique_clause
715
+ ctx__entity_body__where_clause = ctx__entity_body&.where_clause
716
+
717
+ id = visit_if(ctx__entity_head__entity_id)
718
+ abstract = !!(ctx__entity_head__subsuper__supertype_constraint__abstract_entity_declaration || ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration)
719
+ supertype_expression = visit_if(ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration || ctx__entity_head__subsuper__supertype_constraint__supertype_rule)
720
+ subtype_of = visit_if(ctx__entity_head__subsuper__subtype_declaration)
721
+ attributes = [
722
+ *visit_if_map_flatten(ctx__entity_body__explicit_attr),
723
+ *visit_if(ctx__entity_body__derive_clause),
724
+ *visit_if(ctx__entity_body__inverse_clause)
725
+ ]
726
+ unique = visit_if(ctx__entity_body__unique_clause)
727
+ where = visit_if(ctx__entity_body__where_clause)
728
+
729
+ Model::Entity.new({
730
+ id: id,
731
+ abstract: abstract,
732
+ supertype_expression: supertype_expression,
733
+ subtype_of: subtype_of,
734
+ attributes: attributes,
735
+ unique: unique,
736
+ where: where
737
+ })
738
+ end
739
+
740
+ def visit_entity_head(ctx)
741
+ raise 'Invalid state'
742
+ end
743
+
744
+ def visit_entity_id(ctx)
745
+ ctx__SimpleId = ctx.SimpleId
746
+
747
+ handle_simple_id(ctx__SimpleId)
748
+ end
749
+
750
+ def visit_enumeration_extension(ctx)
751
+ raise 'Invalid state'
752
+ end
753
+
754
+ def visit_enumeration_id(ctx)
755
+ ctx__SimpleId = ctx.SimpleId
756
+
757
+ handle_simple_id(ctx__SimpleId)
758
+ end
759
+
760
+ def visit_enumeration_items(ctx)
761
+ ctx__enumeration_item = ctx.enumeration_item
762
+
763
+ visit_if_map(ctx__enumeration_item)
764
+ end
765
+
766
+ def visit_enumeration_item(ctx)
767
+ ctx__enumeration_id = ctx.enumeration_id
768
+
769
+ id = visit_if(ctx__enumeration_id)
770
+
771
+ Model::EnumerationItem.new({
772
+ id: id
773
+ })
774
+ end
775
+
776
+ def visit_enumeration_reference(ctx)
777
+ ctx__type_ref = ctx.type_ref
778
+ ctx__enumeration_ref = ctx.enumeration_ref
779
+
780
+ if ctx__type_ref
781
+ ref = visit_if(ctx__type_ref)
782
+ attribute = visit_if(ctx__enumeration_ref)
783
+
784
+ Model::Expressions::AttributeReference.new({
785
+ ref: ref,
786
+ attribute: attribute
787
+ })
788
+ else
789
+ visit_if(ctx__enumeration_ref)
790
+ end
791
+ end
792
+
793
+ def visit_enumeration_type(ctx)
794
+ ctx__EXTENSIBLE = ctx.EXTENSIBLE
795
+ ctx__enumeration_items = ctx.enumeration_items
796
+ ctx__enumeration_extension = ctx.enumeration_extension
797
+ ctx__enumeration_extension__type_ref = ctx__enumeration_extension&.type_ref
798
+ ctx__enumeration_extension__enumeration_items = ctx__enumeration_extension&.enumeration_items
799
+
800
+ extensible = !!ctx__EXTENSIBLE
801
+ items = visit_if(ctx__enumeration_items)
802
+ extension_type = visit_if(ctx__enumeration_extension__type_ref)
803
+ extension_items = visit_if(ctx__enumeration_extension__enumeration_items)
804
+
805
+ Model::Types::Enumeration.new({
806
+ extensible: extensible,
807
+ items: items,
808
+ extension_type: extension_type,
809
+ extension_items: extension_items
810
+ })
811
+ end
812
+
813
+ def visit_escape_stmt(ctx)
814
+ Model::Statements::Escape.new
815
+ end
816
+
817
+ def visit_explicit_attr(ctx)
818
+ ctx__attribute_decl = ctx.attribute_decl
819
+ ctx__OPTIONAL = ctx.OPTIONAL
820
+ ctx__parameter_type = ctx.parameter_type
821
+
822
+ attributes = visit_if_map(ctx__attribute_decl)
823
+ optional = !!ctx__OPTIONAL
824
+ type = visit_if(ctx__parameter_type)
825
+
826
+ attributes.map do |attribute|
827
+ Model::Attribute.new({
828
+ id: attribute.id,
829
+ kind: Model::Attribute::EXPLICIT,
830
+ supertype_attribute: attribute.supertype_attribute,
831
+ optional: optional,
832
+ type: type
833
+ })
834
+ end
835
+ end
836
+
837
+ def visit_expression(ctx)
838
+ ctx__simple_expression = ctx.simple_expression
839
+ ctx__rel_op_extended = ctx.rel_op_extended
840
+
841
+ if ctx__simple_expression.length == 2
842
+ operator = visit_if(ctx__rel_op_extended)
843
+ operand1 = visit_if(ctx__simple_expression[0])
844
+ operand2 = visit_if(ctx__simple_expression[1])
845
+
846
+ Model::Expressions::BinaryExpression.new({
847
+ operator: operator,
848
+ operand1: operand1,
849
+ operand2: operand2
850
+ })
851
+ else
852
+ visit_if(ctx__simple_expression[0])
853
+ end
854
+ end
855
+
856
+ def visit_factor(ctx)
857
+ ctx__simple_factor = ctx.simple_factor
858
+
859
+ if ctx__simple_factor.length == 2
860
+ operator = Model::Expressions::BinaryExpression::EXPONENTIATION
861
+ operand1 = visit(ctx__simple_factor[0])
862
+ operand2 = visit(ctx__simple_factor[1])
863
+
864
+ Model::Expressions::BinaryExpression.new({
865
+ operator: operator,
866
+ operand1: operand1,
867
+ operand2: operand2
868
+ })
869
+ elsif ctx__simple_factor.length == 1
870
+ visit_if(ctx__simple_factor[0])
871
+ else
872
+ raise 'Invalid state'
873
+ end
874
+ end
875
+
876
+ def visit_formal_parameter(ctx)
877
+ ctx__parameter_id = ctx.parameter_id
878
+ ctx__parameter_type = ctx.parameter_type
879
+
880
+ ids = visit_if_map(ctx__parameter_id)
881
+ type = visit_if(ctx__parameter_type)
882
+
883
+ ids.map do |id|
884
+ Model::Parameter.new({
885
+ id: id,
886
+ type: type
887
+ })
888
+ end
889
+ end
890
+
891
+ def visit_function_call(ctx)
892
+ ctx__built_in_function = ctx.built_in_function
893
+ ctx__function_ref = ctx.function_ref
894
+ ctx__actual_parameter_list = ctx.actual_parameter_list
895
+
896
+ ref = visit_if(ctx__built_in_function || ctx__function_ref)
897
+ parameters = visit_if(ctx__actual_parameter_list)
898
+
899
+ Model::Expressions::Call.new({
900
+ ref: ref,
901
+ parameters: parameters
902
+ })
903
+ end
904
+
905
+ def visit_function_decl(ctx)
906
+ ctx__function_head = ctx.function_head
907
+ ctx__algorithm_head = ctx.algorithm_head
908
+ ctx__stmt = ctx.stmt
909
+ ctx__function_head__function_id = ctx__function_head&.function_id
910
+ ctx__function_head__formal_parameter = ctx__function_head&.formal_parameter
911
+ ctx__function_head__parameter_type = ctx__function_head&.parameter_type
912
+ ctx__algorithm_head__declaration = ctx__algorithm_head&.declaration
913
+ ctx__algorithm_head__constant_decl = ctx__algorithm_head&.constant_decl
914
+ ctx__algorithm_head__local_decl = ctx__algorithm_head&.local_decl
915
+
916
+ id = visit_if(ctx__function_head__function_id)
917
+ parameters = visit_if_map_flatten(ctx__function_head__formal_parameter)
918
+ return_type = visit_if(ctx__function_head__parameter_type)
919
+ declarations = visit_if_map(ctx__algorithm_head__declaration)
920
+ constants = visit_if(ctx__algorithm_head__constant_decl)
921
+ variables = visit_if(ctx__algorithm_head__local_decl)
922
+ statements = visit_if_map(ctx__stmt)
923
+
924
+ Model::Function.new({
925
+ id: id,
926
+ parameters: parameters,
927
+ return_type: return_type,
928
+ declarations: declarations,
929
+ constants: constants,
930
+ variables: variables,
931
+ statements: statements
932
+ })
933
+ end
934
+
935
+ def visit_function_head(ctx)
936
+ raise 'Invalid state'
937
+ end
938
+
939
+ def visit_function_id(ctx)
940
+ ctx__SimpleId = ctx.SimpleId
941
+
942
+ handle_simple_id(ctx__SimpleId)
943
+ end
944
+
945
+ def visit_generalized_types(ctx)
946
+ ctx__aggregate_type = ctx.aggregate_type
947
+ ctx__general_aggregation_types = ctx.general_aggregation_types
948
+ ctx__generic_entity_type = ctx.generic_entity_type
949
+ ctx__generic_type = ctx.generic_type
950
+
951
+ visit_if(ctx__aggregate_type || ctx__general_aggregation_types || ctx__generic_entity_type || ctx__generic_type)
952
+ end
953
+
954
+ def visit_general_aggregation_types(ctx)
955
+ ctx__general_array_type = ctx.general_array_type
956
+ ctx__general_bag_type = ctx.general_bag_type
957
+ ctx__general_list_type = ctx.general_list_type
958
+ ctx__general_set_type = ctx.general_set_type
959
+
960
+ visit_if(ctx__general_array_type || ctx__general_bag_type || ctx__general_list_type || ctx__general_set_type)
961
+ end
962
+
963
+ def visit_general_array_type(ctx)
964
+ ctx__bound_spec = ctx.bound_spec
965
+ ctx__OPTIONAL = ctx.OPTIONAL
966
+ ctx__UNIQUE = ctx.UNIQUE
967
+ ctx__parameter_type = ctx.parameter_type
968
+ ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
969
+ ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
970
+
971
+ bound1 = visit_if(ctx__bound_spec__bound1)
972
+ bound2 = visit_if(ctx__bound_spec__bound2)
973
+ optional = !!ctx__OPTIONAL
974
+ unique = !!ctx__UNIQUE
975
+ base_type = visit_if(ctx__parameter_type)
976
+
977
+ Model::Types::Array.new({
978
+ bound1: bound1,
979
+ bound2: bound2,
980
+ optional: optional,
981
+ unique: unique,
982
+ base_type: base_type
983
+ })
984
+ end
985
+
986
+ def visit_general_bag_type(ctx)
987
+ ctx__bound_spec = ctx.bound_spec
988
+ ctx__parameter_type = ctx.parameter_type
989
+ ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
990
+ ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
991
+
992
+ bound1 = visit_if(ctx__bound_spec__bound1)
993
+ bound2 = visit_if(ctx__bound_spec__bound2)
994
+ base_type = visit_if(ctx__parameter_type)
995
+
996
+ Model::Types::Bag.new({
997
+ bound1: bound1,
998
+ bound2: bound2,
999
+ base_type: base_type
1000
+ })
1001
+ end
1002
+
1003
+ def visit_general_list_type(ctx)
1004
+ ctx__bound_spec = ctx.bound_spec
1005
+ ctx__UNIQUE = ctx.UNIQUE
1006
+ ctx__parameter_type = ctx.parameter_type
1007
+ ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
1008
+ ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
1009
+
1010
+ bound1 = visit_if(ctx__bound_spec__bound1)
1011
+ bound2 = visit_if(ctx__bound_spec__bound2)
1012
+ unique = !!ctx__UNIQUE
1013
+ base_type = visit_if(ctx__parameter_type)
1014
+
1015
+ Model::Types::List.new({
1016
+ bound1: bound1,
1017
+ bound2: bound2,
1018
+ unique: unique,
1019
+ base_type: base_type
1020
+ })
1021
+ end
1022
+
1023
+ def visit_general_ref(ctx)
1024
+ ctx__parameter_ref = ctx.parameter_ref
1025
+ ctx__variable_id = ctx.variable_id
1026
+
1027
+ visit_if(ctx__parameter_ref || ctx__variable_id)
1028
+ end
1029
+
1030
+ def visit_general_set_type(ctx)
1031
+ ctx__bound_spec = ctx.bound_spec
1032
+ ctx__parameter_type = ctx.parameter_type
1033
+ ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
1034
+ ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
1035
+
1036
+ bound1 = visit_if(ctx__bound_spec__bound1)
1037
+ bound2 = visit_if(ctx__bound_spec__bound2)
1038
+ base_type = visit_if(ctx__parameter_type)
1039
+
1040
+ Model::Types::Set.new({
1041
+ bound1: bound1,
1042
+ bound2: bound2,
1043
+ base_type: base_type
1044
+ })
1045
+ end
1046
+
1047
+ def visit_generic_entity_type(ctx)
1048
+ ctx__type_label = ctx.type_label
1049
+
1050
+ id = visit_if(ctx__type_label)
1051
+
1052
+ Model::Types::GenericEntity.new({
1053
+ id: id
1054
+ })
1055
+ end
1056
+
1057
+ def visit_generic_type(ctx)
1058
+ ctx__type_label = ctx.type_label
1059
+
1060
+ id = visit_if(ctx__type_label)
1061
+
1062
+ Model::Types::Generic.new({
1063
+ id: id
1064
+ })
1065
+ end
1066
+
1067
+ def visit_group_qualifier(ctx)
1068
+ ctx__entity_ref = ctx.entity_ref
1069
+
1070
+ entity = visit_if(ctx__entity_ref)
1071
+
1072
+ Model::Expressions::GroupReference.new({
1073
+ entity: entity
1074
+ })
1075
+ end
1076
+
1077
+ def visit_group_reference(ctx)
1078
+ raise 'Invalid state'
1079
+ end
1080
+
1081
+ def visit_if_stmt(ctx)
1082
+ ctx__logical_expression = ctx.logical_expression
1083
+ ctx__if_stmt_statements = ctx.if_stmt_statements
1084
+ ctx__if_stmt_else_statements = ctx.if_stmt_else_statements
1085
+
1086
+ expression = visit_if(ctx__logical_expression)
1087
+ statements = visit_if(ctx__if_stmt_statements)
1088
+ else_statements = visit_if(ctx__if_stmt_else_statements)
1089
+
1090
+ Model::Statements::If.new({
1091
+ expression: expression,
1092
+ statements: statements,
1093
+ else_statements: else_statements
1094
+ })
1095
+ end
1096
+
1097
+ def visit_if_stmt_statements(ctx)
1098
+ ctx__stmt = ctx.stmt
1099
+
1100
+ visit_if_map(ctx__stmt)
1101
+ end
1102
+
1103
+ def visit_if_stmt_else_statements(ctx)
1104
+ ctx__stmt = ctx.stmt
1105
+
1106
+ visit_if_map(ctx__stmt)
1107
+ end
1108
+
1109
+ def visit_increment(ctx)
1110
+ ctx__numeric_expression = ctx.numeric_expression
1111
+
1112
+ visit_if(ctx__numeric_expression)
1113
+ end
1114
+
1115
+ def visit_increment_control(ctx)
1116
+ raise 'Invalid state'
1117
+ end
1118
+
1119
+ def visit_index(ctx)
1120
+ ctx__numeric_expression = ctx.numeric_expression
1121
+
1122
+ visit_if(ctx__numeric_expression)
1123
+ end
1124
+
1125
+ def visit_index1(ctx)
1126
+ ctx__index = ctx.index
1127
+
1128
+ visit_if(ctx__index)
1129
+ end
1130
+
1131
+ def visit_index2(ctx)
1132
+ ctx__index = ctx.index
1133
+
1134
+ visit_if(ctx__index)
1135
+ end
1136
+
1137
+ def visit_index_qualifier(ctx)
1138
+ ctx__index1 = ctx.index1
1139
+ ctx__index2 = ctx.index2
1140
+
1141
+ index1 = visit_if(ctx__index1)
1142
+ index2 = visit_if(ctx__index2)
1143
+
1144
+ Model::Expressions::IndexReference.new({
1145
+ index1: index1,
1146
+ index2: index2
1147
+ })
1148
+ end
1149
+
1150
+ def visit_index_reference(ctx)
1151
+ raise 'Invalid state'
1152
+ end
1153
+
1154
+ def visit_instantiable_type(ctx)
1155
+ ctx__concrete_types = ctx.concrete_types
1156
+ ctx__entity_ref = ctx.entity_ref
1157
+
1158
+ visit_if(ctx__concrete_types || ctx__entity_ref)
1159
+ end
1160
+
1161
+ def visit_integer_type(ctx)
1162
+ Model::Types::Integer.new
1163
+ end
1164
+
1165
+ def visit_interface_specification(ctx)
1166
+ ctx__reference_clause = ctx.reference_clause
1167
+ ctx__use_clause = ctx.use_clause
1168
+
1169
+ visit_if(ctx__reference_clause || ctx__use_clause)
1170
+ end
1171
+
1172
+ def visit_interval(ctx)
1173
+ ctx__interval_low = ctx.interval_low
1174
+ ctx__interval_op = ctx.interval_op
1175
+ ctx__interval_item = ctx.interval_item
1176
+ ctx__interval_high = ctx.interval_high
1177
+
1178
+ low = visit_if(ctx__interval_low)
1179
+ operator1 = visit_if(ctx__interval_op[0])
1180
+ item = visit_if(ctx__interval_item)
1181
+ operator2 = visit_if(ctx__interval_op[1])
1182
+ high = visit_if(ctx__interval_high)
1183
+
1184
+ Model::Expressions::Interval.new({
1185
+ low: low,
1186
+ operator1: operator1,
1187
+ item: item,
1188
+ operator2: operator2,
1189
+ high: high
1190
+ })
1191
+ end
1192
+
1193
+ def visit_interval_high(ctx)
1194
+ ctx__simple_expression = ctx.simple_expression
1195
+
1196
+ visit_if(ctx__simple_expression)
1197
+ end
1198
+
1199
+ def visit_interval_item(ctx)
1200
+ ctx__simple_expression = ctx.simple_expression
1201
+
1202
+ visit_if(ctx__simple_expression)
1203
+ end
1204
+
1205
+ def visit_interval_low(ctx)
1206
+ ctx__simple_expression = ctx.simple_expression
1207
+
1208
+ visit_if(ctx__simple_expression)
1209
+ end
1210
+
1211
+ def visit_interval_op(ctx)
1212
+ ctx__text = ctx.text
1213
+ ctx__LESS_THAN = ctx__text == '<'
1214
+ ctx__LESS_THAN_OR_EQUAL = ctx__text == '<='
1215
+
1216
+ if ctx__LESS_THAN
1217
+ Model::Expressions::BinaryExpression::LESS_THAN
1218
+ elsif ctx__LESS_THAN_OR_EQUAL
1219
+ Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL
1220
+ else
1221
+ raise 'Invalid state'
1222
+ end
1223
+ end
1224
+
1225
+ def visit_inverse_attr(ctx)
1226
+ ctx__attribute_decl = ctx.attribute_decl
1227
+ ctx__inverse_attr_type = ctx.inverse_attr_type
1228
+ ctx__entity_ref = ctx.entity_ref
1229
+ ctx__attribute_ref = ctx.attribute_ref
1230
+
1231
+ attribute = visit_if(ctx__attribute_decl)
1232
+ type = visit_if(ctx__inverse_attr_type)
1233
+ expression = if ctx__entity_ref
1234
+ ref = visit(ctx__entity_ref)
1235
+ attribute_ref = visit(ctx__attribute_ref)
1236
+
1237
+ Model::Expressions::AttributeReference.new({
1238
+ ref: ref,
1239
+ attribute: attribute_ref
1240
+ })
1241
+ else
1242
+ visit(ctx__attribute_ref)
1243
+ end
1244
+
1245
+ Model::Attribute.new({
1246
+ id: attribute.id,
1247
+ kind: Model::Attribute::INVERSE,
1248
+ supertype_attribute: attribute.supertype_attribute,
1249
+ type: type,
1250
+ expression: expression
1251
+ })
1252
+ end
1253
+
1254
+ def visit_inverse_attr_type(ctx)
1255
+ ctx__SET = ctx.SET
1256
+ ctx__BAG = ctx.BAG
1257
+ ctx__bound_spec = ctx.bound_spec
1258
+ ctx__entity_ref = ctx.entity_ref
1259
+ ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
1260
+ ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
1261
+
1262
+ if ctx__SET
1263
+ bound1 = visit_if(ctx__bound_spec__bound1)
1264
+ bound2 = visit_if(ctx__bound_spec__bound2)
1265
+ base_type = visit_if(ctx__entity_ref)
1266
+
1267
+ Model::Types::Set.new({
1268
+ bound1: bound1,
1269
+ bound2: bound2,
1270
+ base_type: base_type
1271
+ })
1272
+ elsif ctx__BAG
1273
+ bound1 = visit_if(ctx__bound_spec__bound1)
1274
+ bound2 = visit_if(ctx__bound_spec__bound2)
1275
+ base_type = visit_if(ctx__entity_ref)
1276
+
1277
+ Model::Types::Bag.new({
1278
+ bound1: bound1,
1279
+ bound2: bound2,
1280
+ base_type: base_type
1281
+ })
1282
+ else
1283
+ visit_if(ctx__entity_ref)
1284
+ end
1285
+ end
1286
+
1287
+ def visit_inverse_clause(ctx)
1288
+ ctx__inverse_attr = ctx.inverse_attr
1289
+
1290
+ visit_if_map(ctx__inverse_attr)
1291
+ end
1292
+
1293
+ def visit_list_type(ctx)
1294
+ ctx__bound_spec = ctx.bound_spec
1295
+ ctx__UNIQUE = ctx.UNIQUE
1296
+ ctx__instantiable_type = ctx.instantiable_type
1297
+ ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
1298
+ ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
1299
+
1300
+ bound1 = visit_if(ctx__bound_spec__bound1)
1301
+ bound2 = visit_if(ctx__bound_spec__bound2)
1302
+ unique = !!ctx__UNIQUE
1303
+ base_type = visit_if(ctx__instantiable_type)
1304
+
1305
+ Model::Types::List.new({
1306
+ bound1: bound1,
1307
+ bound2: bound2,
1308
+ unique: unique,
1309
+ base_type: base_type
1310
+ })
1311
+ end
1312
+
1313
+ def visit_literal(ctx)
1314
+ ctx__BinaryLiteral = ctx.BinaryLiteral
1315
+ ctx__IntegerLiteral = ctx.IntegerLiteral
1316
+ ctx__logical_literal = ctx.logical_literal
1317
+ ctx__RealLiteral = ctx.RealLiteral
1318
+ ctx__string_literal = ctx.string_literal
1319
+
1320
+ if ctx__BinaryLiteral
1321
+ handle_binary_literal(ctx__BinaryLiteral)
1322
+ elsif ctx__IntegerLiteral
1323
+ handle_integer_literal(ctx__IntegerLiteral)
1324
+ elsif ctx__logical_literal
1325
+ visit(ctx__logical_literal)
1326
+ elsif ctx__RealLiteral
1327
+ handle_real_literal(ctx__RealLiteral)
1328
+ elsif ctx__string_literal
1329
+ visit(ctx__string_literal)
1330
+ else
1331
+ raise 'Invalid state'
1332
+ end
1333
+ end
1334
+
1335
+ def visit_local_decl(ctx)
1336
+ ctx__local_variable = ctx.local_variable
1337
+
1338
+ visit_if_map_flatten(ctx__local_variable)
1339
+ end
1340
+
1341
+ def visit_local_variable(ctx)
1342
+ ctx__variable_id = ctx.variable_id
1343
+ ctx__parameter_type = ctx.parameter_type
1344
+ ctx__expression = ctx.expression
1345
+
1346
+ ids = visit_if_map(ctx__variable_id)
1347
+ type = visit_if(ctx__parameter_type)
1348
+ expression = visit_if(ctx__expression)
1349
+
1350
+ ids.map do |id|
1351
+ Model::Variable.new({
1352
+ id: id,
1353
+ type: type,
1354
+ expression: expression
1355
+ })
1356
+ end
1357
+ end
1358
+
1359
+ def visit_logical_expression(ctx)
1360
+ ctx__expression = ctx.expression
1361
+
1362
+ visit_if(ctx__expression)
1363
+ end
1364
+
1365
+ def visit_logical_literal(ctx)
1366
+ ctx__TRUE = ctx.TRUE
1367
+ ctx__FALSE = ctx.FALSE
1368
+ ctx__UNKNOWN = ctx.UNKNOWN
1369
+
1370
+ value = if ctx__TRUE
1371
+ Model::Literals::Logical::TRUE
1372
+ elsif ctx__FALSE
1373
+ Model::Literals::Logical::FALSE
1374
+ elsif ctx__UNKNOWN
1375
+ Model::Literals::Logical::UNKNOWN
1376
+ else
1377
+ raise 'Invalid state'
1378
+ end
1379
+
1380
+ Model::Literals::Logical.new({
1381
+ value: value
1382
+ })
1383
+ end
1384
+
1385
+ def visit_logical_type(ctx)
1386
+ Model::Types::Logical.new
1387
+ end
1388
+
1389
+ def visit_multiplication_like_op(ctx)
1390
+ ctx__text = ctx.text
1391
+ ctx__MULTIPLICATION = ctx__text == '*'
1392
+ ctx__REAL_DIVISION = ctx__text == '/'
1393
+ ctx__INTEGER_DIVISION = ctx.DIV
1394
+ ctx__MODULO = ctx.MOD
1395
+ ctx__AND = ctx.AND
1396
+ ctx__COMBINE = ctx__text == '||'
1397
+
1398
+ if ctx__MULTIPLICATION
1399
+ Model::Expressions::BinaryExpression::MULTIPLICATION
1400
+ elsif ctx__REAL_DIVISION
1401
+ Model::Expressions::BinaryExpression::REAL_DIVISION
1402
+ elsif ctx__INTEGER_DIVISION
1403
+ Model::Expressions::BinaryExpression::INTEGER_DIVISION
1404
+ elsif ctx__MODULO
1405
+ Model::Expressions::BinaryExpression::MODULO
1406
+ elsif ctx__AND
1407
+ Model::Expressions::BinaryExpression::AND
1408
+ elsif ctx__COMBINE
1409
+ Model::Expressions::BinaryExpression::COMBINE
1410
+ else
1411
+ raise 'Invalid state'
1412
+ end
1413
+ end
1414
+
1415
+ def visit_named_types(ctx)
1416
+ ctx__entity_ref = ctx.entity_ref
1417
+ ctx__type_ref = ctx.type_ref
1418
+
1419
+ visit_if(ctx__entity_ref || ctx__type_ref)
1420
+ end
1421
+
1422
+ def visit_named_type_or_rename(ctx)
1423
+ ctx__named_types = ctx.named_types
1424
+ ctx__entity_id = ctx.entity_id
1425
+ ctx__type_id = ctx.type_id
1426
+
1427
+ ref = visit_if(ctx__named_types)
1428
+ id = visit_if(ctx__entity_id || ctx__type_id)
1429
+
1430
+ if id
1431
+ Model::RenamedRef.new({
1432
+ ref: ref,
1433
+ id: id
1434
+ })
1435
+ else
1436
+ ref
1437
+ end
1438
+ end
1439
+
1440
+ def visit_null_stmt(ctx)
1441
+ Model::Statements::Null.new
1442
+ end
1443
+
1444
+ def visit_number_type(ctx)
1445
+ Model::Types::Number.new
1446
+ end
1447
+
1448
+ def visit_numeric_expression(ctx)
1449
+ ctx__simple_expression = ctx.simple_expression
1450
+
1451
+ visit_if(ctx__simple_expression)
1452
+ end
1453
+
1454
+ def visit_one_of(ctx)
1455
+ ctx__supertype_expression = ctx.supertype_expression
1456
+
1457
+ ref = Model::Expressions::SimpleReference.new({ id: 'ONEOF' })
1458
+ parameters = visit_if_map(ctx__supertype_expression)
1459
+
1460
+ Model::Expressions::Call.new({
1461
+ ref: ref,
1462
+ parameters: parameters
1463
+ })
1464
+ end
1465
+
1466
+ def visit_parameter(ctx)
1467
+ ctx__expression = ctx.expression
1468
+
1469
+ visit_if(ctx__expression)
1470
+ end
1471
+
1472
+ def visit_parameter_id(ctx)
1473
+ ctx__SimpleId = ctx.SimpleId
1474
+
1475
+ handle_simple_id(ctx__SimpleId)
1476
+ end
1477
+
1478
+ def visit_parameter_type(ctx)
1479
+ ctx__generalized_types = ctx.generalized_types
1480
+ ctx__named_types = ctx.named_types
1481
+ ctx__simple_types = ctx.simple_types
1482
+
1483
+ visit_if(ctx__generalized_types || ctx__named_types || ctx__simple_types)
1484
+ end
1485
+
1486
+ def visit_population(ctx)
1487
+ ctx__entity_ref = ctx.entity_ref
1488
+
1489
+ visit_if(ctx__entity_ref)
1490
+ end
1491
+
1492
+ def visit_precision_spec(ctx)
1493
+ ctx__numeric_expression = ctx.numeric_expression
1494
+
1495
+ visit_if(ctx__numeric_expression)
1496
+ end
1497
+
1498
+ def visit_primary(ctx)
1499
+ ctx__literal = ctx.literal
1500
+ ctx__qualifiable_factor = ctx.qualifiable_factor
1501
+ ctx__qualifier = ctx.qualifier
1502
+
1503
+ if ctx__literal
1504
+ visit(ctx__literal)
1505
+ elsif ctx__qualifiable_factor
1506
+ handle_qualified_ref(visit(ctx__qualifiable_factor), ctx__qualifier)
1507
+ else
1508
+ raise 'Invalid state'
1509
+ end
1510
+ end
1511
+
1512
+ def visit_procedure_call_stmt(ctx)
1513
+ ctx__built_in_procedure = ctx.built_in_procedure
1514
+ ctx__procedure_ref = ctx.procedure_ref
1515
+ ctx__actual_parameter_list = ctx.actual_parameter_list
1516
+
1517
+ ref = visit_if(ctx__built_in_procedure || ctx__procedure_ref)
1518
+ parameters = visit_if(ctx__actual_parameter_list)
1519
+
1520
+ Model::Statements::Call.new({
1521
+ ref: ref,
1522
+ parameters: parameters
1523
+ })
1524
+ end
1525
+
1526
+ def visit_procedure_decl(ctx)
1527
+ ctx__procedure_head = ctx.procedure_head
1528
+ ctx__algorithm_head = ctx.algorithm_head
1529
+ ctx__stmt = ctx.stmt
1530
+ ctx__procedure_head__procedure_id = ctx__procedure_head&.procedure_id
1531
+ ctx__procedure_head__procedure_head_parameter = ctx__procedure_head&.procedure_head_parameter
1532
+ ctx__algorithm_head__declaration = ctx__algorithm_head&.declaration
1533
+ ctx__algorithm_head__constant_decl = ctx__algorithm_head&.constant_decl
1534
+ ctx__algorithm_head__local_decl = ctx__algorithm_head&.local_decl
1535
+
1536
+ id = visit_if(ctx__procedure_head__procedure_id)
1537
+ parameters = visit_if_map_flatten(ctx__procedure_head__procedure_head_parameter)
1538
+ declarations = visit_if_map(ctx__algorithm_head__declaration)
1539
+ constants = visit_if(ctx__algorithm_head__constant_decl)
1540
+ variables = visit_if(ctx__algorithm_head__local_decl)
1541
+ statements = visit_if_map(ctx__stmt)
1542
+
1543
+ Model::Procedure.new({
1544
+ id: id,
1545
+ parameters: parameters,
1546
+ declarations: declarations,
1547
+ constants: constants,
1548
+ variables: variables,
1549
+ statements: statements
1550
+ })
1551
+ end
1552
+
1553
+ def visit_procedure_head(ctx)
1554
+ raise 'Invalid state'
1555
+ end
1556
+
1557
+ def visit_procedure_head_parameter(ctx)
1558
+ ctx__formal_parameter = ctx.formal_parameter
1559
+ ctx__VAR = ctx.VAR
1560
+
1561
+ parameters = visit(ctx__formal_parameter)
1562
+
1563
+ if ctx.VAR
1564
+ parameters.map do |parameter|
1565
+ Model::Parameter.new({
1566
+ id: parameter.id,
1567
+ var: true,
1568
+ type: parameter.type
1569
+ })
1570
+ end
1571
+ else
1572
+ parameters
1573
+ end
1574
+ end
1575
+
1576
+ def visit_procedure_id(ctx)
1577
+ ctx__SimpleId = ctx.SimpleId
1578
+
1579
+ handle_simple_id(ctx__SimpleId)
1580
+ end
1581
+
1582
+ def visit_qualifiable_factor(ctx)
1583
+ ctx__attribute_ref = ctx.attribute_ref
1584
+ ctx__constant_factor = ctx.constant_factor
1585
+ ctx__function_call = ctx.function_call
1586
+ ctx__general_ref = ctx.general_ref
1587
+ ctx__population = ctx.population
1588
+
1589
+ visit_if(ctx__attribute_ref || ctx__constant_factor || ctx__function_call || ctx__general_ref || ctx__population)
1590
+ end
1591
+
1592
+ def visit_qualified_attribute(ctx)
1593
+ ctx__group_qualifier = ctx.group_qualifier
1594
+ ctx__attribute_qualifier = ctx.attribute_qualifier
1595
+
1596
+ id = 'SELF'
1597
+ group_reference = visit_if(ctx__group_qualifier)
1598
+ attribute_reference = visit_if(ctx__attribute_qualifier)
1599
+
1600
+ Model::Expressions::AttributeReference.new({
1601
+ ref: Model::Expressions::GroupReference.new({
1602
+ ref: Model::Expressions::SimpleReference.new({
1603
+ id: id
1604
+ }),
1605
+ entity: group_reference.entity
1606
+ }),
1607
+ attribute: attribute_reference.attribute
1608
+ })
1609
+ end
1610
+
1611
+ def visit_qualifier(ctx)
1612
+ ctx__attribute_qualifier = ctx.attribute_qualifier
1613
+ ctx__group_qualifier = ctx.group_qualifier
1614
+ ctx__index_qualifier = ctx.index_qualifier
1615
+
1616
+ visit_if(ctx__attribute_qualifier || ctx__group_qualifier || ctx__index_qualifier)
1617
+ end
1618
+
1619
+ def visit_query_expression(ctx)
1620
+ ctx__variable_id = ctx.variable_id
1621
+ ctx__aggregate_source = ctx.aggregate_source
1622
+ ctx__logical_expression = ctx.logical_expression
1623
+
1624
+ id = visit_if(ctx__variable_id)
1625
+ aggregate_source = visit_if(ctx__aggregate_source)
1626
+ expression = visit_if(ctx__logical_expression)
1627
+
1628
+ Model::Expressions::QueryExpression.new({
1629
+ id: id,
1630
+ aggregate_source: aggregate_source,
1631
+ expression: expression
1632
+ })
1633
+ end
1634
+
1635
+ def visit_real_type(ctx)
1636
+ ctx__precision_spec = ctx.precision_spec
1637
+
1638
+ precision = visit_if(ctx__precision_spec)
1639
+
1640
+ Model::Types::Real.new({
1641
+ precision: precision
1642
+ })
1643
+ end
1644
+
1645
+ def visit_redeclared_attribute(ctx)
1646
+ raise 'Invalid state'
1647
+ end
1648
+
1649
+ def visit_referenced_attribute(ctx)
1650
+ ctx__attribute_ref = ctx.attribute_ref
1651
+ ctx__qualified_attribute = ctx.qualified_attribute
1652
+
1653
+ visit_if(ctx__attribute_ref || ctx__qualified_attribute)
1654
+ end
1655
+
1656
+ def visit_reference_clause(ctx)
1657
+ ctx__schema_ref = ctx.schema_ref
1658
+ ctx__resource_or_rename = ctx.resource_or_rename
1659
+
1660
+ schema = visit_if(ctx__schema_ref)
1661
+ items = visit_if_map(ctx__resource_or_rename)
1662
+
1663
+ Model::Interface.new({
1664
+ kind: Model::Interface::REFERENCE,
1665
+ schema: schema,
1666
+ items: items
1667
+ })
1668
+ end
1669
+
1670
+ def visit_rel_op(ctx)
1671
+ ctx__text = ctx.text
1672
+ ctx__LESS_THAN = ctx__text == '<'
1673
+ ctx__GREATER_THAN = ctx__text == '>'
1674
+ ctx__LESS_THAN_OR_EQUAL = ctx__text == '<='
1675
+ ctx__GREATER_THAN_OR_EQUAL = ctx__text == '>='
1676
+ ctx__NOT_EQUAL = ctx__text == '<>'
1677
+ ctx__EQUAL = ctx__text == '='
1678
+ ctx__INSTANCE_NOT_EQUAL = ctx__text == ':<>:'
1679
+ ctx__INSTANCE_EQUAL = ctx__text == ':=:'
1680
+
1681
+ if ctx__LESS_THAN
1682
+ Model::Expressions::BinaryExpression::LESS_THAN
1683
+ elsif ctx__GREATER_THAN
1684
+ Model::Expressions::BinaryExpression::GREATER_THAN
1685
+ elsif ctx__LESS_THAN_OR_EQUAL
1686
+ Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL
1687
+ elsif ctx__GREATER_THAN_OR_EQUAL
1688
+ Model::Expressions::BinaryExpression::GREATER_THAN_OR_EQUAL
1689
+ elsif ctx__NOT_EQUAL
1690
+ Model::Expressions::BinaryExpression::NOT_EQUAL
1691
+ elsif ctx__EQUAL
1692
+ Model::Expressions::BinaryExpression::EQUAL
1693
+ elsif ctx__INSTANCE_NOT_EQUAL
1694
+ Model::Expressions::BinaryExpression::INSTANCE_NOT_EQUAL
1695
+ elsif ctx__INSTANCE_EQUAL
1696
+ Model::Expressions::BinaryExpression::INSTANCE_EQUAL
1697
+ else
1698
+ raise 'Invalid state'
1699
+ end
1700
+ end
1701
+
1702
+ def visit_rel_op_extended(ctx)
1703
+ ctx__rel_op = ctx.rel_op
1704
+ ctx__IN = ctx.IN
1705
+ ctx__LIKE = ctx.LIKE
1706
+
1707
+ if ctx__rel_op
1708
+ visit(ctx__rel_op)
1709
+ elsif ctx__IN
1710
+ Model::Expressions::BinaryExpression::IN
1711
+ elsif ctx__LIKE
1712
+ Model::Expressions::BinaryExpression::LIKE
1713
+ else
1714
+ raise 'Invalid state'
1715
+ end
1716
+ end
1717
+
1718
+ def visit_rename_id(ctx)
1719
+ ctx__constant_id = ctx.constant_id
1720
+ ctx__entity_id = ctx.entity_id
1721
+ ctx__function_id = ctx.function_id
1722
+ ctx__procedure_id = ctx.procedure_id
1723
+ ctx__type_id = ctx.type_id
1724
+
1725
+ visit_if(ctx__constant_id || ctx__entity_id || ctx__function_id || ctx__procedure_id || ctx__type_id)
1726
+ end
1727
+
1728
+ def visit_repeat_control(ctx)
1729
+ raise 'Invalid state'
1730
+ end
1731
+
1732
+ def visit_repeat_stmt(ctx)
1733
+ ctx__repeat_control = ctx.repeat_control
1734
+ ctx__stmt = ctx.stmt
1735
+ ctx__repeat_control__increment_control = ctx__repeat_control&.increment_control
1736
+ ctx__repeat_control__increment_control__variable_id = ctx__repeat_control__increment_control&.variable_id
1737
+ ctx__repeat_control__increment_control__bound1 = ctx__repeat_control__increment_control&.bound1
1738
+ ctx__repeat_control__increment_control__bound2 = ctx__repeat_control__increment_control&.bound2
1739
+ ctx__repeat_control__increment_control__increment = ctx__repeat_control__increment_control&.increment
1740
+ ctx__repeat_control__while_control = ctx__repeat_control&.while_control
1741
+ ctx__repeat_control__until_control = ctx__repeat_control&.until_control
1742
+
1743
+ id = visit_if(ctx__repeat_control__increment_control__variable_id)
1744
+ bound1 = visit_if(ctx__repeat_control__increment_control__bound1)
1745
+ bound2 = visit_if(ctx__repeat_control__increment_control__bound2)
1746
+ increment = visit_if(ctx__repeat_control__increment_control__increment)
1747
+ while_expression = visit_if(ctx__repeat_control__while_control)
1748
+ until_expression = visit_if(ctx__repeat_control__until_control)
1749
+ statements = visit_if_map(ctx__stmt)
1750
+
1751
+ Model::Statements::Repeat.new({
1752
+ id: id,
1753
+ bound1: bound1,
1754
+ bound2: bound2,
1755
+ increment: increment,
1756
+ while_expression: while_expression,
1757
+ until_expression: until_expression,
1758
+ statements: statements
1759
+ })
1760
+ end
1761
+
1762
+ def visit_repetition(ctx)
1763
+ ctx__numeric_expression = ctx.numeric_expression
1764
+
1765
+ visit_if(ctx__numeric_expression)
1766
+ end
1767
+
1768
+ def visit_resource_or_rename(ctx)
1769
+ ctx__resource_ref = ctx.resource_ref
1770
+ ctx__rename_id = ctx.rename_id
1771
+
1772
+ if ctx__resource_ref
1773
+ if ctx__rename_id
1774
+ ref = visit(ctx__resource_ref)
1775
+ id = visit(ctx__rename_id)
1776
+
1777
+ Model::RenamedRef.new({
1778
+ ref: ref,
1779
+ id: id
1780
+ })
1781
+ else
1782
+ visit(ctx__resource_ref)
1783
+ end
1784
+ else
1785
+ raise 'Invalid state'
1786
+ end
1787
+ end
1788
+
1789
+ def visit_resource_ref(ctx)
1790
+ ctx__constant_ref = ctx.constant_ref
1791
+ ctx__entity_ref = ctx.entity_ref
1792
+ ctx__function_ref = ctx.function_ref
1793
+ ctx__procedure_ref = ctx.procedure_ref
1794
+ ctx__type_ref = ctx.type_ref
1795
+
1796
+ visit_if(ctx__constant_ref || ctx__entity_ref || ctx__function_ref || ctx__procedure_ref || ctx__type_ref)
1797
+ end
1798
+
1799
+ def visit_return_stmt(ctx)
1800
+ ctx__expression = ctx.expression
1801
+
1802
+ expression = visit_if(ctx__expression)
1803
+
1804
+ Model::Statements::Return.new({
1805
+ expression: expression
1806
+ })
1807
+ end
1808
+
1809
+ def visit_rule_decl(ctx)
1810
+ ctx__rule_head = ctx.rule_head
1811
+ ctx__algorithm_head = ctx.algorithm_head
1812
+ ctx__stmt = ctx.stmt
1813
+ ctx__where_clause = ctx.where_clause
1814
+ ctx__rule_head__rule_id = ctx__rule_head&.rule_id
1815
+ ctx__rule_head__entity_ref = ctx__rule_head&.entity_ref
1816
+ ctx__algorithm_head__declaration = ctx__algorithm_head&.declaration
1817
+ ctx__algorithm_head__constant_decl = ctx__algorithm_head&.constant_decl
1818
+ ctx__algorithm_head__local_decl = ctx__algorithm_head&.local_decl
1819
+
1820
+ id = visit_if(ctx__rule_head__rule_id)
1821
+ applies_to = visit_if_map(ctx__rule_head__entity_ref)
1822
+ declarations = visit_if_map(ctx__algorithm_head__declaration)
1823
+ constants = visit_if(ctx__algorithm_head__constant_decl)
1824
+ variables = visit_if(ctx__algorithm_head__local_decl)
1825
+ statements = visit_if_map(ctx__stmt)
1826
+ where = visit_if(ctx__where_clause)
1827
+
1828
+ Model::Rule.new({
1829
+ id: id,
1830
+ applies_to: applies_to,
1831
+ declarations: declarations,
1832
+ constants: constants,
1833
+ variables: variables,
1834
+ statements: statements,
1835
+ where: where
1836
+ })
1837
+ end
1838
+
1839
+ def visit_rule_head(ctx)
1840
+ raise 'Invalid state'
1841
+ end
1842
+
1843
+ def visit_rule_id(ctx)
1844
+ ctx__SimpleId = ctx.SimpleId
1845
+
1846
+ handle_simple_id(ctx__SimpleId)
1847
+ end
1848
+
1849
+ def visit_rule_label_id(ctx)
1850
+ ctx__SimpleId = ctx.SimpleId
1851
+
1852
+ handle_simple_id(ctx__SimpleId)
1853
+ end
1854
+
1855
+ def visit_schema_body(ctx)
1856
+ raise 'Invalid state'
1857
+ end
1858
+
1859
+ def visit_schema_body_declaration(ctx)
1860
+ ctx__declaration = ctx.declaration
1861
+ ctx__rule_decl = ctx.rule_decl
1862
+
1863
+ visit_if(ctx__declaration || ctx__rule_decl)
1864
+ end
1865
+
1866
+ def visit_schema_decl(ctx)
1867
+ ctx__schema_id = ctx.schema_id
1868
+ ctx__schema_version_id = ctx.schema_version_id
1869
+ ctx__schema_body = ctx.schema_body
1870
+ ctx__schema_body__interface_specification = ctx__schema_body&.interface_specification
1871
+ ctx__schema_body__constant_decl = ctx__schema_body&.constant_decl
1872
+ ctx__schema_body__schema_body_declaration = ctx__schema_body&.schema_body_declaration
1873
+
1874
+ id = visit_if(ctx__schema_id)
1875
+ version = visit_if(ctx__schema_version_id)
1876
+ interfaces = visit_if_map(ctx__schema_body__interface_specification)
1877
+ constants = visit_if(ctx__schema_body__constant_decl)
1878
+ declarations = visit_if_map(ctx__schema_body__schema_body_declaration)
1879
+
1880
+ Model::Schema.new({
1881
+ id: id,
1882
+ version: version,
1883
+ interfaces: interfaces,
1884
+ constants: constants,
1885
+ declarations: declarations
1886
+ })
1887
+ end
1888
+
1889
+ def visit_schema_id(ctx)
1890
+ ctx__SimpleId = ctx.SimpleId
1891
+
1892
+ handle_simple_id(ctx__SimpleId)
1893
+ end
1894
+
1895
+ def visit_schema_version_id(ctx)
1896
+ ctx__string_literal = ctx.string_literal
1897
+
1898
+ visit_if(ctx__string_literal)
1899
+ end
1900
+
1901
+ def visit_selector(ctx)
1902
+ raise 'Invalid state'
1903
+ end
1904
+
1905
+ def visit_select_extension(ctx)
1906
+ ctx__named_types = ctx.named_types
1907
+
1908
+ visit_if_map(ctx__named_types)
1909
+ end
1910
+
1911
+ def visit_select_list(ctx)
1912
+ ctx__named_types = ctx.named_types
1913
+
1914
+ visit_if_map(ctx__named_types)
1915
+ end
1916
+
1917
+ def visit_select_type(ctx)
1918
+ ctx__EXTENSIBLE = ctx.EXTENSIBLE
1919
+ ctx__GENERIC_ENTITY = ctx.GENERIC_ENTITY
1920
+ ctx__select_list = ctx.select_list
1921
+ ctx__select_extension = ctx.select_extension
1922
+ ctx__select_extension__type_ref = ctx.select_extension&.type_ref
1923
+ ctx__select_extension__select_list = ctx__select_extension&.select_list
1924
+
1925
+ extensible = !!ctx__EXTENSIBLE
1926
+ generic_entity = !!ctx__GENERIC_ENTITY
1927
+ items = visit_if(ctx__select_list)
1928
+ extension_type = visit_if(ctx__select_extension__type_ref)
1929
+ extension_items = visit_if(ctx__select_extension__select_list)
1930
+
1931
+ Model::Types::Select.new({
1932
+ extensible: extensible,
1933
+ generic_entity: generic_entity,
1934
+ items: items,
1935
+ extension_type: extension_type,
1936
+ extension_items: extension_items
1937
+ })
1938
+ end
1939
+
1940
+ def visit_set_type(ctx)
1941
+ ctx__bound_spec = ctx.bound_spec
1942
+ ctx__instantiable_type = ctx.instantiable_type
1943
+ ctx__bound_spec__bound1 = ctx__bound_spec&.bound1
1944
+ ctx__bound_spec__bound2 = ctx__bound_spec&.bound2
1945
+
1946
+ bound1 = visit_if(ctx__bound_spec__bound1)
1947
+ bound2 = visit_if(ctx__bound_spec__bound2)
1948
+ base_type = visit_if(ctx__instantiable_type)
1949
+
1950
+ Model::Types::Set.new({
1951
+ bound1: bound1,
1952
+ bound2: bound2,
1953
+ base_type: base_type
1954
+ })
1955
+ end
1956
+
1957
+ def visit_simple_expression(ctx)
1958
+ ctx__term = ctx.term
1959
+ ctx__add_like_op = ctx.add_like_op
1960
+
1961
+ if ctx__term
1962
+ if ctx__term.length >= 2
1963
+ if ctx__add_like_op and ctx__add_like_op.length == ctx__term.length - 1
1964
+ operands = ctx__term.map(&self.method(:visit))
1965
+ operators = ctx__add_like_op.map(&self.method(:visit))
1966
+
1967
+ handle_binary_expression(operands, operators)
1968
+ else
1969
+ raise 'Invalid state'
1970
+ end
1971
+ elsif ctx__term.length == 1
1972
+ visit(ctx__term[0])
1973
+ else
1974
+ raise 'Invalid state'
1975
+ end
1976
+ end
1977
+ end
1978
+
1979
+ def visit_simple_factor(ctx)
1980
+ ctx__aggregate_initializer = ctx.aggregate_initializer
1981
+ ctx__entity_constructor = ctx.entity_constructor
1982
+ ctx__enumeration_reference = ctx.enumeration_reference
1983
+ ctx__interval = ctx.interval
1984
+ ctx__query_expression = ctx.query_expression
1985
+ ctx__simple_factor_expression = ctx.simple_factor_expression
1986
+ ctx__simple_factor_unary_expression = ctx.simple_factor_unary_expression
1987
+
1988
+ visit_if(ctx__aggregate_initializer || ctx__entity_constructor || ctx__enumeration_reference || ctx__interval || ctx__query_expression || ctx__simple_factor_expression || ctx__simple_factor_unary_expression)
1989
+ end
1990
+
1991
+ def visit_simple_factor_expression(ctx)
1992
+ ctx__expression = ctx.expression
1993
+ ctx__primary = ctx.primary
1994
+
1995
+ visit_if(ctx__expression || ctx__primary)
1996
+ end
1997
+
1998
+ def visit_simple_factor_unary_expression(ctx)
1999
+ ctx__unary_op = ctx.unary_op
2000
+ ctx__simple_factor_expression = ctx.simple_factor_expression
2001
+
2002
+ operator = visit_if(ctx__unary_op)
2003
+ operand = visit_if(ctx__simple_factor_expression)
2004
+
2005
+ Model::Expressions::UnaryExpression.new({
2006
+ operator: operator,
2007
+ operand: operand
2008
+ })
2009
+ end
2010
+
2011
+ def visit_simple_types(ctx)
2012
+ ctx__binary_type = ctx.binary_type
2013
+ ctx__boolean_type = ctx.boolean_type
2014
+ ctx__integer_type = ctx.integer_type
2015
+ ctx__logical_type = ctx.logical_type
2016
+ ctx__number_type = ctx.number_type
2017
+ ctx__real_type = ctx.real_type
2018
+ ctx__string_type = ctx.string_type
2019
+
2020
+ visit_if(ctx__binary_type || ctx__boolean_type || ctx__integer_type || ctx__logical_type || ctx__number_type || ctx__real_type || ctx__string_type)
2021
+ end
2022
+
2023
+ def visit_skip_stmt(ctx)
2024
+ Model::Statements::Skip.new
2025
+ end
2026
+
2027
+ def visit_stmt(ctx)
2028
+ ctx__alias_stmt = ctx.alias_stmt
2029
+ ctx__assignment_stmt = ctx.assignment_stmt
2030
+ ctx__case_stmt = ctx.case_stmt
2031
+ ctx__compound_stmt = ctx.compound_stmt
2032
+ ctx__escape_stmt = ctx.escape_stmt
2033
+ ctx__if_stmt = ctx.if_stmt
2034
+ ctx__null_stmt = ctx.null_stmt
2035
+ ctx__procedure_call_stmt = ctx.procedure_call_stmt
2036
+ ctx__repeat_stmt = ctx.repeat_stmt
2037
+ ctx__return_stmt = ctx.return_stmt
2038
+ ctx__skip_stmt = ctx.skip_stmt
2039
+
2040
+ visit_if(ctx__alias_stmt || ctx__assignment_stmt || ctx__case_stmt || ctx__compound_stmt || ctx__escape_stmt || ctx__if_stmt || ctx__null_stmt || ctx__procedure_call_stmt || ctx__repeat_stmt || ctx__return_stmt || ctx__skip_stmt)
2041
+ end
2042
+
2043
+ def visit_string_literal(ctx)
2044
+ ctx__SimpleStringLiteral = ctx.SimpleStringLiteral
2045
+ ctx__EncodedStringLiteral = ctx.EncodedStringLiteral
2046
+
2047
+ if ctx__SimpleStringLiteral
2048
+ handle_simple_string_literal(ctx__SimpleStringLiteral)
2049
+ elsif ctx__EncodedStringLiteral
2050
+ handle_encoded_string_literal(ctx__EncodedStringLiteral)
2051
+ else
2052
+ raise 'Invalid state'
2053
+ end
2054
+ end
2055
+
2056
+ def visit_string_type(ctx)
2057
+ ctx__width_spec = ctx.width_spec
2058
+ ctx__width_spec__width = ctx__width_spec&.width
2059
+ ctx__width_spec__FIXED = ctx__width_spec&.FIXED
2060
+
2061
+ width = visit_if(ctx__width_spec__width)
2062
+ fixed = !!ctx__width_spec__FIXED
2063
+
2064
+ Model::Types::String.new({
2065
+ width: width,
2066
+ fixed: fixed
2067
+ })
2068
+ end
2069
+
2070
+ def visit_subsuper(ctx)
2071
+ raise 'Invalid state'
2072
+ end
2073
+
2074
+ def visit_subtype_constraint(ctx)
2075
+ ctx__supertype_expression = ctx.supertype_expression
2076
+
2077
+ visit_if(ctx__supertype_expression)
2078
+ end
2079
+
2080
+ def visit_subtype_constraint_body(ctx)
2081
+ raise 'Invalid state'
2082
+ end
2083
+
2084
+ def visit_subtype_constraint_decl(ctx)
2085
+ ctx__subtype_constraint_head = ctx.subtype_constraint_head
2086
+ ctx__subtype_constraint_body = ctx.subtype_constraint_body
2087
+ ctx__subtype_constraint_head__subtype_constraint_id = ctx__subtype_constraint_head&.subtype_constraint_id
2088
+ ctx__subtype_constraint_head__entity_ref = ctx__subtype_constraint_head&.entity_ref
2089
+ ctx__subtype_constraint_body__abstract_supertype = ctx__subtype_constraint_body&.abstract_supertype
2090
+ ctx__subtype_constraint_body__total_over = ctx__subtype_constraint_body&.total_over
2091
+ ctx__subtype_constraint_body__supertype_expression = ctx__subtype_constraint_body&.supertype_expression
2092
+
2093
+ id = visit_if(ctx__subtype_constraint_head__subtype_constraint_id)
2094
+ applies_to = visit_if(ctx__subtype_constraint_head__entity_ref)
2095
+ abstract = !!ctx__subtype_constraint_body__abstract_supertype
2096
+ total_over = visit_if(ctx__subtype_constraint_body__total_over)
2097
+ supertype_expression = visit_if(ctx__subtype_constraint_body__supertype_expression)
2098
+
2099
+ Model::SubtypeConstraint.new({
2100
+ id: id,
2101
+ applies_to: applies_to,
2102
+ abstract: abstract,
2103
+ total_over: total_over,
2104
+ supertype_expression: supertype_expression
2105
+ })
2106
+ end
2107
+
2108
+ def visit_subtype_constraint_head(ctx)
2109
+ raise 'Invalid state'
2110
+ end
2111
+
2112
+ def visit_subtype_constraint_id(ctx)
2113
+ ctx__SimpleId = ctx.SimpleId
2114
+
2115
+ handle_simple_id(ctx__SimpleId)
2116
+ end
2117
+
2118
+ def visit_subtype_declaration(ctx)
2119
+ ctx__entity_ref = ctx.entity_ref
2120
+
2121
+ visit_if_map(ctx__entity_ref)
2122
+ end
2123
+
2124
+ def visit_supertype_constraint(ctx)
2125
+ raise 'Invalid state'
2126
+ end
2127
+
2128
+ def visit_supertype_expression(ctx)
2129
+ ctx__supertype_factor = ctx.supertype_factor
2130
+ ctx__ANDOR = ctx.ANDOR
2131
+
2132
+ if ctx__supertype_factor
2133
+ if ctx__supertype_factor.length >= 2
2134
+ if ctx__ANDOR and ctx__ANDOR.length == ctx__supertype_factor.length - 1
2135
+ operands = ctx__supertype_factor.map(&self.method(:visit))
2136
+ operators = ctx__ANDOR.map{Model::Expressions::BinaryExpression::ANDOR}
2137
+
2138
+ handle_binary_expression(operands, operators)
2139
+ else
2140
+ raise 'Invalid state'
2141
+ end
2142
+ elsif ctx__supertype_factor.length == 1
2143
+ visit(ctx__supertype_factor[0])
2144
+ else
2145
+ raise 'Invalid state'
2146
+ end
2147
+ end
2148
+ end
2149
+
2150
+ def visit_supertype_factor(ctx)
2151
+ ctx__supertype_term = ctx.supertype_term
2152
+ ctx__AND = ctx.AND
2153
+
2154
+ if ctx__supertype_term
2155
+ if ctx__supertype_term.length >= 2
2156
+ if ctx__AND and ctx__AND.length == ctx__supertype_term.length - 1
2157
+ operands = ctx__supertype_term.map(&self.method(:visit))
2158
+ operators = ctx__AND.map{Model::Expressions::BinaryExpression::AND}
2159
+
2160
+ handle_binary_expression(operands, operators)
2161
+ else
2162
+ raise 'Invalid state'
2163
+ end
2164
+ elsif ctx__supertype_term.length == 1
2165
+ visit(ctx__supertype_term[0])
2166
+ else
2167
+ raise 'Invalid state'
2168
+ end
2169
+ end
2170
+ end
2171
+
2172
+ def visit_supertype_rule(ctx)
2173
+ ctx__subtype_constraint = ctx.subtype_constraint
2174
+
2175
+ visit_if(ctx__subtype_constraint)
2176
+ end
2177
+
2178
+ def visit_supertype_term(ctx)
2179
+ ctx__entity_ref = ctx.entity_ref
2180
+ ctx__one_of = ctx.one_of
2181
+ ctx__supertype_expression = ctx.supertype_expression
2182
+
2183
+ visit_if(ctx__entity_ref || ctx__one_of || ctx__supertype_expression)
2184
+ end
2185
+
2186
+ def visit_syntax(ctx)
2187
+ ctx__schema_decl = ctx.schema_decl
2188
+
2189
+ schemas = visit_if_map(ctx__schema_decl)
2190
+
2191
+ Model::Repository.new({
2192
+ schemas: schemas
2193
+ })
2194
+ end
2195
+
2196
+ def visit_term(ctx)
2197
+ ctx__factor = ctx.factor
2198
+ ctx__multiplication_like_op = ctx.multiplication_like_op
2199
+
2200
+ if ctx__factor
2201
+ if ctx__factor.length >= 2
2202
+ if ctx__multiplication_like_op and ctx__multiplication_like_op.length == ctx__factor.length - 1
2203
+ operands = ctx__factor.map(&self.method(:visit))
2204
+ operators = ctx__multiplication_like_op.map(&self.method(:visit))
2205
+
2206
+ handle_binary_expression(operands, operators)
2207
+ else
2208
+ raise 'Invalid state'
2209
+ end
2210
+ elsif ctx__factor.length == 1
2211
+ visit(ctx__factor[0])
2212
+ else
2213
+ raise 'Invalid state'
2214
+ end
2215
+ end
2216
+ end
2217
+
2218
+ def visit_total_over(ctx)
2219
+ ctx__entity_ref = ctx.entity_ref
2220
+
2221
+ visit_if_map(ctx__entity_ref)
2222
+ end
2223
+
2224
+ def visit_type_decl(ctx)
2225
+ ctx__type_id = ctx.type_id
2226
+ ctx__underlying_type = ctx.underlying_type
2227
+ ctx__where_clause = ctx.where_clause
2228
+
2229
+ id = visit_if(ctx__type_id)
2230
+ type = visit_if(ctx__underlying_type)
2231
+ where = visit_if(ctx__where_clause)
2232
+
2233
+ Model::Type.new({
2234
+ id: id,
2235
+ type: type,
2236
+ where: where
2237
+ })
2238
+ end
2239
+
2240
+ def visit_type_id(ctx)
2241
+ ctx__SimpleId = ctx.SimpleId
2242
+
2243
+ handle_simple_id(ctx__SimpleId)
2244
+ end
2245
+
2246
+ def visit_type_label(ctx)
2247
+ ctx__type_label_id = ctx.type_label_id
2248
+ ctx__type_label_ref = ctx.type_label_ref
2249
+
2250
+ visit_if(ctx__type_label_id || ctx__type_label_ref)
2251
+ end
2252
+
2253
+ def visit_type_label_id(ctx)
2254
+ ctx__SimpleId = ctx.SimpleId
2255
+
2256
+ handle_simple_id(ctx__SimpleId)
2257
+ end
2258
+
2259
+ def visit_unary_op(ctx)
2260
+ ctx__text = ctx.text
2261
+ ctx__PLUS = ctx__text == '+'
2262
+ ctx__MINUS = ctx__text == '-'
2263
+ ctx__NOT = ctx.NOT
2264
+
2265
+ if ctx__PLUS
2266
+ Model::Expressions::UnaryExpression::PLUS
2267
+ elsif ctx__MINUS
2268
+ Model::Expressions::UnaryExpression::MINUS
2269
+ elsif ctx__NOT
2270
+ Model::Expressions::UnaryExpression::NOT
2271
+ else
2272
+ raise 'Invalid state'
2273
+ end
2274
+ end
2275
+
2276
+ def visit_underlying_type(ctx)
2277
+ ctx__concrete_types = ctx.concrete_types
2278
+ ctx__constructed_types = ctx.constructed_types
2279
+
2280
+ visit_if(ctx__concrete_types || ctx__constructed_types)
2281
+ end
2282
+
2283
+ def visit_unique_clause(ctx)
2284
+ ctx__unique_rule = ctx.unique_rule
2285
+
2286
+ visit_if_map(ctx__unique_rule)
2287
+ end
2288
+
2289
+ def visit_unique_rule(ctx)
2290
+ ctx__rule_label_id = ctx.rule_label_id
2291
+ ctx__referenced_attribute = ctx.referenced_attribute
2292
+
2293
+ id = visit_if(ctx__rule_label_id)
2294
+ attributes = visit_if_map(ctx__referenced_attribute)
2295
+
2296
+ Model::Unique.new({
2297
+ id: id,
2298
+ attributes: attributes
2299
+ })
2300
+ end
2301
+
2302
+ def visit_until_control(ctx)
2303
+ ctx__logical_expression = ctx.logical_expression
2304
+
2305
+ visit_if(ctx__logical_expression)
2306
+ end
2307
+
2308
+ def visit_use_clause(ctx)
2309
+ ctx__schema_ref = ctx.schema_ref
2310
+ ctx__named_type_or_rename = ctx.named_type_or_rename
2311
+
2312
+ schema = visit_if(ctx__schema_ref)
2313
+ items = visit_if_map(ctx__named_type_or_rename)
2314
+
2315
+ Model::Interface.new({
2316
+ kind: Model::Interface::USE,
2317
+ schema: schema,
2318
+ items: items
2319
+ })
2320
+ end
2321
+
2322
+ def visit_variable_id(ctx)
2323
+ ctx__SimpleId = ctx.SimpleId
2324
+
2325
+ handle_simple_id(ctx__SimpleId)
2326
+ end
2327
+
2328
+ def visit_where_clause(ctx)
2329
+ ctx__domain_rule = ctx.domain_rule
2330
+
2331
+ visit_if_map(ctx__domain_rule)
2332
+ end
2333
+
2334
+ def visit_while_control(ctx)
2335
+ ctx__logical_expression = ctx.logical_expression
2336
+
2337
+ visit_if(ctx__logical_expression)
2338
+ end
2339
+
2340
+ def visit_width(ctx)
2341
+ ctx__numeric_expression = ctx.numeric_expression
2342
+
2343
+ visit_if(ctx__numeric_expression)
2344
+ end
2345
+
2346
+ def visit_width_spec(ctx)
2347
+ raise 'Invalid state'
2348
+ end
2349
+
2350
+ private
2351
+
2352
+ def handle_binary_expression(operands, operators)
2353
+ if operands.length != operators.length + 1
2354
+ raise 'Invalid state'
2355
+ end
2356
+
2357
+ expression = Model::Expressions::BinaryExpression.new({
2358
+ operator: operators[0],
2359
+ operand1: operands[0],
2360
+ operand2: operands[1]
2361
+ })
2362
+ operators[1..(operators.length - 1)].each_with_index do |operator, i|
2363
+ expression = Model::Expressions::BinaryExpression.new({
2364
+ operator: operator,
2365
+ operand1: expression,
2366
+ operand2: operands[i + 2]
2367
+ })
2368
+ end
2369
+ expression
2370
+ end
2371
+
2372
+ def handle_qualified_ref(ref, qualifiers)
2373
+ qualifiers.reduce(ref) do |ref, ctx|
2374
+ ctx__attribute_qualifier = ctx.attribute_qualifier
2375
+ ctx__group_qualifier = ctx.group_qualifier
2376
+ ctx__index_qualifier = ctx.index_qualifier
2377
+
2378
+ if ctx__attribute_qualifier
2379
+ attribute_reference = visit_if(ctx__attribute_qualifier)
2380
+
2381
+ Model::Expressions::AttributeReference.new({
2382
+ ref: ref,
2383
+ attribute: attribute_reference.attribute
2384
+ })
2385
+ elsif ctx__group_qualifier
2386
+ group_reference = visit_if(ctx__group_qualifier)
2387
+
2388
+ Model::Expressions::GroupReference.new({
2389
+ ref: ref,
2390
+ entity: group_reference.entity
2391
+ })
2392
+ elsif ctx__index_qualifier
2393
+ index_reference = visit_if(ctx__index_qualifier)
2394
+
2395
+ Model::Expressions::IndexReference.new({
2396
+ ref: ref,
2397
+ index1: index_reference.index1,
2398
+ index2: index_reference.index2
2399
+ })
2400
+ else
2401
+ raise 'Invalid state'
2402
+ end
2403
+ end
2404
+ end
2405
+
2406
+ def handle_binary_literal(ctx)
2407
+ ctx__text = ctx.text
2408
+
2409
+ value = ctx__text[1..(ctx__text.length - 1)]
2410
+
2411
+ Model::Literals::Binary.new({
2412
+ value: value
2413
+ })
2414
+ end
2415
+
2416
+ def handle_integer_literal(ctx)
2417
+ ctx__text = ctx.text
2418
+
2419
+ value = ctx__text
2420
+
2421
+ Model::Literals::Integer.new({
2422
+ value: value
2423
+ })
2424
+ end
2425
+
2426
+ def handle_real_literal(ctx)
2427
+ ctx__text = ctx.text
2428
+
2429
+ value = ctx__text
2430
+
2431
+ Model::Literals::Real.new({
2432
+ value: value
2433
+ })
2434
+ end
2435
+
2436
+ def handle_simple_id(ctx)
2437
+ ctx__text = ctx.text
2438
+
2439
+ ctx__text
2440
+ end
2441
+
2442
+ def handle_simple_string_literal(ctx)
2443
+ ctx__text = ctx.text
2444
+
2445
+ value = ctx__text[1..(ctx__text.length - 2)].force_encoding('UTF-8')
2446
+
2447
+ Model::Literals::String.new({
2448
+ value: value
2449
+ })
2450
+ end
2451
+
2452
+ def handle_encoded_string_literal(ctx)
2453
+ ctx__text = ctx.text
2454
+
2455
+ value = ctx__text[1..(ctx__text.length - 2)].force_encoding('UTF-8')
2456
+
2457
+ Model::Literals::String.new({
2458
+ value: value,
2459
+ encoded: true
2460
+ })
2461
+ end
2462
+ end
2463
+ end
2451
2464
  end