expressir 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +0 -6
  3. data/.github/workflows/rake.yml +200 -9
  4. data/.gitignore +7 -2
  5. data/.gitmodules +3 -0
  6. data/.rubocop.yml +13 -4
  7. data/Rakefile +4 -1
  8. data/bin/console +0 -1
  9. data/bin/rspec +3 -3
  10. data/exe/expressir +4 -2
  11. data/exe/format +1 -1
  12. data/exe/format-test +25 -25
  13. data/exe/generate-parser +16 -13
  14. data/expressir.gemspec +11 -9
  15. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -34
  16. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
  17. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
  18. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
  19. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
  20. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
  21. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
  22. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +11 -4
  23. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
  24. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +20 -20
  25. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -6
  26. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +30 -19
  27. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +13 -10
  28. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
  29. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
  30. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
  31. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
  32. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
  33. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
  34. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -6
  35. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -1
  36. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -13
  37. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
  38. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
  39. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +47 -27
  40. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -6
  41. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
  42. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
  43. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +19 -22
  44. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +20 -20
  45. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
  46. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
  47. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +10 -21
  48. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
  49. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
  50. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
  51. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -32
  52. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +1 -1
  53. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +2 -7
  54. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
  55. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
  56. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
  57. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -45
  58. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -26
  59. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -61
  60. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
  61. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +4 -55
  62. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +34 -20
  63. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +30 -35
  64. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +35 -32
  65. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
  66. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
  67. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
  68. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
  69. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -462
  70. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -68
  71. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
  72. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
  73. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
  74. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +41 -42
  75. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
  76. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
  77. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
  78. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
  79. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
  80. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
  81. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
  82. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
  83. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
  84. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
  85. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
  86. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
  87. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
  88. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
  89. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
  90. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
  91. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
  92. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -106
  93. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +9 -48
  94. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
  95. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
  96. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
  97. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +15 -33
  98. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
  99. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
  100. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
  101. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
  102. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
  103. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
  104. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
  105. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
  106. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
  107. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
  108. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
  109. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
  110. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
  111. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
  112. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
  113. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
  114. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
  115. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
  116. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
  117. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
  118. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
  119. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
  120. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
  121. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
  122. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
  123. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
  124. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
  125. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
  126. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +164 -151
  127. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
  128. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
  129. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
  130. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
  131. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
  132. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
  133. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
  134. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
  135. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
  136. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
  137. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
  138. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +86 -127
  139. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
  140. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
  141. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
  142. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
  143. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
  144. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
  145. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
  146. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
  147. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
  148. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
  149. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
  150. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
  151. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
  152. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
  153. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
  154. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
  155. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
  156. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
  157. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
  158. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
  159. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
  160. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
  161. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
  162. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
  163. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
  164. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
  165. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
  166. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
  167. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
  168. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
  169. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
  170. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
  171. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
  172. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
  173. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
  174. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +9 -21
  175. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
  176. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -8
  177. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
  178. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
  179. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
  180. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
  181. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
  182. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
  183. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
  184. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
  185. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
  186. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +7 -20
  187. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
  188. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
  189. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +34 -14
  190. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
  191. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
  192. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
  193. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
  194. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +12 -53
  195. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
  196. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
  197. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
  198. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -33
  199. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -62
  200. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
  201. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
  202. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
  203. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
  204. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
  205. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
  206. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
  207. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
  208. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
  209. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +13 -4
  210. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
  211. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
  212. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
  213. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +4 -4
  214. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
  215. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
  216. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
  217. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
  218. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
  219. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
  220. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
  221. data/ext/express-parser/antlrgen/Express.interp +1 -1
  222. data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
  223. data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
  224. data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
  225. data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
  226. data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
  227. data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
  228. data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
  229. data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
  230. data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
  231. data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
  232. data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
  233. data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
  234. data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
  235. data/ext/express-parser/express_parser.cpp +207 -75
  236. data/ext/express-parser/extconf.rb +10 -9
  237. data/lib/expressir/config.rb +1 -1
  238. data/lib/expressir/express/parser.rb +2 -2
  239. data/lib/expressir/express/visitor.rb +7 -5
  240. data/lib/expressir/model.rb +78 -78
  241. data/lib/expressir/version.rb +1 -1
  242. data/rakelib/antlr4-native.rake +63 -0
  243. data/rakelib/cross-ruby.rake +213 -162
  244. data/spec/acceptance/version_spec.rb +7 -2
  245. data/spec/expressir/express/cache_spec.rb +8 -5
  246. data/spec/expressir/express/formatter_spec.rb +16 -8
  247. data/spec/expressir/express/parser_spec.rb +17 -11
  248. data/spec/expressir/model/model_element_spec.rb +154 -146
  249. metadata +79 -91
  250. data/demo.rb +0 -18
  251. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
  252. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
  253. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
  254. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
  255. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
  256. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
  257. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
  258. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
  259. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
  260. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
  261. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
  262. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
  263. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
  264. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
  265. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
  266. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
  267. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
  268. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
  269. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
  270. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
  271. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
  272. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
  273. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
  274. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
  275. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
  276. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
  277. data/original/examples/employment/eclipse/.project +0 -17
  278. data/original/examples/employment/eclipse/Export/Employment.png +0 -0
  279. data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
  280. data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
  281. data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
  282. data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
  283. data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
  284. data/original/examples/employment/eclipse/readme.txt +0 -7
  285. data/original/examples/employment/employment_schema.exp +0 -33
  286. data/original/examples/employment/employment_schema.rb +0 -232
  287. data/original/examples/employment/employment_schema.xml +0 -93
  288. data/original/examples/employment/employment_schema___module.rb +0 -46
  289. data/original/examples/employment/employment_schema___p28attr.rb +0 -126
  290. data/original/examples/employment/employment_schema___p28inst.rb +0 -26
  291. data/original/examples/employment/example_employment_data.xml +0 -1
  292. data/original/examples/employment/example_employment_data_copy.xml +0 -1
  293. data/original/examples/employment/example_employment_reader.rb +0 -30
  294. data/original/examples/employment/example_employment_writer.rb +0 -51
  295. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
  296. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
  297. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
  298. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
  299. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
  300. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
  301. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
  302. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
  303. data/original/exp2ruby.rb +0 -525
  304. data/original/expsm.rb +0 -34
  305. data/original/mapping_owl.rb +0 -1018
  306. data/original/mapping_sysml.rb +0 -2281
  307. data/original/mapping_uml2.rb +0 -599
  308. data/original/mapping_uml2_eclipse.rb +0 -433
  309. data/original/reeper.rb +0 -134
  310. data/spec/expressr_spec.rb +0 -5
