expressir 0.2.2 → 0.2.7

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