expressir 1.2.3 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cross_rubies +0 -6
- data/.github/workflows/rake.yml +223 -31
- data/.gitignore +7 -1
- data/.gitmodules +3 -0
- data/.rubocop.yml +13 -4
- data/README.adoc +8 -0
- data/Rakefile +4 -1
- data/bin/console +0 -1
- data/bin/rspec +3 -3
- data/exe/expressir +4 -2
- data/exe/format +1 -1
- data/exe/format-test +25 -25
- data/exe/generate-parser +16 -13
- data/expressir.gemspec +11 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +19 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +51 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +1 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +9 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +43 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +16 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +2 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +9 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +51 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +20 -23
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +21 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +12 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +7 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -53
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -58
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +6 -57
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +35 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +29 -36
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +36 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -464
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -62
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +42 -36
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -108
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +10 -43
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +17 -28
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +169 -152
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +87 -116
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +11 -23
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +2 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +15 -28
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +35 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +13 -54
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -23
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -40
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +14 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +30 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
- data/ext/express-parser/antlrgen/Express.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
- data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
- data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
- data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
- data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
- data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
- data/ext/express-parser/express_parser.cpp +165 -101
- data/ext/express-parser/extconf.rb +14 -14
- data/lib/expressir/config.rb +1 -1
- data/lib/expressir/express/parser.rb +17 -15
- data/lib/expressir/express/visitor.rb +7 -3
- data/lib/expressir/model.rb +78 -78
- data/lib/expressir/version.rb +1 -1
- data/rakelib/antlr4-native.rake +161 -0
- data/rakelib/cross-ruby.rake +213 -162
- data/spec/acceptance/version_spec.rb +17 -2
- data/spec/expressir/express/cache_spec.rb +23 -5
- data/spec/expressir/express/formatter_spec.rb +54 -8
- data/spec/expressir/express/parser_spec.rb +47 -11
- data/spec/expressir/model/model_element_spec.rb +198 -146
- data/spec/spec_helper.rb +7 -0
- metadata +79 -91
- data/demo.rb +0 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
- data/original/examples/employment/eclipse/.project +0 -17
- data/original/examples/employment/eclipse/Export/Employment.png +0 -0
- data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
- data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
- data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
- data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
- data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
- data/original/examples/employment/eclipse/readme.txt +0 -7
- data/original/examples/employment/employment_schema.exp +0 -33
- data/original/examples/employment/employment_schema.rb +0 -232
- data/original/examples/employment/employment_schema.xml +0 -93
- data/original/examples/employment/employment_schema___module.rb +0 -46
- data/original/examples/employment/employment_schema___p28attr.rb +0 -126
- data/original/examples/employment/employment_schema___p28inst.rb +0 -26
- data/original/examples/employment/example_employment_data.xml +0 -1
- data/original/examples/employment/example_employment_data_copy.xml +0 -1
- data/original/examples/employment/example_employment_reader.rb +0 -30
- data/original/examples/employment/example_employment_writer.rb +0 -51
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
- data/original/exp2ruby.rb +0 -525
- data/original/expsm.rb +0 -34
- data/original/mapping_owl.rb +0 -1018
- data/original/mapping_sysml.rb +0 -2281
- data/original/mapping_uml2.rb +0 -599
- data/original/mapping_uml2_eclipse.rb +0 -433
- data/original/reeper.rb +0 -134
- data/spec/expressr_spec.rb +0 -5
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "rubygems"
|
2
|
+
require "mkmf"
|
3
3
|
|
4
|
-
extension_name =
|
5
|
-
cross_build =
|
4
|
+
extension_name = "express_parser"
|
5
|
+
cross_build = enable_config("cross-build")
|
6
6
|
|
7
|
-
antlr4_src =
|
7
|
+
antlr4_src = "antlr4-upstream/runtime/Cpp/runtime/src"
|
8
8
|
src_paths = [
|
9
9
|
".",
|
10
10
|
"antlrgen",
|
11
|
-
|
11
|
+
antlr4_src.to_s,
|
12
12
|
"#{antlr4_src}/atn",
|
13
13
|
"#{antlr4_src}/dfa",
|
14
14
|
"#{antlr4_src}/misc",
|
@@ -23,7 +23,7 @@ if cross_build
|
|
23
23
|
rice_root = Gem.loaded_specs["rice"].full_gem_path
|
24
24
|
rice_src = File.join(rice_root, "include", "rice")
|
25
25
|
rice_embed = File.join(__dir__, rice_subdir)
|
26
|
-
unless File.
|
26
|
+
unless File.exist?(rice_embed)
|
27
27
|
FileUtils.mkdir_p(rice_embed)
|
28
28
|
FileUtils.cp_r(Dir.glob(rice_src), rice_embed)
|
29
29
|
File.delete(*Dir.glob("#{rice_embed}/**/*.o"))
|
@@ -34,22 +34,22 @@ if cross_build
|
|
34
34
|
|
35
35
|
$INCFLAGS << " -I#{__dir__}/#{rice_subdir}"
|
36
36
|
|
37
|
-
|
37
|
+
case RbConfig::CONFIG["target_os"]
|
38
|
+
when /mingw32|mswin/
|
38
39
|
# workaround for 'w64-mingw32-as: express_parser.o: too many sections'
|
39
40
|
$CXXFLAGS << " -O3 -Wa,-mbig-obj"
|
40
41
|
# workaround for LoadError: 127: The specified procedure could not be found.
|
41
|
-
$DLDFLAGS << " -static
|
42
|
-
|
43
|
-
$CXXFLAGS << " -mmacosx-version-min=10.14 -
|
42
|
+
$DLDFLAGS << " -static-libgcc -static-libstdc++"
|
43
|
+
when /darwin/
|
44
|
+
$CXXFLAGS << " -mmacosx-version-min=10.14 -fno-c++-static-destructors"
|
44
45
|
$DLDFLAGS << " -mmacosx-version-min=10.14"
|
45
46
|
end
|
46
47
|
else
|
47
|
-
require
|
48
|
-
|
48
|
+
require "mkmf-rice"
|
49
49
|
dir_config(extension_name)
|
50
50
|
end
|
51
51
|
|
52
|
-
$CPPFLAGS << " -std=c++17 -DANTLR4CPP_STATIC -DHAVE_CXX11"
|
52
|
+
$CPPFLAGS << " -std=c++17 -DANTLR4CPP_STATIC -DHAVE_CXX11 -fno-omit-frame-pointer"
|
53
53
|
$INCFLAGS << " -I#{__dir__}/#{antlr4_src}"
|
54
54
|
$srcs = []
|
55
55
|
|
data/lib/expressir/config.rb
CHANGED
@@ -31,25 +31,27 @@ module Expressir
|
|
31
31
|
# @param [Boolean] include_source attach original source code to model elements
|
32
32
|
# @return [Model::Repository]
|
33
33
|
def self.from_file(file, skip_references: nil, include_source: nil)
|
34
|
-
input = File.read(file)
|
35
34
|
|
36
|
-
|
35
|
+
# An important note re memory management
|
36
|
+
# parse, syntax, visitor methods return complex tree structures created in native (C++) extension
|
37
|
+
# visit method references nodes and leaves of this structures but it is totally untransparent for Ruby GarbageCllector
|
38
|
+
# so in this class we keep those C++ structure marked for GC so they are not freed
|
39
|
+
@parser = ::ExpressParser::ParserExt.new(file.to_s)
|
40
|
+
@parse_tree = @parser.syntax()
|
37
41
|
|
38
|
-
|
42
|
+
@visitor = Visitor.new(@parser.tokens, include_source: include_source)
|
43
|
+
@repository = @visitor.visit(@parse_tree)
|
39
44
|
|
40
|
-
|
41
|
-
repository = visitor.visit(parse_tree)
|
42
|
-
|
43
|
-
repository.schemas.each do |schema|
|
45
|
+
@repository.schemas.each do |schema|
|
44
46
|
schema.file = file.to_s
|
45
47
|
end
|
46
48
|
|
47
49
|
unless skip_references
|
48
|
-
resolve_references_model_visitor = ResolveReferencesModelVisitor.new
|
49
|
-
resolve_references_model_visitor.visit(repository)
|
50
|
+
@resolve_references_model_visitor = ResolveReferencesModelVisitor.new
|
51
|
+
@resolve_references_model_visitor.visit(@repository)
|
50
52
|
end
|
51
53
|
|
52
|
-
repository
|
54
|
+
@repository
|
53
55
|
end
|
54
56
|
|
55
57
|
# Parses Express files into an Express model
|
@@ -65,16 +67,16 @@ module Expressir
|
|
65
67
|
repository.schemas
|
66
68
|
end.flatten
|
67
69
|
|
68
|
-
repository = Model::Repository.new(
|
70
|
+
@repository = Model::Repository.new(
|
69
71
|
schemas: schemas
|
70
72
|
)
|
71
73
|
|
72
|
-
unless skip_references
|
73
|
-
resolve_references_model_visitor = ResolveReferencesModelVisitor.new
|
74
|
-
resolve_references_model_visitor.visit(repository)
|
74
|
+
unless @skip_references
|
75
|
+
@resolve_references_model_visitor = ResolveReferencesModelVisitor.new
|
76
|
+
@resolve_references_model_visitor.visit(@repository)
|
75
77
|
end
|
76
78
|
|
77
|
-
repository
|
79
|
+
@repository
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|
@@ -31,6 +31,8 @@ require "set"
|
|
31
31
|
# - prevents segfault in ANTLR4 C++ runtime, not sure why they are caused
|
32
32
|
# - e.g. see visit_schema_decl
|
33
33
|
|
34
|
+
require 'objspace'
|
35
|
+
|
34
36
|
module Expressir
|
35
37
|
module Express
|
36
38
|
class Visitor < ::ExpressParser::Visitor
|
@@ -138,13 +140,15 @@ module Expressir
|
|
138
140
|
end
|
139
141
|
|
140
142
|
def attach_remarks(ctx, node)
|
141
|
-
remark_tokens = get_tokens(ctx)
|
143
|
+
@remark_tokens = get_tokens(ctx)
|
144
|
+
@remark_tokens = @remark_tokens.select{ |x| x.channel == REMARK_CHANNEL
|
145
|
+
}
|
142
146
|
|
143
147
|
# skip already attached remarks
|
144
|
-
remark_tokens = remark_tokens.select{|x| !@attached_remark_tokens.include?(x)}
|
148
|
+
@remark_tokens = @remark_tokens.select{|x| !@attached_remark_tokens.include?(x)}
|
145
149
|
|
146
150
|
# parse remarks, find remark targets
|
147
|
-
tagged_remark_tokens = remark_tokens.map do |remark_token|
|
151
|
+
tagged_remark_tokens = @remark_tokens.map do |remark_token|
|
148
152
|
_, remark_tag, remark_text = if remark_token.text.start_with?('--')
|
149
153
|
remark_token.text.match(/^--"([^"]*)"(.*)$/).to_a
|
150
154
|
else
|
data/lib/expressir/model.rb
CHANGED
@@ -1,79 +1,79 @@
|
|
1
|
-
require
|
1
|
+
require "expressir/model/model_element"
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
37
|
-
require
|
38
|
-
require
|
39
|
-
require
|
40
|
-
require
|
41
|
-
require
|
42
|
-
require
|
43
|
-
require
|
44
|
-
require
|
45
|
-
require
|
46
|
-
require
|
47
|
-
require
|
48
|
-
require
|
49
|
-
require
|
50
|
-
require
|
51
|
-
require
|
52
|
-
require
|
53
|
-
require
|
54
|
-
require
|
55
|
-
require
|
56
|
-
require
|
57
|
-
require
|
58
|
-
require
|
59
|
-
require
|
60
|
-
require
|
61
|
-
require
|
62
|
-
require
|
63
|
-
require
|
64
|
-
require
|
65
|
-
require
|
66
|
-
require
|
67
|
-
require
|
68
|
-
require
|
69
|
-
require
|
70
|
-
require
|
71
|
-
require
|
72
|
-
require
|
73
|
-
require
|
74
|
-
require
|
75
|
-
require
|
76
|
-
require
|
77
|
-
require
|
78
|
-
require
|
79
|
-
require
|
3
|
+
require "expressir/model/cache"
|
4
|
+
require "expressir/model/data_type"
|
5
|
+
require "expressir/model/declaration"
|
6
|
+
require "expressir/model/expression"
|
7
|
+
require "expressir/model/identifier"
|
8
|
+
require "expressir/model/literal"
|
9
|
+
require "expressir/model/reference"
|
10
|
+
require "expressir/model/repository"
|
11
|
+
require "expressir/model/statement"
|
12
|
+
require "expressir/model/supertype_expression"
|
13
|
+
require "expressir/model/data_types/aggregate"
|
14
|
+
require "expressir/model/data_types/array"
|
15
|
+
require "expressir/model/data_types/bag"
|
16
|
+
require "expressir/model/data_types/binary"
|
17
|
+
require "expressir/model/data_types/boolean"
|
18
|
+
require "expressir/model/data_types/enumeration"
|
19
|
+
require "expressir/model/data_types/enumeration_item"
|
20
|
+
require "expressir/model/data_types/generic_entity"
|
21
|
+
require "expressir/model/data_types/generic"
|
22
|
+
require "expressir/model/data_types/integer"
|
23
|
+
require "expressir/model/data_types/list"
|
24
|
+
require "expressir/model/data_types/logical"
|
25
|
+
require "expressir/model/data_types/number"
|
26
|
+
require "expressir/model/data_types/real"
|
27
|
+
require "expressir/model/data_types/set"
|
28
|
+
require "expressir/model/data_types/select"
|
29
|
+
require "expressir/model/data_types/string"
|
30
|
+
require "expressir/model/declarations/attribute"
|
31
|
+
require "expressir/model/declarations/constant"
|
32
|
+
require "expressir/model/declarations/entity"
|
33
|
+
require "expressir/model/declarations/function"
|
34
|
+
require "expressir/model/declarations/interface"
|
35
|
+
require "expressir/model/declarations/interface_item"
|
36
|
+
require "expressir/model/declarations/interfaced_item"
|
37
|
+
require "expressir/model/declarations/parameter"
|
38
|
+
require "expressir/model/declarations/procedure"
|
39
|
+
require "expressir/model/declarations/remark_item"
|
40
|
+
require "expressir/model/declarations/rule"
|
41
|
+
require "expressir/model/declarations/schema"
|
42
|
+
require "expressir/model/declarations/schema_version"
|
43
|
+
require "expressir/model/declarations/schema_version_item"
|
44
|
+
require "expressir/model/declarations/subtype_constraint"
|
45
|
+
require "expressir/model/declarations/type"
|
46
|
+
require "expressir/model/declarations/unique_rule"
|
47
|
+
require "expressir/model/declarations/variable"
|
48
|
+
require "expressir/model/declarations/where_rule"
|
49
|
+
require "expressir/model/expressions/aggregate_initializer"
|
50
|
+
require "expressir/model/expressions/aggregate_initializer_item"
|
51
|
+
require "expressir/model/expressions/binary_expression"
|
52
|
+
require "expressir/model/expressions/entity_constructor"
|
53
|
+
require "expressir/model/expressions/function_call"
|
54
|
+
require "expressir/model/expressions/interval"
|
55
|
+
require "expressir/model/expressions/query_expression"
|
56
|
+
require "expressir/model/expressions/unary_expression"
|
57
|
+
require "expressir/model/literals/binary"
|
58
|
+
require "expressir/model/literals/integer"
|
59
|
+
require "expressir/model/literals/logical"
|
60
|
+
require "expressir/model/literals/real"
|
61
|
+
require "expressir/model/literals/string"
|
62
|
+
require "expressir/model/references/attribute_reference"
|
63
|
+
require "expressir/model/references/group_reference"
|
64
|
+
require "expressir/model/references/index_reference"
|
65
|
+
require "expressir/model/references/simple_reference"
|
66
|
+
require "expressir/model/statements/alias"
|
67
|
+
require "expressir/model/statements/assignment"
|
68
|
+
require "expressir/model/statements/case"
|
69
|
+
require "expressir/model/statements/case_action"
|
70
|
+
require "expressir/model/statements/compound"
|
71
|
+
require "expressir/model/statements/escape"
|
72
|
+
require "expressir/model/statements/if"
|
73
|
+
require "expressir/model/statements/null"
|
74
|
+
require "expressir/model/statements/procedure_call"
|
75
|
+
require "expressir/model/statements/repeat"
|
76
|
+
require "expressir/model/statements/return"
|
77
|
+
require "expressir/model/statements/skip"
|
78
|
+
require "expressir/model/supertype_expressions/binary_supertype_expression"
|
79
|
+
require "expressir/model/supertype_expressions/oneof_supertype_expression"
|
data/lib/expressir/version.rb
CHANGED
@@ -0,0 +1,161 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "antlr4-native"
|
3
|
+
require "rake"
|
4
|
+
|
5
|
+
def create_class_declarations(parser_source_lines)
|
6
|
+
i = parser_source_lines.index { |x| x == "Class rb_cContextProxy;" }
|
7
|
+
parser_source_lines[i] += <<~CPP.split("\n").map { |x| x == "" ? x : x.to_s }.join("\n")
|
8
|
+
|
9
|
+
Class rb_cParserExt;
|
10
|
+
Class rb_cTokenExt;
|
11
|
+
|
12
|
+
CPP
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_tp_class_definition(parser_source_lines)
|
16
|
+
i = parser_source_lines.index { |x| x == "class ContextProxy {" }
|
17
|
+
parser_source_lines[i - 2] += <<~CPP.split("\n").map { |x| x == "" ? x : x.to_s }.join("\n")
|
18
|
+
|
19
|
+
|
20
|
+
class TokenProxy : public Object {
|
21
|
+
public:
|
22
|
+
TokenProxy(Token* orig) {
|
23
|
+
this -> orig = orig;
|
24
|
+
}
|
25
|
+
|
26
|
+
std::string getText() {
|
27
|
+
return orig->getText();
|
28
|
+
}
|
29
|
+
|
30
|
+
size_t getChannel() {
|
31
|
+
return orig->getChannel();
|
32
|
+
}
|
33
|
+
|
34
|
+
size_t getTokenIndex() {
|
35
|
+
return orig->getTokenIndex();
|
36
|
+
}
|
37
|
+
|
38
|
+
private:
|
39
|
+
Token * orig = nullptr;
|
40
|
+
};
|
41
|
+
|
42
|
+
CPP
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_pp_class_definition(parser_source_lines)
|
46
|
+
i = parser_source_lines.index { |x| x == "extern \"C\"" }
|
47
|
+
parser_source_lines[i - 2] += <<~CPP.split("\n").map { |x| x == "" ? x : x.to_s }.join("\n")
|
48
|
+
|
49
|
+
class ParserProxyExt : public Object {
|
50
|
+
public:
|
51
|
+
ParserProxyExt(Object self, string file) {
|
52
|
+
ifstream stream;
|
53
|
+
stream.open(file);
|
54
|
+
input = new ANTLRInputStream(stream);
|
55
|
+
lexer = new ExpressLexer(input);
|
56
|
+
tokens = new CommonTokenStream(lexer);
|
57
|
+
parser = new ExpressParser(tokens);
|
58
|
+
stream.close();
|
59
|
+
};
|
60
|
+
|
61
|
+
~ParserProxyExt() {
|
62
|
+
delete parser;
|
63
|
+
delete tokens;
|
64
|
+
delete lexer;
|
65
|
+
delete input;
|
66
|
+
}
|
67
|
+
|
68
|
+
Object syntax() {
|
69
|
+
auto ctx = parser -> syntax();
|
70
|
+
|
71
|
+
SyntaxContextProxy proxy((ExpressParser::SyntaxContext*) ctx);
|
72
|
+
return detail::To_Ruby<SyntaxContextProxy>().convert(proxy);
|
73
|
+
}
|
74
|
+
|
75
|
+
Array getTokens() {
|
76
|
+
Array a;
|
77
|
+
for (auto token : tokens -> getTokens()) {
|
78
|
+
a.push(new TokenProxy(token));
|
79
|
+
}
|
80
|
+
return a;
|
81
|
+
}
|
82
|
+
|
83
|
+
Object visit(VisitorProxy* visitor) {
|
84
|
+
auto result = visitor -> visit(parser -> syntax());
|
85
|
+
|
86
|
+
lexer -> reset();
|
87
|
+
parser -> reset();
|
88
|
+
|
89
|
+
try {
|
90
|
+
return std::any_cast<Object>(result);
|
91
|
+
} catch(std::bad_cast) {
|
92
|
+
return Qnil;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
private:
|
97
|
+
ANTLRInputStream* input;
|
98
|
+
ExpressLexer* lexer;
|
99
|
+
CommonTokenStream* tokens;
|
100
|
+
ExpressParser* parser;
|
101
|
+
};
|
102
|
+
|
103
|
+
|
104
|
+
CPP
|
105
|
+
end
|
106
|
+
|
107
|
+
def create_class_api(parser_source_lines)
|
108
|
+
i = parser_source_lines.index { |x| x == " .define_method(\"visit\", &ParserProxy::visit, Return().keepAlive());" }
|
109
|
+
parser_source_lines[i] += <<~CPP.split("\n").map { |x| x == "" ? x : " #{x}" }.join("\n")
|
110
|
+
|
111
|
+
|
112
|
+
rb_cTokenExt = define_class_under<TokenProxy>(rb_mExpressParser, "TokenExt")
|
113
|
+
.define_method("text", &TokenProxy::getText)
|
114
|
+
.define_method("channel", &TokenProxy::getChannel)
|
115
|
+
.define_method("token_index", &TokenProxy::getTokenIndex);
|
116
|
+
|
117
|
+
rb_cParserExt = define_class_under<ParserProxyExt>(rb_mExpressParser, "ParserExt")
|
118
|
+
.define_constructor(Constructor<ParserProxyExt, Object, string>())
|
119
|
+
.define_method("syntax", &ParserProxyExt::syntax, Return().keepAlive())
|
120
|
+
.define_method("tokens", &ParserProxyExt::getTokens)
|
121
|
+
.define_method("visit", &ParserProxyExt::visit, Return().keepAlive());
|
122
|
+
|
123
|
+
CPP
|
124
|
+
end
|
125
|
+
|
126
|
+
def generate_extended_parser
|
127
|
+
# Generate extended parser that provide Ruby access to token stream
|
128
|
+
parser_source_file = File.join("ext", "express-parser", "express_parser.cpp")
|
129
|
+
parser_source_lines = File.read(parser_source_file).split("\n")
|
130
|
+
create_class_declarations(parser_source_lines)
|
131
|
+
create_tp_class_definition(parser_source_lines)
|
132
|
+
create_pp_class_definition(parser_source_lines)
|
133
|
+
create_class_api(parser_source_lines)
|
134
|
+
File.write(parser_source_file, "#{parser_source_lines.join("\n")}\n")
|
135
|
+
end
|
136
|
+
|
137
|
+
desc "Generate parser (Usage: 'rake generate <grammar_file>')"
|
138
|
+
task "generate" do
|
139
|
+
grammar_file = ARGV[1]
|
140
|
+
if grammar_file.nil?
|
141
|
+
grammar_file = File.expand_path(File.join("..", "ext", "express-grammar", "Express.g4"), __dir__)
|
142
|
+
end
|
143
|
+
|
144
|
+
puts "Generating parser from '#{grammar_file}'"
|
145
|
+
# ANTLR does weird things if the grammar file isn't in the current working directory
|
146
|
+
temp_grammar_file = File.join(FileUtils.pwd, File.basename(grammar_file))
|
147
|
+
FileUtils.cp(grammar_file, temp_grammar_file)
|
148
|
+
|
149
|
+
# generate parser
|
150
|
+
generator = Antlr4Native::Generator.new(
|
151
|
+
grammar_files: [File.basename(temp_grammar_file)],
|
152
|
+
output_dir: "ext",
|
153
|
+
parser_root_method: "syntax",
|
154
|
+
)
|
155
|
+
generator.generate
|
156
|
+
|
157
|
+
puts "Generating extended parser"
|
158
|
+
generate_extended_parser
|
159
|
+
# cleanup
|
160
|
+
FileUtils.rm(temp_grammar_file)
|
161
|
+
end
|