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

Sign up to get free protection for your applications and to get access to all the features.
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,1450 +1,1450 @@
1
- require 'expressir/model'
2
-
3
- module Expressir
4
- module ExpressExp
5
- class Formatter
6
- INDENT_CHAR = ' '
7
- INDENT_WIDTH = 2
8
- INDENT = INDENT_CHAR * INDENT_WIDTH
9
-
10
- OPERATOR_PRECEDENCE = {
11
- Model::Expressions::BinaryExpression::EXPONENTIATION => 1,
12
- Model::Expressions::BinaryExpression::MULTIPLICATION => 2,
13
- Model::Expressions::BinaryExpression::REAL_DIVISION => 2,
14
- Model::Expressions::BinaryExpression::INTEGER_DIVISION => 2,
15
- Model::Expressions::BinaryExpression::MODULO => 2,
16
- Model::Expressions::BinaryExpression::AND => 2,
17
- Model::Expressions::BinaryExpression::COMBINE => 2,
18
- Model::Expressions::BinaryExpression::SUBTRACTION => 3,
19
- Model::Expressions::BinaryExpression::ADDITION => 3,
20
- Model::Expressions::BinaryExpression::OR => 3,
21
- Model::Expressions::BinaryExpression::XOR => 3,
22
- Model::Expressions::BinaryExpression::EQUAL => 4,
23
- Model::Expressions::BinaryExpression::NOT_EQUAL => 4,
24
- Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL => 4,
25
- Model::Expressions::BinaryExpression::GREATER_THAN_OR_EQUAL => 4,
26
- Model::Expressions::BinaryExpression::LESS_THAN => 4,
27
- Model::Expressions::BinaryExpression::GREATER_THAN => 4,
28
- Model::Expressions::BinaryExpression::INSTANCE_EQUAL => 4,
29
- Model::Expressions::BinaryExpression::INSTANCE_NOT_EQUAL => 4,
30
- Model::Expressions::BinaryExpression::IN => 4,
31
- Model::Expressions::BinaryExpression::LIKE => 4,
32
- Model::Expressions::BinaryExpression::ANDOR => 4,
33
- }
34
-
35
- def self.format(node)
36
- formatter = self.new
37
- formatter.format(node)
38
- end
39
-
40
- def format(node)
41
- if node.instance_of? Model::Attribute
42
- format_attribute(node)
43
- elsif node.instance_of? Model::Constant
44
- format_constant(node)
45
- elsif node.instance_of? Model::Entity
46
- format_entity(node)
47
- elsif node.instance_of? Model::EnumerationItem
48
- format_enumeration_item(node)
49
- elsif node.instance_of? Model::Function
50
- format_function(node)
51
- elsif node.instance_of? Model::Interface
52
- format_interface(node)
53
- elsif node.instance_of? Model::Parameter
54
- format_parameter(node)
55
- elsif node.instance_of? Model::Procedure
56
- format_procedure(node)
57
- elsif node.instance_of? Model::RenamedRef
58
- format_renamed_ref(node)
59
- elsif node.instance_of? Model::Repository
60
- format_repository(node)
61
- elsif node.instance_of? Model::Rule
62
- format_rule(node)
63
- elsif node.instance_of? Model::Schema
64
- format_schema(node)
65
- elsif node.instance_of? Model::SubtypeConstraint
66
- format_subtype_constraint(node)
67
- elsif node.instance_of? Model::Type
68
- format_type(node)
69
- elsif node.instance_of? Model::Unique
70
- format_unique(node)
71
- elsif node.instance_of? Model::Variable
72
- format_variable(node)
73
- elsif node.instance_of? Model::Where
74
- format_where(node)
75
- elsif node.instance_of? Model::Expressions::AggregateInitializer
76
- format_expressions_aggregate_initializer(node)
77
- elsif node.instance_of? Model::Expressions::AggregateItem
78
- format_expressions_aggregate_item(node)
79
- elsif node.instance_of? Model::Expressions::AttributeReference
80
- format_expressions_attribute_reference(node)
81
- elsif node.instance_of? Model::Expressions::BinaryExpression
82
- format_expressions_binary_expression(node)
83
- elsif node.instance_of? Model::Expressions::Call
84
- format_expressions_call(node)
85
- elsif node.instance_of? Model::Expressions::EntityConstructor
86
- format_expressions_entity_constructor(node)
87
- elsif node.instance_of? Model::Expressions::GroupReference
88
- format_expressions_group_reference(node)
89
- elsif node.instance_of? Model::Expressions::IndexReference
90
- format_expressions_index_reference(node)
91
- elsif node.instance_of? Model::Expressions::Interval
92
- format_expressions_interval(node)
93
- elsif node.instance_of? Model::Expressions::QueryExpression
94
- format_expressions_query_expression(node)
95
- elsif node.instance_of? Model::Expressions::SimpleReference
96
- format_expressions_simple_reference(node)
97
- elsif node.instance_of? Model::Expressions::UnaryExpression
98
- format_expressions_unary_expression(node)
99
- elsif node.instance_of? Model::Literals::Binary
100
- format_literals_binary(node)
101
- elsif node.instance_of? Model::Literals::Integer
102
- format_literals_integer(node)
103
- elsif node.instance_of? Model::Literals::Logical
104
- format_literals_logical(node)
105
- elsif node.instance_of? Model::Literals::Real
106
- format_literals_real(node)
107
- elsif node.instance_of? Model::Literals::String
108
- format_literals_string(node)
109
- elsif node.instance_of? Model::Statements::Alias
110
- format_statements_alias(node)
111
- elsif node.instance_of? Model::Statements::Assignment
112
- format_statements_assignment(node)
113
- elsif node.instance_of? Model::Statements::Call
114
- format_statements_call(node)
115
- elsif node.instance_of? Model::Statements::Case
116
- format_statements_case(node)
117
- elsif node.instance_of? Model::Statements::CaseAction
118
- format_statements_case_action(node)
119
- elsif node.instance_of? Model::Statements::Compound
120
- format_statements_compound(node)
121
- elsif node.instance_of? Model::Statements::Escape
122
- format_statements_escape(node)
123
- elsif node.instance_of? Model::Statements::If
124
- format_statements_if(node)
125
- elsif node.instance_of? Model::Statements::Null
126
- format_statements_null(node)
127
- elsif node.instance_of? Model::Statements::Repeat
128
- format_statements_repeat(node)
129
- elsif node.instance_of? Model::Statements::Return
130
- format_statements_return(node)
131
- elsif node.instance_of? Model::Statements::Skip
132
- format_statements_skip(node)
133
- elsif node.instance_of? Model::Types::Aggregate
134
- format_types_aggregate(node)
135
- elsif node.instance_of? Model::Types::Array
136
- format_types_array(node)
137
- elsif node.instance_of? Model::Types::Bag
138
- format_types_bag(node)
139
- elsif node.instance_of? Model::Types::Binary
140
- format_types_binary(node)
141
- elsif node.instance_of? Model::Types::Boolean
142
- format_types_boolean(node)
143
- elsif node.instance_of? Model::Types::Enumeration
144
- format_types_enumeration(node)
145
- elsif node.instance_of? Model::Types::GenericEntity
146
- format_types_generic_entity(node)
147
- elsif node.instance_of? Model::Types::Generic
148
- format_types_generic(node)
149
- elsif node.instance_of? Model::Types::Integer
150
- format_types_integer(node)
151
- elsif node.instance_of? Model::Types::List
152
- format_types_list(node)
153
- elsif node.instance_of? Model::Types::Logical
154
- format_types_logical(node)
155
- elsif node.instance_of? Model::Types::Number
156
- format_types_number(node)
157
- elsif node.instance_of? Model::Types::Real
158
- format_types_real(node)
159
- elsif node.instance_of? Model::Types::Select
160
- format_types_select(node)
161
- elsif node.instance_of? Model::Types::Set
162
- format_types_set(node)
163
- elsif node.instance_of? Model::Types::String
164
- format_types_string(node)
165
- else
166
- puts node.class
167
- end
168
- end
169
-
170
- private
171
-
172
- def format_attribute(node)
173
- [
174
- *if node.supertype_attribute
175
- [
176
- format(node.supertype_attribute),
177
- ' ',
178
- ].join('')
179
- end,
180
- *if node.supertype_attribute and node.id
181
- [
182
- 'RENAMED',
183
- ' '
184
- ].join('')
185
- end,
186
- *if node.id
187
- [
188
- node.id,
189
- ' '
190
- ].join('')
191
- end,
192
- ':',
193
- *if node.optional
194
- [
195
- ' ',
196
- 'OPTIONAL'
197
- ].join('')
198
- end,
199
- ' ',
200
- format(node.type),
201
- *if node.kind == Model::Attribute::DERIVED
202
- [
203
- ' ',
204
- ':=',
205
- ' ',
206
- format(node.expression)
207
- ].join('')
208
- elsif node.kind == Model::Attribute::INVERSE
209
- [
210
- ' ',
211
- 'FOR',
212
- ' ',
213
- format(node.expression)
214
- ].join('')
215
- end,
216
- ';',
217
- ].join('')
218
- end
219
-
220
- def format_constant(node)
221
- [
222
- node.id,
223
- ' ',
224
- ':',
225
- ' ',
226
- format(node.type),
227
- ' ',
228
- ':=',
229
- ' ',
230
- format(node.expression),
231
- ';'
232
- ].join('')
233
- end
234
-
235
- def format_entity(node)
236
- [
237
- [
238
- 'ENTITY',
239
- ' ',
240
- node.id,
241
- *if node.abstract and !node.supertype_expression
242
- [
243
- "\n",
244
- INDENT,
245
- 'ABSTRACT',
246
- ' ',
247
- 'SUPERTYPE'
248
- ].join('')
249
- end,
250
- *if node.abstract and node.supertype_expression
251
- [
252
- "\n",
253
- INDENT,
254
- 'ABSTRACT',
255
- ' ',
256
- 'SUPERTYPE',
257
- ' ',
258
- 'OF',
259
- ' ',
260
- '(',
261
- format(node.supertype_expression),
262
- ')'
263
- ].join('')
264
- end,
265
- *if !node.abstract and node.supertype_expression
266
- [
267
- "\n",
268
- INDENT,
269
- 'SUPERTYPE',
270
- ' ',
271
- 'OF',
272
- ' ',
273
- '(',
274
- format(node.supertype_expression),
275
- ')'
276
- ].join('')
277
- end,
278
- *if node.subtype_of and node.subtype_of.length > 0
279
- [
280
- "\n",
281
- INDENT,
282
- 'SUBTYPE',
283
- ' ',
284
- 'OF',
285
- ' ',
286
- '(',
287
- node.subtype_of.map{|x| format(x)}.join(', '),
288
- ')'
289
- ].join('')
290
- end,
291
- ';'
292
- ].join(''),
293
- *if node.explicit_attributes and node.explicit_attributes.length > 0
294
- indent(node.explicit_attributes.map{|x| format(x)}.join("\n"))
295
- end,
296
- *if node.derived_attributes and node.derived_attributes.length > 0
297
- indent([
298
- 'DERIVE',
299
- indent(node.derived_attributes.map{|x| format(x)}.join("\n")),
300
- ].join("\n"))
301
- end,
302
- *if node.inverse_attributes and node.inverse_attributes.length > 0
303
- indent([
304
- 'INVERSE',
305
- indent(node.inverse_attributes.map{|x| format(x)}.join("\n")),
306
- ].join("\n"))
307
- end,
308
- *if node.unique and node.unique.length > 0
309
- indent([
310
- 'UNIQUE',
311
- indent(node.unique.map{|x| format(x)}.join("\n"))
312
- ].join("\n"))
313
- end,
314
- *if node.where and node.where.length > 0
315
- indent([
316
- 'WHERE',
317
- indent(node.where.map{|x| format(x)}.join("\n")),
318
- ].join("\n"))
319
- end,
320
- [
321
- 'END_ENTITY',
322
- ';'
323
- ].join('')
324
- ].join("\n")
325
- end
326
-
327
- def format_enumeration_item(node)
328
- node.id
329
- end
330
-
331
- def format_function(node)
332
- [
333
- [
334
- 'FUNCTION',
335
- ' ',
336
- node.id,
337
- *if node.parameters and node.parameters.length > 0
338
- [
339
- '(',
340
- node.parameters.map{|x| format(x)}.join('; '),
341
- ')'
342
- ].join('')
343
- end,
344
- ' ',
345
- ':',
346
- ' ',
347
- format(node.return_type),
348
- ';'
349
- ].join(''),
350
- *if node.declarations and node.declarations.length > 0
351
- indent(node.declarations.map{|x| format(x)}.join("\n"))
352
- end,
353
- *if node.constants and node.constants.length > 0
354
- indent([
355
- 'CONSTANT',
356
- indent(node.constants.map{|x| format(x)}.join("\n")),
357
- [
358
- 'END_CONSTANT',
359
- ';'
360
- ].join('')
361
- ].join("\n"))
362
- end,
363
- *if node.variables and node.variables.length > 0
364
- indent([
365
- 'LOCAL',
366
- indent(node.variables.map{|x| format(x)}.join("\n")),
367
- [
368
- 'END_LOCAL',
369
- ';'
370
- ].join('')
371
- ].join("\n"))
372
- end,
373
- *if node.statements and node.statements.length > 0
374
- indent(node.statements.map{|x| format(x)}.join("\n"))
375
- end,
376
- [
377
- 'END_FUNCTION',
378
- ';'
379
- ].join('')
380
- ].join("\n")
381
- end
382
-
383
- def format_interface(node)
384
- [
385
- case node.kind
386
- when Model::Interface::USE then 'USE'
387
- when Model::Interface::REFERENCE then 'REFERENCE'
388
- end,
389
- ' ',
390
- 'FROM',
391
- ' ',
392
- format(node.schema),
393
- *if node.items and node.items.length > 0
394
- [
395
- "\n",
396
- INDENT,
397
- '(',
398
- node.items.map{|x| format(x)},
399
- ')'
400
- ].join('')
401
- end,
402
- ';',
403
- ].join('')
404
- end
405
-
406
- def format_parameter(node)
407
- [
408
- *if node.var
409
- [
410
- 'VAR',
411
- ' '
412
- ].join('')
413
- end,
414
- node.id,
415
- ' ',
416
- ':',
417
- ' ',
418
- format(node.type)
419
- ].join('')
420
- end
421
-
422
- def format_procedure(node)
423
- [
424
- [
425
- 'PROCEDURE',
426
- ' ',
427
- node.id,
428
- *if node.parameters and node.parameters.length > 0
429
- [
430
- '(',
431
- node.parameters.map{|x| format(x)}.join('; '),
432
- ')'
433
- ].join('')
434
- end,
435
- ';'
436
- ].join(''),
437
- *if node.declarations and node.declarations.length > 0
438
- indent(node.declarations.map{|x| format(x)}.join("\n"))
439
- end,
440
- *if node.constants and node.constants.length > 0
441
- indent([
442
- 'CONSTANT',
443
- indent(node.constants.map{|x| format(x)}.join("\n")),
444
- [
445
- 'END_CONSTANT',
446
- ';'
447
- ].join('')
448
- ].join("\n"))
449
- end,
450
- *if node.variables and node.variables.length > 0
451
- indent([
452
- 'LOCAL',
453
- indent(node.variables.map{|x| format(x)}.join("\n")),
454
- [
455
- 'END_LOCAL',
456
- ';'
457
- ].join('')
458
- ].join("\n"))
459
- end,
460
- *if node.statements and node.statements.length > 0
461
- indent(node.statements.map{|x| format(x)}.join("\n"))
462
- end,
463
- [
464
- 'END_PROCEDURE',
465
- ';'
466
- ].join('')
467
- ].join("\n")
468
- end
469
-
470
- def format_renamed_ref(node)
471
- [
472
- format(node.ref),
473
- ' ',
474
- 'AS',
475
- ' ',
476
- node.id
477
- ].join('')
478
- end
479
-
480
- def format_repository(node)
481
- [
482
- *if node.schemas and node.schemas.length > 0
483
- node.schemas.map{|node| format(node)}
484
- end,
485
- *format_scope_remarks(node)
486
- ].join("\n")
487
- end
488
-
489
- def format_rule(node)
490
- [
491
- [
492
- 'RULE',
493
- ' ',
494
- node.id,
495
- ' ',
496
- 'FOR',
497
- ' ',
498
- '(',
499
- node.applies_to.map{|x| format(x)}.join(', '),
500
- ')',
501
- ';'
502
- ].join(''),
503
- *if node.declarations and node.declarations.length > 0
504
- indent(node.declarations.map{|x| format(x)}.join("\n"))
505
- end,
506
- *if node.constants and node.constants.length > 0
507
- indent([
508
- 'CONSTANT',
509
- indent(node.constants.map{|x| format(x)}.join("\n")),
510
- [
511
- 'END_CONSTANT',
512
- ';'
513
- ].join('')
514
- ].join("\n"))
515
- end,
516
- *if node.variables and node.variables.length > 0
517
- indent([
518
- 'LOCAL',
519
- indent(node.variables.map{|x| format(x)}.join("\n")),
520
- [
521
- 'END_LOCAL',
522
- ';'
523
- ].join('')
524
- ].join("\n"))
525
- end,
526
- *if node.statements and node.statements.length > 0
527
- indent(node.statements.map{|x| format(x)}.join("\n"))
528
- end,
529
- *if node.where and node.where.length > 0
530
- indent([
531
- 'WHERE',
532
- indent(node.where.map{|x| format(x)}.join("\n"))
533
- ].join("\n"))
534
- end,
535
- [
536
- 'END_RULE',
537
- ';'
538
- ].join('')
539
- ].join("\n")
540
- end
541
-
542
- def format_schema(node)
543
- [
544
- [
545
- 'SCHEMA',
546
- ' ',
547
- node.id,
548
- *if node.version
549
- [
550
- ' ',
551
- format(node.version),
552
- ].join('')
553
- end,
554
- ';'
555
- ].join(''),
556
- *if node.interfaces and node.interfaces.length > 0
557
- node.interfaces.map{|x| format(x)}.join("\n")
558
- end,
559
- *if node.constants and node.constants.length > 0
560
- [
561
- 'CONSTANT',
562
- indent(node.constants.map{|x| format(x)}.join("\n")),
563
- [
564
- 'END_CONSTANT',
565
- ';'
566
- ].join('')
567
- ].join("\n")
568
- end,
569
- *if node.declarations and node.declarations.length > 0
570
- node.declarations.map{|x| format(x)}.join("\n\n")
571
- end,
572
- [
573
- 'END_SCHEMA',
574
- ';'
575
- ].join('')
576
- ].join("\n")
577
- end
578
-
579
- def format_subtype_constraint(node)
580
- [
581
- [
582
- 'SUBTYPE_CONSTRAINT',
583
- ' ',
584
- node.id,
585
- ' ',
586
- 'FOR',
587
- ' ',
588
- format(node.applies_to),
589
- ';'
590
- ].join(''),
591
- *if node.abstract
592
- indent([
593
- 'ABSTRACT',
594
- ' ',
595
- 'SUPERTYPE',
596
- ';'
597
- ].join(''))
598
- end,
599
- *if node.total_over and node.total_over.length > 0
600
- indent([
601
- 'TOTAL_OVER',
602
- '(',
603
- node.total_over.map{|x| format(x)}.join(', '),
604
- ')',
605
- ';'
606
- ].join(''))
607
- end,
608
- *if node.supertype_expression
609
- indent([
610
- format(node.supertype_expression),
611
- ';'
612
- ].join(''))
613
- end,
614
- [
615
- 'END_SUBTYPE_CONSTRAINT',
616
- ';'
617
- ].join('')
618
- ].join("\n")
619
- end
620
-
621
- def format_type(node)
622
- [
623
- [
624
- 'TYPE',
625
- ' ',
626
- node.id,
627
- ' ',
628
- '=',
629
- ' ',
630
- format(node.type),
631
- ';',
632
- ].join(''),
633
- *if node.where and node.where.length > 0
634
- indent([
635
- 'WHERE',
636
- indent(node.where.map{|x| format(x)}.join("\n"))
637
- ].join("\n"))
638
- end,
639
- [
640
- 'END_TYPE',
641
- ';'
642
- ].join('')
643
- ].join("\n")
644
- end
645
-
646
- def format_unique(node)
647
- [
648
- *if node.id
649
- [
650
- node.id,
651
- ' ',
652
- ':',
653
- ' '
654
- ].join('')
655
- end,
656
- node.attributes.map{|x| format(x)}.join(', '),
657
- ';'
658
- ].join('')
659
- end
660
-
661
- def format_variable(node)
662
- [
663
- node.id,
664
- ' ',
665
- ':',
666
- ' ',
667
- format(node.type),
668
- *if node.expression
669
- [
670
- ' ',
671
- ':=',
672
- ' ',
673
- format(node.expression),
674
- ].join('')
675
- end,
676
- ';'
677
- ].join('')
678
- end
679
-
680
- def format_where(node)
681
- [
682
- *if node.id
683
- [
684
- node.id,
685
- ' ',
686
- ':',
687
- ' '
688
- ].join('')
689
- end,
690
- format(node.expression),
691
- ';'
692
- ].join('')
693
- end
694
-
695
- def format_expressions_aggregate_initializer(node)
696
- [
697
- '[',
698
- node.items.map{|x| format(x)}.join(', '),
699
- ']'
700
- ].join('')
701
- end
702
-
703
- def format_expressions_aggregate_item(node)
704
- [
705
- format(node.expression),
706
- ':',
707
- format(node.repetition)
708
- ].join('')
709
- end
710
-
711
- def format_expressions_attribute_reference(node)
712
- [
713
- format(node.ref),
714
- '.',
715
- format(node.attribute)
716
- ].join('')
717
- end
718
-
719
- def format_expressions_binary_expression(node)
720
- [
721
- *if node.operand1.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
722
- '('
723
- end,
724
- format(node.operand1),
725
- *if node.operand1.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
726
- ')'
727
- end,
728
- ' ',
729
- case node.operator
730
- when Model::Expressions::BinaryExpression::ADDITION then '+'
731
- when Model::Expressions::BinaryExpression::AND then 'AND'
732
- when Model::Expressions::BinaryExpression::ANDOR then 'ANDOR'
733
- when Model::Expressions::BinaryExpression::COMBINE then '||'
734
- when Model::Expressions::BinaryExpression::EQUAL then '='
735
- when Model::Expressions::BinaryExpression::EXPONENTIATION then '**'
736
- when Model::Expressions::BinaryExpression::GREATER_THAN then '>'
737
- when Model::Expressions::BinaryExpression::GREATER_THAN_OR_EQUAL then '>='
738
- when Model::Expressions::BinaryExpression::IN then 'IN'
739
- when Model::Expressions::BinaryExpression::INSTANCE_EQUAL then ':=:'
740
- when Model::Expressions::BinaryExpression::INSTANCE_NOT_EQUAL then ':<>:'
741
- when Model::Expressions::BinaryExpression::INTEGER_DIVISION then 'DIV'
742
- when Model::Expressions::BinaryExpression::LESS_THAN then '<'
743
- when Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL then '<='
744
- when Model::Expressions::BinaryExpression::LIKE then 'LIKE'
745
- when Model::Expressions::BinaryExpression::MODULO then 'MOD'
746
- when Model::Expressions::BinaryExpression::MULTIPLICATION then '*'
747
- when Model::Expressions::BinaryExpression::NOT_EQUAL then '<>'
748
- when Model::Expressions::BinaryExpression::OR then 'OR'
749
- when Model::Expressions::BinaryExpression::REAL_DIVISION then '/'
750
- when Model::Expressions::BinaryExpression::SUBTRACTION then '-'
751
- when Model::Expressions::BinaryExpression::XOR then 'XOR'
752
- end,
753
- ' ',
754
- *if node.operand2.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
755
- '('
756
- end,
757
- format(node.operand2),
758
- *if node.operand2.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
759
- ')'
760
- end,
761
- ].join('')
762
- end
763
-
764
- def format_expressions_call(node)
765
- [
766
- format(node.ref),
767
- '(',
768
- node.parameters.map{|x| format(x)}.join(', '),
769
- ')'
770
- ].join('')
771
- end
772
-
773
- def format_expressions_entity_constructor(node)
774
- [
775
- format(node.entity),
776
- '(',
777
- node.parameters.map{|x| format(x)}.join(', '),
778
- ')'
779
- ].join('')
780
- end
781
-
782
- def format_expressions_group_reference(node)
783
- [
784
- format(node.ref),
785
- '\\',
786
- format(node.entity)
787
- ].join('')
788
- end
789
-
790
- def format_expressions_index_reference(node)
791
- [
792
- format(node.ref),
793
- '[',
794
- format(node.index1),
795
- *if node.index2
796
- [
797
- ':',
798
- format(node.index2)
799
- ].join('')
800
- end,
801
- ']'
802
- ].join('')
803
- end
804
-
805
- def format_expressions_interval(node)
806
- [
807
- '{',
808
- format(node.low),
809
- ' ',
810
- case node.operator1
811
- when Model::Expressions::BinaryExpression::LESS_THAN then '<'
812
- when Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL then '<='
813
- end,
814
- ' ',
815
- format(node.item),
816
- ' ',
817
- case node.operator2
818
- when Model::Expressions::BinaryExpression::LESS_THAN then '<'
819
- when Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL then '<='
820
- end,
821
- ' ',
822
- format(node.high),
823
- '}'
824
- ].join('')
825
- end
826
-
827
- def format_expressions_query_expression(node)
828
- [
829
- 'QUERY',
830
- '(',
831
- node.id,
832
- ' ',
833
- '<*',
834
- ' ',
835
- format(node.source),
836
- ' ',
837
- '|',
838
- ' ',
839
- format(node.expression),
840
- *format_remarks(node).instance_eval{|x| x.length > 0 ? ["\n", *x, "\n"] : x},
841
- ')'
842
- ].join('')
843
- end
844
-
845
- def format_expressions_simple_reference(node)
846
- node.id
847
- end
848
-
849
- def format_expressions_unary_expression(node)
850
- [
851
- case node.operator
852
- when Model::Expressions::UnaryExpression::MINUS then '-'
853
- when Model::Expressions::UnaryExpression::NOT then 'NOT'
854
- when Model::Expressions::UnaryExpression::PLUS then '+'
855
- end,
856
- if node.operator == Model::Expressions::UnaryExpression::NOT
857
- ' '
858
- end,
859
- *if node.operand.instance_of? Model::Expressions::BinaryExpression
860
- '('
861
- end,
862
- format(node.operand),
863
- *if node.operand.instance_of? Model::Expressions::BinaryExpression
864
- ')'
865
- end
866
- ].join('')
867
- end
868
-
869
- def format_literals_binary(node)
870
- [
871
- '%',
872
- node.value
873
- ].join('')
874
- end
875
-
876
- def format_literals_integer(node)
877
- node.value
878
- end
879
-
880
- def format_literals_logical(node)
881
- case node.value
882
- when Model::Literals::Logical::TRUE then 'TRUE'
883
- when Model::Literals::Logical::FALSE then 'FALSE'
884
- when Model::Literals::Logical::UNKNOWN then 'UNKNOWN'
885
- end
886
- end
887
-
888
- def format_literals_real(node)
889
- node.value
890
- end
891
-
892
- def format_literals_string(node)
893
- if node.encoded
894
- [
895
- "\"",
896
- node.value,
897
- "\""
898
- ].join('')
899
- else
900
- [
901
- "'",
902
- node.value,
903
- "'"
904
- ].join('')
905
- end
906
- end
907
-
908
- def format_statements_alias(node)
909
- [
910
- [
911
- 'ALIAS',
912
- ' ',
913
- node.id,
914
- ' ',
915
- 'FOR',
916
- ' ',
917
- format(node.expression),
918
- ';'
919
- ].join(''),
920
- *if node.statements and node.statements.length > 0
921
- indent(node.statements.map{|x| format(x)}.join("\n"))
922
- end,
923
- *format_remarks(node),
924
- [
925
- 'END_ALIAS',
926
- ';'
927
- ].join('')
928
- ].join("\n")
929
- end
930
-
931
- def format_statements_assignment(node)
932
- [
933
- format(node.ref),
934
- ' ',
935
- ':=',
936
- ' ',
937
- format(node.expression),
938
- ';'
939
- ].join('')
940
- end
941
-
942
- def format_statements_call(node)
943
- [
944
- format(node.ref),
945
- *if node.parameters and node.parameters.length > 0
946
- [
947
- '(',
948
- node.parameters.map{|x| format(x)}.join(', '),
949
- ')'
950
- ].join('')
951
- end,
952
- ';'
953
- ].join('')
954
- end
955
-
956
- def format_statements_case(node)
957
- [
958
- [
959
- 'CASE',
960
- ' ',
961
- format(node.expression),
962
- ' ',
963
- 'OF'
964
- ].join(''),
965
- *if node.actions and node.actions.length > 0
966
- node.actions.map{|x| format(x)}
967
- end,
968
- *if node.otherwise_statement
969
- [
970
- [
971
- 'OTHERWISE',
972
- ' ',
973
- ':'
974
- ].join(''),
975
- indent(format(node.otherwise_statement))
976
- ]
977
- end,
978
- [
979
- 'END_CASE',
980
- ';'
981
- ].join('')
982
- ].join("\n")
983
- end
984
-
985
- def format_statements_case_action(node)
986
- [
987
- [
988
- node.labels.map{|x| format(x)}.join(', '),
989
- ' ',
990
- ':'
991
- ].join(''),
992
- indent(format(node.statement))
993
- ].join("\n")
994
- end
995
-
996
- def format_statements_compound(node)
997
- [
998
- 'BEGIN',
999
- *if node.statements and node.statements.length > 0
1000
- indent(node.statements.map{|x| format(x)}.join("\n"))
1001
- end,
1002
- [
1003
- 'END',
1004
- ';'
1005
- ].join('')
1006
- ].join("\n")
1007
- end
1008
-
1009
- def format_statements_escape(node)
1010
- [
1011
- 'ESCAPE',
1012
- ';'
1013
- ].join('')
1014
- end
1015
-
1016
- def format_statements_if(node)
1017
- [
1018
- [
1019
- 'IF',
1020
- ' ',
1021
- format(node.expression),
1022
- ' ',
1023
- 'THEN'
1024
- ].join(''),
1025
- *if node.statements and node.statements.length > 0
1026
- indent(node.statements.map{|x| format(x)}.join("\n"))
1027
- end,
1028
- *if node.else_statements and node.else_statements.length > 0
1029
- [
1030
- 'ELSE',
1031
- indent(node.else_statements.map{|x| format(x)}.join("\n")),
1032
- ].join("\n")
1033
- end,
1034
- [
1035
- 'END_IF',
1036
- ';'
1037
- ].join('')
1038
- ].join("\n")
1039
- end
1040
-
1041
- def format_statements_null(node)
1042
- ';'
1043
- end
1044
-
1045
- def format_statements_repeat(node)
1046
- [
1047
- [
1048
- 'REPEAT',
1049
- *if node.id
1050
- [
1051
- ' ',
1052
- node.id,
1053
- ' ',
1054
- ':=',
1055
- ' ',
1056
- format(node.bound1),
1057
- ' ',
1058
- 'TO',
1059
- ' ',
1060
- format(node.bound2),
1061
- *if node.increment
1062
- [
1063
- ' ',
1064
- 'BY',
1065
- ' ',
1066
- format(node.increment)
1067
- ].join('')
1068
- end
1069
- ].join('')
1070
- end,
1071
- *if node.while_expression
1072
- [
1073
- ' ',
1074
- 'WHILE',
1075
- ' ',
1076
- format(node.while_expression)
1077
- ].join('')
1078
- end,
1079
- *if node.until_expression
1080
- [
1081
- ' ',
1082
- 'UNTIL',
1083
- ' ',
1084
- format(node.until_expression)
1085
- ].join('')
1086
- end,
1087
- ';'
1088
- ].join(''),
1089
- *if node.statements and node.statements.length > 0
1090
- indent(node.statements.map{|x| format(x)}.join("\n"))
1091
- end,
1092
- *format_remarks(node),
1093
- [
1094
- 'END_REPEAT',
1095
- ';'
1096
- ].join('')
1097
- ].join("\n")
1098
- end
1099
-
1100
- def format_statements_return(node)
1101
- [
1102
- 'RETURN',
1103
- *if node.expression
1104
- [
1105
- ' ',
1106
- '(',
1107
- format(node.expression),
1108
- ')'
1109
- ].join('')
1110
- end,
1111
- ';'
1112
- ].join('')
1113
- end
1114
-
1115
- def format_statements_skip(node)
1116
- [
1117
- 'SKIP',
1118
- ';'
1119
- ].join('')
1120
- end
1121
-
1122
- def format_types_aggregate(node)
1123
- 'AGGREGATE'
1124
- end
1125
-
1126
- def format_types_array(node)
1127
- [
1128
- 'ARRAY',
1129
- *if node.bound1 and node.bound2
1130
- [
1131
- ' ',
1132
- '[',
1133
- format(node.bound1),
1134
- ':',
1135
- format(node.bound2),
1136
- ']',
1137
- ].join('')
1138
- end,
1139
- ' ',
1140
- 'OF',
1141
- *if node.optional
1142
- [
1143
- ' ',
1144
- 'OPTIONAL'
1145
- ].join('')
1146
- end,
1147
- *if node.unique
1148
- [
1149
- ' ',
1150
- 'UNIQUE'
1151
- ].join('')
1152
- end,
1153
- ' ',
1154
- format(node.base_type)
1155
- ].join('')
1156
- end
1157
-
1158
- def format_types_bag(node)
1159
- [
1160
- 'BAG',
1161
- *if node.bound1 and node.bound2
1162
- [
1163
- ' ',
1164
- '[',
1165
- format(node.bound1),
1166
- ':',
1167
- format(node.bound2),
1168
- ']',
1169
- ].join('')
1170
- end,
1171
- ' ',
1172
- 'OF',
1173
- ' ',
1174
- format(node.base_type)
1175
- ].join('')
1176
- end
1177
-
1178
- def format_types_binary(node)
1179
- [
1180
- 'BINARY',
1181
- *if node.width
1182
- [
1183
- ' ',
1184
- '(',
1185
- format(node.width),
1186
- ')'
1187
- ].join('')
1188
- end,
1189
- *if node.fixed
1190
- [
1191
- ' ',
1192
- 'FIXED'
1193
- ].join('')
1194
- end
1195
- ].join('')
1196
- end
1197
-
1198
- def format_types_boolean(node)
1199
- 'BOOLEAN'
1200
- end
1201
-
1202
- def format_types_enumeration(node)
1203
- [
1204
- *if node.extensible
1205
- [
1206
- 'EXTENSIBLE',
1207
- ' '
1208
- ].join('')
1209
- end,
1210
- 'ENUMERATION',
1211
- *if node.items and node.items.length > 0
1212
- [
1213
- ' ',
1214
- 'OF',
1215
- ' ',
1216
- '(',
1217
- node.items.map{|x| format(x)}.join(', '),
1218
- ')'
1219
- ].join('')
1220
- end,
1221
- *if node.extension_type
1222
- [
1223
- ' ',
1224
- 'BASED_ON',
1225
- ' ',
1226
- format(node.extension_type)
1227
- ].join('')
1228
- end,
1229
- *if node.extension_items
1230
- [
1231
- ' ',
1232
- 'WITH',
1233
- ' ',
1234
- '(',
1235
- node.extension_items.map{|x| format(x)}.join(', '),
1236
- ')'
1237
- ].join('')
1238
- end
1239
- ].join('')
1240
- end
1241
-
1242
- def format_types_generic_entity(node)
1243
- 'GENERIC_ENTITY'
1244
- end
1245
-
1246
- def format_types_generic(node)
1247
- 'GENERIC'
1248
- end
1249
-
1250
- def format_types_integer(node)
1251
- 'INTEGER'
1252
- end
1253
-
1254
- def format_types_list(node)
1255
- [
1256
- 'LIST',
1257
- *if node.bound1 and node.bound2
1258
- [
1259
- ' ',
1260
- '[',
1261
- format(node.bound1),
1262
- ':',
1263
- format(node.bound2),
1264
- ']',
1265
- ].join('')
1266
- end,
1267
- ' ',
1268
- 'OF',
1269
- *if node.unique
1270
- [
1271
- ' ',
1272
- 'UNIQUE'
1273
- ].join('')
1274
- end,
1275
- ' ',
1276
- format(node.base_type)
1277
- ].join('')
1278
- end
1279
-
1280
- def format_types_logical(node)
1281
- 'LOGICAL'
1282
- end
1283
-
1284
- def format_types_number(node)
1285
- 'NUMBER'
1286
- end
1287
-
1288
- def format_types_real(node)
1289
- [
1290
- 'REAL',
1291
- *if node.precision
1292
- [
1293
- ' ',
1294
- '(',
1295
- format(node.precision),
1296
- ')'
1297
- ].join('')
1298
- end
1299
- ].join('')
1300
- end
1301
-
1302
- def format_types_select(node)
1303
- [
1304
- *if node.extensible
1305
- [
1306
- 'EXTENSIBLE',
1307
- ' '
1308
- ].join('')
1309
- end,
1310
- *if node.generic_entity
1311
- [
1312
- 'GENERIC_ENTITY',
1313
- ' '
1314
- ].join('')
1315
- end,
1316
- 'SELECT',
1317
- *if node.items and node.items.length > 0
1318
- [
1319
- ' ',
1320
- '(',
1321
- node.items.map{|x| format(x)}.join(', '),
1322
- ')'
1323
- ].join('')
1324
- end,
1325
- *if node.extension_type
1326
- [
1327
- ' ',
1328
- 'BASED_ON',
1329
- ' ',
1330
- format(node.extension_type)
1331
- ].join('')
1332
- end,
1333
- *if node.extension_items
1334
- [
1335
- ' ',
1336
- 'WITH',
1337
- ' ',
1338
- '(',
1339
- node.extension_items.map{|x| format(x)}.join(', '),
1340
- ')'
1341
- ].join('')
1342
- end
1343
- ].join('')
1344
- end
1345
-
1346
- def format_types_set(node)
1347
- [
1348
- 'SET',
1349
- *if node.bound1 and node.bound2
1350
- [
1351
- ' ',
1352
- '[',
1353
- format(node.bound1),
1354
- ':',
1355
- format(node.bound2),
1356
- ']',
1357
- ].join('')
1358
- end,
1359
- ' ',
1360
- 'OF',
1361
- ' ',
1362
- format(node.base_type)
1363
- ].join('')
1364
- end
1365
-
1366
- def format_types_string(node)
1367
- [
1368
- 'STRING',
1369
- *if node.width
1370
- [
1371
- ' ',
1372
- '(',
1373
- format(node.width),
1374
- ')'
1375
- ].join('')
1376
- end,
1377
- *if node.fixed
1378
- [
1379
- ' ',
1380
- 'FIXED'
1381
- ].join('')
1382
- end
1383
- ].join('')
1384
- end
1385
-
1386
- def indent(str)
1387
- str.split("\n").map{|x| "#{INDENT}#{x}"}.join("\n")
1388
- end
1389
-
1390
- def format_remark_ref(node)
1391
- [
1392
- *if node.class.method_defined? :parent and node.parent.class.method_defined? :id and node.parent != node
1393
- [
1394
- format_remark_ref(node.parent),
1395
- '.'
1396
- ].join('')
1397
- end,
1398
- node.id,
1399
- ].join('')
1400
- end
1401
-
1402
- def format_remark(node, remark)
1403
- if remark.include?("\n")
1404
- [
1405
- [
1406
- '(*',
1407
- '"',
1408
- format_remark_ref(node),
1409
- '"',
1410
- ].join(''),
1411
- remark,
1412
- '*)'
1413
- ].join("\n")
1414
- else
1415
- [
1416
- '--',
1417
- '"',
1418
- format_remark_ref(node),
1419
- '"',
1420
- ' ',
1421
- remark
1422
- ].join('')
1423
- end
1424
- end
1425
-
1426
- def format_remarks(node)
1427
- if node.class.method_defined? :remarks and node.remarks and node.remarks.length > 0
1428
- node.remarks.map do |remark|
1429
- format_remark(node, remark)
1430
- end
1431
- else
1432
- []
1433
- end
1434
- end
1435
-
1436
- def format_scope_remarks(node)
1437
- [
1438
- *format_remarks(node),
1439
- *if node.class.method_defined? :children
1440
- node.children.flat_map do |x|
1441
- if x != node
1442
- format_scope_remarks(x)
1443
- end
1444
- end
1445
- end
1446
- ]
1447
- end
1448
- end
1449
- end
1
+ require 'expressir/model'
2
+
3
+ module Expressir
4
+ module ExpressExp
5
+ class Formatter
6
+ INDENT_CHAR = ' '
7
+ INDENT_WIDTH = 2
8
+ INDENT = INDENT_CHAR * INDENT_WIDTH
9
+
10
+ OPERATOR_PRECEDENCE = {
11
+ Model::Expressions::BinaryExpression::EXPONENTIATION => 1,
12
+ Model::Expressions::BinaryExpression::MULTIPLICATION => 2,
13
+ Model::Expressions::BinaryExpression::REAL_DIVISION => 2,
14
+ Model::Expressions::BinaryExpression::INTEGER_DIVISION => 2,
15
+ Model::Expressions::BinaryExpression::MODULO => 2,
16
+ Model::Expressions::BinaryExpression::AND => 2,
17
+ Model::Expressions::BinaryExpression::COMBINE => 2,
18
+ Model::Expressions::BinaryExpression::SUBTRACTION => 3,
19
+ Model::Expressions::BinaryExpression::ADDITION => 3,
20
+ Model::Expressions::BinaryExpression::OR => 3,
21
+ Model::Expressions::BinaryExpression::XOR => 3,
22
+ Model::Expressions::BinaryExpression::EQUAL => 4,
23
+ Model::Expressions::BinaryExpression::NOT_EQUAL => 4,
24
+ Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL => 4,
25
+ Model::Expressions::BinaryExpression::GREATER_THAN_OR_EQUAL => 4,
26
+ Model::Expressions::BinaryExpression::LESS_THAN => 4,
27
+ Model::Expressions::BinaryExpression::GREATER_THAN => 4,
28
+ Model::Expressions::BinaryExpression::INSTANCE_EQUAL => 4,
29
+ Model::Expressions::BinaryExpression::INSTANCE_NOT_EQUAL => 4,
30
+ Model::Expressions::BinaryExpression::IN => 4,
31
+ Model::Expressions::BinaryExpression::LIKE => 4,
32
+ Model::Expressions::BinaryExpression::ANDOR => 4,
33
+ }
34
+
35
+ def self.format(node)
36
+ formatter = self.new
37
+ formatter.format(node)
38
+ end
39
+
40
+ def format(node)
41
+ if node.instance_of? Model::Attribute
42
+ format_attribute(node)
43
+ elsif node.instance_of? Model::Constant
44
+ format_constant(node)
45
+ elsif node.instance_of? Model::Entity
46
+ format_entity(node)
47
+ elsif node.instance_of? Model::EnumerationItem
48
+ format_enumeration_item(node)
49
+ elsif node.instance_of? Model::Function
50
+ format_function(node)
51
+ elsif node.instance_of? Model::Interface
52
+ format_interface(node)
53
+ elsif node.instance_of? Model::Parameter
54
+ format_parameter(node)
55
+ elsif node.instance_of? Model::Procedure
56
+ format_procedure(node)
57
+ elsif node.instance_of? Model::RenamedRef
58
+ format_renamed_ref(node)
59
+ elsif node.instance_of? Model::Repository
60
+ format_repository(node)
61
+ elsif node.instance_of? Model::Rule
62
+ format_rule(node)
63
+ elsif node.instance_of? Model::Schema
64
+ format_schema(node)
65
+ elsif node.instance_of? Model::SubtypeConstraint
66
+ format_subtype_constraint(node)
67
+ elsif node.instance_of? Model::Type
68
+ format_type(node)
69
+ elsif node.instance_of? Model::Unique
70
+ format_unique(node)
71
+ elsif node.instance_of? Model::Variable
72
+ format_variable(node)
73
+ elsif node.instance_of? Model::Where
74
+ format_where(node)
75
+ elsif node.instance_of? Model::Expressions::AggregateInitializer
76
+ format_expressions_aggregate_initializer(node)
77
+ elsif node.instance_of? Model::Expressions::AggregateItem
78
+ format_expressions_aggregate_item(node)
79
+ elsif node.instance_of? Model::Expressions::AttributeReference
80
+ format_expressions_attribute_reference(node)
81
+ elsif node.instance_of? Model::Expressions::BinaryExpression
82
+ format_expressions_binary_expression(node)
83
+ elsif node.instance_of? Model::Expressions::Call
84
+ format_expressions_call(node)
85
+ elsif node.instance_of? Model::Expressions::EntityConstructor
86
+ format_expressions_entity_constructor(node)
87
+ elsif node.instance_of? Model::Expressions::GroupReference
88
+ format_expressions_group_reference(node)
89
+ elsif node.instance_of? Model::Expressions::IndexReference
90
+ format_expressions_index_reference(node)
91
+ elsif node.instance_of? Model::Expressions::Interval
92
+ format_expressions_interval(node)
93
+ elsif node.instance_of? Model::Expressions::QueryExpression
94
+ format_expressions_query_expression(node)
95
+ elsif node.instance_of? Model::Expressions::SimpleReference
96
+ format_expressions_simple_reference(node)
97
+ elsif node.instance_of? Model::Expressions::UnaryExpression
98
+ format_expressions_unary_expression(node)
99
+ elsif node.instance_of? Model::Literals::Binary
100
+ format_literals_binary(node)
101
+ elsif node.instance_of? Model::Literals::Integer
102
+ format_literals_integer(node)
103
+ elsif node.instance_of? Model::Literals::Logical
104
+ format_literals_logical(node)
105
+ elsif node.instance_of? Model::Literals::Real
106
+ format_literals_real(node)
107
+ elsif node.instance_of? Model::Literals::String
108
+ format_literals_string(node)
109
+ elsif node.instance_of? Model::Statements::Alias
110
+ format_statements_alias(node)
111
+ elsif node.instance_of? Model::Statements::Assignment
112
+ format_statements_assignment(node)
113
+ elsif node.instance_of? Model::Statements::Call
114
+ format_statements_call(node)
115
+ elsif node.instance_of? Model::Statements::Case
116
+ format_statements_case(node)
117
+ elsif node.instance_of? Model::Statements::CaseAction
118
+ format_statements_case_action(node)
119
+ elsif node.instance_of? Model::Statements::Compound
120
+ format_statements_compound(node)
121
+ elsif node.instance_of? Model::Statements::Escape
122
+ format_statements_escape(node)
123
+ elsif node.instance_of? Model::Statements::If
124
+ format_statements_if(node)
125
+ elsif node.instance_of? Model::Statements::Null
126
+ format_statements_null(node)
127
+ elsif node.instance_of? Model::Statements::Repeat
128
+ format_statements_repeat(node)
129
+ elsif node.instance_of? Model::Statements::Return
130
+ format_statements_return(node)
131
+ elsif node.instance_of? Model::Statements::Skip
132
+ format_statements_skip(node)
133
+ elsif node.instance_of? Model::Types::Aggregate
134
+ format_types_aggregate(node)
135
+ elsif node.instance_of? Model::Types::Array
136
+ format_types_array(node)
137
+ elsif node.instance_of? Model::Types::Bag
138
+ format_types_bag(node)
139
+ elsif node.instance_of? Model::Types::Binary
140
+ format_types_binary(node)
141
+ elsif node.instance_of? Model::Types::Boolean
142
+ format_types_boolean(node)
143
+ elsif node.instance_of? Model::Types::Enumeration
144
+ format_types_enumeration(node)
145
+ elsif node.instance_of? Model::Types::GenericEntity
146
+ format_types_generic_entity(node)
147
+ elsif node.instance_of? Model::Types::Generic
148
+ format_types_generic(node)
149
+ elsif node.instance_of? Model::Types::Integer
150
+ format_types_integer(node)
151
+ elsif node.instance_of? Model::Types::List
152
+ format_types_list(node)
153
+ elsif node.instance_of? Model::Types::Logical
154
+ format_types_logical(node)
155
+ elsif node.instance_of? Model::Types::Number
156
+ format_types_number(node)
157
+ elsif node.instance_of? Model::Types::Real
158
+ format_types_real(node)
159
+ elsif node.instance_of? Model::Types::Select
160
+ format_types_select(node)
161
+ elsif node.instance_of? Model::Types::Set
162
+ format_types_set(node)
163
+ elsif node.instance_of? Model::Types::String
164
+ format_types_string(node)
165
+ else
166
+ puts node.class
167
+ end
168
+ end
169
+
170
+ private
171
+
172
+ def format_attribute(node)
173
+ [
174
+ *if node.supertype_attribute
175
+ [
176
+ format(node.supertype_attribute),
177
+ ' ',
178
+ ].join('')
179
+ end,
180
+ *if node.supertype_attribute and node.id
181
+ [
182
+ 'RENAMED',
183
+ ' '
184
+ ].join('')
185
+ end,
186
+ *if node.id
187
+ [
188
+ node.id,
189
+ ' '
190
+ ].join('')
191
+ end,
192
+ ':',
193
+ *if node.optional
194
+ [
195
+ ' ',
196
+ 'OPTIONAL'
197
+ ].join('')
198
+ end,
199
+ ' ',
200
+ format(node.type),
201
+ *if node.kind == Model::Attribute::DERIVED
202
+ [
203
+ ' ',
204
+ ':=',
205
+ ' ',
206
+ format(node.expression)
207
+ ].join('')
208
+ elsif node.kind == Model::Attribute::INVERSE
209
+ [
210
+ ' ',
211
+ 'FOR',
212
+ ' ',
213
+ format(node.expression)
214
+ ].join('')
215
+ end,
216
+ ';',
217
+ ].join('')
218
+ end
219
+
220
+ def format_constant(node)
221
+ [
222
+ node.id,
223
+ ' ',
224
+ ':',
225
+ ' ',
226
+ format(node.type),
227
+ ' ',
228
+ ':=',
229
+ ' ',
230
+ format(node.expression),
231
+ ';'
232
+ ].join('')
233
+ end
234
+
235
+ def format_entity(node)
236
+ [
237
+ [
238
+ 'ENTITY',
239
+ ' ',
240
+ node.id,
241
+ *if node.abstract and !node.supertype_expression
242
+ [
243
+ "\n",
244
+ INDENT,
245
+ 'ABSTRACT',
246
+ ' ',
247
+ 'SUPERTYPE'
248
+ ].join('')
249
+ end,
250
+ *if node.abstract and node.supertype_expression
251
+ [
252
+ "\n",
253
+ INDENT,
254
+ 'ABSTRACT',
255
+ ' ',
256
+ 'SUPERTYPE',
257
+ ' ',
258
+ 'OF',
259
+ ' ',
260
+ '(',
261
+ format(node.supertype_expression),
262
+ ')'
263
+ ].join('')
264
+ end,
265
+ *if !node.abstract and node.supertype_expression
266
+ [
267
+ "\n",
268
+ INDENT,
269
+ 'SUPERTYPE',
270
+ ' ',
271
+ 'OF',
272
+ ' ',
273
+ '(',
274
+ format(node.supertype_expression),
275
+ ')'
276
+ ].join('')
277
+ end,
278
+ *if node.subtype_of and node.subtype_of.length > 0
279
+ [
280
+ "\n",
281
+ INDENT,
282
+ 'SUBTYPE',
283
+ ' ',
284
+ 'OF',
285
+ ' ',
286
+ '(',
287
+ node.subtype_of.map{|x| format(x)}.join(', '),
288
+ ')'
289
+ ].join('')
290
+ end,
291
+ ';'
292
+ ].join(''),
293
+ *if node.explicit_attributes and node.explicit_attributes.length > 0
294
+ indent(node.explicit_attributes.map{|x| format(x)}.join("\n"))
295
+ end,
296
+ *if node.derived_attributes and node.derived_attributes.length > 0
297
+ indent([
298
+ 'DERIVE',
299
+ indent(node.derived_attributes.map{|x| format(x)}.join("\n")),
300
+ ].join("\n"))
301
+ end,
302
+ *if node.inverse_attributes and node.inverse_attributes.length > 0
303
+ indent([
304
+ 'INVERSE',
305
+ indent(node.inverse_attributes.map{|x| format(x)}.join("\n")),
306
+ ].join("\n"))
307
+ end,
308
+ *if node.unique and node.unique.length > 0
309
+ indent([
310
+ 'UNIQUE',
311
+ indent(node.unique.map{|x| format(x)}.join("\n"))
312
+ ].join("\n"))
313
+ end,
314
+ *if node.where and node.where.length > 0
315
+ indent([
316
+ 'WHERE',
317
+ indent(node.where.map{|x| format(x)}.join("\n")),
318
+ ].join("\n"))
319
+ end,
320
+ [
321
+ 'END_ENTITY',
322
+ ';'
323
+ ].join('')
324
+ ].join("\n")
325
+ end
326
+
327
+ def format_enumeration_item(node)
328
+ node.id
329
+ end
330
+
331
+ def format_function(node)
332
+ [
333
+ [
334
+ 'FUNCTION',
335
+ ' ',
336
+ node.id,
337
+ *if node.parameters and node.parameters.length > 0
338
+ [
339
+ '(',
340
+ node.parameters.map{|x| format(x)}.join('; '),
341
+ ')'
342
+ ].join('')
343
+ end,
344
+ ' ',
345
+ ':',
346
+ ' ',
347
+ format(node.return_type),
348
+ ';'
349
+ ].join(''),
350
+ *if node.declarations and node.declarations.length > 0
351
+ indent(node.declarations.map{|x| format(x)}.join("\n"))
352
+ end,
353
+ *if node.constants and node.constants.length > 0
354
+ indent([
355
+ 'CONSTANT',
356
+ indent(node.constants.map{|x| format(x)}.join("\n")),
357
+ [
358
+ 'END_CONSTANT',
359
+ ';'
360
+ ].join('')
361
+ ].join("\n"))
362
+ end,
363
+ *if node.variables and node.variables.length > 0
364
+ indent([
365
+ 'LOCAL',
366
+ indent(node.variables.map{|x| format(x)}.join("\n")),
367
+ [
368
+ 'END_LOCAL',
369
+ ';'
370
+ ].join('')
371
+ ].join("\n"))
372
+ end,
373
+ *if node.statements and node.statements.length > 0
374
+ indent(node.statements.map{|x| format(x)}.join("\n"))
375
+ end,
376
+ [
377
+ 'END_FUNCTION',
378
+ ';'
379
+ ].join('')
380
+ ].join("\n")
381
+ end
382
+
383
+ def format_interface(node)
384
+ [
385
+ case node.kind
386
+ when Model::Interface::USE then 'USE'
387
+ when Model::Interface::REFERENCE then 'REFERENCE'
388
+ end,
389
+ ' ',
390
+ 'FROM',
391
+ ' ',
392
+ format(node.schema),
393
+ *if node.items and node.items.length > 0
394
+ [
395
+ "\n",
396
+ INDENT,
397
+ '(',
398
+ node.items.map{|x| format(x)},
399
+ ')'
400
+ ].join('')
401
+ end,
402
+ ';',
403
+ ].join('')
404
+ end
405
+
406
+ def format_parameter(node)
407
+ [
408
+ *if node.var
409
+ [
410
+ 'VAR',
411
+ ' '
412
+ ].join('')
413
+ end,
414
+ node.id,
415
+ ' ',
416
+ ':',
417
+ ' ',
418
+ format(node.type)
419
+ ].join('')
420
+ end
421
+
422
+ def format_procedure(node)
423
+ [
424
+ [
425
+ 'PROCEDURE',
426
+ ' ',
427
+ node.id,
428
+ *if node.parameters and node.parameters.length > 0
429
+ [
430
+ '(',
431
+ node.parameters.map{|x| format(x)}.join('; '),
432
+ ')'
433
+ ].join('')
434
+ end,
435
+ ';'
436
+ ].join(''),
437
+ *if node.declarations and node.declarations.length > 0
438
+ indent(node.declarations.map{|x| format(x)}.join("\n"))
439
+ end,
440
+ *if node.constants and node.constants.length > 0
441
+ indent([
442
+ 'CONSTANT',
443
+ indent(node.constants.map{|x| format(x)}.join("\n")),
444
+ [
445
+ 'END_CONSTANT',
446
+ ';'
447
+ ].join('')
448
+ ].join("\n"))
449
+ end,
450
+ *if node.variables and node.variables.length > 0
451
+ indent([
452
+ 'LOCAL',
453
+ indent(node.variables.map{|x| format(x)}.join("\n")),
454
+ [
455
+ 'END_LOCAL',
456
+ ';'
457
+ ].join('')
458
+ ].join("\n"))
459
+ end,
460
+ *if node.statements and node.statements.length > 0
461
+ indent(node.statements.map{|x| format(x)}.join("\n"))
462
+ end,
463
+ [
464
+ 'END_PROCEDURE',
465
+ ';'
466
+ ].join('')
467
+ ].join("\n")
468
+ end
469
+
470
+ def format_renamed_ref(node)
471
+ [
472
+ format(node.ref),
473
+ ' ',
474
+ 'AS',
475
+ ' ',
476
+ node.id
477
+ ].join('')
478
+ end
479
+
480
+ def format_repository(node)
481
+ [
482
+ *if node.schemas and node.schemas.length > 0
483
+ node.schemas.map{|node| format(node)}
484
+ end,
485
+ *format_scope_remarks(node)
486
+ ].join("\n")
487
+ end
488
+
489
+ def format_rule(node)
490
+ [
491
+ [
492
+ 'RULE',
493
+ ' ',
494
+ node.id,
495
+ ' ',
496
+ 'FOR',
497
+ ' ',
498
+ '(',
499
+ node.applies_to.map{|x| format(x)}.join(', '),
500
+ ')',
501
+ ';'
502
+ ].join(''),
503
+ *if node.declarations and node.declarations.length > 0
504
+ indent(node.declarations.map{|x| format(x)}.join("\n"))
505
+ end,
506
+ *if node.constants and node.constants.length > 0
507
+ indent([
508
+ 'CONSTANT',
509
+ indent(node.constants.map{|x| format(x)}.join("\n")),
510
+ [
511
+ 'END_CONSTANT',
512
+ ';'
513
+ ].join('')
514
+ ].join("\n"))
515
+ end,
516
+ *if node.variables and node.variables.length > 0
517
+ indent([
518
+ 'LOCAL',
519
+ indent(node.variables.map{|x| format(x)}.join("\n")),
520
+ [
521
+ 'END_LOCAL',
522
+ ';'
523
+ ].join('')
524
+ ].join("\n"))
525
+ end,
526
+ *if node.statements and node.statements.length > 0
527
+ indent(node.statements.map{|x| format(x)}.join("\n"))
528
+ end,
529
+ *if node.where and node.where.length > 0
530
+ indent([
531
+ 'WHERE',
532
+ indent(node.where.map{|x| format(x)}.join("\n"))
533
+ ].join("\n"))
534
+ end,
535
+ [
536
+ 'END_RULE',
537
+ ';'
538
+ ].join('')
539
+ ].join("\n")
540
+ end
541
+
542
+ def format_schema(node)
543
+ [
544
+ [
545
+ 'SCHEMA',
546
+ ' ',
547
+ node.id,
548
+ *if node.version
549
+ [
550
+ ' ',
551
+ format(node.version),
552
+ ].join('')
553
+ end,
554
+ ';'
555
+ ].join(''),
556
+ *if node.interfaces and node.interfaces.length > 0
557
+ node.interfaces.map{|x| format(x)}.join("\n")
558
+ end,
559
+ *if node.constants and node.constants.length > 0
560
+ [
561
+ 'CONSTANT',
562
+ indent(node.constants.map{|x| format(x)}.join("\n")),
563
+ [
564
+ 'END_CONSTANT',
565
+ ';'
566
+ ].join('')
567
+ ].join("\n")
568
+ end,
569
+ *if node.declarations and node.declarations.length > 0
570
+ node.declarations.map{|x| format(x)}.join("\n\n")
571
+ end,
572
+ [
573
+ 'END_SCHEMA',
574
+ ';'
575
+ ].join('')
576
+ ].join("\n")
577
+ end
578
+
579
+ def format_subtype_constraint(node)
580
+ [
581
+ [
582
+ 'SUBTYPE_CONSTRAINT',
583
+ ' ',
584
+ node.id,
585
+ ' ',
586
+ 'FOR',
587
+ ' ',
588
+ format(node.applies_to),
589
+ ';'
590
+ ].join(''),
591
+ *if node.abstract
592
+ indent([
593
+ 'ABSTRACT',
594
+ ' ',
595
+ 'SUPERTYPE',
596
+ ';'
597
+ ].join(''))
598
+ end,
599
+ *if node.total_over and node.total_over.length > 0
600
+ indent([
601
+ 'TOTAL_OVER',
602
+ '(',
603
+ node.total_over.map{|x| format(x)}.join(', '),
604
+ ')',
605
+ ';'
606
+ ].join(''))
607
+ end,
608
+ *if node.supertype_expression
609
+ indent([
610
+ format(node.supertype_expression),
611
+ ';'
612
+ ].join(''))
613
+ end,
614
+ [
615
+ 'END_SUBTYPE_CONSTRAINT',
616
+ ';'
617
+ ].join('')
618
+ ].join("\n")
619
+ end
620
+
621
+ def format_type(node)
622
+ [
623
+ [
624
+ 'TYPE',
625
+ ' ',
626
+ node.id,
627
+ ' ',
628
+ '=',
629
+ ' ',
630
+ format(node.type),
631
+ ';',
632
+ ].join(''),
633
+ *if node.where and node.where.length > 0
634
+ indent([
635
+ 'WHERE',
636
+ indent(node.where.map{|x| format(x)}.join("\n"))
637
+ ].join("\n"))
638
+ end,
639
+ [
640
+ 'END_TYPE',
641
+ ';'
642
+ ].join('')
643
+ ].join("\n")
644
+ end
645
+
646
+ def format_unique(node)
647
+ [
648
+ *if node.id
649
+ [
650
+ node.id,
651
+ ' ',
652
+ ':',
653
+ ' '
654
+ ].join('')
655
+ end,
656
+ node.attributes.map{|x| format(x)}.join(', '),
657
+ ';'
658
+ ].join('')
659
+ end
660
+
661
+ def format_variable(node)
662
+ [
663
+ node.id,
664
+ ' ',
665
+ ':',
666
+ ' ',
667
+ format(node.type),
668
+ *if node.expression
669
+ [
670
+ ' ',
671
+ ':=',
672
+ ' ',
673
+ format(node.expression),
674
+ ].join('')
675
+ end,
676
+ ';'
677
+ ].join('')
678
+ end
679
+
680
+ def format_where(node)
681
+ [
682
+ *if node.id
683
+ [
684
+ node.id,
685
+ ' ',
686
+ ':',
687
+ ' '
688
+ ].join('')
689
+ end,
690
+ format(node.expression),
691
+ ';'
692
+ ].join('')
693
+ end
694
+
695
+ def format_expressions_aggregate_initializer(node)
696
+ [
697
+ '[',
698
+ node.items.map{|x| format(x)}.join(', '),
699
+ ']'
700
+ ].join('')
701
+ end
702
+
703
+ def format_expressions_aggregate_item(node)
704
+ [
705
+ format(node.expression),
706
+ ':',
707
+ format(node.repetition)
708
+ ].join('')
709
+ end
710
+
711
+ def format_expressions_attribute_reference(node)
712
+ [
713
+ format(node.ref),
714
+ '.',
715
+ format(node.attribute)
716
+ ].join('')
717
+ end
718
+
719
+ def format_expressions_binary_expression(node)
720
+ [
721
+ *if node.operand1.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
722
+ '('
723
+ end,
724
+ format(node.operand1),
725
+ *if node.operand1.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
726
+ ')'
727
+ end,
728
+ ' ',
729
+ case node.operator
730
+ when Model::Expressions::BinaryExpression::ADDITION then '+'
731
+ when Model::Expressions::BinaryExpression::AND then 'AND'
732
+ when Model::Expressions::BinaryExpression::ANDOR then 'ANDOR'
733
+ when Model::Expressions::BinaryExpression::COMBINE then '||'
734
+ when Model::Expressions::BinaryExpression::EQUAL then '='
735
+ when Model::Expressions::BinaryExpression::EXPONENTIATION then '**'
736
+ when Model::Expressions::BinaryExpression::GREATER_THAN then '>'
737
+ when Model::Expressions::BinaryExpression::GREATER_THAN_OR_EQUAL then '>='
738
+ when Model::Expressions::BinaryExpression::IN then 'IN'
739
+ when Model::Expressions::BinaryExpression::INSTANCE_EQUAL then ':=:'
740
+ when Model::Expressions::BinaryExpression::INSTANCE_NOT_EQUAL then ':<>:'
741
+ when Model::Expressions::BinaryExpression::INTEGER_DIVISION then 'DIV'
742
+ when Model::Expressions::BinaryExpression::LESS_THAN then '<'
743
+ when Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL then '<='
744
+ when Model::Expressions::BinaryExpression::LIKE then 'LIKE'
745
+ when Model::Expressions::BinaryExpression::MODULO then 'MOD'
746
+ when Model::Expressions::BinaryExpression::MULTIPLICATION then '*'
747
+ when Model::Expressions::BinaryExpression::NOT_EQUAL then '<>'
748
+ when Model::Expressions::BinaryExpression::OR then 'OR'
749
+ when Model::Expressions::BinaryExpression::REAL_DIVISION then '/'
750
+ when Model::Expressions::BinaryExpression::SUBTRACTION then '-'
751
+ when Model::Expressions::BinaryExpression::XOR then 'XOR'
752
+ end,
753
+ ' ',
754
+ *if node.operand2.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
755
+ '('
756
+ end,
757
+ format(node.operand2),
758
+ *if node.operand2.instance_of? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
759
+ ')'
760
+ end,
761
+ ].join('')
762
+ end
763
+
764
+ def format_expressions_call(node)
765
+ [
766
+ format(node.ref),
767
+ '(',
768
+ node.parameters.map{|x| format(x)}.join(', '),
769
+ ')'
770
+ ].join('')
771
+ end
772
+
773
+ def format_expressions_entity_constructor(node)
774
+ [
775
+ format(node.entity),
776
+ '(',
777
+ node.parameters.map{|x| format(x)}.join(', '),
778
+ ')'
779
+ ].join('')
780
+ end
781
+
782
+ def format_expressions_group_reference(node)
783
+ [
784
+ format(node.ref),
785
+ '\\',
786
+ format(node.entity)
787
+ ].join('')
788
+ end
789
+
790
+ def format_expressions_index_reference(node)
791
+ [
792
+ format(node.ref),
793
+ '[',
794
+ format(node.index1),
795
+ *if node.index2
796
+ [
797
+ ':',
798
+ format(node.index2)
799
+ ].join('')
800
+ end,
801
+ ']'
802
+ ].join('')
803
+ end
804
+
805
+ def format_expressions_interval(node)
806
+ [
807
+ '{',
808
+ format(node.low),
809
+ ' ',
810
+ case node.operator1
811
+ when Model::Expressions::BinaryExpression::LESS_THAN then '<'
812
+ when Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL then '<='
813
+ end,
814
+ ' ',
815
+ format(node.item),
816
+ ' ',
817
+ case node.operator2
818
+ when Model::Expressions::BinaryExpression::LESS_THAN then '<'
819
+ when Model::Expressions::BinaryExpression::LESS_THAN_OR_EQUAL then '<='
820
+ end,
821
+ ' ',
822
+ format(node.high),
823
+ '}'
824
+ ].join('')
825
+ end
826
+
827
+ def format_expressions_query_expression(node)
828
+ [
829
+ 'QUERY',
830
+ '(',
831
+ node.id,
832
+ ' ',
833
+ '<*',
834
+ ' ',
835
+ format(node.aggregate_source),
836
+ ' ',
837
+ '|',
838
+ ' ',
839
+ format(node.expression),
840
+ *format_remarks(node).instance_eval{|x| x.length > 0 ? ["\n", *x, "\n"] : x},
841
+ ')'
842
+ ].join('')
843
+ end
844
+
845
+ def format_expressions_simple_reference(node)
846
+ node.id
847
+ end
848
+
849
+ def format_expressions_unary_expression(node)
850
+ [
851
+ case node.operator
852
+ when Model::Expressions::UnaryExpression::MINUS then '-'
853
+ when Model::Expressions::UnaryExpression::NOT then 'NOT'
854
+ when Model::Expressions::UnaryExpression::PLUS then '+'
855
+ end,
856
+ if node.operator == Model::Expressions::UnaryExpression::NOT
857
+ ' '
858
+ end,
859
+ *if node.operand.instance_of? Model::Expressions::BinaryExpression
860
+ '('
861
+ end,
862
+ format(node.operand),
863
+ *if node.operand.instance_of? Model::Expressions::BinaryExpression
864
+ ')'
865
+ end
866
+ ].join('')
867
+ end
868
+
869
+ def format_literals_binary(node)
870
+ [
871
+ '%',
872
+ node.value
873
+ ].join('')
874
+ end
875
+
876
+ def format_literals_integer(node)
877
+ node.value
878
+ end
879
+
880
+ def format_literals_logical(node)
881
+ case node.value
882
+ when Model::Literals::Logical::TRUE then 'TRUE'
883
+ when Model::Literals::Logical::FALSE then 'FALSE'
884
+ when Model::Literals::Logical::UNKNOWN then 'UNKNOWN'
885
+ end
886
+ end
887
+
888
+ def format_literals_real(node)
889
+ node.value
890
+ end
891
+
892
+ def format_literals_string(node)
893
+ if node.encoded
894
+ [
895
+ "\"",
896
+ node.value,
897
+ "\""
898
+ ].join('')
899
+ else
900
+ [
901
+ "'",
902
+ node.value,
903
+ "'"
904
+ ].join('')
905
+ end
906
+ end
907
+
908
+ def format_statements_alias(node)
909
+ [
910
+ [
911
+ 'ALIAS',
912
+ ' ',
913
+ node.id,
914
+ ' ',
915
+ 'FOR',
916
+ ' ',
917
+ format(node.expression),
918
+ ';'
919
+ ].join(''),
920
+ *if node.statements and node.statements.length > 0
921
+ indent(node.statements.map{|x| format(x)}.join("\n"))
922
+ end,
923
+ *format_remarks(node),
924
+ [
925
+ 'END_ALIAS',
926
+ ';'
927
+ ].join('')
928
+ ].join("\n")
929
+ end
930
+
931
+ def format_statements_assignment(node)
932
+ [
933
+ format(node.ref),
934
+ ' ',
935
+ ':=',
936
+ ' ',
937
+ format(node.expression),
938
+ ';'
939
+ ].join('')
940
+ end
941
+
942
+ def format_statements_call(node)
943
+ [
944
+ format(node.ref),
945
+ *if node.parameters and node.parameters.length > 0
946
+ [
947
+ '(',
948
+ node.parameters.map{|x| format(x)}.join(', '),
949
+ ')'
950
+ ].join('')
951
+ end,
952
+ ';'
953
+ ].join('')
954
+ end
955
+
956
+ def format_statements_case(node)
957
+ [
958
+ [
959
+ 'CASE',
960
+ ' ',
961
+ format(node.expression),
962
+ ' ',
963
+ 'OF'
964
+ ].join(''),
965
+ *if node.actions and node.actions.length > 0
966
+ node.actions.map{|x| format(x)}
967
+ end,
968
+ *if node.otherwise_statement
969
+ [
970
+ [
971
+ 'OTHERWISE',
972
+ ' ',
973
+ ':'
974
+ ].join(''),
975
+ indent(format(node.otherwise_statement))
976
+ ]
977
+ end,
978
+ [
979
+ 'END_CASE',
980
+ ';'
981
+ ].join('')
982
+ ].join("\n")
983
+ end
984
+
985
+ def format_statements_case_action(node)
986
+ [
987
+ [
988
+ node.labels.map{|x| format(x)}.join(', '),
989
+ ' ',
990
+ ':'
991
+ ].join(''),
992
+ indent(format(node.statement))
993
+ ].join("\n")
994
+ end
995
+
996
+ def format_statements_compound(node)
997
+ [
998
+ 'BEGIN',
999
+ *if node.statements and node.statements.length > 0
1000
+ indent(node.statements.map{|x| format(x)}.join("\n"))
1001
+ end,
1002
+ [
1003
+ 'END',
1004
+ ';'
1005
+ ].join('')
1006
+ ].join("\n")
1007
+ end
1008
+
1009
+ def format_statements_escape(node)
1010
+ [
1011
+ 'ESCAPE',
1012
+ ';'
1013
+ ].join('')
1014
+ end
1015
+
1016
+ def format_statements_if(node)
1017
+ [
1018
+ [
1019
+ 'IF',
1020
+ ' ',
1021
+ format(node.expression),
1022
+ ' ',
1023
+ 'THEN'
1024
+ ].join(''),
1025
+ *if node.statements and node.statements.length > 0
1026
+ indent(node.statements.map{|x| format(x)}.join("\n"))
1027
+ end,
1028
+ *if node.else_statements and node.else_statements.length > 0
1029
+ [
1030
+ 'ELSE',
1031
+ indent(node.else_statements.map{|x| format(x)}.join("\n")),
1032
+ ].join("\n")
1033
+ end,
1034
+ [
1035
+ 'END_IF',
1036
+ ';'
1037
+ ].join('')
1038
+ ].join("\n")
1039
+ end
1040
+
1041
+ def format_statements_null(node)
1042
+ ';'
1043
+ end
1044
+
1045
+ def format_statements_repeat(node)
1046
+ [
1047
+ [
1048
+ 'REPEAT',
1049
+ *if node.id
1050
+ [
1051
+ ' ',
1052
+ node.id,
1053
+ ' ',
1054
+ ':=',
1055
+ ' ',
1056
+ format(node.bound1),
1057
+ ' ',
1058
+ 'TO',
1059
+ ' ',
1060
+ format(node.bound2),
1061
+ *if node.increment
1062
+ [
1063
+ ' ',
1064
+ 'BY',
1065
+ ' ',
1066
+ format(node.increment)
1067
+ ].join('')
1068
+ end
1069
+ ].join('')
1070
+ end,
1071
+ *if node.while_expression
1072
+ [
1073
+ ' ',
1074
+ 'WHILE',
1075
+ ' ',
1076
+ format(node.while_expression)
1077
+ ].join('')
1078
+ end,
1079
+ *if node.until_expression
1080
+ [
1081
+ ' ',
1082
+ 'UNTIL',
1083
+ ' ',
1084
+ format(node.until_expression)
1085
+ ].join('')
1086
+ end,
1087
+ ';'
1088
+ ].join(''),
1089
+ *if node.statements and node.statements.length > 0
1090
+ indent(node.statements.map{|x| format(x)}.join("\n"))
1091
+ end,
1092
+ *format_remarks(node),
1093
+ [
1094
+ 'END_REPEAT',
1095
+ ';'
1096
+ ].join('')
1097
+ ].join("\n")
1098
+ end
1099
+
1100
+ def format_statements_return(node)
1101
+ [
1102
+ 'RETURN',
1103
+ *if node.expression
1104
+ [
1105
+ ' ',
1106
+ '(',
1107
+ format(node.expression),
1108
+ ')'
1109
+ ].join('')
1110
+ end,
1111
+ ';'
1112
+ ].join('')
1113
+ end
1114
+
1115
+ def format_statements_skip(node)
1116
+ [
1117
+ 'SKIP',
1118
+ ';'
1119
+ ].join('')
1120
+ end
1121
+
1122
+ def format_types_aggregate(node)
1123
+ 'AGGREGATE'
1124
+ end
1125
+
1126
+ def format_types_array(node)
1127
+ [
1128
+ 'ARRAY',
1129
+ *if node.bound1 and node.bound2
1130
+ [
1131
+ ' ',
1132
+ '[',
1133
+ format(node.bound1),
1134
+ ':',
1135
+ format(node.bound2),
1136
+ ']',
1137
+ ].join('')
1138
+ end,
1139
+ ' ',
1140
+ 'OF',
1141
+ *if node.optional
1142
+ [
1143
+ ' ',
1144
+ 'OPTIONAL'
1145
+ ].join('')
1146
+ end,
1147
+ *if node.unique
1148
+ [
1149
+ ' ',
1150
+ 'UNIQUE'
1151
+ ].join('')
1152
+ end,
1153
+ ' ',
1154
+ format(node.base_type)
1155
+ ].join('')
1156
+ end
1157
+
1158
+ def format_types_bag(node)
1159
+ [
1160
+ 'BAG',
1161
+ *if node.bound1 and node.bound2
1162
+ [
1163
+ ' ',
1164
+ '[',
1165
+ format(node.bound1),
1166
+ ':',
1167
+ format(node.bound2),
1168
+ ']',
1169
+ ].join('')
1170
+ end,
1171
+ ' ',
1172
+ 'OF',
1173
+ ' ',
1174
+ format(node.base_type)
1175
+ ].join('')
1176
+ end
1177
+
1178
+ def format_types_binary(node)
1179
+ [
1180
+ 'BINARY',
1181
+ *if node.width
1182
+ [
1183
+ ' ',
1184
+ '(',
1185
+ format(node.width),
1186
+ ')'
1187
+ ].join('')
1188
+ end,
1189
+ *if node.fixed
1190
+ [
1191
+ ' ',
1192
+ 'FIXED'
1193
+ ].join('')
1194
+ end
1195
+ ].join('')
1196
+ end
1197
+
1198
+ def format_types_boolean(node)
1199
+ 'BOOLEAN'
1200
+ end
1201
+
1202
+ def format_types_enumeration(node)
1203
+ [
1204
+ *if node.extensible
1205
+ [
1206
+ 'EXTENSIBLE',
1207
+ ' '
1208
+ ].join('')
1209
+ end,
1210
+ 'ENUMERATION',
1211
+ *if node.items and node.items.length > 0
1212
+ [
1213
+ ' ',
1214
+ 'OF',
1215
+ ' ',
1216
+ '(',
1217
+ node.items.map{|x| format(x)}.join(', '),
1218
+ ')'
1219
+ ].join('')
1220
+ end,
1221
+ *if node.extension_type
1222
+ [
1223
+ ' ',
1224
+ 'BASED_ON',
1225
+ ' ',
1226
+ format(node.extension_type)
1227
+ ].join('')
1228
+ end,
1229
+ *if node.extension_items
1230
+ [
1231
+ ' ',
1232
+ 'WITH',
1233
+ ' ',
1234
+ '(',
1235
+ node.extension_items.map{|x| format(x)}.join(', '),
1236
+ ')'
1237
+ ].join('')
1238
+ end
1239
+ ].join('')
1240
+ end
1241
+
1242
+ def format_types_generic_entity(node)
1243
+ 'GENERIC_ENTITY'
1244
+ end
1245
+
1246
+ def format_types_generic(node)
1247
+ 'GENERIC'
1248
+ end
1249
+
1250
+ def format_types_integer(node)
1251
+ 'INTEGER'
1252
+ end
1253
+
1254
+ def format_types_list(node)
1255
+ [
1256
+ 'LIST',
1257
+ *if node.bound1 and node.bound2
1258
+ [
1259
+ ' ',
1260
+ '[',
1261
+ format(node.bound1),
1262
+ ':',
1263
+ format(node.bound2),
1264
+ ']',
1265
+ ].join('')
1266
+ end,
1267
+ ' ',
1268
+ 'OF',
1269
+ *if node.unique
1270
+ [
1271
+ ' ',
1272
+ 'UNIQUE'
1273
+ ].join('')
1274
+ end,
1275
+ ' ',
1276
+ format(node.base_type)
1277
+ ].join('')
1278
+ end
1279
+
1280
+ def format_types_logical(node)
1281
+ 'LOGICAL'
1282
+ end
1283
+
1284
+ def format_types_number(node)
1285
+ 'NUMBER'
1286
+ end
1287
+
1288
+ def format_types_real(node)
1289
+ [
1290
+ 'REAL',
1291
+ *if node.precision
1292
+ [
1293
+ ' ',
1294
+ '(',
1295
+ format(node.precision),
1296
+ ')'
1297
+ ].join('')
1298
+ end
1299
+ ].join('')
1300
+ end
1301
+
1302
+ def format_types_select(node)
1303
+ [
1304
+ *if node.extensible
1305
+ [
1306
+ 'EXTENSIBLE',
1307
+ ' '
1308
+ ].join('')
1309
+ end,
1310
+ *if node.generic_entity
1311
+ [
1312
+ 'GENERIC_ENTITY',
1313
+ ' '
1314
+ ].join('')
1315
+ end,
1316
+ 'SELECT',
1317
+ *if node.items and node.items.length > 0
1318
+ [
1319
+ ' ',
1320
+ '(',
1321
+ node.items.map{|x| format(x)}.join(', '),
1322
+ ')'
1323
+ ].join('')
1324
+ end,
1325
+ *if node.extension_type
1326
+ [
1327
+ ' ',
1328
+ 'BASED_ON',
1329
+ ' ',
1330
+ format(node.extension_type)
1331
+ ].join('')
1332
+ end,
1333
+ *if node.extension_items
1334
+ [
1335
+ ' ',
1336
+ 'WITH',
1337
+ ' ',
1338
+ '(',
1339
+ node.extension_items.map{|x| format(x)}.join(', '),
1340
+ ')'
1341
+ ].join('')
1342
+ end
1343
+ ].join('')
1344
+ end
1345
+
1346
+ def format_types_set(node)
1347
+ [
1348
+ 'SET',
1349
+ *if node.bound1 and node.bound2
1350
+ [
1351
+ ' ',
1352
+ '[',
1353
+ format(node.bound1),
1354
+ ':',
1355
+ format(node.bound2),
1356
+ ']',
1357
+ ].join('')
1358
+ end,
1359
+ ' ',
1360
+ 'OF',
1361
+ ' ',
1362
+ format(node.base_type)
1363
+ ].join('')
1364
+ end
1365
+
1366
+ def format_types_string(node)
1367
+ [
1368
+ 'STRING',
1369
+ *if node.width
1370
+ [
1371
+ ' ',
1372
+ '(',
1373
+ format(node.width),
1374
+ ')'
1375
+ ].join('')
1376
+ end,
1377
+ *if node.fixed
1378
+ [
1379
+ ' ',
1380
+ 'FIXED'
1381
+ ].join('')
1382
+ end
1383
+ ].join('')
1384
+ end
1385
+
1386
+ def indent(str)
1387
+ str.split("\n").map{|x| "#{INDENT}#{x}"}.join("\n")
1388
+ end
1389
+
1390
+ def format_remark_ref(node)
1391
+ [
1392
+ *if node.class.method_defined? :parent and node.parent.class.method_defined? :id and node.parent != node
1393
+ [
1394
+ format_remark_ref(node.parent),
1395
+ '.'
1396
+ ].join('')
1397
+ end,
1398
+ node.id,
1399
+ ].join('')
1400
+ end
1401
+
1402
+ def format_remark(node, remark)
1403
+ if remark.include?("\n")
1404
+ [
1405
+ [
1406
+ '(*',
1407
+ '"',
1408
+ format_remark_ref(node),
1409
+ '"',
1410
+ ].join(''),
1411
+ remark,
1412
+ '*)'
1413
+ ].join("\n")
1414
+ else
1415
+ [
1416
+ '--',
1417
+ '"',
1418
+ format_remark_ref(node),
1419
+ '"',
1420
+ ' ',
1421
+ remark
1422
+ ].join('')
1423
+ end
1424
+ end
1425
+
1426
+ def format_remarks(node)
1427
+ if node.class.method_defined? :remarks and node.remarks and node.remarks.length > 0
1428
+ node.remarks.map do |remark|
1429
+ format_remark(node, remark)
1430
+ end
1431
+ else
1432
+ []
1433
+ end
1434
+ end
1435
+
1436
+ def format_scope_remarks(node)
1437
+ [
1438
+ *format_remarks(node),
1439
+ *if node.class.method_defined? :children
1440
+ node.children.flat_map do |x|
1441
+ if x != node
1442
+ format_scope_remarks(x)
1443
+ end
1444
+ end
1445
+ end
1446
+ ]
1447
+ end
1448
+ end
1449
+ end
1450
1450
  end