@@ -1,1018 +0,0 @@
1
- require 'erb'
2
- # EXPRESS to OWL Structural Mapping
3
- # Version 0.5
4
- # This function navigates the EXPRESS STEPMod Model Ruby Classes
5
- # and performs a structural EXPRESS-to-OWL mapping using Ruby ERB templates.
6
- # The output is in OWL RDF/XML abbreviated syntax.
7
- # Mapping summary reports constructs where mapping is not sufficient (i.e. may need editing) or uses newer OWL capabilities
8
- #
9
- # Configurable items are:
10
- # If file named definitions.csv is found, definitions of items are read from that CSV.
11
- # Double quotes around ITEM and DEFINITION column values is required
12
- # include_dublin_core - If true, import of the Dublin Core OWL is included. Set to true if dc used in annotation_list
13
- # annotation_list - added to each construct created if found. Annotations are added if not 'nil'.
14
- # usr_base of namespace for OWL constructs
15
- # top_class - if not nil, makes every OWL class created a subclass if this class which is added to output
16
- # thing_attributes - if specified, OWL DatatypeProperty domain is set to OWL Thing and range set to string
17
- # datatype_hash - sets mappings for EXPRESS builtin to XSD datatypes
18
- # post_processed_schema - If true, write post-processed schema data (e.g. propety hash) for inclusion in other program or script
19
- #
20
- # Mappings are:
21
- # Entity Types and Subtypes are mapped to OWL Class hierarchy.
22
- # Entity Type SUPERTYPE OF ONEOF( list-of-EntityTypes ) are mapped to OWL disjoint between Classes
23
- # Select Types that resolve to all Entity Types are mapped to OWL Class hierarchy.
24
- # Select Types that resolve to all Type are mapped to RDFS Datatype.
25
- # Select Types that resolve to mixed Entity Types and Type are mapped to OWL Class hierarchy, so may need cleanup
26
- # Enumeration Types are mapped to OWL Enumerated Classes
27
- # Type = builtin are mapped to RDFS Datatypes that subtype XSD datatypes
28
- # Type of Type of ... that ultimately resolve to builtin are mapped to datatype subtype hierarchy
29
- # Explicit attrs of Type = builtin are mapped to OWL DatatypeProperties
30
- # Type = AGGR are mapped to subClassOf rdf:List and type of element not specified
31
-
32
- # Explicit attrs of 1-D LIST/ARRAY OF builtin/Type = builtin mapped to OWL ObjectProperty and subClassOf rdf:List and cardinality 1
33
- # Explicit attrs of n-D AGGR mapped to OWL ObjectProperty and subClassOf rdf:List, type of element not specified, and cardinality 1
34
-
35
- # Inverse attrs are mapped to OWL DatatypeProperties with inverseOf set, except inverse of inherited not mapped
36
- # BOOLEAN attributes are mapped to OWL DatatypeProperties.
37
-
38
- # Attribute redeclarations that ref Entity/Select are mapped to ObjectProperty that is subproperty of that it redeclares
39
- # Attribute redeclarations that ref builting simple types are mapped to DatatypeProperty that is subproperty of that it redeclares
40
- # Type = type that is a select are mapped to Class subclass of referenced select Class
41
- # Single Attribute OPTIONAL or not maps to cardinality restriction on Class owning attribute
42
- # 1D SET/BAG Attribute bound maps to cardinality restriction on Class owning attribute
43
- # n-dimensional aggregates map to rdf List with no internal structure and type of element not specified
44
-
45
-
46
- #
47
- def map_from_express( mapinput )
48
- puts ' '
49
- puts 'EXPRESS to OWL Structural Mapping V0.5'
50
- puts ' '
51
-
52
- ######### Mapping Configuration Starts Here ##############
53
-
54
- # Set the base of the URI (i.e. the namespace) for OWL constructs created during the mapping
55
- uri_base = 'http://www.reeper.org'
56
-
57
- # Add RDFS andor Dublin Core basic annotations
58
-
59
- # Set to true if any annotation_list elements use Dublin Core (dc: or dcterms:)
60
- include_dublin_core = false
61
-
62
- annotation_list = Array.new
63
- # rdfs:comment must be position 0 as definition assignment hardcoded there
64
- #annotation_list[0] = ['rdfs:comment', nil]
65
- #annotation_list[1] = ['owl:versionInfo', '1']
66
- #annotation_list[2] = ['dc:creator', 'David Price, TopQuadrant Limited']
67
- #annotation_list[3] = ['dcterms:created','2010-10-22']
68
- #annotation_list[4] = ['dc:source', '{ iso standard 10303 part(214) version(2) object(1) automotive-design-schema(1) }']
69
-
70
- # Read definitions from csv file if found
71
- definition_hash = Hash.new
72
- if FileTest.exist?('definitions.csv')
73
- require 'csv'
74
- puts '-- Definitions CSV File Found'
75
- CSV.open('definitions.csv', 'r') do |row|
76
- definition_hash[row[0].downcase] = row[1]
77
- end
78
- end
79
-
80
- # set to class name (e.g. 'TOP-THING') to make all created OWL Classes subclasses of a topmost class
81
- top_class = 'AP233-ARM-THING'
82
-
83
- # add common string attributes to use OWL Thing as domain rather than schema classes
84
- thing_attributes = []
85
- #thing_attributes.push 'id'
86
- #thing_attributes.push 'name'
87
- #thing_attributes.push 'description'
88
-
89
- # datatypes for simple and aggregates of simple type
90
- datatype_hash = Hash.new
91
- datatype_hash["INTEGER"] = 'http://www.w3.org/2001/XMLSchema#integer'
92
- datatype_hash["REAL"] = 'http://www.w3.org/2001/XMLSchema#float'
93
- datatype_hash["NUMBER"] = 'http://www.w3.org/2001/XMLSchema#float'
94
- datatype_hash["BINARY"] = 'http://www.w3.org/2001/XMLSchema#hexBinary'
95
- datatype_hash["BOOLEAN"] = 'http://www.w3.org/2001/XMLSchema#boolean'
96
- datatype_hash["LOGICAL"] = 'http://www.w3.org/2001/XMLSchema#boolean'
97
- datatype_hash["STRING"] = 'http://www.w3.org/2001/XMLSchema#string'
98
-
99
- # Write the property_type_hash for inclusion in other scripts or not
100
- post_processed_schema = false
101
- post_processed_schema_file_name = 'postprocessed_schema.rb'
102
- post_processed_schema_file = File.new(post_processed_schema_file_name,'w') if post_processed_schema
103
-
104
- ######### Mapping Configuration Ends Here ##############
105
-
106
-
107
- # Template covering the start of the output file
108
- overall_start_template = %{<rdf:RDF
109
- xmlns:owl="http://www.w3.org/2002/07/owl#"
110
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
111
- xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
112
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
113
- <% if include_dublin_core %>
114
- xmlns:dc="http://purl.org/dc/elements/1.1/"
115
- xmlns:dcterms="http://purl.org/dc/terms/"
116
- <% end %>
117
- }
118
-
119
- # Template covering the output file contents for each schema start
120
- schema_start_template = %{xmlns="<%= uri_base %>/<%= schema.name %>#"
121
- xml:base="<%= uri_base %>/<%= schema.name %>#" >
122
-
123
- <owl:Ontology rdf:about='' rdfs:label='<%= schema.name %>' >
124
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
125
- <% end %>
126
- <% if include_dublin_core %>
127
- <owl:imports rdf:resource="http://purl.org/dc/terms/"/>
128
- <owl:imports rdf:resource="http://purl.org/dc/elements/1.1/"/>
129
- <% end %>
130
- </owl:Ontology>
131
- <% if top_class != nil %>
132
- <owl:Class rdf:ID='<%= top_class %>' />
133
- <% end %>
134
- }
135
-
136
- # Template covering the output file contents for each entity type start or start of type = type that is a select
137
- entity_start_template = %{
138
- <owl:Class rdf:ID='<%= class_name %>' >
139
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
140
- <% end %>
141
- }
142
- # Template covering the output file contents for each entity type end or end of type = type that is a select
143
- entity_end_template = %{
144
- <% if top_class != nil %>
145
- <rdfs:subClassOf rdf:resource='#<%= top_class %>' />
146
- <% end %>
147
- </owl:Class>
148
- }
149
-
150
- # Template covering the output file contents for end of type = type that is a select
151
- class_end_template = %{</owl:Class>}
152
-
153
- # Template covering the output file contents for each select type start
154
- select_start_template = %{
155
- <owl:Class rdf:ID='<%= select.name %>' >
156
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
157
- <% end %>
158
- }
159
- # Template covering the output file contents for each select type end
160
- select_end_template = %{<% if top_class != nil %>
161
- <rdfs:subClassOf rdf:resource='#<%= top_class %>' />
162
- <% end %>
163
- </owl:Class>
164
- }
165
-
166
- # Template covering the supertype(s) for each entity type and type = type that is a select
167
- supertype_template = %{<rdfs:subClassOf rdf:resource='#<%= superclass_name %>' />
168
- }
169
-
170
- # Template covering OWL collections of class contents
171
- class_collection_template = %{<owl:Class><owl:unionOf rdf:parseType="Collection">
172
- <% item_name_list.each do |name| %>
173
- <rdf:Description rdf:about='#<%= name %>'/>
174
- <% end %>
175
- </owl:unionOf>
176
- </owl:Class>}
177
-
178
- # Template covering OWL collections of RDFS datatypes
179
- datatype_collection_template = %{<rdfs:Datatype rdf:ID='<%= type_name %>'>
180
- <owl:equivalentClass><rdfs:Datatype><owl:unionOf rdf:parseType="Collection">
181
- <% type_name_list.each do |name| %>
182
- <rdf:Description rdf:about='#<%= name %>' />
183
- <% end %>
184
- </owl:unionOf>
185
- </rdfs:Datatype></owl:equivalentClass>
186
- </rdfs:Datatype>}
187
-
188
- # Template covering abstract entity types
189
- abstract_entity_template = %{<rdfs:subClassOf rdf:resource='#<%= supertype.name %>' />
190
- }
191
-
192
- # Template covering the output file contents for each defined type of builtin datatype
193
- type_builtin_template = %{
194
- <rdfs:Datatype rdf:ID='<%= datatype_name %>'>
195
- <rdfs:subClassOf rdf:resource='<%= superdatatype_name %>'/>
196
- </rdfs:Datatype>
197
- }
198
-
199
- # Template covering the mappings to rdf list
200
- rdflist_template = %{<rdfs:Class rdf:ID='<%= list_name %>'>
201
- <rdfs:subClassOf rdf:resource='<%= superlist_name %>'/>
202
- </rdfs:Class>}
203
-
204
- # Template covering the output file contents for each attribute that is an aggregate
205
- attribute_aggregate_template = %{}
206
-
207
- # Template covering the output file contents for each attribute that is an aggregate of select of entity
208
- attribute_aggregate_entity_select_template = %{}
209
-
210
- # Template covering the output file contents for each attribute that is a select of entity
211
- attribute_entity_select_template = %{}
212
-
213
- # Template covering the output file contents for each attribute
214
- attribute_template = %{}
215
-
216
- # Template covering the output file contents for each attribute that is builtin datatype
217
- attribute_builtin_template = %{<owl:DatatypeProperty rdf:ID='<%= owl_property_name %>'>
218
- <% if owl_property_domain != nil %>
219
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
220
- <% end %>
221
- <rdfs:range rdf:resource='<%= owl_property_range %>' />
222
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
223
- <% end %>
224
- <% if owl_super_property_name != nil %>
225
- <rdfs:subPropertyOf rdf:resource='#<%= owl_super_property_name %>' />
226
- <% end %>
227
- </owl:DatatypeProperty>
228
- }
229
-
230
- # Template covering the output file contents for each attribute that is type that is builtin datatype
231
- attribute_typebuiltin_template = %{<owl:DatatypeProperty rdf:ID='<%= owl_property_name %>'>
232
- <% if owl_property_domain != nil %>
233
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
234
- <% end %>
235
- <rdfs:range rdf:resource='#<%= owl_property_range %>' />
236
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
237
- <% end %>
238
- </owl:DatatypeProperty>
239
- }
240
-
241
- # Template covering the output file contents for each attribute that is entity or select type
242
- attribute_entity_template = %{<owl:ObjectProperty rdf:ID='<%= owl_property_name %>'>
243
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
244
- <rdfs:range rdf:resource='#<%= owl_property_range %>' />
245
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
246
- <% end %>
247
- </owl:ObjectProperty>
248
- }
249
-
250
- # Template covering the output file contents for each attribute that is entity or select type
251
- inverse_entity_template = %{<owl:ObjectProperty rdf:ID='<%= owl_property_name %>'>
252
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
253
- <rdfs:range rdf:resource='#<%= owl_property_range %>' />
254
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
255
- <% end %>
256
- <owl:inverseOf rdf:resource="#<%= owl_inverted_property_name %>"/>
257
- </owl:ObjectProperty>
258
- }
259
-
260
- # Template covering the output file contents for each attribute that is a redeclaration and reference to an entity or select type
261
- attribute_redeclare_entity_template = %{<owl:ObjectProperty rdf:ID='<%= owl_property_name %>'>
262
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
263
- <rdfs:range rdf:resource='#<%= owl_property_range %>' />
264
- <rdfs:subPropertyOf rdf:resource='#<%= owl_super_property_name %>' />
265
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
266
- <% end %>
267
- </owl:ObjectProperty>
268
- }
269
-
270
-
271
-
272
- # Template covering the output file contents for each attribute that is enum datatype
273
- class_enum_template = %{<owl:Class rdf:ID='<%= owl_class_name %>'>
274
- <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
275
- <owl:oneOf rdf:parseType="Collection">
276
- <% enumitem_name_list.each do |name| %>
277
- <rdf:Description rdf:ID="<%= owl_class_name + '.' + name %>"/>
278
- <% end %>
279
- </owl:oneOf>
280
- </owl:Class>}
281
-
282
-
283
- # Template covering the output file contents for each attribute that is enum datatype
284
- attribute_enum_template = %{<owl:DatatypeProperty rdf:ID='<%= owl_property_name %>'>
285
- <rdfs:domain rdf:resource='#<%= owl_property_domain %>' />
286
- <rdfs:range><owl:DataRange><owl:oneOf><rdf:List>
287
- <% enumitem_name_list.each do |name| %>
288
- <rdf:first rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= name %></rdf:first>
289
- <% if enumitem_name_list[enumitem_name_list.size-1] != name %>
290
- <rdf:rest><rdf:List>
291
- <% end %>
292
- <% if enumitem_name_list[enumitem_name_list.size-1] == name %>
293
- <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/> </rdf:List>
294
- <% end %>
295
- <% end %>
296
- <% (1..enumitem_name_list.size-1).each do %>
297
- </rdf:rest></rdf:List>
298
- <% end %>
299
- </owl:oneOf></owl:DataRange></rdfs:range>
300
- <% annotation_list.each do |i| %><% if i[1] != nil and i[1] != '' %><<%= i[0] %> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"><%= i[1] %></<%= i[0] %>><% end %>
301
- <% end %>
302
- </owl:DatatypeProperty>}
303
-
304
-
305
-
306
- # Template covering min cardinality
307
- min_cardinality_template = %{<rdf:Description rdf:about='#<%= class_name %>'>
308
- <rdfs:subClassOf>
309
- <owl:Restriction>
310
- <owl:onProperty rdf:resource='#<%= owl_property_name %>'/>
311
- <owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"><%= min_cardinality %></owl:minCardinality>
312
- </owl:Restriction>
313
- </rdfs:subClassOf>
314
- </rdf:Description>}
315
-
316
-
317
- # Template covering max cardinality
318
- max_cardinality_template = %{<rdf:Description rdf:about='#<%= class_name %>'>
319
- <rdfs:subClassOf>
320
- <owl:Restriction>
321
- <owl:onProperty rdf:resource='#<%= owl_property_name %>'/>
322
- <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"><%= max_cardinality %></owl:maxCardinality>
323
- </owl:Restriction>
324
- </rdfs:subClassOf>
325
- </rdf:Description>}
326
-
327
- # Template covering cardinality
328
- cardinality_template = %{<rdf:Description rdf:about='#<%= class_name %>'>
329
- <rdfs:subClassOf>
330
- <owl:Restriction>
331
- <owl:onProperty rdf:resource='#<%= owl_property_name %>'/>
332
- <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"><%= min_cardinality %></owl:cardinality>
333
- </owl:Restriction>
334
- </rdfs:subClassOf>
335
- </rdf:Description>}
336
-
337
- # Template covering the output file contents for each schema end
338
- disjoint_template = %{
339
- <rdf:Description rdf:about='#<%= first_class_name %>'>
340
- <owl:disjointWith rdf:resource="#<%= disjoint_class_name %>"/>
341
- </rdf:Description>}
342
-
343
-
344
- # Template covering the output file contents for each schema end
345
- schema_end_template = %{}
346
-
347
- # Template covering the end of the output file
348
- overall_end_template = %{ </rdf:RDF>}
349
-
350
-
351
- def post_process_entity(entity, post_processed_schema_file, datatype_hash)
352
- attribute_list = entity.attributes_all_array.find_all{ |a| a.kind_of? EXPSM::Explicit}
353
-
354
- for attribute in attribute_list
355
-
356
- express_attribute_domain = nil
357
- if !attribute.isBuiltin
358
- express_attribute_domain = NamedType.find_by_name( attribute.domain )
359
- end
360
- p28_property_name = entity.name.capitalize + '.' + attribute.name.capitalize
361
- property_quoted = false
362
- property_list = false
363
- property_type = '"' + attribute.domain + '"'
364
- if attribute.isBuiltin
365
- property_type = '"' + datatype_hash[attribute.domain] + '"'
366
- end
367
- if attribute.isBuiltin and attribute.domain == 'STRING'
368
- property_quoted = true
369
- end
370
- if (!attribute.redeclare_entity and express_attribute_domain.instance_of? EXPSM::Type and express_attribute_domain.isBuiltin and express_attribute_domain == 'STRING')
371
- property_quoted = true
372
- property_type = '"' + datatype_hash[express_attribute_domain.domain] + '"'
373
- end
374
- if ( attribute.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
375
- property_list = true
376
- property_type = '"' + datatype_hash[attribute.domain] + '"'
377
- end
378
-
379
- if (express_attribute_domain.instance_of? EXPSM::Type and express_attribute_domain.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
380
- property_list = true
381
- property_type = '"' + datatype_hash[express_attribute_domain.domain] + '"'
382
- end
383
-
384
- property_type = property_type.gsub('http://www.w3.org/2001/XMLSchema#','xsd:')
385
- post_processed_schema_file.puts 'property_range_hash["' + p28_property_name + '"] = [' + property_quoted.to_s + ',' + property_list.to_s + ',' + property_type.to_s + ']'
386
- end
387
- end
388
-
389
-
390
- # A recursive function to return complete set of items, following nested selects, for a select that are not selects themselves
391
- def get_all_selections( item_list )
392
- select_items = item_list.find_all{ |a| a.kind_of? EXPSM::TypeSelect}
393
- if select_items.size == 0
394
- return item_list
395
- end
396
- temp_item_list = item_list
397
- for select in select_items
398
- temp_item_list.delete( select )
399
- temp_item_list = temp_item_list + select.selectitems_array
400
- end
401
- final_list = get_all_selections( temp_item_list )
402
- end
403
-
404
- # A recursive function to return the ultimate underlying type of a type
405
- def is_utlimate_type_builtin( the_type )
406
- return true if the_type.isBuiltin
407
- base_type = NamedType.find_by_name( the_type.domain )
408
- case
409
- when (base_type.instance_of? EXPSM::TypeSelect or base_type.instance_of? EXPSM::Entity)
410
- return false
411
- when (base_type.kind_of? EXPSM::Type and base_type.isBuiltin)
412
- return true
413
- else
414
- return is_utlimate_type_builtin( base_type )
415
- end
416
- end
417
-
418
- # Set up list of schemas to process, input may be a repository containing schemas or a single schema
419
- if mapinput.kind_of? EXPSM::Repository
420
- schema_list = mapinput.schemas
421
- elsif mapinput.kind_of? EXPSM::SchemaDefinition
422
- schema_list = [mapinput]
423
- else
424
- puts "ERROR : map_from_express input no Repository instance or Schema instance"
425
- exit
426
- end
427
-
428
-
429
- for schema in schema_list
430
-
431
- type_mapped_list = []
432
- entity_mapped_list = []
433
- explicit_mapped_list = []
434
- inverse_mapped_list = []
435
- thing_attr_mapped_list = []
436
- superexpression_mapped_list = []
437
- list_mapped_attr_list = []
438
- list_mapped_type_list = []
439
- type_union_mapped_list = []
440
- mixed_select_list = []
441
- all_explicit_list = []
442
- all_derived_list = []
443
- all_inverse_list = []
444
- all_superexpression_list = []
445
-
446
- # Set up separate file for each schema
447
- filename = schema.name.to_s + ".owl"
448
- file = File.new(filename, "w")
449
-
450
- # Evaluate and write file start template
451
- res = ERB.new(overall_start_template)
452
- t = res.result(binding)
453
- file.puts t
454
-
455
- # Evaluate and write schema start template
456
- res = ERB.new(schema_start_template)
457
- t = res.result(binding)
458
- file.puts t
459
-
460
- select_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::TypeSelect }
461
- entity_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Entity }
462
- defined_type_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::Type }
463
- enum_type_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::TypeEnum }
464
- defined_type_not_builtin_list = defined_type_list.find_all{ |e| !e.isBuiltin }
465
- defined_type_builtin_list = defined_type_list.find_all{ |e| e.isBuiltin }
466
-
467
- # Handle enumeration type maps to RDFS Datatype string
468
-
469
- for type_enum in enum_type_list
470
- type_mapped_list.push type_enum
471
- owl_class_name = type_enum.name
472
- enumitem_name_list = type_enum.items.scan(/\w+/)
473
- res = ERB.new(class_enum_template)
474
- t = res.result(binding)
475
- file.puts t
476
- end
477
-
478
-
479
- # Handle defined type maps to RDFS Datatype
480
-
481
- for type_builtin in defined_type_builtin_list
482
-
483
- # Handle defined type maps to RDFS Datatype
484
- if !type_builtin.instance_of? EXPSM::TypeAggregate
485
- type_mapped_list.push type_builtin
486
- datatype_name = type_builtin.name
487
- superdatatype_name = datatype_hash[type_builtin.domain]
488
- res = ERB.new(type_builtin_template)
489
- t = res.result(binding)
490
- file.puts t
491
- # Handle defined type maps to RDF List
492
- else
493
- list_mapped_type_list.push type_builtin
494
- type_mapped_list.push type_builtin
495
- list_name = type_builtin.name
496
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
497
- res = ERB.new(rdflist_template)
498
- t = res.result(binding)
499
- file.puts t
500
- end
501
- end
502
-
503
-
504
- for type_not_builtin in defined_type_not_builtin_list
505
-
506
- type_domain = NamedType.find_by_name( type_not_builtin.domain )
507
- type_is_builtin = is_utlimate_type_builtin( type_not_builtin )
508
-
509
- case
510
-
511
- # Handle simple defined type refining simple defined type of builtin map to RDFS Datatype
512
- when (!type_not_builtin.instance_of? EXPSM::TypeAggregate and type_is_builtin and !type_domain.instance_of? EXPSM::TypeAggregate)
513
- type_mapped_list.push type_not_builtin
514
- datatype_name = type_not_builtin.name
515
- superdatatype_name = '#' + type_domain.name
516
- res = ERB.new(type_builtin_template)
517
- t = res.result(binding)
518
- file.puts t
519
-
520
- # Handle simple defined type of aggr defined type of builtin map to RDF List
521
- when (!type_not_builtin.instance_of? EXPSM::TypeAggregate and type_domain.instance_of? EXPSM::TypeAggregate and type_is_builtin)
522
- type_mapped_list.push type_not_builtin
523
- list_mapped_type_list.push type_not_builtin
524
- list_name = type_not_builtin.name
525
- superlist_name = '#' + type_domain.name
526
- res = ERB.new(rdflist_template)
527
- t = res.result(binding)
528
- file.puts t
529
-
530
- # Handle aggr defined type of simple defined type of builtin map to RDF List
531
- when (type_not_builtin.instance_of? EXPSM::TypeAggregate and type_domain.instance_of? EXPSM::Type and type_is_builtin)
532
- type_mapped_list.push type_not_builtin
533
- list_mapped_type_list.push type_not_builtin
534
- list_name = type_not_builtin.name
535
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
536
- res = ERB.new(rdflist_template)
537
- t = res.result(binding)
538
- file.puts t
539
-
540
- # Handle aggr of entity/select type map to RDF List
541
- when (type_not_builtin.instance_of? EXPSM::TypeAggregate and (type_domain.instance_of? EXPSM::Entity or type_domain.instance_of? EXPSM::TypeSelect))
542
- type_mapped_list.push type_not_builtin
543
- list_mapped_type_list.push type_not_builtin
544
- list_name = type_not_builtin.name
545
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
546
- res = ERB.new(rdflist_template)
547
- t = res.result(binding)
548
- file.puts t
549
-
550
- # Handle defined type that are type = type that is a select
551
- when (type_domain.kind_of? EXPSM::TypeSelect)
552
- type_mapped_list.push type_not_builtin
553
- superclass_name = type_not_builtin.domain
554
- class_name = type_not_builtin.name
555
- res = ERB.new(entity_start_template)
556
- t = res.result(binding)
557
- file.puts t
558
-
559
- superclass_name = type_not_builtin.domain
560
- res = ERB.new(supertype_template)
561
- t = res.result(binding)
562
- file.puts t
563
-
564
- res = ERB.new(class_end_template)
565
- t = res.result(binding)
566
- file.puts t
567
-
568
- else
569
- puts 'ERROR : Not mapped = ' + type_not_builtin.name
570
- end
571
- end
572
-
573
-
574
- # Handle EXPRESS SELECT Type mapping to OWL Class hierarchy and RDFS Datatypes
575
-
576
- for select in select_list
577
-
578
- item_name_list = select.selectitems.scan(/\w+/)
579
-
580
- this_select_all_items = get_all_selections( select.selectitems_array )
581
- this_select_type_items = this_select_all_items.find_all{ |a| a.kind_of? EXPSM::Type}
582
-
583
- case
584
-
585
- # Handle case of select items resolving to containing only items that are non-select Type
586
- when this_select_type_items.size == this_select_all_items.size
587
- type_mapped_list.push select
588
- type_union_mapped_list.push select
589
- type_name_list = item_name_list
590
- type_name = select.name
591
- res = ERB.new(datatype_collection_template)
592
- t = res.result(binding)
593
- file.puts t
594
-
595
- # Handle case of select items resolving to containing no item that is a non-select Type
596
- else
597
- type_mapped_list.push select
598
-
599
- res = ERB.new(select_start_template)
600
- t = res.result(binding)
601
- file.puts t
602
- file.puts '<owl:equivalentClass>'
603
-
604
- res = ERB.new(class_collection_template)
605
- t = res.result(binding)
606
- file.puts t
607
- file.puts '</owl:equivalentClass>'
608
-
609
- res = ERB.new(select_end_template)
610
- t = res.result(binding)
611
- file.puts t
612
- if (this_select_type_items.size != 0 and this_select_type_items.size != this_select_all_items.size)
613
- mixed_select_list.push select
614
- end
615
-
616
- end
617
- end
618
-
619
- # Handle EXPRESS Entity mappings to OWL Class hierarchy
620
-
621
- for entity in entity_list
622
-
623
- if definition_hash[entity.name.downcase] != nil
624
- annotation_list[0] = ['rdfs:comment', definition_hash[entity.name.downcase]]
625
- else
626
- annotation_list[0] = ['rdfs:comment', nil]
627
- end
628
-
629
- entity_mapped_list.push entity
630
-
631
- class_name = entity.name
632
- res = ERB.new(entity_start_template)
633
- t = res.result(binding)
634
- file.puts t
635
-
636
- for supertype in entity.supertypes_array
637
- superclass_name = supertype.name
638
- res = ERB.new(supertype_template)
639
- t = res.result(binding)
640
- file.puts t
641
- end
642
-
643
- res = ERB.new(entity_end_template)
644
- t = res.result(binding)
645
- file.puts t
646
-
647
- # Post-process the entity
648
- post_process_entity(entity, post_processed_schema_file, datatype_hash) if post_processed_schema
649
-
650
-
651
- if entity.superexpression != nil
652
- all_superexpression_list.push entity
653
-
654
- # Handle simple case of one ONEOF in supertype expression mapped to disjoint between listed subclasses
655
- case
656
- # when (entity.superexpression.include?('ONEOF') and !entity.superexpression.include?('ANDOR') and !entity.superexpression.include?('TOTAL_OVER') and !entity.superexpression.include?('AND') and !entity.superexpression.include?('ABSTRACT'))
657
-
658
- when (entity.superexpression.include?('ONEOF'))
659
- superexpression_mapped_list.push entity
660
- tempexpression = entity.superexpression
661
- if entity.superexpression.index('ONEOF') != 0
662
- puts 'WARNING: ' + entity.name + ' supertype mapping may be incomplete, only ONEOFs processed'
663
- end
664
- while (tempexpression.include?('ONEOF'))
665
- posoneof = tempexpression.index('ONEOF')
666
- tempexpression = tempexpression[posoneof + 5,tempexpression.length - 5]
667
- posclose = tempexpression.index(')')
668
- oneof_name_list = tempexpression[0,posclose].scan(/\w+/)
669
- while oneof_name_list.size != 0
670
- first_class_name = oneof_name_list[0]
671
- oneof_name_list.delete(first_class_name)
672
- for disjoint_class_name in oneof_name_list
673
- res = ERB.new(disjoint_template)
674
- t = res.result(binding)
675
- file.puts t
676
- end
677
- end
678
- end
679
- else
680
- end
681
-
682
- end
683
-
684
-
685
- end
686
-
687
- # Handle mapping common string attributes to OWL DatatypeProperties of OWL Thing
688
-
689
- for thing_attribute in thing_attributes
690
- owl_property_name = thing_attribute
691
- owl_property_range = 'http://www.w3.org/2001/XMLSchema#string'
692
- owl_property_domain = nil
693
- owl_super_property_name = nil
694
- res = ERB.new(attribute_builtin_template)
695
- t = res.result(binding)
696
- file.puts t
697
- end
698
-
699
- # Handle EXPRESS attributes on an entity-by-entity basis
700
- for entity in entity_list
701
-
702
- class_name = entity.name
703
-
704
- attribute_list = entity.attributes.find_all{ |a| a.kind_of? EXPSM::Explicit and !thing_attributes.include?(a.name)}
705
- thing_attr_list = entity.attributes.find_all{ |a| a.kind_of? EXPSM::Explicit and thing_attributes.include?(a.name)}
706
- inverse_list = entity.attributes.find_all{ |a| a.kind_of? EXPSM::Inverse and !thing_attributes.include?(a.name)}
707
-
708
- thing_attr_mapped_list = thing_attr_mapped_list + thing_attr_list
709
-
710
- all_explicit_list = all_explicit_list + entity.attributes.find_all{ |a| a.kind_of? EXPSM::Explicit}
711
- all_derived_list = all_derived_list + entity.attributes.find_all{ |a| a.kind_of? EXPSM::Derived}
712
-
713
- all_inverse_list = all_inverse_list + inverse_list
714
-
715
- # Handle EXPRESS inverse attribute mapping to OWL inverse property
716
- for attribute in inverse_list
717
- if attribute.reverseAttr != []
718
- inverse_mapped_list.push attribute
719
- owl_property_range = attribute.domain
720
- owl_property_name = entity.name + '.' + attribute.name
721
- owl_property_domain = entity.name
722
- owl_inverted_property_name = attribute.reverseEntity.name + '.' + attribute.reverseAttr.name
723
- res = ERB.new(inverse_entity_template)
724
- t = res.result(binding)
725
- file.puts t
726
- end
727
- end
728
-
729
- # Handle EXPRESS explicit attribute mapping to OWL property
730
- for attribute in attribute_list
731
-
732
- express_attribute_domain = nil
733
- type_is_builtin = false
734
- if !attribute.isBuiltin
735
- express_attribute_domain = NamedType.find_by_name( attribute.domain )
736
- if express_attribute_domain.instance_of? EXPSM::Type
737
- type_is_builtin = is_utlimate_type_builtin( express_attribute_domain )
738
- end
739
- end
740
-
741
- case
742
-
743
- # Handle EXPRESS explicit attributes of LIST of built-in simple type, including redeclaration
744
- when (attribute.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
745
- explicit_mapped_list.push attribute
746
- list_mapped_attr_list.push attribute
747
- list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-List'
748
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
749
- res = ERB.new(rdflist_template)
750
- t = res.result(binding)
751
- file.puts t
752
- owl_property_name = entity.name + '.' + attribute.name
753
- owl_property_domain = entity.name
754
- owl_property_range = list_name
755
- res = ERB.new(attribute_entity_template)
756
- t = res.result(binding)
757
- file.puts t
758
-
759
- # Handle EXPRESS explicit attributes of ARRAY of built-in simple type, including redeclaration
760
- when (attribute.isBuiltin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'ARRAY')
761
- explicit_mapped_list.push attribute
762
- list_mapped_attr_list.push attribute
763
- list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-Array'
764
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
765
- res = ERB.new(rdflist_template)
766
- t = res.result(binding)
767
- file.puts t
768
- owl_property_name = entity.name + '.' + attribute.name
769
- owl_property_domain = entity.name
770
- owl_property_range = list_name
771
- res = ERB.new(attribute_entity_template)
772
- t = res.result(binding)
773
- file.puts t
774
-
775
- # Handle EXPRESS explicit attributes of LIST of TYPE that is built-in simple type, including redeclaration
776
- when (express_attribute_domain.instance_of? EXPSM::Type and type_is_builtin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'LIST')
777
- explicit_mapped_list.push attribute
778
- list_mapped_attr_list.push attribute
779
- list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-List'
780
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
781
- res = ERB.new(rdflist_template)
782
- t = res.result(binding)
783
- file.puts t
784
- owl_property_name = entity.name + '.' + attribute.name
785
- owl_property_domain = entity.name
786
- owl_property_range = list_name
787
- res = ERB.new(attribute_entity_template)
788
- t = res.result(binding)
789
- file.puts t
790
-
791
- # Handle EXPRESS explicit attributes of ARRAY of TYPE that is built-in simple type, including redeclaration
792
- when (express_attribute_domain.instance_of? EXPSM::Type and type_is_builtin and attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype = 'ARRAY')
793
- explicit_mapped_list.push attribute
794
- list_mapped_attr_list.push attribute
795
- list_name = entity.name + '.' + attribute.name + '-' + attribute.domain.to_s + '-Array'
796
- superlist_name = "http://www.w3.org/1999/02/22-rdf-syntax-ns#List"
797
- res = ERB.new(rdflist_template)
798
- t = res.result(binding)
799
- file.puts t
800
- owl_property_name = entity.name + '.' + attribute.name
801
- owl_property_domain = entity.name
802
- owl_property_range = list_name
803
- res = ERB.new(attribute_entity_template)
804
- t = res.result(binding)
805
- file.puts t
806
-
807
-
808
- # Handle EXPRESS explicit attributes of built-in simple type, including redeclaration
809
- when (attribute.isBuiltin)
810
- explicit_mapped_list.push attribute
811
- owl_property_range = datatype_hash[attribute.domain]
812
- owl_property_name = entity.name + '.' + attribute.name
813
- owl_property_domain = entity.name
814
- owl_super_property_name = nil
815
- if attribute.redeclare_entity != nil
816
- if attribute.redeclare_oldname == nil
817
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.name
818
- else
819
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.redeclare_oldname
820
- end
821
- end
822
- res = ERB.new(attribute_builtin_template)
823
- t = res.result(binding)
824
- file.puts t
825
-
826
- # Handle EXPRESS explicit attribute, not redeclaration, refers to Type that is Type = builtin datatype
827
- when (!attribute.redeclare_entity and express_attribute_domain.instance_of? EXPSM::Type and type_is_builtin)
828
- explicit_mapped_list.push attribute
829
- owl_property_range = attribute.domain
830
- owl_property_name = entity.name + '.' + attribute.name
831
- owl_property_domain = entity.name
832
- res = ERB.new(attribute_typebuiltin_template)
833
- t = res.result(binding)
834
- file.puts t
835
-
836
- # Handle EXPRESS explicit attributes of enum type, ignoring redeclarations
837
- when (express_attribute_domain.kind_of? EXPSM::TypeEnum)
838
- explicit_mapped_list.push attribute
839
- owl_property_name = entity.name + '.' + attribute.name
840
- owl_property_domain = entity.name
841
- owl_property_range = attribute.domain
842
- res = ERB.new(attribute_entity_template)
843
-
844
- # if !type_mapped_list.include?(express_attribute_domain)
845
- # type_mapped_list.push express_attribute_domain
846
- # end
847
- # enumitem_name_list = express_attribute_domain.items.scan(/\w+/)
848
- # res = ERB.new(attribute_enum_template)
849
-
850
- t = res.result(binding)
851
- file.puts t
852
- if attribute.redeclare_entity
853
- puts 'WARNING: ' + entity.name + ' ' + attribute.name + ' Attribute redeclaration for Enumerations not mapped'
854
- end
855
-
856
- # Handle EXPRESS explicit attribute, not redeclaration, and only refer to EXPRESS Select or Entity
857
- when (!attribute.redeclare_entity and (express_attribute_domain.kind_of? EXPSM::Entity or express_attribute_domain.kind_of? EXPSM::TypeSelect))
858
- explicit_mapped_list.push attribute
859
- owl_property_range = attribute.domain
860
- owl_property_name = entity.name + '.' + attribute.name
861
- owl_property_domain = entity.name
862
- res = ERB.new(attribute_entity_template)
863
- t = res.result(binding)
864
- file.puts t
865
-
866
- # Handle EXPRESS explicit attribute, redeclaration, and only refer to EXPRESS Select or Entity
867
- when (attribute.redeclare_entity and (express_attribute_domain.kind_of? EXPSM::Entity or express_attribute_domain.kind_of? EXPSM::TypeSelect))
868
- explicit_mapped_list.push attribute
869
- owl_property_range = attribute.domain
870
- owl_property_name = entity.name + '.' + attribute.name
871
- if attribute.redeclare_oldname == nil
872
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.name
873
- else
874
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.redeclare_oldname
875
- end
876
- owl_property_domain = entity.name
877
- res = ERB.new(attribute_redeclare_entity_template)
878
- t = res.result(binding)
879
- file.puts t
880
-
881
- # Handle EXPRESS explicit attribute of EXPRESS Type = A Type name that is a Select
882
- when (express_attribute_domain.kind_of? EXPSM::Type and NamedType.find_by_name( express_attribute_domain.domain ).kind_of? EXPSM::TypeSelect)
883
- explicit_mapped_list.push attribute
884
- owl_property_range = attribute.domain
885
- owl_property_name = entity.name + '.' + attribute.name
886
- owl_property_domain = entity.name
887
- res = ERB.new(attribute_entity_template)
888
- t = res.result(binding)
889
- file.puts t
890
-
891
- # Handle EXPRESS explicit attribute, redeclaration, and only refer to EXPRESS Type = A Type name that is a Select
892
- when (attribute.redeclare_entity and (express_attribute_domain.kind_of? EXPSM::Type and NamedType.find_by_name( express_attribute_domain.domain ).kind_of? EXPSM::TypeSelect))
893
-
894
- explicit_mapped_list.push attribute
895
- owl_property_range = attribute.domain
896
- owl_property_name = entity.name + '.' + attribute.name
897
- if attribute.redeclare_oldname == nil
898
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.name
899
- else
900
- owl_super_property_name = attribute.redeclare_entity + '.' + attribute.redeclare_oldname
901
- end
902
- owl_property_domain = entity.name
903
- res = ERB.new(attribute_redeclare_entity_template)
904
- t = res.result(binding)
905
- file.puts t
906
-
907
- else
908
- puts 'WARNING: ' + entity.name + ' ' + attribute.name + ' Attribute type not yet mapped'
909
- end
910
-
911
- min_cardinality = 1
912
- max_cardinality = 1
913
-
914
- if attribute.isOptional == true
915
- min_cardinality = 0
916
- end
917
-
918
- if (attribute.instance_of? EXPSM::ExplicitAggregate and attribute.rank == 1 and attribute.dimensions[0].aggrtype != 'LIST' and attribute.dimensions[0].aggrtype != 'ARRAY')
919
- if attribute.isOptional == false
920
- min_cardinality = attribute.dimensions[0].lower.to_i
921
- end
922
- if attribute.dimensions[0].upper == '?'
923
- max_cardinality = -1
924
- else
925
- max_cardinality = attribute.dimensions[0].upper.to_i
926
- end
927
- if attribute.rank > 1
928
- puts 'WARNING: ' + owl_property_name + ' n-dimensional aggregate attribute cardinalities not mapped '
929
- max_cardinality = -1
930
- end
931
- end
932
-
933
- if min_cardinality == max_cardinality
934
- res = ERB.new(cardinality_template)
935
- t = res.result(binding)
936
- file.puts t
937
- else
938
- res = ERB.new(min_cardinality_template)
939
- t = res.result(binding)
940
- file.puts t
941
- if max_cardinality != -1
942
- res = ERB.new(max_cardinality_template)
943
- t = res.result(binding)
944
- file.puts t
945
- end
946
- end
947
-
948
-
949
- if (attribute.redeclare_entity and !(express_attribute_domain.kind_of? EXPSM::Entity or express_attribute_domain.kind_of? EXPSM::TypeSelect))
950
- if (attribute.redeclare_entity and !(express_attribute_domain.kind_of? EXPSM::Type and NamedType.find_by_name( express_attribute_domain.domain ).kind_of? EXPSM::TypeSelect))
951
- if (attribute.redeclare_entity and !attribute.isBuiltin)
952
- puts 'WARNING: ' + entity.name + ' ' + attribute.name + ' Attribute redeclaration may need hand editing'
953
- end
954
- end
955
- end
956
-
957
- end
958
-
959
- end
960
-
961
-
962
- res = ERB.new(schema_end_template)
963
- t = res.result(binding)
964
- file.puts t
965
-
966
- puts ' '
967
- puts 'Schema Mapping Summary for : ' + schema.name
968
- all_type_list = schema.contents.find_all{ |e| e.kind_of? EXPSM::DefinedType }
969
-
970
-
971
- puts ' ENTITYs mapped = ' + entity_mapped_list.size.to_s + ' of ' + entity_list.size.to_s
972
- puts ' - ' + superexpression_mapped_list.size.to_s + ' of ' + all_superexpression_list.size.to_s + ' ENTITY SUPERTYPE expressions mapped (only simple ONEOF supported)'
973
- for t in all_superexpression_list - superexpression_mapped_list
974
- puts ' Not mapped: ' + t.name
975
- end
976
- puts ' - ' + inverse_mapped_list.size.to_s + ' of ' + all_inverse_list.size.to_s + ' inverse attributes mapped (inverse of inherited not supported)'
977
- notmapped_list = all_inverse_list - inverse_mapped_list
978
- for t in notmapped_list
979
- puts ' Not mapped: ' + t.entity.name + '.' + t.name
980
- end
981
- puts ' - ' + thing_attr_mapped_list.size.to_s + ' of ' + all_explicit_list.size.to_s + ' explicit attributes mapped with owl:Thing as domain (configurable)'
982
- puts ' - ' + explicit_mapped_list.size.to_s + ' of ' + all_explicit_list.size.to_s + ' explicit attributes mapped'
983
- for t in list_mapped_attr_list
984
- puts ' rdf:List mapped: ' + t.name
985
- end
986
-
987
- notmapped_list = all_explicit_list - explicit_mapped_list - thing_attr_mapped_list
988
- for t in notmapped_list
989
- puts ' Not mapped: ' + t.entity.name + '.' + t.name
990
- end
991
- puts ' - ' + all_derived_list.size.to_s + ' derived attributes not mapped, not supported'
992
- puts ' TYPEs mapped = ' + type_mapped_list.size.to_s + ' of ' + all_type_list.size.to_s
993
- for t in list_mapped_type_list
994
- puts ' rdf:List mapped: ' + t.name
995
- end
996
- for t in mixed_select_list
997
- puts ' Select of entity & type Class mapped: ' + t.name
998
- end
999
- for t in type_union_mapped_list
1000
- puts ' Select RDFS Datatype owl:unionOf mapped: ' + t.name
1001
- end
1002
- notmapped_list = all_type_list - type_mapped_list
1003
- for t in notmapped_list
1004
- puts ' Not mapped: ' + t.name
1005
- end
1006
- puts ' '
1007
- puts 'Wrote post-processed schema to file: ' + post_processed_schema_file_name if post_processed_schema
1008
-
1009
-
1010
- end
1011
-
1012
- res = ERB.new(overall_end_template)
1013
- t = res.result(binding)
1014
- file.puts t
1015
-
1016
- post_processed_schema_file.close if post_processed_schema
1017
-
1018
- end