expressir 0.2.0 → 0.2.5

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