expressir 0.2.3 → 0.2.8

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