openpinescript 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openpinescript/__init__.py +129 -0
- openpinescript/__main__.py +5 -0
- openpinescript/_cli.py +24 -0
- openpinescript/_engine/LICENSE +674 -0
- openpinescript/_engine/VERSION +1 -0
- openpinescript/_engine/dist/cli.mjs +108691 -0
- openpinescript/_engine/node_modules/antlr4ng/LICENSE.txt +29 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATN.cjs +3159 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATN.js +3159 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATN.mjs +3139 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfig.cjs +911 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfig.js +911 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfig.mjs +891 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfigSet.cjs +3781 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfigSet.js +3781 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNConfigSet.mjs +3761 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializationOptions.cjs +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializationOptions.js +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializationOptions.mjs +0 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializer.cjs +4300 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializer.js +4300 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNDeserializer.mjs +4280 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSerializer.cjs +4798 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSerializer.js +4798 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSerializer.mjs +4778 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSimulator.cjs +982 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSimulator.js +982 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNSimulator.mjs +962 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNState.cjs +85 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNState.js +85 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ATNState.mjs +67 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/AbstractPredicateTransition.cjs +78 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/AbstractPredicateTransition.js +78 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/AbstractPredicateTransition.mjs +58 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ActionTransition.cjs +96 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ActionTransition.js +96 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ActionTransition.mjs +76 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/AmbiguityInfo.cjs +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/AmbiguityInfo.js +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/AmbiguityInfo.mjs +0 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ArrayPredictionContext.cjs +243 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ArrayPredictionContext.js +243 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ArrayPredictionContext.mjs +223 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/AtomTransition.cjs +904 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/AtomTransition.js +904 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/AtomTransition.mjs +884 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicBlockStartState.cjs +112 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicBlockStartState.js +112 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicBlockStartState.mjs +92 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicState.cjs +95 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicState.js +95 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BasicState.mjs +75 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockEndState.cjs +96 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockEndState.js +96 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockEndState.mjs +76 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockStartState.cjs +104 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockStartState.js +104 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/BlockStartState.mjs +84 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/CodePointTransitions.cjs +947 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/CodePointTransitions.js +947 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/CodePointTransitions.mjs +927 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ContextSensitivityInfo.cjs +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ContextSensitivityInfo.js +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ContextSensitivityInfo.mjs +0 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionEventInfo.cjs +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionEventInfo.js +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionEventInfo.mjs +0 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionInfo.cjs +206 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionInfo.js +206 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionInfo.mjs +188 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionState.cjs +96 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionState.js +96 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/DecisionState.mjs +76 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/EmptyPredictionContext.cjs +237 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/EmptyPredictionContext.js +237 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/EmptyPredictionContext.mjs +217 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/EpsilonTransition.cjs +103 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/EpsilonTransition.js +103 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/EpsilonTransition.mjs +83 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LL1Analyzer.cjs +3159 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LL1Analyzer.js +3159 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LL1Analyzer.mjs +3139 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNConfig.cjs +961 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNConfig.js +961 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNConfig.mjs +941 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNSimulator.cjs +5604 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNSimulator.js +5604 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerATNSimulator.mjs +5584 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerAction.cjs +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerAction.js +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerAction.mjs +0 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionExecutor.cjs +305 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionExecutor.js +305 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionExecutor.mjs +285 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionType.cjs +42 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionType.js +42 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerActionType.mjs +22 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerChannelAction.cjs +163 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerChannelAction.js +163 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerChannelAction.mjs +143 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerCustomAction.cjs +169 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerCustomAction.js +169 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerCustomAction.mjs +149 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerIndexedCustomAction.cjs +142 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerIndexedCustomAction.js +142 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerIndexedCustomAction.mjs +122 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerModeAction.cjs +163 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerModeAction.js +163 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerModeAction.mjs +143 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerMoreAction.cjs +73 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerMoreAction.js +73 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerMoreAction.mjs +53 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPopModeAction.cjs +73 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPopModeAction.js +73 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPopModeAction.mjs +53 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPushModeAction.cjs +163 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPushModeAction.js +163 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerPushModeAction.mjs +143 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerSkipAction.cjs +71 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerSkipAction.js +71 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerSkipAction.mjs +51 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerTypeAction.cjs +159 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerTypeAction.js +159 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LexerTypeAction.mjs +139 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LookaheadEventInfo.cjs +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LookaheadEventInfo.js +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LookaheadEventInfo.mjs +0 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LoopEndState.cjs +96 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LoopEndState.js +96 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/LoopEndState.mjs +76 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/NotSetTransition.cjs +921 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/NotSetTransition.js +921 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/NotSetTransition.mjs +901 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/OrderedATNConfigSet.cjs +3824 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/OrderedATNConfigSet.js +3824 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/OrderedATNConfigSet.mjs +3804 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParseInfo.cjs +156 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParseInfo.js +156 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParseInfo.mjs +138 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParserATNSimulator.cjs +6082 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParserATNSimulator.js +6082 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ParserATNSimulator.mjs +6062 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusBlockStartState.cjs +113 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusBlockStartState.js +113 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusBlockStartState.mjs +93 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusLoopbackState.cjs +104 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusLoopbackState.js +104 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PlusLoopbackState.mjs +84 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PrecedencePredicateTransition.cjs +887 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PrecedencePredicateTransition.js +887 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PrecedencePredicateTransition.mjs +867 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateEvalInfo.cjs +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateEvalInfo.js +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateEvalInfo.mjs +0 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateTransition.cjs +892 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateTransition.js +892 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredicateTransition.mjs +872 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContext.cjs +153 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContext.js +153 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContext.mjs +133 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextCache.cjs +715 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextCache.js +715 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextCache.mjs +695 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextUtils.cjs +3604 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextUtils.js +3604 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionContextUtils.mjs +3584 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionMode.cjs +4284 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionMode.js +4284 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/PredictionMode.mjs +4264 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ProfilingATNSimulator.cjs +6467 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ProfilingATNSimulator.js +6467 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/ProfilingATNSimulator.mjs +6447 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RangeTransition.cjs +905 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RangeTransition.js +905 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RangeTransition.mjs +885 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStartState.cjs +97 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStartState.js +97 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStartState.mjs +77 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStopState.cjs +95 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStopState.js +95 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleStopState.mjs +75 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleTransition.cjs +93 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleTransition.js +93 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/RuleTransition.mjs +73 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/SemanticContext.cjs +807 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/SemanticContext.js +807 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/SemanticContext.mjs +787 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/SetTransition.cjs +905 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/SetTransition.js +905 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/SetTransition.mjs +885 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/SingletonPredictionContext.cjs +207 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/SingletonPredictionContext.js +207 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/SingletonPredictionContext.mjs +187 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarBlockStartState.cjs +112 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarBlockStartState.js +112 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarBlockStartState.mjs +92 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopEntryState.cjs +117 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopEntryState.js +117 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopEntryState.mjs +97 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopbackState.cjs +95 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopbackState.js +95 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/StarLoopbackState.mjs +75 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/TokensStartState.cjs +104 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/TokensStartState.js +104 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/TokensStartState.mjs +84 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/Transition.cjs +66 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/Transition.js +66 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/Transition.mjs +48 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/WildcardTransition.cjs +84 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/WildcardTransition.js +84 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/WildcardTransition.mjs +64 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/helpers.cjs +246 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/helpers.js +246 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/helpers.mjs +226 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/index.cjs +9485 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/index.js +9485 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/atn/index.mjs +9465 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFA.cjs +559 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFA.js +559 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFA.mjs +539 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFASerializer.cjs +76 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFASerializer.js +76 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFASerializer.mjs +58 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAState.cjs +136 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAState.js +136 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAState.mjs +116 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAStateEqualityComparator.cjs +150 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAStateEqualityComparator.js +150 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/DFAStateEqualityComparator.mjs +130 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/LexerDFASerializer.cjs +237 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/LexerDFASerializer.js +237 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/LexerDFASerializer.mjs +217 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/PredPrediction.cjs +31 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/PredPrediction.js +31 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/PredPrediction.mjs +13 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/index.cjs +571 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/index.js +571 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/dfa/index.mjs +551 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/index.cjs +17501 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/index.mjs +17481 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/BitSet.cjs +208 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/BitSet.js +208 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/BitSet.mjs +190 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/DefaultEqualityComparator.cjs +68 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/DefaultEqualityComparator.js +68 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/DefaultEqualityComparator.mjs +48 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/EqualityComparator.cjs +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/EqualityComparator.js +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/EqualityComparator.mjs +0 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashMap.cjs +545 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashMap.js +545 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashMap.mjs +525 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashSet.cjs +438 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashSet.js +438 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/HashSet.mjs +418 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/InterpreterDataReader.cjs +4420 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/InterpreterDataReader.js +4420 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/InterpreterDataReader.mjs +4400 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/Interval.cjs +133 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/Interval.js +133 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/Interval.mjs +115 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/IntervalSet.cjs +834 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/IntervalSet.js +834 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/IntervalSet.mjs +814 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/MapKeyEqualityOperator.cjs +40 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/MapKeyEqualityOperator.js +40 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/MapKeyEqualityOperator.mjs +22 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/MultiMap.cjs +55 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/MultiMap.js +55 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/MultiMap.mjs +37 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/ObjectEqualityComparator.cjs +43 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/ObjectEqualityComparator.js +43 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/ObjectEqualityComparator.mjs +25 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashMap.cjs +610 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashMap.js +610 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashMap.mjs +590 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashSet.cjs +470 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashSet.js +470 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/OrderedHashSet.mjs +450 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/ParseCancellationException.cjs +34 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/ParseCancellationException.js +34 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/ParseCancellationException.mjs +16 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/index.cjs +4643 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/index.js +4643 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/misc/index.mjs +4623 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/AbstractParseTreeVisitor.cjs +63 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/AbstractParseTreeVisitor.js +63 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/AbstractParseTreeVisitor.mjs +45 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ErrorNode.cjs +211 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ErrorNode.js +211 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ErrorNode.mjs +191 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTree.cjs +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTree.js +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTree.mjs +0 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeListener.cjs +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeListener.js +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeListener.mjs +0 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeVisitor.cjs +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeVisitor.js +17 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeVisitor.mjs +0 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeWalker.cjs +267 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeWalker.js +267 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/ParseTreeWalker.mjs +247 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/TerminalNode.cjs +201 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/TerminalNode.js +201 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/TerminalNode.mjs +181 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/Trees.cjs +3159 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/Trees.js +3159 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/Trees.mjs +3139 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/index.cjs +16018 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/index.js +16018 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/tree/index.mjs +15998 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/DoubleDict.cjs +568 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/DoubleDict.js +568 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/DoubleDict.mjs +548 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/MurmurHash.cjs +98 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/MurmurHash.js +98 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/MurmurHash.mjs +80 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/helpers.cjs +78 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/helpers.js +78 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/helpers.mjs +60 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/index.cjs +625 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/index.js +625 -0
- openpinescript/_engine/node_modules/antlr4ng/dist/utils/index.mjs +605 -0
- openpinescript/_engine/node_modules/antlr4ng/package.json +72 -0
- openpinescript/_engine/package.json +94 -0
- openpinescript/_runtime.py +29 -0
- openpinescript-0.1.1.dist-info/METADATA +140 -0
- openpinescript-0.1.1.dist-info/RECORD +332 -0
- openpinescript-0.1.1.dist-info/WHEEL +4 -0
- openpinescript-0.1.1.dist-info/entry_points.txt +2 -0
- openpinescript-0.1.1.dist-info/licenses/LICENSE +674 -0
|
@@ -0,0 +1,4300 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/atn/ATNDeserializer.ts
|
|
21
|
+
var ATNDeserializer_exports = {};
|
|
22
|
+
__export(ATNDeserializer_exports, {
|
|
23
|
+
ATNDeserializer: () => ATNDeserializer
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(ATNDeserializer_exports);
|
|
26
|
+
|
|
27
|
+
// src/IntStream.ts
|
|
28
|
+
var IntStream;
|
|
29
|
+
((IntStream2) => {
|
|
30
|
+
IntStream2.EOF = -1;
|
|
31
|
+
IntStream2.UNKNOWN_SOURCE_NAME = "<unknown>";
|
|
32
|
+
})(IntStream || (IntStream = {}));
|
|
33
|
+
|
|
34
|
+
// src/Token.ts
|
|
35
|
+
var Token;
|
|
36
|
+
((Token2) => {
|
|
37
|
+
Token2.INVALID_TYPE = 0;
|
|
38
|
+
Token2.EPSILON = -2;
|
|
39
|
+
Token2.MIN_USER_TOKEN_TYPE = 1;
|
|
40
|
+
Token2.EOF = IntStream.EOF;
|
|
41
|
+
Token2.DEFAULT_CHANNEL = 0;
|
|
42
|
+
Token2.HIDDEN_CHANNEL = 1;
|
|
43
|
+
Token2.MIN_USER_CHANNEL_VALUE = 2;
|
|
44
|
+
})(Token || (Token = {}));
|
|
45
|
+
var isToken = /* @__PURE__ */ __name((candidate) => {
|
|
46
|
+
const token = candidate;
|
|
47
|
+
return token.tokenSource !== void 0 && token.channel !== void 0;
|
|
48
|
+
}, "isToken");
|
|
49
|
+
|
|
50
|
+
// src/misc/BitSet.ts
|
|
51
|
+
var BitSet = class {
|
|
52
|
+
static {
|
|
53
|
+
__name(this, "BitSet");
|
|
54
|
+
}
|
|
55
|
+
data;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new bit set. All bits are initially `false`.
|
|
58
|
+
*
|
|
59
|
+
* @param data Optional initial data.
|
|
60
|
+
*/
|
|
61
|
+
constructor(data) {
|
|
62
|
+
if (data) {
|
|
63
|
+
this.data = new Uint32Array(data.map((value) => {
|
|
64
|
+
return value >>> 0;
|
|
65
|
+
}));
|
|
66
|
+
} else {
|
|
67
|
+
this.data = new Uint32Array(1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @returns an iterator over all set bits.
|
|
72
|
+
*/
|
|
73
|
+
[Symbol.iterator]() {
|
|
74
|
+
const length = this.data.length;
|
|
75
|
+
let currentIndex = 0;
|
|
76
|
+
let currentWord = this.data[currentIndex];
|
|
77
|
+
const words = this.data;
|
|
78
|
+
return {
|
|
79
|
+
[Symbol.iterator]() {
|
|
80
|
+
return this;
|
|
81
|
+
},
|
|
82
|
+
next: /* @__PURE__ */ __name(() => {
|
|
83
|
+
while (currentIndex < length) {
|
|
84
|
+
if (currentWord !== 0) {
|
|
85
|
+
const t = currentWord & -currentWord;
|
|
86
|
+
const value = (currentIndex << 5) + this.bitCount(t - 1);
|
|
87
|
+
currentWord ^= t;
|
|
88
|
+
return { done: false, value };
|
|
89
|
+
} else {
|
|
90
|
+
currentIndex++;
|
|
91
|
+
if (currentIndex < length) {
|
|
92
|
+
currentWord = words[currentIndex];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return { done: true, value: void 0 };
|
|
97
|
+
}, "next")
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Sets a single bit or all of the bits in this `BitSet` to `false`.
|
|
102
|
+
*
|
|
103
|
+
* @param index the index of the bit to be cleared, or undefined to clear all bits.
|
|
104
|
+
*/
|
|
105
|
+
clear(index) {
|
|
106
|
+
if (index === void 0) {
|
|
107
|
+
this.data = new Uint32Array();
|
|
108
|
+
} else {
|
|
109
|
+
this.resize(index);
|
|
110
|
+
this.data[index >>> 5] &= ~(1 << index);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Performs a logical **OR** of this bit set with the bit set argument. This bit set is modified so that a bit in it
|
|
115
|
+
* has the value `true` if and only if it either already had the value `true` or the corresponding bit in the bit
|
|
116
|
+
* set argument has the value `true`.
|
|
117
|
+
*
|
|
118
|
+
* @param set the bit set to be ORed with.
|
|
119
|
+
*/
|
|
120
|
+
or(set) {
|
|
121
|
+
const minCount = Math.min(this.data.length, set.data.length);
|
|
122
|
+
for (let k = 0; k < minCount; ++k) {
|
|
123
|
+
this.data[k] |= set.data[k];
|
|
124
|
+
}
|
|
125
|
+
if (this.data.length < set.data.length) {
|
|
126
|
+
this.resize((set.data.length << 5) - 1);
|
|
127
|
+
const c = set.data.length;
|
|
128
|
+
for (let k = minCount; k < c; ++k) {
|
|
129
|
+
this.data[k] = set.data[k];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns the value of the bit with the specified index. The value is `true` if the bit with the index `bitIndex`
|
|
135
|
+
* is currently set in this `BitSet`; otherwise, the result is `false`.
|
|
136
|
+
*
|
|
137
|
+
* @param index the bit index
|
|
138
|
+
*
|
|
139
|
+
* @returns the value of the bit with the specified index.
|
|
140
|
+
*/
|
|
141
|
+
get(index) {
|
|
142
|
+
if (index < 0) {
|
|
143
|
+
throw new RangeError("index cannot be negative");
|
|
144
|
+
}
|
|
145
|
+
const slot = index >>> 5;
|
|
146
|
+
if (slot >= this.data.length) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return (this.data[slot] & 1 << index % 32) !== 0;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @returns the number of set bits.
|
|
153
|
+
*/
|
|
154
|
+
get length() {
|
|
155
|
+
let result = 0;
|
|
156
|
+
const c = this.data.length;
|
|
157
|
+
const w = this.data;
|
|
158
|
+
for (let i = 0; i < c; i++) {
|
|
159
|
+
result += this.bitCount(w[i]);
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* @returns an array with indices of set bits.
|
|
165
|
+
*/
|
|
166
|
+
values() {
|
|
167
|
+
const result = new Array(this.length);
|
|
168
|
+
let pos = 0;
|
|
169
|
+
const length = this.data.length;
|
|
170
|
+
for (let k = 0; k < length; ++k) {
|
|
171
|
+
let w = this.data[k];
|
|
172
|
+
while (w !== 0) {
|
|
173
|
+
const t = w & -w;
|
|
174
|
+
result[pos++] = (k << 5) + this.bitCount(t - 1);
|
|
175
|
+
w ^= t;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* @returns the index of the first bit that is set to `true` that occurs on or after the specified starting index.
|
|
182
|
+
* If no such bit exists then undefined is returned.
|
|
183
|
+
*
|
|
184
|
+
* @param fromIndex the index to start checking from (inclusive)
|
|
185
|
+
*/
|
|
186
|
+
nextSetBit(fromIndex) {
|
|
187
|
+
if (fromIndex < 0) {
|
|
188
|
+
throw new RangeError("index cannot be negative");
|
|
189
|
+
}
|
|
190
|
+
for (const index of this) {
|
|
191
|
+
if (index >= fromIndex) {
|
|
192
|
+
return index;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return void 0;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Sets the bit at the specified index to `true`.
|
|
199
|
+
*
|
|
200
|
+
* @param index a bit index
|
|
201
|
+
*/
|
|
202
|
+
set(index) {
|
|
203
|
+
if (index < 0) {
|
|
204
|
+
throw new RangeError("index cannot be negative");
|
|
205
|
+
}
|
|
206
|
+
this.resize(index);
|
|
207
|
+
this.data[index >>> 5] |= 1 << index % 32;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* @returns a string representation of this bit set.
|
|
211
|
+
*/
|
|
212
|
+
toString() {
|
|
213
|
+
return "{" + this.values().join(", ") + "}";
|
|
214
|
+
}
|
|
215
|
+
resize(index) {
|
|
216
|
+
const count = index + 32 >>> 5;
|
|
217
|
+
if (count <= this.data.length) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const data = new Uint32Array(count);
|
|
221
|
+
data.set(this.data);
|
|
222
|
+
data.fill(0, this.data.length);
|
|
223
|
+
this.data = data;
|
|
224
|
+
}
|
|
225
|
+
bitCount(v) {
|
|
226
|
+
v = v - (v >> 1 & 1431655765);
|
|
227
|
+
v = (v & 858993459) + (v >> 2 & 858993459);
|
|
228
|
+
v = v + (v >> 4) & 252645135;
|
|
229
|
+
v = v + (v >> 8);
|
|
230
|
+
v = v + (v >> 16);
|
|
231
|
+
return v & 63;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// src/utils/MurmurHash.ts
|
|
236
|
+
var c1 = 3432918353;
|
|
237
|
+
var c2 = 461845907;
|
|
238
|
+
var r1 = 15;
|
|
239
|
+
var r2 = 13;
|
|
240
|
+
var m = 5;
|
|
241
|
+
var n = 3864292196;
|
|
242
|
+
var MurmurHash = class _MurmurHash {
|
|
243
|
+
static {
|
|
244
|
+
__name(this, "MurmurHash");
|
|
245
|
+
}
|
|
246
|
+
static defaultSeed = 701;
|
|
247
|
+
constructor() {
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Initialize the hash using the specified {@code seed}.
|
|
251
|
+
*
|
|
252
|
+
* @param seed the seed
|
|
253
|
+
*
|
|
254
|
+
* @returns the intermediate hash value
|
|
255
|
+
*/
|
|
256
|
+
static initialize(seed = _MurmurHash.defaultSeed) {
|
|
257
|
+
return seed;
|
|
258
|
+
}
|
|
259
|
+
static updateFromComparable(hash, value) {
|
|
260
|
+
return this.update(hash, value?.hashCode() ?? 0);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Update the intermediate hash value for the next input {@code value}.
|
|
264
|
+
*
|
|
265
|
+
* @param hash The intermediate hash value.
|
|
266
|
+
* @param value the value to add to the current hash.
|
|
267
|
+
*
|
|
268
|
+
* @returns the updated intermediate hash value
|
|
269
|
+
*/
|
|
270
|
+
static update(hash, value) {
|
|
271
|
+
value = Math.imul(value, c1);
|
|
272
|
+
value = value << r1 | value >>> 32 - r1;
|
|
273
|
+
value = Math.imul(value, c2);
|
|
274
|
+
hash = hash ^ value;
|
|
275
|
+
hash = hash << r2 | hash >>> 32 - r2;
|
|
276
|
+
hash = Math.imul(hash, m) + n;
|
|
277
|
+
return hash;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Apply the final computation steps to the intermediate value {@code hash}
|
|
281
|
+
* to form the final result of the MurmurHash 3 hash function.
|
|
282
|
+
*
|
|
283
|
+
* @param hash The intermediate hash value.
|
|
284
|
+
* @param entryCount The number of values added to the hash.
|
|
285
|
+
*
|
|
286
|
+
* @returns the final hash result
|
|
287
|
+
*/
|
|
288
|
+
static finish(hash, entryCount) {
|
|
289
|
+
hash ^= entryCount * 4;
|
|
290
|
+
hash ^= hash >>> 16;
|
|
291
|
+
hash = Math.imul(hash, 2246822507);
|
|
292
|
+
hash ^= hash >>> 13;
|
|
293
|
+
hash = Math.imul(hash, 3266489909);
|
|
294
|
+
hash ^= hash >>> 16;
|
|
295
|
+
return hash;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* An all-in-one convenience method to compute a hash for a single value.
|
|
299
|
+
*
|
|
300
|
+
* @param value The value to hash.
|
|
301
|
+
* @param seed The seed for the hash value.
|
|
302
|
+
*
|
|
303
|
+
* @returns The computed hash.
|
|
304
|
+
*/
|
|
305
|
+
static hashCode(value, seed) {
|
|
306
|
+
return _MurmurHash.finish(_MurmurHash.update(seed ?? _MurmurHash.defaultSeed, value), 1);
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
// src/misc/ObjectEqualityComparator.ts
|
|
311
|
+
var ObjectEqualityComparator = class _ObjectEqualityComparator {
|
|
312
|
+
static {
|
|
313
|
+
__name(this, "ObjectEqualityComparator");
|
|
314
|
+
}
|
|
315
|
+
static instance = new _ObjectEqualityComparator();
|
|
316
|
+
hashCode(obj) {
|
|
317
|
+
if (obj == null) {
|
|
318
|
+
return 0;
|
|
319
|
+
}
|
|
320
|
+
return obj.hashCode();
|
|
321
|
+
}
|
|
322
|
+
equals(a, b) {
|
|
323
|
+
if (a == null) {
|
|
324
|
+
return b == null;
|
|
325
|
+
}
|
|
326
|
+
return a.equals(b);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// src/misc/DefaultEqualityComparator.ts
|
|
331
|
+
var DefaultEqualityComparator = class _DefaultEqualityComparator {
|
|
332
|
+
static {
|
|
333
|
+
__name(this, "DefaultEqualityComparator");
|
|
334
|
+
}
|
|
335
|
+
static instance = new _DefaultEqualityComparator();
|
|
336
|
+
hashCode(obj) {
|
|
337
|
+
if (obj == null) {
|
|
338
|
+
return 0;
|
|
339
|
+
}
|
|
340
|
+
return ObjectEqualityComparator.instance.hashCode(obj);
|
|
341
|
+
}
|
|
342
|
+
equals(a, b) {
|
|
343
|
+
if (a == null) {
|
|
344
|
+
return b == null;
|
|
345
|
+
}
|
|
346
|
+
if (typeof a === "string" || typeof a === "number") {
|
|
347
|
+
return a === b;
|
|
348
|
+
}
|
|
349
|
+
return ObjectEqualityComparator.instance.equals(a, b);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
// src/misc/HashSet.ts
|
|
354
|
+
var HashSet = class _HashSet {
|
|
355
|
+
static {
|
|
356
|
+
__name(this, "HashSet");
|
|
357
|
+
}
|
|
358
|
+
static defaultLoadFactor = 0.75;
|
|
359
|
+
static initialCapacity = 16;
|
|
360
|
+
// must be power of 2
|
|
361
|
+
comparator;
|
|
362
|
+
buckets;
|
|
363
|
+
threshold;
|
|
364
|
+
/** How many elements in set */
|
|
365
|
+
itemCount = 0;
|
|
366
|
+
constructor(comparatorOrSet, initialCapacity = _HashSet.initialCapacity) {
|
|
367
|
+
if (comparatorOrSet instanceof _HashSet) {
|
|
368
|
+
this.comparator = comparatorOrSet.comparator;
|
|
369
|
+
this.buckets = comparatorOrSet.buckets.slice(0);
|
|
370
|
+
for (let i = 0; i < this.buckets.length; i++) {
|
|
371
|
+
const bucket = this.buckets[i];
|
|
372
|
+
if (bucket) {
|
|
373
|
+
this.buckets[i] = bucket.slice(0);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
this.itemCount = comparatorOrSet.itemCount;
|
|
377
|
+
this.threshold = comparatorOrSet.threshold;
|
|
378
|
+
} else {
|
|
379
|
+
this.comparator = comparatorOrSet ?? DefaultEqualityComparator.instance;
|
|
380
|
+
this.buckets = this.createBuckets(initialCapacity);
|
|
381
|
+
this.threshold = Math.floor(_HashSet.initialCapacity * _HashSet.defaultLoadFactor);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Add `o` to set if not there; return existing value if already
|
|
386
|
+
* there. This method performs the same operation as {@link #add} aside from
|
|
387
|
+
* the return value.
|
|
388
|
+
*
|
|
389
|
+
* @param o the object to add to the set.
|
|
390
|
+
*
|
|
391
|
+
* @returns An existing element that equals to `o` if already in set, otherwise `o`.
|
|
392
|
+
*/
|
|
393
|
+
getOrAdd(o) {
|
|
394
|
+
if (this.itemCount > this.threshold) {
|
|
395
|
+
this.expand();
|
|
396
|
+
}
|
|
397
|
+
const b = this.getBucket(o);
|
|
398
|
+
let bucket = this.buckets[b];
|
|
399
|
+
if (!bucket) {
|
|
400
|
+
bucket = [o];
|
|
401
|
+
this.buckets[b] = bucket;
|
|
402
|
+
++this.itemCount;
|
|
403
|
+
return o;
|
|
404
|
+
}
|
|
405
|
+
for (const existing of bucket) {
|
|
406
|
+
if (this.comparator.equals(existing, o)) {
|
|
407
|
+
return existing;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
bucket.push(o);
|
|
411
|
+
++this.itemCount;
|
|
412
|
+
return o;
|
|
413
|
+
}
|
|
414
|
+
get(o) {
|
|
415
|
+
if (o == null) {
|
|
416
|
+
return o;
|
|
417
|
+
}
|
|
418
|
+
const b = this.getBucket(o);
|
|
419
|
+
const bucket = this.buckets[b];
|
|
420
|
+
if (!bucket) {
|
|
421
|
+
return void 0;
|
|
422
|
+
}
|
|
423
|
+
for (const e of bucket) {
|
|
424
|
+
if (this.comparator.equals(e, o)) {
|
|
425
|
+
return e;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return void 0;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Removes the specified element from this set if it is present.
|
|
432
|
+
*
|
|
433
|
+
* @param o object to be removed from this set, if present.
|
|
434
|
+
*
|
|
435
|
+
* @returns `true` if the set contained the specified element.
|
|
436
|
+
*/
|
|
437
|
+
remove(o) {
|
|
438
|
+
if (o == null) {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
const b = this.getBucket(o);
|
|
442
|
+
const bucket = this.buckets[b];
|
|
443
|
+
if (!bucket) {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
for (let i = 0; i < bucket.length; i++) {
|
|
447
|
+
const existing = bucket[i];
|
|
448
|
+
if (this.comparator.equals(existing, o)) {
|
|
449
|
+
bucket.splice(i, 1);
|
|
450
|
+
--this.itemCount;
|
|
451
|
+
return true;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
hashCode() {
|
|
457
|
+
let hash = MurmurHash.initialize();
|
|
458
|
+
for (const bucket of this.buckets) {
|
|
459
|
+
if (bucket == null) {
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
for (const o of bucket) {
|
|
463
|
+
if (o == null) {
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
hash = MurmurHash.update(hash, this.comparator.hashCode(o));
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
hash = MurmurHash.finish(hash, this.size);
|
|
470
|
+
return hash;
|
|
471
|
+
}
|
|
472
|
+
equals(o) {
|
|
473
|
+
if (o === this) {
|
|
474
|
+
return true;
|
|
475
|
+
}
|
|
476
|
+
if (!(o instanceof _HashSet)) {
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
if (o.size !== this.size) {
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
return this.containsAll(o);
|
|
483
|
+
}
|
|
484
|
+
add(t) {
|
|
485
|
+
const existing = this.getOrAdd(t);
|
|
486
|
+
return existing === t;
|
|
487
|
+
}
|
|
488
|
+
contains(o) {
|
|
489
|
+
return this.containsFast(o);
|
|
490
|
+
}
|
|
491
|
+
containsFast(obj) {
|
|
492
|
+
if (obj == null) {
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
return this.get(obj) !== void 0;
|
|
496
|
+
}
|
|
497
|
+
*[Symbol.iterator]() {
|
|
498
|
+
yield* this.toArray();
|
|
499
|
+
}
|
|
500
|
+
toArray() {
|
|
501
|
+
const a = new Array(this.size);
|
|
502
|
+
let i = 0;
|
|
503
|
+
for (const bucket of this.buckets) {
|
|
504
|
+
if (bucket == null) {
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
for (const o of bucket) {
|
|
508
|
+
if (o == null) {
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
a[i++] = o;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return a;
|
|
515
|
+
}
|
|
516
|
+
containsAll(collection) {
|
|
517
|
+
if (collection instanceof _HashSet) {
|
|
518
|
+
for (const bucket of collection.buckets) {
|
|
519
|
+
if (bucket == null) {
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
for (const o of bucket) {
|
|
523
|
+
if (o == null) {
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
if (!this.containsFast(o)) {
|
|
527
|
+
return false;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
} else {
|
|
532
|
+
for (const o of collection) {
|
|
533
|
+
if (!this.containsFast(o)) {
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return true;
|
|
539
|
+
}
|
|
540
|
+
addAll(c) {
|
|
541
|
+
let changed = false;
|
|
542
|
+
for (const o of c) {
|
|
543
|
+
const existing = this.getOrAdd(o);
|
|
544
|
+
if (existing !== o) {
|
|
545
|
+
changed = true;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return changed;
|
|
549
|
+
}
|
|
550
|
+
clear() {
|
|
551
|
+
this.buckets = this.createBuckets(_HashSet.initialCapacity);
|
|
552
|
+
this.itemCount = 0;
|
|
553
|
+
this.threshold = Math.floor(_HashSet.initialCapacity * _HashSet.defaultLoadFactor);
|
|
554
|
+
}
|
|
555
|
+
toString() {
|
|
556
|
+
if (this.size === 0) {
|
|
557
|
+
return "{}";
|
|
558
|
+
}
|
|
559
|
+
let buf = "{";
|
|
560
|
+
let first = true;
|
|
561
|
+
for (const bucket of this.buckets) {
|
|
562
|
+
if (bucket == null) {
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
for (const o of bucket) {
|
|
566
|
+
if (o == null) {
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
if (first) {
|
|
570
|
+
first = false;
|
|
571
|
+
} else {
|
|
572
|
+
buf += ", ";
|
|
573
|
+
}
|
|
574
|
+
buf += o.toString();
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
buf += "}";
|
|
578
|
+
return buf;
|
|
579
|
+
}
|
|
580
|
+
toTableString() {
|
|
581
|
+
let buf = "";
|
|
582
|
+
for (const bucket of this.buckets) {
|
|
583
|
+
if (bucket == null) {
|
|
584
|
+
buf += "null\n";
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
buf += "[";
|
|
588
|
+
let first = true;
|
|
589
|
+
for (const o of bucket) {
|
|
590
|
+
if (first) {
|
|
591
|
+
first = false;
|
|
592
|
+
} else {
|
|
593
|
+
buf += " ";
|
|
594
|
+
}
|
|
595
|
+
if (o == null) {
|
|
596
|
+
buf += "_";
|
|
597
|
+
} else {
|
|
598
|
+
buf += o.toString();
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
buf += "]\n";
|
|
602
|
+
}
|
|
603
|
+
return buf;
|
|
604
|
+
}
|
|
605
|
+
getBucket(o) {
|
|
606
|
+
const hash = this.comparator.hashCode(o);
|
|
607
|
+
const b = hash & this.buckets.length - 1;
|
|
608
|
+
return b;
|
|
609
|
+
}
|
|
610
|
+
expand() {
|
|
611
|
+
const old = this.buckets;
|
|
612
|
+
const newCapacity = this.buckets.length * 2;
|
|
613
|
+
const newTable = this.createBuckets(newCapacity);
|
|
614
|
+
this.buckets = newTable;
|
|
615
|
+
this.threshold = Math.floor(newCapacity * _HashSet.defaultLoadFactor);
|
|
616
|
+
for (const bucket of old) {
|
|
617
|
+
if (!bucket) {
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
for (const o of bucket) {
|
|
621
|
+
const b = this.getBucket(o);
|
|
622
|
+
let newBucket = this.buckets[b];
|
|
623
|
+
if (!newBucket) {
|
|
624
|
+
newBucket = [];
|
|
625
|
+
this.buckets[b] = newBucket;
|
|
626
|
+
}
|
|
627
|
+
newBucket.push(o);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
get size() {
|
|
632
|
+
return this.itemCount;
|
|
633
|
+
}
|
|
634
|
+
get isEmpty() {
|
|
635
|
+
return this.itemCount === 0;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Return an array of `T[]` with length `capacity`.
|
|
639
|
+
*
|
|
640
|
+
* @param capacity the length of the array to return
|
|
641
|
+
* @returns the newly constructed array
|
|
642
|
+
*/
|
|
643
|
+
createBuckets(capacity) {
|
|
644
|
+
return new Array(capacity);
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
// src/misc/Interval.ts
|
|
649
|
+
var Interval = class _Interval {
|
|
650
|
+
static {
|
|
651
|
+
__name(this, "Interval");
|
|
652
|
+
}
|
|
653
|
+
static INVALID_INTERVAL = new _Interval(-1, -2);
|
|
654
|
+
static INTERVAL_POOL_MAX_VALUE = 1e3;
|
|
655
|
+
static cache = [];
|
|
656
|
+
start;
|
|
657
|
+
stop;
|
|
658
|
+
cachedHashCode;
|
|
659
|
+
constructor(start, stop) {
|
|
660
|
+
this.start = start;
|
|
661
|
+
this.stop = stop;
|
|
662
|
+
this.cachedHashCode = Math.imul(651 + start, 31) + stop;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Creates a new interval from the given values.
|
|
666
|
+
*
|
|
667
|
+
* Interval objects are used readonly so share all with the
|
|
668
|
+
* same single value a==b up to some max size. Use an array as a perfect hash.
|
|
669
|
+
* Return shared object for 0..INTERVAL_POOL_MAX_VALUE or a new
|
|
670
|
+
* Interval object with a..a in it. On Java.g4, 218623 IntervalSets
|
|
671
|
+
* have a..a (set with 1 element).
|
|
672
|
+
*
|
|
673
|
+
* @param a The start of the interval.
|
|
674
|
+
* @param b The end of the interval (inclusive).
|
|
675
|
+
*
|
|
676
|
+
* @returns A cached or new interval.
|
|
677
|
+
*/
|
|
678
|
+
static of(a, b) {
|
|
679
|
+
if (a !== b || a < 0 || a > _Interval.INTERVAL_POOL_MAX_VALUE) {
|
|
680
|
+
return new _Interval(a, b);
|
|
681
|
+
}
|
|
682
|
+
if (!_Interval.cache[a]) {
|
|
683
|
+
_Interval.cache[a] = new _Interval(a, a);
|
|
684
|
+
}
|
|
685
|
+
return _Interval.cache[a];
|
|
686
|
+
}
|
|
687
|
+
equals(o) {
|
|
688
|
+
return this.start === o.start && this.stop === o.stop;
|
|
689
|
+
}
|
|
690
|
+
hashCode() {
|
|
691
|
+
return this.cachedHashCode;
|
|
692
|
+
}
|
|
693
|
+
/** Does this start completely before other? Disjoint */
|
|
694
|
+
startsBeforeDisjoint(other) {
|
|
695
|
+
return this.start < other.start && this.stop < other.start;
|
|
696
|
+
}
|
|
697
|
+
/** Does this start at or before other? Nondisjoint */
|
|
698
|
+
startsBeforeNonDisjoint(other) {
|
|
699
|
+
return this.start <= other.start && this.stop >= other.start;
|
|
700
|
+
}
|
|
701
|
+
/** Does this.start start after other.stop? May or may not be disjoint */
|
|
702
|
+
startsAfter(other) {
|
|
703
|
+
return this.start > other.start;
|
|
704
|
+
}
|
|
705
|
+
/** Does this start completely after other? Disjoint */
|
|
706
|
+
startsAfterDisjoint(other) {
|
|
707
|
+
return this.start > other.stop;
|
|
708
|
+
}
|
|
709
|
+
/** Does this start after other? NonDisjoint */
|
|
710
|
+
startsAfterNonDisjoint(other) {
|
|
711
|
+
return this.start > other.start && this.start <= other.stop;
|
|
712
|
+
}
|
|
713
|
+
/** Are both ranges disjoint? I.e., no overlap? */
|
|
714
|
+
disjoint(other) {
|
|
715
|
+
return this.startsBeforeDisjoint(other) || this.startsAfterDisjoint(other);
|
|
716
|
+
}
|
|
717
|
+
/** Are two intervals adjacent such as 0..41 and 42..42? */
|
|
718
|
+
adjacent(other) {
|
|
719
|
+
return this.start === other.stop + 1 || this.stop === other.start - 1;
|
|
720
|
+
}
|
|
721
|
+
properlyContains(other) {
|
|
722
|
+
return other.start >= this.start && other.stop <= this.stop;
|
|
723
|
+
}
|
|
724
|
+
/** Return the interval computed from combining this and other */
|
|
725
|
+
union(other) {
|
|
726
|
+
return _Interval.of(Math.min(this.start, other.start), Math.max(this.stop, other.stop));
|
|
727
|
+
}
|
|
728
|
+
/** Return the interval in common between this and o */
|
|
729
|
+
intersection(other) {
|
|
730
|
+
return _Interval.of(Math.max(this.start, other.start), Math.min(this.stop, other.stop));
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Return the interval with elements from this not in other;
|
|
734
|
+
* other must not be totally enclosed (properly contained)
|
|
735
|
+
* within this, which would result in two disjoint intervals
|
|
736
|
+
* instead of the single one returned by this method.
|
|
737
|
+
*/
|
|
738
|
+
differenceNotProperlyContained(other) {
|
|
739
|
+
let diff = null;
|
|
740
|
+
if (other.startsBeforeNonDisjoint(this)) {
|
|
741
|
+
diff = _Interval.of(Math.max(this.start, other.stop + 1), this.stop);
|
|
742
|
+
} else if (other.startsAfterNonDisjoint(this)) {
|
|
743
|
+
diff = _Interval.of(this.start, other.start - 1);
|
|
744
|
+
}
|
|
745
|
+
return diff;
|
|
746
|
+
}
|
|
747
|
+
toString() {
|
|
748
|
+
return `${this.start}..${this.stop}`;
|
|
749
|
+
}
|
|
750
|
+
get length() {
|
|
751
|
+
if (this.stop < this.start) {
|
|
752
|
+
return 0;
|
|
753
|
+
}
|
|
754
|
+
return this.stop - this.start + 1;
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
// src/Vocabulary.ts
|
|
759
|
+
var Vocabulary = class _Vocabulary {
|
|
760
|
+
static {
|
|
761
|
+
__name(this, "Vocabulary");
|
|
762
|
+
}
|
|
763
|
+
static EMPTY_NAMES = [];
|
|
764
|
+
/**
|
|
765
|
+
* Gets an empty {@link Vocabulary} instance.
|
|
766
|
+
*
|
|
767
|
+
*
|
|
768
|
+
* No literal or symbol names are assigned to token types, so
|
|
769
|
+
* {@link #getDisplayName(int)} returns the numeric value for all tokens
|
|
770
|
+
* except {@link Token#EOF}.
|
|
771
|
+
*/
|
|
772
|
+
static EMPTY_VOCABULARY = new _Vocabulary(_Vocabulary.EMPTY_NAMES, _Vocabulary.EMPTY_NAMES, _Vocabulary.EMPTY_NAMES);
|
|
773
|
+
maxTokenType;
|
|
774
|
+
literalNames;
|
|
775
|
+
symbolicNames;
|
|
776
|
+
displayNames;
|
|
777
|
+
/**
|
|
778
|
+
* Constructs a new instance of {@link Vocabulary} from the specified
|
|
779
|
+
* literal, symbolic, and display token names.
|
|
780
|
+
*
|
|
781
|
+
* @param literalNames The literal names assigned to tokens, or `null`
|
|
782
|
+
* if no literal names are assigned.
|
|
783
|
+
* @param symbolicNames The symbolic names assigned to tokens, or
|
|
784
|
+
* `null` if no symbolic names are assigned.
|
|
785
|
+
* @param displayNames The display names assigned to tokens, or `null`
|
|
786
|
+
* to use the values in `literalNames` and `symbolicNames` as
|
|
787
|
+
* the source of display names, as described in
|
|
788
|
+
* {@link #getDisplayName(int)}.
|
|
789
|
+
*/
|
|
790
|
+
constructor(literalNames, symbolicNames, displayNames) {
|
|
791
|
+
this.literalNames = literalNames ?? _Vocabulary.EMPTY_NAMES;
|
|
792
|
+
this.symbolicNames = symbolicNames ?? _Vocabulary.EMPTY_NAMES;
|
|
793
|
+
this.displayNames = displayNames ?? _Vocabulary.EMPTY_NAMES;
|
|
794
|
+
this.maxTokenType = Math.max(this.displayNames.length, Math.max(
|
|
795
|
+
this.literalNames.length,
|
|
796
|
+
this.symbolicNames.length
|
|
797
|
+
)) - 1;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Returns a {@link Vocabulary} instance from the specified set of token
|
|
801
|
+
* names. This method acts as a compatibility layer for the single
|
|
802
|
+
* `tokenNames` array generated by previous releases of ANTLR.
|
|
803
|
+
*
|
|
804
|
+
* The resulting vocabulary instance returns `null` for
|
|
805
|
+
* {@link getLiteralName getLiteralName(int)} and {@link getSymbolicName getSymbolicName(int)}, and the
|
|
806
|
+
* value from `tokenNames` for the display names.
|
|
807
|
+
*
|
|
808
|
+
* @param tokenNames The token names, or `null` if no token names are
|
|
809
|
+
* available.
|
|
810
|
+
* @returns A {@link Vocabulary} instance which uses `tokenNames` for
|
|
811
|
+
* the display names of tokens.
|
|
812
|
+
*/
|
|
813
|
+
static fromTokenNames(tokenNames) {
|
|
814
|
+
if (tokenNames == null || tokenNames.length === 0) {
|
|
815
|
+
return _Vocabulary.EMPTY_VOCABULARY;
|
|
816
|
+
}
|
|
817
|
+
const literalNames = [...tokenNames];
|
|
818
|
+
const symbolicNames = [...tokenNames];
|
|
819
|
+
for (let i = 0; i < tokenNames.length; i++) {
|
|
820
|
+
const tokenName = tokenNames[i];
|
|
821
|
+
if (tokenName == null) {
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
if (tokenName.length > 0) {
|
|
825
|
+
const firstChar = tokenName.codePointAt(0);
|
|
826
|
+
if (firstChar === 39) {
|
|
827
|
+
symbolicNames[i] = null;
|
|
828
|
+
continue;
|
|
829
|
+
} else if (firstChar >= 65 && firstChar <= 90) {
|
|
830
|
+
literalNames[i] = null;
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
literalNames[i] = null;
|
|
835
|
+
symbolicNames[i] = null;
|
|
836
|
+
}
|
|
837
|
+
return new _Vocabulary(literalNames, symbolicNames, tokenNames);
|
|
838
|
+
}
|
|
839
|
+
getMaxTokenType() {
|
|
840
|
+
return this.maxTokenType;
|
|
841
|
+
}
|
|
842
|
+
getLiteralName(tokenType) {
|
|
843
|
+
if (tokenType >= 0 && tokenType < this.literalNames.length) {
|
|
844
|
+
return this.literalNames[tokenType];
|
|
845
|
+
}
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
getSymbolicName(tokenType) {
|
|
849
|
+
if (tokenType >= 0 && tokenType < this.symbolicNames.length) {
|
|
850
|
+
return this.symbolicNames[tokenType];
|
|
851
|
+
}
|
|
852
|
+
if (tokenType === Token.EOF) {
|
|
853
|
+
return "EOF";
|
|
854
|
+
}
|
|
855
|
+
return null;
|
|
856
|
+
}
|
|
857
|
+
getDisplayName(tokenType) {
|
|
858
|
+
if (tokenType >= 0 && tokenType < this.displayNames.length) {
|
|
859
|
+
const displayName = this.displayNames[tokenType];
|
|
860
|
+
if (displayName != null) {
|
|
861
|
+
return displayName;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
const literalName = this.getLiteralName(tokenType);
|
|
865
|
+
if (literalName != null) {
|
|
866
|
+
return literalName;
|
|
867
|
+
}
|
|
868
|
+
const symbolicName = this.getSymbolicName(tokenType);
|
|
869
|
+
if (symbolicName != null) {
|
|
870
|
+
return symbolicName;
|
|
871
|
+
}
|
|
872
|
+
return `${tokenType}`;
|
|
873
|
+
}
|
|
874
|
+
getLiteralNames() {
|
|
875
|
+
return this.literalNames;
|
|
876
|
+
}
|
|
877
|
+
getSymbolicNames() {
|
|
878
|
+
return this.symbolicNames;
|
|
879
|
+
}
|
|
880
|
+
getDisplayNames() {
|
|
881
|
+
return this.displayNames;
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
// src/misc/IntervalSet.ts
|
|
886
|
+
var IntervalSet = class _IntervalSet {
|
|
887
|
+
static {
|
|
888
|
+
__name(this, "IntervalSet");
|
|
889
|
+
}
|
|
890
|
+
/** The list of sorted, disjoint intervals. */
|
|
891
|
+
intervals = [];
|
|
892
|
+
cachedHashCode;
|
|
893
|
+
constructor(set) {
|
|
894
|
+
if (set) {
|
|
895
|
+
if (Array.isArray(set)) {
|
|
896
|
+
for (const el of set) {
|
|
897
|
+
this.addOne(el);
|
|
898
|
+
}
|
|
899
|
+
} else {
|
|
900
|
+
this.addSet(set);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
/** Create a set with all ints within range [a..b] (inclusive) */
|
|
905
|
+
static of(a, b) {
|
|
906
|
+
const s = new _IntervalSet();
|
|
907
|
+
s.addRange(a, b);
|
|
908
|
+
return s;
|
|
909
|
+
}
|
|
910
|
+
/** Combine all sets in the array and return the union of them */
|
|
911
|
+
static or(sets) {
|
|
912
|
+
const result = new _IntervalSet();
|
|
913
|
+
for (const set of sets) {
|
|
914
|
+
result.addSet(set);
|
|
915
|
+
}
|
|
916
|
+
return result;
|
|
917
|
+
}
|
|
918
|
+
[Symbol.iterator]() {
|
|
919
|
+
return this.intervals[Symbol.iterator]();
|
|
920
|
+
}
|
|
921
|
+
get(index) {
|
|
922
|
+
return this.intervals[index];
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Returns the minimum value contained in the set if not isNil().
|
|
926
|
+
*
|
|
927
|
+
* @returns the minimum value contained in the set.
|
|
928
|
+
*/
|
|
929
|
+
get minElement() {
|
|
930
|
+
if (this.intervals.length === 0) {
|
|
931
|
+
return Token.INVALID_TYPE;
|
|
932
|
+
}
|
|
933
|
+
return this.intervals[0].start;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Returns the maximum value contained in the set if not isNil().
|
|
937
|
+
*
|
|
938
|
+
* @returns the maximum value contained in the set.
|
|
939
|
+
*/
|
|
940
|
+
get maxElement() {
|
|
941
|
+
if (this.intervals.length === 0) {
|
|
942
|
+
return Token.INVALID_TYPE;
|
|
943
|
+
}
|
|
944
|
+
return this.intervals[this.intervals.length - 1].stop;
|
|
945
|
+
}
|
|
946
|
+
clear() {
|
|
947
|
+
this.cachedHashCode = void 0;
|
|
948
|
+
this.intervals = [];
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Add a single element to the set. An isolated element is stored
|
|
952
|
+
* as a range el..el.
|
|
953
|
+
*/
|
|
954
|
+
addOne(v) {
|
|
955
|
+
this.addInterval(new Interval(v, v));
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Add interval; i.e., add all integers from a to b to set.
|
|
959
|
+
* If b < a, do nothing.
|
|
960
|
+
* Keep list in sorted order (by left range value).
|
|
961
|
+
* If overlap, combine ranges. For example,
|
|
962
|
+
* If this is {1..5, 10..20}, adding 6..7 yields
|
|
963
|
+
* {1..5, 6..7, 10..20}. Adding 4..8 yields {1..8, 10..20}.
|
|
964
|
+
*/
|
|
965
|
+
addRange(l, h) {
|
|
966
|
+
this.addInterval(new Interval(l, h));
|
|
967
|
+
}
|
|
968
|
+
addInterval(addition) {
|
|
969
|
+
this.cachedHashCode = void 0;
|
|
970
|
+
if (this.intervals.length === 0) {
|
|
971
|
+
this.intervals.push(addition);
|
|
972
|
+
} else {
|
|
973
|
+
for (let pos = 0; pos < this.intervals.length; pos++) {
|
|
974
|
+
const existing = this.intervals[pos];
|
|
975
|
+
if (addition.equals(existing)) {
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
if (addition.adjacent(existing) || !addition.disjoint(existing)) {
|
|
979
|
+
const bigger = addition.union(existing);
|
|
980
|
+
this.intervals[pos] = bigger;
|
|
981
|
+
for (let sub = pos + 1; sub < this.intervals.length; ) {
|
|
982
|
+
const next = this.intervals[sub];
|
|
983
|
+
if (!bigger.adjacent(next) && bigger.disjoint(next)) {
|
|
984
|
+
break;
|
|
985
|
+
}
|
|
986
|
+
this.intervals.splice(sub, 1);
|
|
987
|
+
this.intervals[pos] = bigger.union(next);
|
|
988
|
+
}
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
if (addition.startsBeforeDisjoint(existing)) {
|
|
992
|
+
this.intervals.splice(pos, 0, addition);
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
this.intervals.push(addition);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
addSet(other) {
|
|
1000
|
+
other.intervals.forEach((toAdd) => {
|
|
1001
|
+
return this.addInterval(toAdd);
|
|
1002
|
+
}, this);
|
|
1003
|
+
return this;
|
|
1004
|
+
}
|
|
1005
|
+
complementWithVocabulary(vocabulary) {
|
|
1006
|
+
const result = new _IntervalSet();
|
|
1007
|
+
if (!vocabulary) {
|
|
1008
|
+
return result;
|
|
1009
|
+
}
|
|
1010
|
+
if (vocabulary.length === 0) {
|
|
1011
|
+
return result;
|
|
1012
|
+
}
|
|
1013
|
+
result.addSet(vocabulary);
|
|
1014
|
+
return result.subtract(this);
|
|
1015
|
+
}
|
|
1016
|
+
complement(minElement, maxElement) {
|
|
1017
|
+
const result = new _IntervalSet();
|
|
1018
|
+
result.addInterval(new Interval(minElement, maxElement));
|
|
1019
|
+
return result.subtract(this);
|
|
1020
|
+
}
|
|
1021
|
+
/** combine all sets in the array returned the or'd value */
|
|
1022
|
+
or(sets) {
|
|
1023
|
+
const result = new _IntervalSet();
|
|
1024
|
+
result.addSet(this);
|
|
1025
|
+
sets.forEach((set) => {
|
|
1026
|
+
return result.addSet(set);
|
|
1027
|
+
});
|
|
1028
|
+
return result;
|
|
1029
|
+
}
|
|
1030
|
+
and(other) {
|
|
1031
|
+
if (other.length === 0) {
|
|
1032
|
+
return new _IntervalSet();
|
|
1033
|
+
}
|
|
1034
|
+
const myIntervals = this.intervals;
|
|
1035
|
+
const theirIntervals = other.intervals;
|
|
1036
|
+
let intersection;
|
|
1037
|
+
const mySize = myIntervals.length;
|
|
1038
|
+
const theirSize = theirIntervals.length;
|
|
1039
|
+
let i = 0;
|
|
1040
|
+
let j = 0;
|
|
1041
|
+
while (i < mySize && j < theirSize) {
|
|
1042
|
+
const mine = myIntervals[i];
|
|
1043
|
+
const theirs = theirIntervals[j];
|
|
1044
|
+
if (mine.startsBeforeDisjoint(theirs)) {
|
|
1045
|
+
i++;
|
|
1046
|
+
} else if (theirs.startsBeforeDisjoint(mine)) {
|
|
1047
|
+
j++;
|
|
1048
|
+
} else if (mine.properlyContains(theirs)) {
|
|
1049
|
+
if (!intersection) {
|
|
1050
|
+
intersection = new _IntervalSet();
|
|
1051
|
+
}
|
|
1052
|
+
intersection.addInterval(mine.intersection(theirs));
|
|
1053
|
+
j++;
|
|
1054
|
+
} else if (theirs.properlyContains(mine)) {
|
|
1055
|
+
if (!intersection) {
|
|
1056
|
+
intersection = new _IntervalSet();
|
|
1057
|
+
}
|
|
1058
|
+
intersection.addInterval(mine.intersection(theirs));
|
|
1059
|
+
i++;
|
|
1060
|
+
} else if (!mine.disjoint(theirs)) {
|
|
1061
|
+
if (!intersection) {
|
|
1062
|
+
intersection = new _IntervalSet();
|
|
1063
|
+
}
|
|
1064
|
+
intersection.addInterval(mine.intersection(theirs));
|
|
1065
|
+
if (mine.startsAfterNonDisjoint(theirs)) {
|
|
1066
|
+
j++;
|
|
1067
|
+
} else if (theirs.startsAfterNonDisjoint(mine)) {
|
|
1068
|
+
i++;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
if (!intersection) {
|
|
1073
|
+
return new _IntervalSet();
|
|
1074
|
+
}
|
|
1075
|
+
return intersection;
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Compute the set difference between two interval sets. The specific
|
|
1079
|
+
* operation is `left - right`. If either of the input sets is
|
|
1080
|
+
* `null`, it is treated as though it was an empty set.
|
|
1081
|
+
*/
|
|
1082
|
+
subtract(other) {
|
|
1083
|
+
if (this.length === 0) {
|
|
1084
|
+
return new _IntervalSet();
|
|
1085
|
+
}
|
|
1086
|
+
const result = new _IntervalSet(this);
|
|
1087
|
+
if (other.length === 0) {
|
|
1088
|
+
return result;
|
|
1089
|
+
}
|
|
1090
|
+
let resultI = 0;
|
|
1091
|
+
let rightI = 0;
|
|
1092
|
+
while (resultI < result.intervals.length && rightI < other.intervals.length) {
|
|
1093
|
+
const resultInterval = result.intervals[resultI];
|
|
1094
|
+
const rightInterval = other.intervals[rightI];
|
|
1095
|
+
if (rightInterval.stop < resultInterval.start) {
|
|
1096
|
+
rightI++;
|
|
1097
|
+
continue;
|
|
1098
|
+
}
|
|
1099
|
+
if (rightInterval.start > resultInterval.stop) {
|
|
1100
|
+
resultI++;
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
let beforeCurrent;
|
|
1104
|
+
let afterCurrent;
|
|
1105
|
+
if (rightInterval.start > resultInterval.start) {
|
|
1106
|
+
beforeCurrent = new Interval(resultInterval.start, rightInterval.start - 1);
|
|
1107
|
+
}
|
|
1108
|
+
if (rightInterval.stop < resultInterval.stop) {
|
|
1109
|
+
afterCurrent = new Interval(rightInterval.stop + 1, resultInterval.stop);
|
|
1110
|
+
}
|
|
1111
|
+
if (beforeCurrent) {
|
|
1112
|
+
if (afterCurrent) {
|
|
1113
|
+
result.intervals[resultI] = beforeCurrent;
|
|
1114
|
+
result.intervals.splice(resultI + 1, 0, afterCurrent);
|
|
1115
|
+
resultI++;
|
|
1116
|
+
rightI++;
|
|
1117
|
+
} else {
|
|
1118
|
+
result.intervals[resultI] = beforeCurrent;
|
|
1119
|
+
resultI++;
|
|
1120
|
+
}
|
|
1121
|
+
} else {
|
|
1122
|
+
if (afterCurrent) {
|
|
1123
|
+
result.intervals[resultI] = afterCurrent;
|
|
1124
|
+
rightI++;
|
|
1125
|
+
} else {
|
|
1126
|
+
result.intervals.splice(resultI, 1);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
return result;
|
|
1131
|
+
}
|
|
1132
|
+
contains(el) {
|
|
1133
|
+
const n2 = this.intervals.length;
|
|
1134
|
+
let l = 0;
|
|
1135
|
+
let r = n2 - 1;
|
|
1136
|
+
while (l <= r) {
|
|
1137
|
+
const m2 = Math.floor((l + r) / 2);
|
|
1138
|
+
const interval = this.intervals[m2];
|
|
1139
|
+
if (interval.stop < el) {
|
|
1140
|
+
l = m2 + 1;
|
|
1141
|
+
} else if (interval.start > el) {
|
|
1142
|
+
r = m2 - 1;
|
|
1143
|
+
} else {
|
|
1144
|
+
return true;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
return false;
|
|
1148
|
+
}
|
|
1149
|
+
removeRange(toRemove) {
|
|
1150
|
+
this.cachedHashCode = void 0;
|
|
1151
|
+
if (toRemove.start === toRemove.stop) {
|
|
1152
|
+
this.removeOne(toRemove.start);
|
|
1153
|
+
} else if (this.intervals !== null) {
|
|
1154
|
+
let pos = 0;
|
|
1155
|
+
for (const existing of this.intervals) {
|
|
1156
|
+
if (toRemove.stop <= existing.start) {
|
|
1157
|
+
return;
|
|
1158
|
+
} else if (toRemove.start > existing.start && toRemove.stop < existing.stop) {
|
|
1159
|
+
this.intervals[pos] = new Interval(existing.start, toRemove.start);
|
|
1160
|
+
const x = new Interval(toRemove.stop, existing.stop);
|
|
1161
|
+
this.intervals.splice(pos, 0, x);
|
|
1162
|
+
return;
|
|
1163
|
+
} else if (toRemove.start <= existing.start && toRemove.stop >= existing.stop) {
|
|
1164
|
+
this.intervals.splice(pos, 1);
|
|
1165
|
+
pos = pos - 1;
|
|
1166
|
+
} else if (toRemove.start < existing.stop) {
|
|
1167
|
+
this.intervals[pos] = new Interval(existing.start, toRemove.start);
|
|
1168
|
+
} else if (toRemove.stop < existing.stop) {
|
|
1169
|
+
this.intervals[pos] = new Interval(toRemove.stop, existing.stop);
|
|
1170
|
+
}
|
|
1171
|
+
pos += 1;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
removeOne(value) {
|
|
1176
|
+
this.cachedHashCode = void 0;
|
|
1177
|
+
for (let i = 0; i < this.intervals.length; i++) {
|
|
1178
|
+
const existing = this.intervals[i];
|
|
1179
|
+
if (value < existing.start) {
|
|
1180
|
+
return;
|
|
1181
|
+
} else if (value === existing.start && value === existing.stop) {
|
|
1182
|
+
this.intervals.splice(i, 1);
|
|
1183
|
+
return;
|
|
1184
|
+
} else if (value === existing.start) {
|
|
1185
|
+
this.intervals[i] = new Interval(existing.start + 1, existing.stop);
|
|
1186
|
+
return;
|
|
1187
|
+
} else if (value === existing.stop) {
|
|
1188
|
+
this.intervals[i] = new Interval(existing.start, existing.stop - 1);
|
|
1189
|
+
return;
|
|
1190
|
+
} else if (value < existing.stop) {
|
|
1191
|
+
const replace = new Interval(existing.start, value - 1);
|
|
1192
|
+
this.intervals[i] = new Interval(value + 1, existing.stop);
|
|
1193
|
+
this.intervals.splice(i, 0, replace);
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
hashCode() {
|
|
1199
|
+
if (this.cachedHashCode === void 0) {
|
|
1200
|
+
let hash = MurmurHash.initialize();
|
|
1201
|
+
for (const interval of this.intervals) {
|
|
1202
|
+
hash = MurmurHash.update(hash, interval.start);
|
|
1203
|
+
hash = MurmurHash.update(hash, interval.stop);
|
|
1204
|
+
}
|
|
1205
|
+
this.cachedHashCode = MurmurHash.finish(hash, this.intervals.length * 2);
|
|
1206
|
+
}
|
|
1207
|
+
return this.cachedHashCode;
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Are two IntervalSets equal? Because all intervals are sorted and disjoint, equals is a simple linear walk over
|
|
1211
|
+
* both lists to make sure they are the same. Interval.equals() is used by the List.equals() method to check
|
|
1212
|
+
* the ranges.
|
|
1213
|
+
*/
|
|
1214
|
+
equals(other) {
|
|
1215
|
+
if (this === other) {
|
|
1216
|
+
return true;
|
|
1217
|
+
}
|
|
1218
|
+
if (this.intervals.length !== other.intervals.length) {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
for (let i = 0; i < this.intervals.length; i++) {
|
|
1222
|
+
if (!this.intervals[i].equals(other.intervals[i])) {
|
|
1223
|
+
return false;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
return true;
|
|
1227
|
+
}
|
|
1228
|
+
toString(elementsAreChar) {
|
|
1229
|
+
if (this.intervals.length === 0) {
|
|
1230
|
+
return "{}";
|
|
1231
|
+
}
|
|
1232
|
+
let result = "";
|
|
1233
|
+
if (this.length > 1) {
|
|
1234
|
+
result += "{";
|
|
1235
|
+
}
|
|
1236
|
+
for (let i = 0; i < this.intervals.length; ++i) {
|
|
1237
|
+
const interval = this.intervals[i];
|
|
1238
|
+
const start = interval.start;
|
|
1239
|
+
const stop = interval.stop;
|
|
1240
|
+
if (start === stop) {
|
|
1241
|
+
if (start === Token.EOF) {
|
|
1242
|
+
result += "<EOF>";
|
|
1243
|
+
} else if (elementsAreChar) {
|
|
1244
|
+
result += "'" + String.fromCodePoint(start) + "'";
|
|
1245
|
+
} else {
|
|
1246
|
+
result += start;
|
|
1247
|
+
}
|
|
1248
|
+
} else {
|
|
1249
|
+
if (elementsAreChar) {
|
|
1250
|
+
result += "'" + String.fromCodePoint(start) + "'..'" + String.fromCodePoint(stop) + "'";
|
|
1251
|
+
} else {
|
|
1252
|
+
result += start + ".." + stop;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
if (i < this.intervals.length - 1) {
|
|
1256
|
+
result += ", ";
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
if (this.length > 1) {
|
|
1260
|
+
result += "}";
|
|
1261
|
+
}
|
|
1262
|
+
return result;
|
|
1263
|
+
}
|
|
1264
|
+
toStringWithVocabulary(vocabulary) {
|
|
1265
|
+
if (this.intervals.length === 0) {
|
|
1266
|
+
return "{}";
|
|
1267
|
+
}
|
|
1268
|
+
let result = "";
|
|
1269
|
+
if (this.length > 1) {
|
|
1270
|
+
result += "{";
|
|
1271
|
+
}
|
|
1272
|
+
for (let i = 0; i < this.intervals.length; ++i) {
|
|
1273
|
+
const interval = this.intervals[i];
|
|
1274
|
+
const start = interval.start;
|
|
1275
|
+
const stop = interval.stop;
|
|
1276
|
+
if (start === stop) {
|
|
1277
|
+
if (start === Token.EOF) {
|
|
1278
|
+
result += "<EOF>";
|
|
1279
|
+
} else {
|
|
1280
|
+
result += this.elementName(vocabulary, start);
|
|
1281
|
+
}
|
|
1282
|
+
} else {
|
|
1283
|
+
for (let i2 = start; i2 <= stop; ++i2) {
|
|
1284
|
+
if (i2 > start) {
|
|
1285
|
+
result += ", ";
|
|
1286
|
+
}
|
|
1287
|
+
result += this.elementName(vocabulary, i2);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
if (i < this.intervals.length - 1) {
|
|
1291
|
+
result += ", ";
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
if (this.length > 1) {
|
|
1295
|
+
result += "}";
|
|
1296
|
+
}
|
|
1297
|
+
return result;
|
|
1298
|
+
}
|
|
1299
|
+
toStringWithRuleNames(ruleNames) {
|
|
1300
|
+
if (this.intervals.length === 0) {
|
|
1301
|
+
return "{}";
|
|
1302
|
+
}
|
|
1303
|
+
let result = "";
|
|
1304
|
+
if (this.length > 1) {
|
|
1305
|
+
result += "{";
|
|
1306
|
+
}
|
|
1307
|
+
const vocabulary = Vocabulary.fromTokenNames(ruleNames);
|
|
1308
|
+
for (let i = 0; i < this.intervals.length; ++i) {
|
|
1309
|
+
const interval = this.intervals[i];
|
|
1310
|
+
const start = interval.start;
|
|
1311
|
+
const stop = interval.stop;
|
|
1312
|
+
if (start === stop) {
|
|
1313
|
+
if (start === Token.EOF) {
|
|
1314
|
+
result += "<EOF>";
|
|
1315
|
+
} else {
|
|
1316
|
+
result += this.elementName(vocabulary, start);
|
|
1317
|
+
}
|
|
1318
|
+
} else {
|
|
1319
|
+
for (let i2 = start; i2 <= stop; ++i2) {
|
|
1320
|
+
if (i2 > start) {
|
|
1321
|
+
result += ", ";
|
|
1322
|
+
}
|
|
1323
|
+
result += this.elementName(vocabulary, i2);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
if (i < this.intervals.length - 1) {
|
|
1327
|
+
result += ", ";
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
if (this.length > 1) {
|
|
1331
|
+
result += "}";
|
|
1332
|
+
}
|
|
1333
|
+
return result;
|
|
1334
|
+
}
|
|
1335
|
+
toArray() {
|
|
1336
|
+
const data = [];
|
|
1337
|
+
for (const interval of this.intervals) {
|
|
1338
|
+
for (let j = interval.start; j <= interval.stop; j++) {
|
|
1339
|
+
data.push(j);
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
return data;
|
|
1343
|
+
}
|
|
1344
|
+
/** @returns the number of elements in this set. */
|
|
1345
|
+
get length() {
|
|
1346
|
+
let result = 0;
|
|
1347
|
+
for (const interval of this.intervals) {
|
|
1348
|
+
result += interval.length;
|
|
1349
|
+
}
|
|
1350
|
+
return result;
|
|
1351
|
+
}
|
|
1352
|
+
elementName(vocabulary, token) {
|
|
1353
|
+
if (token === Token.EOF) {
|
|
1354
|
+
return "<EOF>";
|
|
1355
|
+
}
|
|
1356
|
+
if (token === Token.EPSILON) {
|
|
1357
|
+
return "<EPSILON>";
|
|
1358
|
+
}
|
|
1359
|
+
return vocabulary.getDisplayName(token);
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1362
|
+
|
|
1363
|
+
// src/utils/helpers.ts
|
|
1364
|
+
var equalArrays = /* @__PURE__ */ __name((a, b) => {
|
|
1365
|
+
if (a === b) {
|
|
1366
|
+
return true;
|
|
1367
|
+
}
|
|
1368
|
+
if (a.length !== b.length) {
|
|
1369
|
+
return false;
|
|
1370
|
+
}
|
|
1371
|
+
for (let i = 0; i < a.length; i++) {
|
|
1372
|
+
const left = a[i];
|
|
1373
|
+
const right = b[i];
|
|
1374
|
+
if (left === right) {
|
|
1375
|
+
continue;
|
|
1376
|
+
}
|
|
1377
|
+
if (!left || !left.equals(right)) {
|
|
1378
|
+
return false;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
return true;
|
|
1382
|
+
}, "equalArrays");
|
|
1383
|
+
var escapeWhitespace = /* @__PURE__ */ __name((s, escapeSpaces = false) => {
|
|
1384
|
+
s = s.replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
|
|
1385
|
+
if (escapeSpaces) {
|
|
1386
|
+
s = s.replace(/ /g, "\xB7");
|
|
1387
|
+
}
|
|
1388
|
+
return s;
|
|
1389
|
+
}, "escapeWhitespace");
|
|
1390
|
+
|
|
1391
|
+
// src/atn/SemanticContext.ts
|
|
1392
|
+
var SemanticContext = class _SemanticContext {
|
|
1393
|
+
static {
|
|
1394
|
+
__name(this, "SemanticContext");
|
|
1395
|
+
}
|
|
1396
|
+
cachedHashCode;
|
|
1397
|
+
static andContext(a, b) {
|
|
1398
|
+
if (a === null || a === _SemanticContext.NONE) {
|
|
1399
|
+
return b;
|
|
1400
|
+
}
|
|
1401
|
+
if (b === null || b === _SemanticContext.NONE) {
|
|
1402
|
+
return a;
|
|
1403
|
+
}
|
|
1404
|
+
const result = new AND(a, b);
|
|
1405
|
+
if (result.operands.length === 1) {
|
|
1406
|
+
return result.operands[0];
|
|
1407
|
+
}
|
|
1408
|
+
return result;
|
|
1409
|
+
}
|
|
1410
|
+
static orContext(a, b) {
|
|
1411
|
+
if (a === null) {
|
|
1412
|
+
return b;
|
|
1413
|
+
}
|
|
1414
|
+
if (b === null) {
|
|
1415
|
+
return a;
|
|
1416
|
+
}
|
|
1417
|
+
if (a === _SemanticContext.NONE || b === _SemanticContext.NONE) {
|
|
1418
|
+
return _SemanticContext.NONE;
|
|
1419
|
+
}
|
|
1420
|
+
const result = new OR(a, b);
|
|
1421
|
+
if (result.operands.length === 1) {
|
|
1422
|
+
return result.operands[0];
|
|
1423
|
+
} else {
|
|
1424
|
+
return result;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
static filterPrecedencePredicates(set) {
|
|
1428
|
+
const result = [];
|
|
1429
|
+
for (const context of set) {
|
|
1430
|
+
if (context instanceof _SemanticContext.PrecedencePredicate) {
|
|
1431
|
+
result.push(context);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
return result;
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Evaluate the precedence predicates for the context and reduce the result.
|
|
1438
|
+
*
|
|
1439
|
+
* @param _parser The parser instance.
|
|
1440
|
+
* @param _parserCallStack The current parser context object.
|
|
1441
|
+
* @returns The simplified semantic context after precedence predicates are
|
|
1442
|
+
* evaluated, which will be one of the following values.
|
|
1443
|
+
* - {@link NONE}: if the predicate simplifies to `true` after
|
|
1444
|
+
* precedence predicates are evaluated.
|
|
1445
|
+
* - `null`: if the predicate simplifies to `false` after
|
|
1446
|
+
* precedence predicates are evaluated.
|
|
1447
|
+
* - `this`: if the semantic context is not changed as a result of
|
|
1448
|
+
* precedence predicate evaluation.
|
|
1449
|
+
* - A non-`null` {@link SemanticContext}: the new simplified
|
|
1450
|
+
* semantic context after precedence predicates are evaluated.
|
|
1451
|
+
*/
|
|
1452
|
+
evalPrecedence(_parser, _parserCallStack) {
|
|
1453
|
+
return this;
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
var AND = class _AND extends SemanticContext {
|
|
1457
|
+
static {
|
|
1458
|
+
__name(this, "AND");
|
|
1459
|
+
}
|
|
1460
|
+
operands;
|
|
1461
|
+
/**
|
|
1462
|
+
* A semantic context which is true whenever none of the contained contexts
|
|
1463
|
+
* is false
|
|
1464
|
+
*/
|
|
1465
|
+
constructor(a, b) {
|
|
1466
|
+
super();
|
|
1467
|
+
const operands = new HashSet();
|
|
1468
|
+
if (a instanceof _AND) {
|
|
1469
|
+
a.operands.forEach((o) => {
|
|
1470
|
+
operands.add(o);
|
|
1471
|
+
});
|
|
1472
|
+
} else {
|
|
1473
|
+
operands.add(a);
|
|
1474
|
+
}
|
|
1475
|
+
if (b instanceof _AND) {
|
|
1476
|
+
b.operands.forEach((o) => {
|
|
1477
|
+
operands.add(o);
|
|
1478
|
+
});
|
|
1479
|
+
} else {
|
|
1480
|
+
operands.add(b);
|
|
1481
|
+
}
|
|
1482
|
+
const precedencePredicates = SemanticContext.filterPrecedencePredicates(operands);
|
|
1483
|
+
if (precedencePredicates.length > 0) {
|
|
1484
|
+
let reduced = null;
|
|
1485
|
+
precedencePredicates.forEach((p) => {
|
|
1486
|
+
if (reduced === null || p.precedence < reduced.precedence) {
|
|
1487
|
+
reduced = p;
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
if (reduced) {
|
|
1491
|
+
operands.add(reduced);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
this.operands = operands.toArray();
|
|
1495
|
+
}
|
|
1496
|
+
equals(other) {
|
|
1497
|
+
if (this === other) {
|
|
1498
|
+
return true;
|
|
1499
|
+
}
|
|
1500
|
+
if (!(other instanceof _AND)) {
|
|
1501
|
+
return false;
|
|
1502
|
+
}
|
|
1503
|
+
return equalArrays(this.operands, other.operands);
|
|
1504
|
+
}
|
|
1505
|
+
hashCode() {
|
|
1506
|
+
if (this.cachedHashCode === void 0) {
|
|
1507
|
+
let hash = MurmurHash.initialize();
|
|
1508
|
+
for (const operand of this.operands) {
|
|
1509
|
+
hash = MurmurHash.updateFromComparable(hash, operand);
|
|
1510
|
+
}
|
|
1511
|
+
hash = MurmurHash.update(hash, 3813686060);
|
|
1512
|
+
this.cachedHashCode = MurmurHash.finish(hash, this.operands.length + 1);
|
|
1513
|
+
}
|
|
1514
|
+
return this.cachedHashCode;
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* {@inheritDoc}
|
|
1518
|
+
*
|
|
1519
|
+
*
|
|
1520
|
+
* The evaluation of predicates by this context is short-circuiting, but
|
|
1521
|
+
* unordered.
|
|
1522
|
+
*/
|
|
1523
|
+
evaluate(parser, parserCallStack) {
|
|
1524
|
+
for (const operand of this.operands) {
|
|
1525
|
+
if (!operand.evaluate(parser, parserCallStack)) {
|
|
1526
|
+
return false;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
return true;
|
|
1530
|
+
}
|
|
1531
|
+
evalPrecedence(parser, parserCallStack) {
|
|
1532
|
+
let differs = false;
|
|
1533
|
+
const operands = [];
|
|
1534
|
+
for (const context of this.operands) {
|
|
1535
|
+
const evaluated = context.evalPrecedence(parser, parserCallStack);
|
|
1536
|
+
differs ||= evaluated !== context;
|
|
1537
|
+
if (evaluated === null) {
|
|
1538
|
+
return null;
|
|
1539
|
+
} else if (evaluated !== SemanticContext.NONE) {
|
|
1540
|
+
operands.push(evaluated);
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
if (!differs) {
|
|
1544
|
+
return this;
|
|
1545
|
+
}
|
|
1546
|
+
if (operands.length === 0) {
|
|
1547
|
+
return SemanticContext.NONE;
|
|
1548
|
+
}
|
|
1549
|
+
let result = null;
|
|
1550
|
+
operands.forEach((o) => {
|
|
1551
|
+
result = result === null ? o : SemanticContext.andContext(result, o);
|
|
1552
|
+
});
|
|
1553
|
+
return result;
|
|
1554
|
+
}
|
|
1555
|
+
toString() {
|
|
1556
|
+
const s = this.operands.map((o) => {
|
|
1557
|
+
return o.toString();
|
|
1558
|
+
});
|
|
1559
|
+
return (s.length > 3 ? s.slice(3) : s).join("&&");
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1562
|
+
var OR = class _OR extends SemanticContext {
|
|
1563
|
+
static {
|
|
1564
|
+
__name(this, "OR");
|
|
1565
|
+
}
|
|
1566
|
+
operands;
|
|
1567
|
+
/**
|
|
1568
|
+
* A semantic context which is true whenever at least one of the contained
|
|
1569
|
+
* contexts is true
|
|
1570
|
+
*/
|
|
1571
|
+
constructor(a, b) {
|
|
1572
|
+
super();
|
|
1573
|
+
const operands = new HashSet();
|
|
1574
|
+
if (a instanceof _OR) {
|
|
1575
|
+
a.operands.forEach((o) => {
|
|
1576
|
+
operands.add(o);
|
|
1577
|
+
});
|
|
1578
|
+
} else {
|
|
1579
|
+
operands.add(a);
|
|
1580
|
+
}
|
|
1581
|
+
if (b instanceof _OR) {
|
|
1582
|
+
b.operands.forEach((o) => {
|
|
1583
|
+
operands.add(o);
|
|
1584
|
+
});
|
|
1585
|
+
} else {
|
|
1586
|
+
operands.add(b);
|
|
1587
|
+
}
|
|
1588
|
+
const precedencePredicates = SemanticContext.filterPrecedencePredicates(operands);
|
|
1589
|
+
if (precedencePredicates.length > 0) {
|
|
1590
|
+
const s = precedencePredicates.sort((a2, b2) => {
|
|
1591
|
+
return a2.compareTo(b2);
|
|
1592
|
+
});
|
|
1593
|
+
const reduced = s[s.length - 1];
|
|
1594
|
+
operands.add(reduced);
|
|
1595
|
+
}
|
|
1596
|
+
this.operands = operands.toArray();
|
|
1597
|
+
}
|
|
1598
|
+
equals(other) {
|
|
1599
|
+
if (this === other) {
|
|
1600
|
+
return true;
|
|
1601
|
+
} else if (!(other instanceof _OR)) {
|
|
1602
|
+
return false;
|
|
1603
|
+
} else {
|
|
1604
|
+
return equalArrays(this.operands, other.operands);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
hashCode() {
|
|
1608
|
+
if (this.cachedHashCode === void 0) {
|
|
1609
|
+
let hash = MurmurHash.initialize();
|
|
1610
|
+
for (const operand of this.operands) {
|
|
1611
|
+
hash = MurmurHash.updateFromComparable(hash, operand);
|
|
1612
|
+
}
|
|
1613
|
+
hash = MurmurHash.update(hash, 3383313031);
|
|
1614
|
+
this.cachedHashCode = MurmurHash.finish(hash, this.operands.length + 1);
|
|
1615
|
+
}
|
|
1616
|
+
return this.cachedHashCode;
|
|
1617
|
+
}
|
|
1618
|
+
/**
|
|
1619
|
+
* The evaluation of predicates by this context is short-circuiting, but unordered.
|
|
1620
|
+
*/
|
|
1621
|
+
evaluate(parser, parserCallStack) {
|
|
1622
|
+
for (const operand of this.operands) {
|
|
1623
|
+
if (operand.evaluate(parser, parserCallStack)) {
|
|
1624
|
+
return true;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
return false;
|
|
1628
|
+
}
|
|
1629
|
+
evalPrecedence(parser, parserCallStack) {
|
|
1630
|
+
let differs = false;
|
|
1631
|
+
const operands = [];
|
|
1632
|
+
for (const context of this.operands) {
|
|
1633
|
+
const evaluated = context.evalPrecedence(parser, parserCallStack);
|
|
1634
|
+
differs ||= evaluated !== context;
|
|
1635
|
+
if (evaluated === SemanticContext.NONE) {
|
|
1636
|
+
return SemanticContext.NONE;
|
|
1637
|
+
} else if (evaluated !== null) {
|
|
1638
|
+
operands.push(evaluated);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
if (!differs) {
|
|
1642
|
+
return this;
|
|
1643
|
+
}
|
|
1644
|
+
if (operands.length === 0) {
|
|
1645
|
+
return null;
|
|
1646
|
+
}
|
|
1647
|
+
let result = null;
|
|
1648
|
+
operands.forEach((o) => {
|
|
1649
|
+
result = result === null ? o : SemanticContext.orContext(result, o);
|
|
1650
|
+
});
|
|
1651
|
+
return result;
|
|
1652
|
+
}
|
|
1653
|
+
toString() {
|
|
1654
|
+
const s = this.operands.map((o) => {
|
|
1655
|
+
return o.toString();
|
|
1656
|
+
});
|
|
1657
|
+
return (s.length > 3 ? s.slice(3) : s).join("||");
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
((SemanticContext2) => {
|
|
1661
|
+
class Predicate extends SemanticContext2 {
|
|
1662
|
+
static {
|
|
1663
|
+
__name(this, "Predicate");
|
|
1664
|
+
}
|
|
1665
|
+
ruleIndex;
|
|
1666
|
+
predIndex;
|
|
1667
|
+
isCtxDependent;
|
|
1668
|
+
// e.g., $i ref in pred
|
|
1669
|
+
constructor(ruleIndex, predIndex, isCtxDependent) {
|
|
1670
|
+
super();
|
|
1671
|
+
this.ruleIndex = ruleIndex ?? -1;
|
|
1672
|
+
this.predIndex = predIndex ?? -1;
|
|
1673
|
+
this.isCtxDependent = isCtxDependent ?? false;
|
|
1674
|
+
}
|
|
1675
|
+
evaluate(parser, outerContext) {
|
|
1676
|
+
const localctx = this.isCtxDependent ? outerContext : null;
|
|
1677
|
+
return parser.sempred(localctx, this.ruleIndex, this.predIndex);
|
|
1678
|
+
}
|
|
1679
|
+
hashCode() {
|
|
1680
|
+
if (this.cachedHashCode === void 0) {
|
|
1681
|
+
let hashCode = MurmurHash.initialize();
|
|
1682
|
+
hashCode = MurmurHash.update(hashCode, this.ruleIndex);
|
|
1683
|
+
hashCode = MurmurHash.update(hashCode, this.predIndex);
|
|
1684
|
+
hashCode = MurmurHash.update(hashCode, this.isCtxDependent ? 1 : 0);
|
|
1685
|
+
hashCode = MurmurHash.finish(hashCode, 3);
|
|
1686
|
+
this.cachedHashCode = hashCode;
|
|
1687
|
+
}
|
|
1688
|
+
return this.cachedHashCode;
|
|
1689
|
+
}
|
|
1690
|
+
equals(other) {
|
|
1691
|
+
if (this === other) {
|
|
1692
|
+
return true;
|
|
1693
|
+
}
|
|
1694
|
+
return this.ruleIndex === other.ruleIndex && this.predIndex === other.predIndex && this.isCtxDependent === other.isCtxDependent;
|
|
1695
|
+
}
|
|
1696
|
+
toString() {
|
|
1697
|
+
return "{" + this.ruleIndex + ":" + this.predIndex + "}?";
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
SemanticContext2.Predicate = Predicate;
|
|
1701
|
+
class PrecedencePredicate extends SemanticContext2 {
|
|
1702
|
+
static {
|
|
1703
|
+
__name(this, "PrecedencePredicate");
|
|
1704
|
+
}
|
|
1705
|
+
precedence;
|
|
1706
|
+
constructor(precedence) {
|
|
1707
|
+
super();
|
|
1708
|
+
this.precedence = precedence ?? 0;
|
|
1709
|
+
}
|
|
1710
|
+
evaluate(parser, outerContext) {
|
|
1711
|
+
return parser.precpred(outerContext, this.precedence);
|
|
1712
|
+
}
|
|
1713
|
+
evalPrecedence(parser, outerContext) {
|
|
1714
|
+
if (parser.precpred(outerContext ?? null, this.precedence)) {
|
|
1715
|
+
return SemanticContext2.NONE;
|
|
1716
|
+
}
|
|
1717
|
+
return null;
|
|
1718
|
+
}
|
|
1719
|
+
compareTo(other) {
|
|
1720
|
+
return this.precedence - other.precedence;
|
|
1721
|
+
}
|
|
1722
|
+
hashCode() {
|
|
1723
|
+
return 31 + this.precedence;
|
|
1724
|
+
}
|
|
1725
|
+
equals(other) {
|
|
1726
|
+
if (this === other) {
|
|
1727
|
+
return true;
|
|
1728
|
+
}
|
|
1729
|
+
return this.precedence === other.precedence;
|
|
1730
|
+
}
|
|
1731
|
+
toString() {
|
|
1732
|
+
return "{" + this.precedence + ">=prec}?";
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
SemanticContext2.PrecedencePredicate = PrecedencePredicate;
|
|
1736
|
+
SemanticContext2.NONE = new Predicate();
|
|
1737
|
+
})(SemanticContext || (SemanticContext = {}));
|
|
1738
|
+
|
|
1739
|
+
// src/atn/ATNConfig.ts
|
|
1740
|
+
var ATNConfig = class _ATNConfig {
|
|
1741
|
+
static {
|
|
1742
|
+
__name(this, "ATNConfig");
|
|
1743
|
+
}
|
|
1744
|
+
/** The ATN state associated with this configuration */
|
|
1745
|
+
state;
|
|
1746
|
+
/** What alt (or lexer rule) is predicted by this configuration */
|
|
1747
|
+
alt;
|
|
1748
|
+
/**
|
|
1749
|
+
* We cannot execute predicates dependent upon local context unless
|
|
1750
|
+
* we know for sure we are in the correct context. Because there is
|
|
1751
|
+
* no way to do this efficiently, we simply cannot evaluate
|
|
1752
|
+
* dependent predicates unless we are in the rule that initially
|
|
1753
|
+
* invokes the ATN simulator.
|
|
1754
|
+
*
|
|
1755
|
+
* closure() tracks the depth of how far we dip into the outer context:
|
|
1756
|
+
* depth > 0.
|
|
1757
|
+
*/
|
|
1758
|
+
reachesIntoOuterContext = false;
|
|
1759
|
+
// Not used in hash code.
|
|
1760
|
+
precedenceFilterSuppressed = false;
|
|
1761
|
+
// Not used in hash code.
|
|
1762
|
+
get semanticContext() {
|
|
1763
|
+
return this.#semanticContext;
|
|
1764
|
+
}
|
|
1765
|
+
cachedHashCode;
|
|
1766
|
+
// Shared with LexerATNConfig.
|
|
1767
|
+
/**
|
|
1768
|
+
* The syntactic context is a graph-structured stack node whose
|
|
1769
|
+
* path(s) to the root is the rule invocation(s)
|
|
1770
|
+
* chain used to arrive at the state. The semantic context is
|
|
1771
|
+
* the tree of semantic predicates encountered before reaching
|
|
1772
|
+
* an ATN state
|
|
1773
|
+
*/
|
|
1774
|
+
#context = null;
|
|
1775
|
+
#semanticContext;
|
|
1776
|
+
/** Never create config classes directly. Use the factory methods below. */
|
|
1777
|
+
constructor(c, state, context, semanticContext) {
|
|
1778
|
+
this.state = state;
|
|
1779
|
+
this.alt = c.alt;
|
|
1780
|
+
this.context = context;
|
|
1781
|
+
this.#semanticContext = semanticContext ?? SemanticContext.NONE;
|
|
1782
|
+
this.reachesIntoOuterContext = c.reachesIntoOuterContext;
|
|
1783
|
+
if (c.precedenceFilterSuppressed !== void 0) {
|
|
1784
|
+
this.precedenceFilterSuppressed = c.precedenceFilterSuppressed;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
static duplicate(old, semanticContext) {
|
|
1788
|
+
return new _ATNConfig(old, old.state, old.context, semanticContext ?? old.semanticContext);
|
|
1789
|
+
}
|
|
1790
|
+
static createWithContext(state, alt, context, semanticContext) {
|
|
1791
|
+
return new _ATNConfig({ alt }, state, context, semanticContext);
|
|
1792
|
+
}
|
|
1793
|
+
static createWithConfig(state, config, context) {
|
|
1794
|
+
return new _ATNConfig(config, state, context ?? config.context, config.semanticContext);
|
|
1795
|
+
}
|
|
1796
|
+
static createWithSemanticContext(state, c, semanticContext) {
|
|
1797
|
+
return new _ATNConfig(c, state ?? c.state, c.context, semanticContext);
|
|
1798
|
+
}
|
|
1799
|
+
hashCode() {
|
|
1800
|
+
if (this.cachedHashCode === void 0) {
|
|
1801
|
+
let hashCode = MurmurHash.initialize(7);
|
|
1802
|
+
hashCode = MurmurHash.update(hashCode, this.state.stateNumber);
|
|
1803
|
+
hashCode = MurmurHash.update(hashCode, this.alt);
|
|
1804
|
+
hashCode = MurmurHash.updateFromComparable(hashCode, this.#context);
|
|
1805
|
+
hashCode = MurmurHash.updateFromComparable(hashCode, this.semanticContext);
|
|
1806
|
+
hashCode = MurmurHash.finish(hashCode, 4);
|
|
1807
|
+
this.cachedHashCode = hashCode;
|
|
1808
|
+
}
|
|
1809
|
+
return this.cachedHashCode;
|
|
1810
|
+
}
|
|
1811
|
+
/**
|
|
1812
|
+
* The stack of invoking states leading to the rule/states associated
|
|
1813
|
+
* with this config. We track only those contexts pushed during
|
|
1814
|
+
* execution of the ATN simulator.
|
|
1815
|
+
*/
|
|
1816
|
+
get context() {
|
|
1817
|
+
return this.#context;
|
|
1818
|
+
}
|
|
1819
|
+
set context(context) {
|
|
1820
|
+
this.#context = context;
|
|
1821
|
+
this.cachedHashCode = void 0;
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* An ATN configuration is equal to another if both have
|
|
1825
|
+
* the same state, they predict the same alternative, and
|
|
1826
|
+
* syntactic/semantic contexts are the same.
|
|
1827
|
+
*/
|
|
1828
|
+
equals(other) {
|
|
1829
|
+
if (this === other) {
|
|
1830
|
+
return true;
|
|
1831
|
+
}
|
|
1832
|
+
return this.state.stateNumber === other.state.stateNumber && this.alt === other.alt && (this.context === null ? other.context === null : this.context.equals(other.context)) && this.semanticContext.equals(other.semanticContext) && this.precedenceFilterSuppressed === other.precedenceFilterSuppressed;
|
|
1833
|
+
}
|
|
1834
|
+
toString(_recog, showAlt = true) {
|
|
1835
|
+
let alt = "";
|
|
1836
|
+
if (showAlt) {
|
|
1837
|
+
alt = "," + this.alt;
|
|
1838
|
+
}
|
|
1839
|
+
return "(" + this.state + alt + (this.context !== null ? ",[" + this.context.toString() + "]" : "") + (this.semanticContext !== SemanticContext.NONE ? "," + this.semanticContext.toString() : "") + (this.reachesIntoOuterContext ? ",up=" + this.reachesIntoOuterContext : "") + ")";
|
|
1840
|
+
}
|
|
1841
|
+
};
|
|
1842
|
+
|
|
1843
|
+
// src/atn/ATNState.ts
|
|
1844
|
+
var ATNState = class _ATNState {
|
|
1845
|
+
static {
|
|
1846
|
+
__name(this, "ATNState");
|
|
1847
|
+
}
|
|
1848
|
+
static INVALID_STATE_NUMBER = -1;
|
|
1849
|
+
static INVALID_TYPE = 0;
|
|
1850
|
+
static BASIC = 1;
|
|
1851
|
+
static RULE_START = 2;
|
|
1852
|
+
static BLOCK_START = 3;
|
|
1853
|
+
static PLUS_BLOCK_START = 4;
|
|
1854
|
+
static STAR_BLOCK_START = 5;
|
|
1855
|
+
static TOKEN_START = 6;
|
|
1856
|
+
static RULE_STOP = 7;
|
|
1857
|
+
static BLOCK_END = 8;
|
|
1858
|
+
static STAR_LOOP_BACK = 9;
|
|
1859
|
+
static STAR_LOOP_ENTRY = 10;
|
|
1860
|
+
static PLUS_LOOP_BACK = 11;
|
|
1861
|
+
static LOOP_END = 12;
|
|
1862
|
+
static stateType = _ATNState.INVALID_STATE_NUMBER;
|
|
1863
|
+
stateNumber = 0;
|
|
1864
|
+
ruleIndex = 0;
|
|
1865
|
+
// at runtime, we don't have Rule objects
|
|
1866
|
+
epsilonOnlyTransitions = false;
|
|
1867
|
+
/** Used to cache lookahead during parsing, not used during construction */
|
|
1868
|
+
nextTokenWithinRule;
|
|
1869
|
+
/** Track the transitions emanating from this ATN state. */
|
|
1870
|
+
transitions = [];
|
|
1871
|
+
hashCode() {
|
|
1872
|
+
return this.stateNumber;
|
|
1873
|
+
}
|
|
1874
|
+
equals(other) {
|
|
1875
|
+
return this.stateNumber === other.stateNumber;
|
|
1876
|
+
}
|
|
1877
|
+
toString() {
|
|
1878
|
+
return `${this.stateNumber}`;
|
|
1879
|
+
}
|
|
1880
|
+
addTransitionAtIndex(index, transition) {
|
|
1881
|
+
if (this.transitions.length === 0) {
|
|
1882
|
+
this.epsilonOnlyTransitions = transition.isEpsilon;
|
|
1883
|
+
} else if (this.epsilonOnlyTransitions !== transition.isEpsilon) {
|
|
1884
|
+
this.epsilonOnlyTransitions = false;
|
|
1885
|
+
}
|
|
1886
|
+
this.transitions.splice(index, 1, transition);
|
|
1887
|
+
}
|
|
1888
|
+
addTransition(transition) {
|
|
1889
|
+
if (this.transitions.length === 0) {
|
|
1890
|
+
this.epsilonOnlyTransitions = transition.isEpsilon;
|
|
1891
|
+
} else if (this.epsilonOnlyTransitions !== transition.isEpsilon) {
|
|
1892
|
+
this.epsilonOnlyTransitions = false;
|
|
1893
|
+
}
|
|
1894
|
+
this.transitions.push(transition);
|
|
1895
|
+
}
|
|
1896
|
+
setTransition(i, e) {
|
|
1897
|
+
this.transitions.splice(i, 1, e);
|
|
1898
|
+
}
|
|
1899
|
+
removeTransition(index) {
|
|
1900
|
+
const t = this.transitions.splice(index, 1);
|
|
1901
|
+
return t[0];
|
|
1902
|
+
}
|
|
1903
|
+
};
|
|
1904
|
+
|
|
1905
|
+
// src/atn/PredictionContext.ts
|
|
1906
|
+
var PredictionContext = class _PredictionContext {
|
|
1907
|
+
static {
|
|
1908
|
+
__name(this, "PredictionContext");
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* Represents `$` in an array in full context mode, when `$`
|
|
1912
|
+
* doesn't mean wildcard: `$ + x = [$,x]`. Here,
|
|
1913
|
+
* `$` = {@link EMPTY_RETURN_STATE}.
|
|
1914
|
+
*/
|
|
1915
|
+
static EMPTY_RETURN_STATE = 2147483647;
|
|
1916
|
+
static traceATNSimulator = false;
|
|
1917
|
+
cachedHashCode;
|
|
1918
|
+
constructor(cachedHashCode) {
|
|
1919
|
+
this.cachedHashCode = cachedHashCode;
|
|
1920
|
+
}
|
|
1921
|
+
static calculateEmptyHashCode() {
|
|
1922
|
+
let hash = MurmurHash.initialize(31);
|
|
1923
|
+
hash = MurmurHash.finish(hash, 0);
|
|
1924
|
+
return hash;
|
|
1925
|
+
}
|
|
1926
|
+
static calculateHashCodeSingle(parent, returnState) {
|
|
1927
|
+
let hash = MurmurHash.initialize(31);
|
|
1928
|
+
hash = MurmurHash.updateFromComparable(hash, parent);
|
|
1929
|
+
hash = MurmurHash.update(hash, returnState);
|
|
1930
|
+
hash = MurmurHash.finish(hash, 2);
|
|
1931
|
+
return hash;
|
|
1932
|
+
}
|
|
1933
|
+
static calculateHashCodeList(parents, returnStates) {
|
|
1934
|
+
let hash = MurmurHash.initialize(31);
|
|
1935
|
+
for (const parent of parents) {
|
|
1936
|
+
hash = MurmurHash.updateFromComparable(hash, parent);
|
|
1937
|
+
}
|
|
1938
|
+
for (const returnState of returnStates) {
|
|
1939
|
+
hash = MurmurHash.update(hash, returnState);
|
|
1940
|
+
}
|
|
1941
|
+
hash = MurmurHash.finish(hash, 2 * parents.length);
|
|
1942
|
+
return hash;
|
|
1943
|
+
}
|
|
1944
|
+
isEmpty() {
|
|
1945
|
+
return false;
|
|
1946
|
+
}
|
|
1947
|
+
hasEmptyPath() {
|
|
1948
|
+
return this.getReturnState(this.length - 1) === _PredictionContext.EMPTY_RETURN_STATE;
|
|
1949
|
+
}
|
|
1950
|
+
hashCode() {
|
|
1951
|
+
return this.cachedHashCode;
|
|
1952
|
+
}
|
|
1953
|
+
toString(_recog) {
|
|
1954
|
+
return "";
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
|
|
1958
|
+
// src/atn/SingletonPredictionContext.ts
|
|
1959
|
+
var SingletonPredictionContext = class _SingletonPredictionContext extends PredictionContext {
|
|
1960
|
+
static {
|
|
1961
|
+
__name(this, "SingletonPredictionContext");
|
|
1962
|
+
}
|
|
1963
|
+
parent;
|
|
1964
|
+
returnState;
|
|
1965
|
+
constructor(parent, returnState) {
|
|
1966
|
+
super(
|
|
1967
|
+
parent ? PredictionContext.calculateHashCodeSingle(parent, returnState) : PredictionContext.calculateEmptyHashCode()
|
|
1968
|
+
);
|
|
1969
|
+
this.parent = parent ?? null;
|
|
1970
|
+
this.returnState = returnState;
|
|
1971
|
+
}
|
|
1972
|
+
getParent(_index) {
|
|
1973
|
+
return this.parent;
|
|
1974
|
+
}
|
|
1975
|
+
getReturnState(_index) {
|
|
1976
|
+
return this.returnState;
|
|
1977
|
+
}
|
|
1978
|
+
equals(other) {
|
|
1979
|
+
if (this === other) {
|
|
1980
|
+
return true;
|
|
1981
|
+
}
|
|
1982
|
+
if (!(other instanceof _SingletonPredictionContext)) {
|
|
1983
|
+
return false;
|
|
1984
|
+
}
|
|
1985
|
+
if (this.hashCode() !== other.hashCode()) {
|
|
1986
|
+
return false;
|
|
1987
|
+
}
|
|
1988
|
+
if (this.returnState !== other.returnState) {
|
|
1989
|
+
return false;
|
|
1990
|
+
}
|
|
1991
|
+
if (this.parent == null) {
|
|
1992
|
+
return other.parent == null;
|
|
1993
|
+
}
|
|
1994
|
+
return this.parent.equals(other.parent);
|
|
1995
|
+
}
|
|
1996
|
+
toString() {
|
|
1997
|
+
const up = this.parent === null ? "" : this.parent.toString();
|
|
1998
|
+
if (up.length === 0) {
|
|
1999
|
+
if (this.returnState === PredictionContext.EMPTY_RETURN_STATE) {
|
|
2000
|
+
return "$";
|
|
2001
|
+
}
|
|
2002
|
+
return "" + this.returnState;
|
|
2003
|
+
} else {
|
|
2004
|
+
return "" + this.returnState + " " + up;
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
get length() {
|
|
2008
|
+
return 1;
|
|
2009
|
+
}
|
|
2010
|
+
};
|
|
2011
|
+
|
|
2012
|
+
// src/atn/EmptyPredictionContext.ts
|
|
2013
|
+
var EmptyPredictionContext = class _EmptyPredictionContext extends SingletonPredictionContext {
|
|
2014
|
+
static {
|
|
2015
|
+
__name(this, "EmptyPredictionContext");
|
|
2016
|
+
}
|
|
2017
|
+
/**
|
|
2018
|
+
* Represents `$` in local context prediction, which means wildcard.
|
|
2019
|
+
* `*+x = *`.
|
|
2020
|
+
*/
|
|
2021
|
+
static instance = new _EmptyPredictionContext();
|
|
2022
|
+
constructor() {
|
|
2023
|
+
super(void 0, PredictionContext.EMPTY_RETURN_STATE);
|
|
2024
|
+
}
|
|
2025
|
+
isEmpty() {
|
|
2026
|
+
return true;
|
|
2027
|
+
}
|
|
2028
|
+
getParent() {
|
|
2029
|
+
return null;
|
|
2030
|
+
}
|
|
2031
|
+
getReturnState() {
|
|
2032
|
+
return this.returnState;
|
|
2033
|
+
}
|
|
2034
|
+
equals(other) {
|
|
2035
|
+
return this === other;
|
|
2036
|
+
}
|
|
2037
|
+
toString() {
|
|
2038
|
+
return "$";
|
|
2039
|
+
}
|
|
2040
|
+
};
|
|
2041
|
+
|
|
2042
|
+
// src/atn/Transition.ts
|
|
2043
|
+
var Transition = class {
|
|
2044
|
+
static {
|
|
2045
|
+
__name(this, "Transition");
|
|
2046
|
+
}
|
|
2047
|
+
static INVALID = 0;
|
|
2048
|
+
static EPSILON = 1;
|
|
2049
|
+
static RANGE = 2;
|
|
2050
|
+
static RULE = 3;
|
|
2051
|
+
static PREDICATE = 4;
|
|
2052
|
+
// e.g., {isType(input.LT(1))}
|
|
2053
|
+
static ATOM = 5;
|
|
2054
|
+
static ACTION = 6;
|
|
2055
|
+
static SET = 7;
|
|
2056
|
+
// ~(A|B) or ~atom, wildcard, which convert to next
|
|
2057
|
+
static NOT_SET = 8;
|
|
2058
|
+
static WILDCARD = 9;
|
|
2059
|
+
static PRECEDENCE = 10;
|
|
2060
|
+
/** The target of this transition. */
|
|
2061
|
+
target;
|
|
2062
|
+
constructor(target) {
|
|
2063
|
+
this.target = target;
|
|
2064
|
+
}
|
|
2065
|
+
/**
|
|
2066
|
+
* Determines if the transition is an "epsilon" transition.
|
|
2067
|
+
*
|
|
2068
|
+
* The default implementation returns `false`.
|
|
2069
|
+
*
|
|
2070
|
+
* @returns `true` if traversing this transition in the ATN does not
|
|
2071
|
+
* consume an input symbol; otherwise, `false` if traversing this
|
|
2072
|
+
* transition consumes (matches) an input symbol.
|
|
2073
|
+
*/
|
|
2074
|
+
get isEpsilon() {
|
|
2075
|
+
return false;
|
|
2076
|
+
}
|
|
2077
|
+
get label() {
|
|
2078
|
+
return null;
|
|
2079
|
+
}
|
|
2080
|
+
toString() {
|
|
2081
|
+
return "";
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
2084
|
+
|
|
2085
|
+
// src/atn/SetTransition.ts
|
|
2086
|
+
var SetTransition = class extends Transition {
|
|
2087
|
+
static {
|
|
2088
|
+
__name(this, "SetTransition");
|
|
2089
|
+
}
|
|
2090
|
+
set;
|
|
2091
|
+
constructor(target, set) {
|
|
2092
|
+
super(target);
|
|
2093
|
+
if (set) {
|
|
2094
|
+
this.set = set;
|
|
2095
|
+
} else {
|
|
2096
|
+
this.set = IntervalSet.of(Token.INVALID_TYPE, Token.INVALID_TYPE);
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
get transitionType() {
|
|
2100
|
+
return Transition.SET;
|
|
2101
|
+
}
|
|
2102
|
+
get label() {
|
|
2103
|
+
return this.set;
|
|
2104
|
+
}
|
|
2105
|
+
matches(symbol, _minVocabSymbol, _maxVocabSymbol) {
|
|
2106
|
+
return this.set.contains(symbol);
|
|
2107
|
+
}
|
|
2108
|
+
toString() {
|
|
2109
|
+
return this.set.toString();
|
|
2110
|
+
}
|
|
2111
|
+
};
|
|
2112
|
+
|
|
2113
|
+
// src/atn/NotSetTransition.ts
|
|
2114
|
+
var NotSetTransition = class extends SetTransition {
|
|
2115
|
+
static {
|
|
2116
|
+
__name(this, "NotSetTransition");
|
|
2117
|
+
}
|
|
2118
|
+
get transitionType() {
|
|
2119
|
+
return Transition.NOT_SET;
|
|
2120
|
+
}
|
|
2121
|
+
matches(symbol, minVocabSymbol, maxVocabSymbol) {
|
|
2122
|
+
return symbol >= minVocabSymbol && symbol <= maxVocabSymbol && !super.matches(symbol, minVocabSymbol, maxVocabSymbol);
|
|
2123
|
+
}
|
|
2124
|
+
toString() {
|
|
2125
|
+
return "~" + super.toString();
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
|
|
2129
|
+
// src/tree/TerminalNode.ts
|
|
2130
|
+
var TerminalNode = class {
|
|
2131
|
+
static {
|
|
2132
|
+
__name(this, "TerminalNode");
|
|
2133
|
+
}
|
|
2134
|
+
parent = null;
|
|
2135
|
+
symbol;
|
|
2136
|
+
constructor(symbol) {
|
|
2137
|
+
this.symbol = symbol;
|
|
2138
|
+
}
|
|
2139
|
+
getChild(_i) {
|
|
2140
|
+
return null;
|
|
2141
|
+
}
|
|
2142
|
+
getSymbol() {
|
|
2143
|
+
return this.symbol;
|
|
2144
|
+
}
|
|
2145
|
+
getPayload() {
|
|
2146
|
+
return this.symbol;
|
|
2147
|
+
}
|
|
2148
|
+
getSourceInterval() {
|
|
2149
|
+
if (this.symbol === null) {
|
|
2150
|
+
return Interval.INVALID_INTERVAL;
|
|
2151
|
+
}
|
|
2152
|
+
const tokenIndex = this.symbol.tokenIndex;
|
|
2153
|
+
return new Interval(tokenIndex, tokenIndex);
|
|
2154
|
+
}
|
|
2155
|
+
getChildCount() {
|
|
2156
|
+
return 0;
|
|
2157
|
+
}
|
|
2158
|
+
accept(visitor) {
|
|
2159
|
+
return visitor.visitTerminal(this);
|
|
2160
|
+
}
|
|
2161
|
+
getText() {
|
|
2162
|
+
return this.symbol?.text ?? "";
|
|
2163
|
+
}
|
|
2164
|
+
toString() {
|
|
2165
|
+
if (this.symbol?.type === Token.EOF) {
|
|
2166
|
+
return "<EOF>";
|
|
2167
|
+
} else {
|
|
2168
|
+
return this.symbol?.text ?? "";
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
toStringTree() {
|
|
2172
|
+
return this.toString();
|
|
2173
|
+
}
|
|
2174
|
+
};
|
|
2175
|
+
|
|
2176
|
+
// src/tree/ErrorNode.ts
|
|
2177
|
+
var ErrorNode = class extends TerminalNode {
|
|
2178
|
+
static {
|
|
2179
|
+
__name(this, "ErrorNode");
|
|
2180
|
+
}
|
|
2181
|
+
accept(visitor) {
|
|
2182
|
+
return visitor.visitErrorNode(this);
|
|
2183
|
+
}
|
|
2184
|
+
};
|
|
2185
|
+
|
|
2186
|
+
// src/CommonToken.ts
|
|
2187
|
+
var CommonToken = class _CommonToken {
|
|
2188
|
+
static {
|
|
2189
|
+
__name(this, "CommonToken");
|
|
2190
|
+
}
|
|
2191
|
+
/**
|
|
2192
|
+
* An empty tuple which is used as the default value of
|
|
2193
|
+
* {@link source} for tokens that do not have a source.
|
|
2194
|
+
*/
|
|
2195
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2196
|
+
static EMPTY_SOURCE = [null, null];
|
|
2197
|
+
/**
|
|
2198
|
+
* These properties share a field to reduce the memory footprint of
|
|
2199
|
+
* {@link CommonToken}. Tokens created by a {@link CommonTokenFactory} from
|
|
2200
|
+
* the same source and input stream share a reference to the same
|
|
2201
|
+
* {@link Pair} containing these values.
|
|
2202
|
+
*/
|
|
2203
|
+
source;
|
|
2204
|
+
tokenIndex;
|
|
2205
|
+
start;
|
|
2206
|
+
stop;
|
|
2207
|
+
/**
|
|
2208
|
+
* This is the backing field for {@link #getType} and {@link #setType}.
|
|
2209
|
+
*/
|
|
2210
|
+
type;
|
|
2211
|
+
/**
|
|
2212
|
+
* The (one-based) line number on which the 1st character of this token was.
|
|
2213
|
+
*/
|
|
2214
|
+
line;
|
|
2215
|
+
/**
|
|
2216
|
+
* The zero-based index of the first character position in its line.
|
|
2217
|
+
*/
|
|
2218
|
+
column;
|
|
2219
|
+
/**
|
|
2220
|
+
* The token's channel.
|
|
2221
|
+
*/
|
|
2222
|
+
channel;
|
|
2223
|
+
/**
|
|
2224
|
+
* This is the backing field for {@link getText} when the token text is
|
|
2225
|
+
* explicitly set in the constructor or via {@link setText}.
|
|
2226
|
+
*/
|
|
2227
|
+
#text;
|
|
2228
|
+
constructor(details) {
|
|
2229
|
+
this.type = details.type;
|
|
2230
|
+
this.source = details.source;
|
|
2231
|
+
this.tokenIndex = details.tokenIndex ?? -1;
|
|
2232
|
+
this.line = details.line ?? 0;
|
|
2233
|
+
this.column = details.column ?? -1;
|
|
2234
|
+
this.channel = details.channel ?? Token.DEFAULT_CHANNEL;
|
|
2235
|
+
this.start = details.start ?? 0;
|
|
2236
|
+
this.stop = details.stop ?? 0;
|
|
2237
|
+
this.#text = details.text;
|
|
2238
|
+
if (details.line === void 0 && details.source[0] !== null) {
|
|
2239
|
+
this.line = details.source[0].line;
|
|
2240
|
+
}
|
|
2241
|
+
if (details.column === void 0 && details.source[0] !== null) {
|
|
2242
|
+
this.column = details.source[0].column;
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
/**
|
|
2246
|
+
* Constructs a new {@link CommonToken} as a copy of another {@link Token}.
|
|
2247
|
+
*
|
|
2248
|
+
* If `token` is also a {@link CommonToken} instance, the newly
|
|
2249
|
+
* constructed token will share a reference to the {@link #text} field and
|
|
2250
|
+
* the {@link Pair} stored in {@link source}. Otherwise, {@link text} will
|
|
2251
|
+
* be assigned the result of calling {@link getText}, and {@link source}
|
|
2252
|
+
* will be constructed from the result of {@link Token.getTokenSource} and
|
|
2253
|
+
* {@link Token#getInputStream}.
|
|
2254
|
+
*
|
|
2255
|
+
* @param token The token to copy.
|
|
2256
|
+
*/
|
|
2257
|
+
static fromToken(token) {
|
|
2258
|
+
const source = [token.tokenSource, token.inputStream];
|
|
2259
|
+
return new _CommonToken({
|
|
2260
|
+
type: token.type,
|
|
2261
|
+
line: token.line,
|
|
2262
|
+
tokenIndex: token.tokenIndex,
|
|
2263
|
+
column: token.column,
|
|
2264
|
+
channel: token.channel,
|
|
2265
|
+
start: token.start,
|
|
2266
|
+
stop: token.stop,
|
|
2267
|
+
text: token.text,
|
|
2268
|
+
source
|
|
2269
|
+
});
|
|
2270
|
+
}
|
|
2271
|
+
/**
|
|
2272
|
+
* Constructs a new {@link CommonToken} with the specified token type and text.
|
|
2273
|
+
*
|
|
2274
|
+
* @param type The token type.
|
|
2275
|
+
* @param text The text of the token.
|
|
2276
|
+
*/
|
|
2277
|
+
static fromType(type, text) {
|
|
2278
|
+
return new _CommonToken({ type, text, source: _CommonToken.EMPTY_SOURCE });
|
|
2279
|
+
}
|
|
2280
|
+
static fromSource(source, type, channel, start, stop) {
|
|
2281
|
+
return new _CommonToken({ type, channel, start, stop, source });
|
|
2282
|
+
}
|
|
2283
|
+
get tokenSource() {
|
|
2284
|
+
return this.source[0];
|
|
2285
|
+
}
|
|
2286
|
+
get inputStream() {
|
|
2287
|
+
return this.source[1];
|
|
2288
|
+
}
|
|
2289
|
+
set inputStream(input) {
|
|
2290
|
+
this.source[1] = input;
|
|
2291
|
+
}
|
|
2292
|
+
/**
|
|
2293
|
+
* Constructs a new {@link CommonToken} as a copy of another {@link Token}.
|
|
2294
|
+
*
|
|
2295
|
+
* If `oldToken` is also a {@link CommonToken} instance, the newly
|
|
2296
|
+
* constructed token will share a reference to the {@link text} field and
|
|
2297
|
+
* the {@link Pair} stored in {@link source}. Otherwise, {@link text} will
|
|
2298
|
+
* be assigned the result of calling {@link getText}, and {@link source}
|
|
2299
|
+
* will be constructed from the result of {@link Token.getTokenSource} and
|
|
2300
|
+
* {@link Token.getInputStream}.
|
|
2301
|
+
*/
|
|
2302
|
+
clone() {
|
|
2303
|
+
const t = new _CommonToken({
|
|
2304
|
+
source: this.source,
|
|
2305
|
+
type: this.type,
|
|
2306
|
+
channel: this.channel,
|
|
2307
|
+
start: this.start,
|
|
2308
|
+
stop: this.stop,
|
|
2309
|
+
tokenIndex: this.tokenIndex,
|
|
2310
|
+
line: this.line,
|
|
2311
|
+
column: this.column,
|
|
2312
|
+
text: this.#text
|
|
2313
|
+
});
|
|
2314
|
+
return t;
|
|
2315
|
+
}
|
|
2316
|
+
toString(recognizer) {
|
|
2317
|
+
let channelStr = "";
|
|
2318
|
+
if (this.channel > 0) {
|
|
2319
|
+
channelStr = ",channel=" + this.channel;
|
|
2320
|
+
}
|
|
2321
|
+
let text = this.text;
|
|
2322
|
+
if (text) {
|
|
2323
|
+
text = text.replace(/\n/g, "\\n");
|
|
2324
|
+
text = text.replace(/\r/g, "\\r");
|
|
2325
|
+
text = text.replace(/\t/g, "\\t");
|
|
2326
|
+
} else {
|
|
2327
|
+
text = "<no text>";
|
|
2328
|
+
}
|
|
2329
|
+
let typeString = String(this.type);
|
|
2330
|
+
if (recognizer) {
|
|
2331
|
+
typeString = recognizer.vocabulary.getDisplayName(this.type) ?? "<unknown>";
|
|
2332
|
+
}
|
|
2333
|
+
return "[@" + this.tokenIndex + "," + this.start + ":" + this.stop + "='" + text + "',<" + typeString + ">" + channelStr + "," + this.line + ":" + this.column + "]";
|
|
2334
|
+
}
|
|
2335
|
+
get text() {
|
|
2336
|
+
if (this.#text !== void 0) {
|
|
2337
|
+
return this.#text;
|
|
2338
|
+
}
|
|
2339
|
+
const input = this.inputStream;
|
|
2340
|
+
if (!input) {
|
|
2341
|
+
return void 0;
|
|
2342
|
+
}
|
|
2343
|
+
const n2 = input.size;
|
|
2344
|
+
if (this.start < n2 && this.stop < n2) {
|
|
2345
|
+
return input.getTextFromRange(this.start, this.stop);
|
|
2346
|
+
}
|
|
2347
|
+
return "<EOF>";
|
|
2348
|
+
}
|
|
2349
|
+
set text(text) {
|
|
2350
|
+
this.#text = text;
|
|
2351
|
+
}
|
|
2352
|
+
// WritableToken implementation
|
|
2353
|
+
setText(text) {
|
|
2354
|
+
this.#text = text;
|
|
2355
|
+
}
|
|
2356
|
+
setType(ttype) {
|
|
2357
|
+
this.type = ttype;
|
|
2358
|
+
}
|
|
2359
|
+
setLine(line) {
|
|
2360
|
+
this.line = line;
|
|
2361
|
+
}
|
|
2362
|
+
setCharPositionInLine(pos) {
|
|
2363
|
+
this.column = pos;
|
|
2364
|
+
}
|
|
2365
|
+
setChannel(channel) {
|
|
2366
|
+
this.channel = channel;
|
|
2367
|
+
}
|
|
2368
|
+
setTokenIndex(index) {
|
|
2369
|
+
this.tokenIndex = index;
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
|
|
2373
|
+
// src/tree/Trees.ts
|
|
2374
|
+
var Trees = class _Trees {
|
|
2375
|
+
static {
|
|
2376
|
+
__name(this, "Trees");
|
|
2377
|
+
}
|
|
2378
|
+
/**
|
|
2379
|
+
* Print out a whole tree in LISP form. {@link getNodeText} is used on the
|
|
2380
|
+
* node payloads to get the text for the nodes. Detect
|
|
2381
|
+
* parse trees and extract data appropriately.
|
|
2382
|
+
*/
|
|
2383
|
+
static toStringTree(tree, ruleNames, recog) {
|
|
2384
|
+
ruleNames = ruleNames ?? null;
|
|
2385
|
+
if (recog) {
|
|
2386
|
+
ruleNames = recog.ruleNames;
|
|
2387
|
+
}
|
|
2388
|
+
let s = _Trees.getNodeText(tree, ruleNames);
|
|
2389
|
+
s = escapeWhitespace(s, false);
|
|
2390
|
+
const c = tree.getChildCount();
|
|
2391
|
+
if (c === 0) {
|
|
2392
|
+
return s;
|
|
2393
|
+
}
|
|
2394
|
+
let res = "(" + s + " ";
|
|
2395
|
+
if (c > 0) {
|
|
2396
|
+
s = _Trees.toStringTree(tree.getChild(0), ruleNames);
|
|
2397
|
+
res = res.concat(s);
|
|
2398
|
+
}
|
|
2399
|
+
for (let i = 1; i < c; i++) {
|
|
2400
|
+
s = _Trees.toStringTree(tree.getChild(i), ruleNames);
|
|
2401
|
+
res = res.concat(" " + s);
|
|
2402
|
+
}
|
|
2403
|
+
res = res.concat(")");
|
|
2404
|
+
return res;
|
|
2405
|
+
}
|
|
2406
|
+
static getNodeText(t, ruleNames, recog) {
|
|
2407
|
+
ruleNames = ruleNames ?? null;
|
|
2408
|
+
if (recog) {
|
|
2409
|
+
ruleNames = recog.ruleNames;
|
|
2410
|
+
}
|
|
2411
|
+
if (ruleNames !== null) {
|
|
2412
|
+
if (t instanceof ParserRuleContext) {
|
|
2413
|
+
const context = t.ruleContext;
|
|
2414
|
+
const altNumber = context.getAltNumber();
|
|
2415
|
+
if (altNumber !== 0) {
|
|
2416
|
+
return ruleNames[t.ruleIndex] + ":" + altNumber;
|
|
2417
|
+
}
|
|
2418
|
+
return ruleNames[t.ruleIndex];
|
|
2419
|
+
} else if (t instanceof ErrorNode) {
|
|
2420
|
+
return t.toString();
|
|
2421
|
+
} else if (t instanceof TerminalNode) {
|
|
2422
|
+
return t.symbol.text;
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
const payload = t.getPayload();
|
|
2426
|
+
if (isToken(payload)) {
|
|
2427
|
+
return payload.text;
|
|
2428
|
+
}
|
|
2429
|
+
return String(t.getPayload());
|
|
2430
|
+
}
|
|
2431
|
+
/**
|
|
2432
|
+
* Return ordered list of all children of this node
|
|
2433
|
+
*/
|
|
2434
|
+
static getChildren(t) {
|
|
2435
|
+
const list = [];
|
|
2436
|
+
for (let i = 0; i < t.getChildCount(); i++) {
|
|
2437
|
+
list.push(t.getChild(i));
|
|
2438
|
+
}
|
|
2439
|
+
return list;
|
|
2440
|
+
}
|
|
2441
|
+
/**
|
|
2442
|
+
* Return a list of all ancestors of this node. The first node of
|
|
2443
|
+
* list is the root and the last is the parent of this node.
|
|
2444
|
+
*/
|
|
2445
|
+
static getAncestors(t) {
|
|
2446
|
+
if (t.parent === null) {
|
|
2447
|
+
return [];
|
|
2448
|
+
}
|
|
2449
|
+
let ancestors = [];
|
|
2450
|
+
let p = t.parent;
|
|
2451
|
+
while (p !== null) {
|
|
2452
|
+
ancestors = [p].concat(ancestors);
|
|
2453
|
+
p = p.parent;
|
|
2454
|
+
}
|
|
2455
|
+
return ancestors;
|
|
2456
|
+
}
|
|
2457
|
+
/**
|
|
2458
|
+
* Return true if t is u's parent or a node on path to root from u.
|
|
2459
|
+
*/
|
|
2460
|
+
static isAncestorOf(t, u) {
|
|
2461
|
+
if (t === null || u === null || t.parent === null) {
|
|
2462
|
+
return false;
|
|
2463
|
+
}
|
|
2464
|
+
let p = u.parent;
|
|
2465
|
+
while (p !== null) {
|
|
2466
|
+
if (t === p) {
|
|
2467
|
+
return true;
|
|
2468
|
+
}
|
|
2469
|
+
p = p.parent;
|
|
2470
|
+
}
|
|
2471
|
+
return false;
|
|
2472
|
+
}
|
|
2473
|
+
static findAllTokenNodes(t, ttype) {
|
|
2474
|
+
return _Trees.findAllNodes(t, ttype, true);
|
|
2475
|
+
}
|
|
2476
|
+
static findAllRuleNodes(t, ruleIndex) {
|
|
2477
|
+
return _Trees.findAllNodes(t, ruleIndex, false);
|
|
2478
|
+
}
|
|
2479
|
+
static findAllNodes(t, index, findTokens) {
|
|
2480
|
+
const nodes = [];
|
|
2481
|
+
_Trees.doFindAllNodes(t, index, findTokens, nodes);
|
|
2482
|
+
return nodes;
|
|
2483
|
+
}
|
|
2484
|
+
static descendants(t) {
|
|
2485
|
+
let nodes = [t];
|
|
2486
|
+
for (let i = 0; i < t.getChildCount(); i++) {
|
|
2487
|
+
nodes = nodes.concat(_Trees.descendants(t.getChild(i)));
|
|
2488
|
+
}
|
|
2489
|
+
return nodes;
|
|
2490
|
+
}
|
|
2491
|
+
/**
|
|
2492
|
+
* Find smallest subtree of t enclosing range startTokenIndex..stopTokenIndex
|
|
2493
|
+
* inclusively using post order traversal. Recursive depth-first-search.
|
|
2494
|
+
*/
|
|
2495
|
+
static getRootOfSubtreeEnclosingRegion(t, startTokenIndex, stopTokenIndex) {
|
|
2496
|
+
const n2 = t.getChildCount();
|
|
2497
|
+
for (let i = 0; i < n2; i++) {
|
|
2498
|
+
const child = t.getChild(i);
|
|
2499
|
+
const r = this.getRootOfSubtreeEnclosingRegion(child, startTokenIndex, stopTokenIndex);
|
|
2500
|
+
if (r !== null) {
|
|
2501
|
+
return r;
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
if (t instanceof ParserRuleContext) {
|
|
2505
|
+
if (startTokenIndex >= t.start.tokenIndex && // is range fully contained in t?
|
|
2506
|
+
(t.stop === null || stopTokenIndex <= t.stop.tokenIndex)) {
|
|
2507
|
+
return t;
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
return null;
|
|
2511
|
+
}
|
|
2512
|
+
/**
|
|
2513
|
+
* Replace any subtree siblings of root that are completely to left
|
|
2514
|
+
* or right of lookahead range with a CommonToken(Token.INVALID_TYPE,"...")
|
|
2515
|
+
* node. The source interval for t is not altered to suit smaller range!
|
|
2516
|
+
*
|
|
2517
|
+
* WARNING: destructive to t.
|
|
2518
|
+
*/
|
|
2519
|
+
static stripChildrenOutOfRange(t, root, startIndex, stopIndex) {
|
|
2520
|
+
if (t === null) {
|
|
2521
|
+
return;
|
|
2522
|
+
}
|
|
2523
|
+
for (let i = 0; i < t.getChildCount(); i++) {
|
|
2524
|
+
const child = t.getChild(i);
|
|
2525
|
+
const range = child.getSourceInterval();
|
|
2526
|
+
if (t instanceof ParserRuleContext && (range.stop < startIndex || range.start > stopIndex)) {
|
|
2527
|
+
if (this.isAncestorOf(child, root)) {
|
|
2528
|
+
const abbrev = CommonToken.fromType(Token.INVALID_TYPE, "...");
|
|
2529
|
+
t.children[i] = new TerminalNode(abbrev);
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
static doFindAllNodes(t, index, findTokens, nodes) {
|
|
2535
|
+
if (findTokens && t instanceof TerminalNode) {
|
|
2536
|
+
if (t.symbol?.type === index) {
|
|
2537
|
+
nodes.push(t);
|
|
2538
|
+
}
|
|
2539
|
+
} else if (!findTokens && t instanceof ParserRuleContext) {
|
|
2540
|
+
if (t.ruleIndex === index) {
|
|
2541
|
+
nodes.push(t);
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
for (let i = 0; i < t.getChildCount(); i++) {
|
|
2545
|
+
_Trees.doFindAllNodes(t.getChild(i), index, findTokens, nodes);
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
};
|
|
2549
|
+
|
|
2550
|
+
// src/ParserRuleContext.ts
|
|
2551
|
+
var ParserRuleContext = class _ParserRuleContext {
|
|
2552
|
+
static {
|
|
2553
|
+
__name(this, "ParserRuleContext");
|
|
2554
|
+
}
|
|
2555
|
+
static empty = new _ParserRuleContext(null);
|
|
2556
|
+
start = null;
|
|
2557
|
+
stop = null;
|
|
2558
|
+
children = [];
|
|
2559
|
+
/**
|
|
2560
|
+
* What state invoked the rule associated with this context?
|
|
2561
|
+
* The "return address" is the followState of invokingState
|
|
2562
|
+
* If parent is null, this should be -1 this context object represents
|
|
2563
|
+
* the start rule.
|
|
2564
|
+
*/
|
|
2565
|
+
invokingState;
|
|
2566
|
+
parent;
|
|
2567
|
+
/**
|
|
2568
|
+
* A rule context is a record of a single rule invocation. It knows
|
|
2569
|
+
* which context invoked it, if any. If there is no parent context, then
|
|
2570
|
+
* naturally the invoking state is not valid. The parent link
|
|
2571
|
+
* provides a chain upwards from the current rule invocation to the root
|
|
2572
|
+
* of the invocation tree, forming a stack. We actually carry no
|
|
2573
|
+
* information about the rule associated with this context (except
|
|
2574
|
+
* when parsing). We keep only the state number of the invoking state from
|
|
2575
|
+
* the ATN submachine that invoked this. Contrast this with the s
|
|
2576
|
+
* pointer inside ParserRuleContext that tracks the current state
|
|
2577
|
+
* being "executed" for the current rule.
|
|
2578
|
+
*
|
|
2579
|
+
* The parent contexts are useful for computing lookahead sets and
|
|
2580
|
+
* getting error information.
|
|
2581
|
+
*
|
|
2582
|
+
* These objects are used during parsing and prediction.
|
|
2583
|
+
* For the special case of parsers, we use the subclass
|
|
2584
|
+
* ParserRuleContext.
|
|
2585
|
+
*/
|
|
2586
|
+
constructor(parent, invokingStateNumber = -1) {
|
|
2587
|
+
this.parent = parent;
|
|
2588
|
+
this.invokingState = invokingStateNumber;
|
|
2589
|
+
}
|
|
2590
|
+
/** Copy a context */
|
|
2591
|
+
copyFrom(ctx) {
|
|
2592
|
+
this.parent = ctx.parent;
|
|
2593
|
+
this.invokingState = ctx.invokingState;
|
|
2594
|
+
this.children.slice(0, this.children.length);
|
|
2595
|
+
this.start = ctx.start;
|
|
2596
|
+
this.stop = ctx.stop;
|
|
2597
|
+
if (ctx.children) {
|
|
2598
|
+
ctx.children.forEach((child) => {
|
|
2599
|
+
if (child instanceof ErrorNode) {
|
|
2600
|
+
this.children.push(child);
|
|
2601
|
+
child.parent = this;
|
|
2602
|
+
}
|
|
2603
|
+
});
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
// Double dispatch methods for listeners
|
|
2607
|
+
enterRule(_listener) {
|
|
2608
|
+
}
|
|
2609
|
+
exitRule(_listener) {
|
|
2610
|
+
}
|
|
2611
|
+
addChild(child) {
|
|
2612
|
+
this.children.push(child);
|
|
2613
|
+
return child;
|
|
2614
|
+
}
|
|
2615
|
+
/**
|
|
2616
|
+
* Used by enterOuterAlt to toss out a RuleContext previously added as
|
|
2617
|
+
* we entered a rule. If we have label, we will need to remove
|
|
2618
|
+
* generic ruleContext object.
|
|
2619
|
+
*/
|
|
2620
|
+
removeLastChild() {
|
|
2621
|
+
this.children.pop();
|
|
2622
|
+
}
|
|
2623
|
+
addTokenNode(token) {
|
|
2624
|
+
const node = new TerminalNode(token);
|
|
2625
|
+
this.children.push(node);
|
|
2626
|
+
node.parent = this;
|
|
2627
|
+
return node;
|
|
2628
|
+
}
|
|
2629
|
+
addErrorNode(errorNode) {
|
|
2630
|
+
errorNode.parent = this;
|
|
2631
|
+
this.children.push(errorNode);
|
|
2632
|
+
return errorNode;
|
|
2633
|
+
}
|
|
2634
|
+
getChild(i, type) {
|
|
2635
|
+
if (i < 0 || i >= this.children.length) {
|
|
2636
|
+
return null;
|
|
2637
|
+
}
|
|
2638
|
+
if (!type) {
|
|
2639
|
+
return this.children[i];
|
|
2640
|
+
}
|
|
2641
|
+
for (const child of this.children) {
|
|
2642
|
+
if (child instanceof type) {
|
|
2643
|
+
if (i === 0) {
|
|
2644
|
+
return child;
|
|
2645
|
+
} else {
|
|
2646
|
+
i -= 1;
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
return null;
|
|
2651
|
+
}
|
|
2652
|
+
getToken(ttype, i) {
|
|
2653
|
+
if (i < 0 || i >= this.children.length) {
|
|
2654
|
+
return null;
|
|
2655
|
+
}
|
|
2656
|
+
for (const child of this.children) {
|
|
2657
|
+
if ("symbol" in child) {
|
|
2658
|
+
if (child.symbol?.type === ttype) {
|
|
2659
|
+
if (i === 0) {
|
|
2660
|
+
return child;
|
|
2661
|
+
} else {
|
|
2662
|
+
i -= 1;
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
return null;
|
|
2668
|
+
}
|
|
2669
|
+
getTokens(ttype) {
|
|
2670
|
+
const tokens = [];
|
|
2671
|
+
for (const child of this.children) {
|
|
2672
|
+
if ("symbol" in child) {
|
|
2673
|
+
if (child.symbol?.type === ttype) {
|
|
2674
|
+
tokens.push(child);
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2678
|
+
return tokens;
|
|
2679
|
+
}
|
|
2680
|
+
// XXX: base the child type selection on the rule index, not the class.
|
|
2681
|
+
getRuleContext(index, ctxType) {
|
|
2682
|
+
return this.getChild(index, ctxType);
|
|
2683
|
+
}
|
|
2684
|
+
// XXX: base the child type selection on the rule index, not the class.
|
|
2685
|
+
getRuleContexts(ctxType) {
|
|
2686
|
+
const contexts = [];
|
|
2687
|
+
for (const child of this.children) {
|
|
2688
|
+
if (child instanceof ctxType) {
|
|
2689
|
+
contexts.push(child);
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2692
|
+
return contexts;
|
|
2693
|
+
}
|
|
2694
|
+
getChildCount() {
|
|
2695
|
+
return this.children.length;
|
|
2696
|
+
}
|
|
2697
|
+
getSourceInterval() {
|
|
2698
|
+
if (this.start === null) {
|
|
2699
|
+
return Interval.INVALID_INTERVAL;
|
|
2700
|
+
}
|
|
2701
|
+
if (this.stop === null || this.stop.tokenIndex < this.start.tokenIndex) {
|
|
2702
|
+
return new Interval(this.start.tokenIndex, this.start.tokenIndex - 1);
|
|
2703
|
+
}
|
|
2704
|
+
return new Interval(this.start.tokenIndex, this.stop.tokenIndex);
|
|
2705
|
+
}
|
|
2706
|
+
depth() {
|
|
2707
|
+
let n2 = 0;
|
|
2708
|
+
let p = this;
|
|
2709
|
+
while (p !== null) {
|
|
2710
|
+
p = p.parent;
|
|
2711
|
+
n2 += 1;
|
|
2712
|
+
}
|
|
2713
|
+
return n2;
|
|
2714
|
+
}
|
|
2715
|
+
/**
|
|
2716
|
+
* A context is empty if there is no invoking state; meaning nobody call
|
|
2717
|
+
* current context.
|
|
2718
|
+
*/
|
|
2719
|
+
isEmpty() {
|
|
2720
|
+
return this.invokingState === -1;
|
|
2721
|
+
}
|
|
2722
|
+
get ruleContext() {
|
|
2723
|
+
return this;
|
|
2724
|
+
}
|
|
2725
|
+
get ruleIndex() {
|
|
2726
|
+
return -1;
|
|
2727
|
+
}
|
|
2728
|
+
getPayload() {
|
|
2729
|
+
return this;
|
|
2730
|
+
}
|
|
2731
|
+
getText() {
|
|
2732
|
+
if (this.children.length === 0) {
|
|
2733
|
+
return "";
|
|
2734
|
+
}
|
|
2735
|
+
return this.children.map((child) => {
|
|
2736
|
+
return child.getText();
|
|
2737
|
+
}).join("");
|
|
2738
|
+
}
|
|
2739
|
+
/**
|
|
2740
|
+
* For rule associated with this parse tree internal node, return
|
|
2741
|
+
* the outer alternative number used to match the input. Default
|
|
2742
|
+
* implementation does not compute nor store this alt num. Create
|
|
2743
|
+
* a subclass of ParserRuleContext with backing field and set
|
|
2744
|
+
* option contextSuperClass.
|
|
2745
|
+
* to set it.
|
|
2746
|
+
*/
|
|
2747
|
+
getAltNumber() {
|
|
2748
|
+
return ATN.INVALID_ALT_NUMBER;
|
|
2749
|
+
}
|
|
2750
|
+
/**
|
|
2751
|
+
* Set the outer alternative number for this context node. Default
|
|
2752
|
+
* implementation does nothing to avoid backing field overhead for
|
|
2753
|
+
* trees that don't need it. Create
|
|
2754
|
+
* a subclass of ParserRuleContext with backing field and set
|
|
2755
|
+
* option contextSuperClass.
|
|
2756
|
+
*/
|
|
2757
|
+
setAltNumber(_altNumber) {
|
|
2758
|
+
}
|
|
2759
|
+
accept(visitor) {
|
|
2760
|
+
return visitor.visitChildren(this);
|
|
2761
|
+
}
|
|
2762
|
+
toStringTree(...args) {
|
|
2763
|
+
if (args.length < 2) {
|
|
2764
|
+
return Trees.toStringTree(this, null, args[0]);
|
|
2765
|
+
}
|
|
2766
|
+
return Trees.toStringTree(this, args[0], args[1]);
|
|
2767
|
+
}
|
|
2768
|
+
toString(ruleNames, stop) {
|
|
2769
|
+
ruleNames = ruleNames ?? null;
|
|
2770
|
+
stop = stop ?? null;
|
|
2771
|
+
let p = this;
|
|
2772
|
+
let s = "[";
|
|
2773
|
+
while (p !== null && p !== stop) {
|
|
2774
|
+
if (ruleNames === null) {
|
|
2775
|
+
if (!p.isEmpty()) {
|
|
2776
|
+
s += p.invokingState;
|
|
2777
|
+
}
|
|
2778
|
+
} else {
|
|
2779
|
+
const ri = p.ruleIndex;
|
|
2780
|
+
const ruleName = ri >= 0 && ri < ruleNames.length ? ruleNames[ri] : "" + ri;
|
|
2781
|
+
s += ruleName;
|
|
2782
|
+
}
|
|
2783
|
+
if (p.parent !== null && (ruleNames !== null || !p.parent.isEmpty())) {
|
|
2784
|
+
s += " ";
|
|
2785
|
+
}
|
|
2786
|
+
p = p.parent;
|
|
2787
|
+
}
|
|
2788
|
+
s += "]";
|
|
2789
|
+
return s;
|
|
2790
|
+
}
|
|
2791
|
+
};
|
|
2792
|
+
|
|
2793
|
+
// src/atn/helpers.ts
|
|
2794
|
+
var createSingletonPredictionContext = /* @__PURE__ */ __name((parent, returnState) => {
|
|
2795
|
+
if (returnState === PredictionContext.EMPTY_RETURN_STATE && parent === null) {
|
|
2796
|
+
return EmptyPredictionContext.instance;
|
|
2797
|
+
} else {
|
|
2798
|
+
return new SingletonPredictionContext(parent, returnState);
|
|
2799
|
+
}
|
|
2800
|
+
}, "createSingletonPredictionContext");
|
|
2801
|
+
|
|
2802
|
+
// src/atn/PredictionContextUtils.ts
|
|
2803
|
+
var predictionContextFromRuleContext = /* @__PURE__ */ __name((atn, outerContext) => {
|
|
2804
|
+
if (!outerContext) {
|
|
2805
|
+
outerContext = ParserRuleContext.empty;
|
|
2806
|
+
}
|
|
2807
|
+
if (!outerContext.parent || outerContext === ParserRuleContext.empty) {
|
|
2808
|
+
return EmptyPredictionContext.instance;
|
|
2809
|
+
}
|
|
2810
|
+
const parent = predictionContextFromRuleContext(atn, outerContext.parent);
|
|
2811
|
+
const state = atn.states[outerContext.invokingState];
|
|
2812
|
+
const transition = state.transitions[0];
|
|
2813
|
+
return createSingletonPredictionContext(parent, transition.followState.stateNumber);
|
|
2814
|
+
}, "predictionContextFromRuleContext");
|
|
2815
|
+
|
|
2816
|
+
// src/atn/LL1Analyzer.ts
|
|
2817
|
+
var LL1Analyzer = class _LL1Analyzer {
|
|
2818
|
+
constructor(atn) {
|
|
2819
|
+
this.atn = atn;
|
|
2820
|
+
}
|
|
2821
|
+
static {
|
|
2822
|
+
__name(this, "LL1Analyzer");
|
|
2823
|
+
}
|
|
2824
|
+
/**
|
|
2825
|
+
* Special value added to the lookahead sets to indicate that we hit
|
|
2826
|
+
* a predicate during analysis if `seeThruPreds==false`.
|
|
2827
|
+
*/
|
|
2828
|
+
static hitPredicate = Token.INVALID_TYPE;
|
|
2829
|
+
/**
|
|
2830
|
+
* Calculates the SLL(1) expected lookahead set for each outgoing transition
|
|
2831
|
+
* of an {@link ATNState}. The returned array has one element for each
|
|
2832
|
+
* outgoing transition in `s`. If the closure from transition
|
|
2833
|
+
* _i_ leads to a semantic predicate before matching a symbol, the
|
|
2834
|
+
* element at index *i* of the result will be `undefined`.
|
|
2835
|
+
*
|
|
2836
|
+
* @param s the ATN state
|
|
2837
|
+
* @returns the expected symbols for each outgoing transition of `s`.
|
|
2838
|
+
*/
|
|
2839
|
+
getDecisionLookahead(s) {
|
|
2840
|
+
const count = s.transitions.length;
|
|
2841
|
+
const look = new Array(count);
|
|
2842
|
+
for (let alt = 0; alt < count; alt++) {
|
|
2843
|
+
const set = new IntervalSet();
|
|
2844
|
+
const lookBusy = new HashSet();
|
|
2845
|
+
this.doLook(
|
|
2846
|
+
s.transitions[alt].target,
|
|
2847
|
+
void 0,
|
|
2848
|
+
EmptyPredictionContext.instance,
|
|
2849
|
+
set,
|
|
2850
|
+
lookBusy,
|
|
2851
|
+
new BitSet(),
|
|
2852
|
+
false,
|
|
2853
|
+
false
|
|
2854
|
+
);
|
|
2855
|
+
if (set.length > 0 && !set.contains(_LL1Analyzer.hitPredicate)) {
|
|
2856
|
+
look[alt] = set;
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
return look;
|
|
2860
|
+
}
|
|
2861
|
+
/**
|
|
2862
|
+
* Compute set of tokens that can follow `s` in the ATN in the
|
|
2863
|
+
* specified `ctx`.
|
|
2864
|
+
*
|
|
2865
|
+
* If `ctx` is `null` and the end of the rule containing
|
|
2866
|
+
* `s` is reached, {@link Token//EPSILON} is added to the result set.
|
|
2867
|
+
* If `ctx` is not `null` and the end of the outermost rule is
|
|
2868
|
+
* reached, {@link Token//EOF} is added to the result set.
|
|
2869
|
+
*
|
|
2870
|
+
* @param s the ATN state
|
|
2871
|
+
* @param stopState the ATN state to stop at. This can be a
|
|
2872
|
+
* {@link BlockEndState} to detect epsilon paths through a closure.
|
|
2873
|
+
* @param ctx the complete parser context, or `null` if the context
|
|
2874
|
+
* should be ignored
|
|
2875
|
+
*
|
|
2876
|
+
* @returns The set of tokens that can follow `s` in the ATN in the
|
|
2877
|
+
* specified `ctx`.
|
|
2878
|
+
*/
|
|
2879
|
+
look(s, stopState, ctx) {
|
|
2880
|
+
const r = new IntervalSet();
|
|
2881
|
+
const lookContext = ctx ? predictionContextFromRuleContext(this.atn, ctx) : null;
|
|
2882
|
+
this.doLook(s, stopState, lookContext, r, new HashSet(), new BitSet(), true, true);
|
|
2883
|
+
return r;
|
|
2884
|
+
}
|
|
2885
|
+
/**
|
|
2886
|
+
* Compute set of tokens that can follow `s` in the ATN in the
|
|
2887
|
+
* specified `ctx`.
|
|
2888
|
+
*
|
|
2889
|
+
* If `ctx` is `null` and `stopState` or the end of the
|
|
2890
|
+
* rule containing `s` is reached, {@link Token//EPSILON} is added to
|
|
2891
|
+
* the result set. If `ctx` is not `null` and `addEOF` is
|
|
2892
|
+
* `true` and `stopState` or the end of the outermost rule is
|
|
2893
|
+
* reached, {@link Token//EOF} is added to the result set.
|
|
2894
|
+
*
|
|
2895
|
+
* @param s the ATN state.
|
|
2896
|
+
* @param stopState the ATN state to stop at. This can be a
|
|
2897
|
+
* {@link BlockEndState} to detect epsilon paths through a closure.
|
|
2898
|
+
* @param ctx The outer context, or `null` if the outer context should
|
|
2899
|
+
* not be used.
|
|
2900
|
+
* @param look The result lookahead set.
|
|
2901
|
+
* @param lookBusy A set used for preventing epsilon closures in the ATN
|
|
2902
|
+
* from causing a stack overflow. Outside code should pass
|
|
2903
|
+
* `new CustomizedSet<ATNConfig>` for this argument.
|
|
2904
|
+
* @param calledRuleStack A set used for preventing left recursion in the
|
|
2905
|
+
* ATN from causing a stack overflow. Outside code should pass
|
|
2906
|
+
* `new BitSet()` for this argument.
|
|
2907
|
+
* @param seeThruPreds `true` to true semantic predicates as
|
|
2908
|
+
* implicitly `true` and "see through them", otherwise `false`
|
|
2909
|
+
* to treat semantic predicates as opaque and add {@link hitPredicate} to the
|
|
2910
|
+
* result if one is encountered.
|
|
2911
|
+
* @param addEOF Add {@link Token//EOF} to the result if the end of the
|
|
2912
|
+
* outermost context is reached. This parameter has no effect if `ctx`
|
|
2913
|
+
* is `null`.
|
|
2914
|
+
*/
|
|
2915
|
+
doLook(s, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) {
|
|
2916
|
+
const c = ATNConfig.createWithContext(s, 0, ctx);
|
|
2917
|
+
if (lookBusy.get(c)) {
|
|
2918
|
+
return;
|
|
2919
|
+
}
|
|
2920
|
+
lookBusy.add(c);
|
|
2921
|
+
if (s === stopState) {
|
|
2922
|
+
if (!ctx) {
|
|
2923
|
+
look.addOne(Token.EPSILON);
|
|
2924
|
+
return;
|
|
2925
|
+
} else if (ctx.isEmpty() && addEOF) {
|
|
2926
|
+
look.addOne(Token.EOF);
|
|
2927
|
+
return;
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
if (s.constructor.stateType === ATNState.RULE_STOP) {
|
|
2931
|
+
if (!ctx) {
|
|
2932
|
+
look.addOne(Token.EPSILON);
|
|
2933
|
+
return;
|
|
2934
|
+
} else if (ctx.isEmpty() && addEOF) {
|
|
2935
|
+
look.addOne(Token.EOF);
|
|
2936
|
+
return;
|
|
2937
|
+
}
|
|
2938
|
+
if (ctx !== EmptyPredictionContext.instance) {
|
|
2939
|
+
const removed = calledRuleStack.get(s.ruleIndex);
|
|
2940
|
+
try {
|
|
2941
|
+
calledRuleStack.clear(s.ruleIndex);
|
|
2942
|
+
for (let i = 0; i < ctx.length; i++) {
|
|
2943
|
+
const returnState = this.atn.states[ctx.getReturnState(i)];
|
|
2944
|
+
this.doLook(
|
|
2945
|
+
returnState,
|
|
2946
|
+
stopState,
|
|
2947
|
+
ctx.getParent(i),
|
|
2948
|
+
look,
|
|
2949
|
+
lookBusy,
|
|
2950
|
+
calledRuleStack,
|
|
2951
|
+
seeThruPreds,
|
|
2952
|
+
addEOF
|
|
2953
|
+
);
|
|
2954
|
+
}
|
|
2955
|
+
} finally {
|
|
2956
|
+
if (removed) {
|
|
2957
|
+
calledRuleStack.set(s.ruleIndex);
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
return;
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
for (const t of s.transitions) {
|
|
2964
|
+
switch (t.transitionType) {
|
|
2965
|
+
case Transition.RULE: {
|
|
2966
|
+
if (calledRuleStack.get(t.target.ruleIndex)) {
|
|
2967
|
+
continue;
|
|
2968
|
+
}
|
|
2969
|
+
const newContext = createSingletonPredictionContext(
|
|
2970
|
+
ctx ?? void 0,
|
|
2971
|
+
t.followState.stateNumber
|
|
2972
|
+
);
|
|
2973
|
+
try {
|
|
2974
|
+
calledRuleStack.set(t.target.ruleIndex);
|
|
2975
|
+
this.doLook(
|
|
2976
|
+
t.target,
|
|
2977
|
+
stopState,
|
|
2978
|
+
newContext,
|
|
2979
|
+
look,
|
|
2980
|
+
lookBusy,
|
|
2981
|
+
calledRuleStack,
|
|
2982
|
+
seeThruPreds,
|
|
2983
|
+
addEOF
|
|
2984
|
+
);
|
|
2985
|
+
} finally {
|
|
2986
|
+
calledRuleStack.clear(t.target.ruleIndex);
|
|
2987
|
+
}
|
|
2988
|
+
break;
|
|
2989
|
+
}
|
|
2990
|
+
case Transition.PREDICATE:
|
|
2991
|
+
case Transition.PRECEDENCE: {
|
|
2992
|
+
if (seeThruPreds) {
|
|
2993
|
+
this.doLook(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
|
|
2994
|
+
} else {
|
|
2995
|
+
look.addOne(_LL1Analyzer.hitPredicate);
|
|
2996
|
+
}
|
|
2997
|
+
break;
|
|
2998
|
+
}
|
|
2999
|
+
case Transition.WILDCARD: {
|
|
3000
|
+
look.addRange(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType);
|
|
3001
|
+
break;
|
|
3002
|
+
}
|
|
3003
|
+
default: {
|
|
3004
|
+
if (t.isEpsilon) {
|
|
3005
|
+
this.doLook(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
|
|
3006
|
+
} else {
|
|
3007
|
+
let set = t.label;
|
|
3008
|
+
if (set) {
|
|
3009
|
+
if (t instanceof NotSetTransition) {
|
|
3010
|
+
set = set.complement(Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType);
|
|
3011
|
+
}
|
|
3012
|
+
look.addSet(set);
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
break;
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
};
|
|
3021
|
+
|
|
3022
|
+
// src/atn/ATN.ts
|
|
3023
|
+
var ATN = class {
|
|
3024
|
+
static {
|
|
3025
|
+
__name(this, "ATN");
|
|
3026
|
+
}
|
|
3027
|
+
static INVALID_ALT_NUMBER = 0;
|
|
3028
|
+
/** Represents the type of recognizer an ATN applies to */
|
|
3029
|
+
static LEXER = 0;
|
|
3030
|
+
static PARSER = 1;
|
|
3031
|
+
/**
|
|
3032
|
+
* Used for runtime deserialization of ATNs from strings
|
|
3033
|
+
* The type of the ATN.
|
|
3034
|
+
*/
|
|
3035
|
+
grammarType;
|
|
3036
|
+
/** The maximum value for any symbol recognized by a transition in the ATN. */
|
|
3037
|
+
maxTokenType;
|
|
3038
|
+
states = [];
|
|
3039
|
+
/**
|
|
3040
|
+
* Each subrule/rule is a decision point and we must track them so we
|
|
3041
|
+
* can go back later and build DFA predictors for them. This includes
|
|
3042
|
+
* all the rules, subrules, optional blocks, ()+, ()* etc...
|
|
3043
|
+
*/
|
|
3044
|
+
decisionToState = [];
|
|
3045
|
+
/** Maps from rule index to starting state number. */
|
|
3046
|
+
ruleToStartState = [];
|
|
3047
|
+
// Initialized by the ATN deserializer.
|
|
3048
|
+
/** Maps from rule index to stop state number. */
|
|
3049
|
+
ruleToStopState = [];
|
|
3050
|
+
// Initialized by the ATN deserializer.
|
|
3051
|
+
modeNameToStartState = /* @__PURE__ */ new Map();
|
|
3052
|
+
/**
|
|
3053
|
+
* For lexer ATNs, this maps the rule index to the resulting token type.
|
|
3054
|
+
* For parser ATNs, this maps the rule index to the generated bypass token
|
|
3055
|
+
* type if the {@link ATNDeserializationOptions//isGenerateRuleBypassTransitions}
|
|
3056
|
+
* deserialization option was specified; otherwise, this is `null`
|
|
3057
|
+
*/
|
|
3058
|
+
ruleToTokenType = [];
|
|
3059
|
+
// Initialized by the ATN deserializer.
|
|
3060
|
+
/**
|
|
3061
|
+
* For lexer ATNs, this is an array of {@link LexerAction} objects which may
|
|
3062
|
+
* be referenced by action transitions in the ATN
|
|
3063
|
+
*/
|
|
3064
|
+
lexerActions = [];
|
|
3065
|
+
modeToStartState = [];
|
|
3066
|
+
analyzer;
|
|
3067
|
+
constructor(grammarType, maxTokenType) {
|
|
3068
|
+
this.grammarType = grammarType;
|
|
3069
|
+
this.maxTokenType = maxTokenType;
|
|
3070
|
+
this.analyzer = new LL1Analyzer(this);
|
|
3071
|
+
}
|
|
3072
|
+
/**
|
|
3073
|
+
* Compute the set of valid tokens that can occur starting in state `s`.
|
|
3074
|
+
* If `ctx` is null, the set of tokens will not include what can follow
|
|
3075
|
+
* the rule surrounding `s`. In other words, the set will be
|
|
3076
|
+
* restricted to tokens reachable staying within `s`'s rule.
|
|
3077
|
+
*/
|
|
3078
|
+
nextTokens(atnState, ctx) {
|
|
3079
|
+
if (!ctx && atnState.nextTokenWithinRule) {
|
|
3080
|
+
return atnState.nextTokenWithinRule;
|
|
3081
|
+
}
|
|
3082
|
+
const next = this.analyzer.look(atnState, void 0, ctx);
|
|
3083
|
+
if (!ctx) {
|
|
3084
|
+
atnState.nextTokenWithinRule = next;
|
|
3085
|
+
}
|
|
3086
|
+
return next;
|
|
3087
|
+
}
|
|
3088
|
+
addState(state) {
|
|
3089
|
+
if (state) {
|
|
3090
|
+
state.stateNumber = this.states.length;
|
|
3091
|
+
}
|
|
3092
|
+
this.states.push(state);
|
|
3093
|
+
}
|
|
3094
|
+
removeState(state) {
|
|
3095
|
+
this.states[state.stateNumber] = null;
|
|
3096
|
+
}
|
|
3097
|
+
defineDecisionState(s) {
|
|
3098
|
+
this.decisionToState.push(s);
|
|
3099
|
+
s.decision = this.decisionToState.length - 1;
|
|
3100
|
+
return s.decision;
|
|
3101
|
+
}
|
|
3102
|
+
getDecisionState(decision) {
|
|
3103
|
+
if (this.decisionToState.length === 0) {
|
|
3104
|
+
return null;
|
|
3105
|
+
} else {
|
|
3106
|
+
return this.decisionToState[decision];
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
getNumberOfDecisions() {
|
|
3110
|
+
return this.decisionToState.length;
|
|
3111
|
+
}
|
|
3112
|
+
/**
|
|
3113
|
+
* Computes the set of input symbols which could follow ATN state number
|
|
3114
|
+
* `stateNumber` in the specified full `context`. This method
|
|
3115
|
+
* considers the complete parser context, but does not evaluate semantic
|
|
3116
|
+
* predicates (i.e. all predicates encountered during the calculation are
|
|
3117
|
+
* assumed true). If a path in the ATN exists from the starting state to the
|
|
3118
|
+
* {@link RuleStopState} of the outermost context without matching any
|
|
3119
|
+
* symbols, {@link Token//EOF} is added to the returned set.
|
|
3120
|
+
*
|
|
3121
|
+
* If `context` is `null`, it is treated as
|
|
3122
|
+
* {@link ParserRuleContext//EMPTY}.
|
|
3123
|
+
*
|
|
3124
|
+
* @param stateNumber the ATN state number
|
|
3125
|
+
* @param context the full parse context
|
|
3126
|
+
*
|
|
3127
|
+
* @returns {IntervalSet} The set of potentially valid input symbols which could follow the
|
|
3128
|
+
* specified state in the specified context.
|
|
3129
|
+
*
|
|
3130
|
+
* @throws IllegalArgumentException if the ATN does not contain a state with
|
|
3131
|
+
* number `stateNumber`
|
|
3132
|
+
*/
|
|
3133
|
+
getExpectedTokens(stateNumber, context) {
|
|
3134
|
+
if (stateNumber < 0 || stateNumber >= this.states.length) {
|
|
3135
|
+
throw new Error("Invalid state number.");
|
|
3136
|
+
}
|
|
3137
|
+
const s = this.states[stateNumber];
|
|
3138
|
+
let following = this.nextTokens(s);
|
|
3139
|
+
if (!following.contains(Token.EPSILON)) {
|
|
3140
|
+
return following;
|
|
3141
|
+
}
|
|
3142
|
+
let ctx = context;
|
|
3143
|
+
const expected = new IntervalSet();
|
|
3144
|
+
expected.addSet(following);
|
|
3145
|
+
expected.removeOne(Token.EPSILON);
|
|
3146
|
+
while (ctx !== null && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) {
|
|
3147
|
+
const invokingState = this.states[ctx.invokingState];
|
|
3148
|
+
const rt = invokingState.transitions[0];
|
|
3149
|
+
following = this.nextTokens(rt.followState);
|
|
3150
|
+
expected.addSet(following);
|
|
3151
|
+
expected.removeOne(Token.EPSILON);
|
|
3152
|
+
ctx = ctx.parent;
|
|
3153
|
+
}
|
|
3154
|
+
if (following.contains(Token.EPSILON)) {
|
|
3155
|
+
expected.addOne(Token.EOF);
|
|
3156
|
+
}
|
|
3157
|
+
return expected;
|
|
3158
|
+
}
|
|
3159
|
+
};
|
|
3160
|
+
|
|
3161
|
+
// src/atn/BasicState.ts
|
|
3162
|
+
var BasicState = class extends ATNState {
|
|
3163
|
+
static {
|
|
3164
|
+
__name(this, "BasicState");
|
|
3165
|
+
}
|
|
3166
|
+
static stateType = ATNState.BASIC;
|
|
3167
|
+
};
|
|
3168
|
+
|
|
3169
|
+
// src/atn/DecisionState.ts
|
|
3170
|
+
var DecisionState = class extends ATNState {
|
|
3171
|
+
static {
|
|
3172
|
+
__name(this, "DecisionState");
|
|
3173
|
+
}
|
|
3174
|
+
decision = -1;
|
|
3175
|
+
nonGreedy = false;
|
|
3176
|
+
};
|
|
3177
|
+
|
|
3178
|
+
// src/atn/BlockStartState.ts
|
|
3179
|
+
var BlockStartState = class extends DecisionState {
|
|
3180
|
+
static {
|
|
3181
|
+
__name(this, "BlockStartState");
|
|
3182
|
+
}
|
|
3183
|
+
endState;
|
|
3184
|
+
};
|
|
3185
|
+
|
|
3186
|
+
// src/atn/BlockEndState.ts
|
|
3187
|
+
var BlockEndState = class extends ATNState {
|
|
3188
|
+
static {
|
|
3189
|
+
__name(this, "BlockEndState");
|
|
3190
|
+
}
|
|
3191
|
+
static stateType = ATNState.BLOCK_END;
|
|
3192
|
+
startState;
|
|
3193
|
+
};
|
|
3194
|
+
|
|
3195
|
+
// src/atn/LoopEndState.ts
|
|
3196
|
+
var LoopEndState = class extends ATNState {
|
|
3197
|
+
static {
|
|
3198
|
+
__name(this, "LoopEndState");
|
|
3199
|
+
}
|
|
3200
|
+
static stateType = ATNState.LOOP_END;
|
|
3201
|
+
loopBackState;
|
|
3202
|
+
};
|
|
3203
|
+
|
|
3204
|
+
// src/atn/RuleStartState.ts
|
|
3205
|
+
var RuleStartState = class extends ATNState {
|
|
3206
|
+
static {
|
|
3207
|
+
__name(this, "RuleStartState");
|
|
3208
|
+
}
|
|
3209
|
+
static stateType = ATNState.RULE_START;
|
|
3210
|
+
stopState;
|
|
3211
|
+
isLeftRecursiveRule = false;
|
|
3212
|
+
};
|
|
3213
|
+
|
|
3214
|
+
// src/atn/RuleStopState.ts
|
|
3215
|
+
var RuleStopState = class extends ATNState {
|
|
3216
|
+
static {
|
|
3217
|
+
__name(this, "RuleStopState");
|
|
3218
|
+
}
|
|
3219
|
+
static stateType = ATNState.RULE_STOP;
|
|
3220
|
+
};
|
|
3221
|
+
|
|
3222
|
+
// src/atn/TokensStartState.ts
|
|
3223
|
+
var TokensStartState = class extends DecisionState {
|
|
3224
|
+
static {
|
|
3225
|
+
__name(this, "TokensStartState");
|
|
3226
|
+
}
|
|
3227
|
+
static stateType = ATNState.TOKEN_START;
|
|
3228
|
+
};
|
|
3229
|
+
|
|
3230
|
+
// src/atn/PlusLoopbackState.ts
|
|
3231
|
+
var PlusLoopbackState = class extends DecisionState {
|
|
3232
|
+
static {
|
|
3233
|
+
__name(this, "PlusLoopbackState");
|
|
3234
|
+
}
|
|
3235
|
+
static stateType = ATNState.PLUS_LOOP_BACK;
|
|
3236
|
+
};
|
|
3237
|
+
|
|
3238
|
+
// src/atn/StarLoopbackState.ts
|
|
3239
|
+
var StarLoopbackState = class extends ATNState {
|
|
3240
|
+
static {
|
|
3241
|
+
__name(this, "StarLoopbackState");
|
|
3242
|
+
}
|
|
3243
|
+
static stateType = ATNState.STAR_LOOP_BACK;
|
|
3244
|
+
};
|
|
3245
|
+
|
|
3246
|
+
// src/atn/StarLoopEntryState.ts
|
|
3247
|
+
var StarLoopEntryState = class extends DecisionState {
|
|
3248
|
+
static {
|
|
3249
|
+
__name(this, "StarLoopEntryState");
|
|
3250
|
+
}
|
|
3251
|
+
static stateType = ATNState.STAR_LOOP_ENTRY;
|
|
3252
|
+
// This is always set during ATN deserialization
|
|
3253
|
+
loopBackState;
|
|
3254
|
+
/**
|
|
3255
|
+
* Indicates whether this state can benefit from a precedence DFA during SLL
|
|
3256
|
+
* decision making.
|
|
3257
|
+
*
|
|
3258
|
+
* This is a computed property that is calculated during ATN deserialization
|
|
3259
|
+
* and stored for use in {@link ParserATNSimulator} and
|
|
3260
|
+
* {@link ParserInterpreter}.
|
|
3261
|
+
*
|
|
3262
|
+
* @see `DFA.isPrecedenceDfa`
|
|
3263
|
+
*/
|
|
3264
|
+
precedenceRuleDecision = false;
|
|
3265
|
+
};
|
|
3266
|
+
|
|
3267
|
+
// src/atn/PlusBlockStartState.ts
|
|
3268
|
+
var PlusBlockStartState = class extends BlockStartState {
|
|
3269
|
+
static {
|
|
3270
|
+
__name(this, "PlusBlockStartState");
|
|
3271
|
+
}
|
|
3272
|
+
static stateType = ATNState.PLUS_BLOCK_START;
|
|
3273
|
+
loopBackState;
|
|
3274
|
+
};
|
|
3275
|
+
|
|
3276
|
+
// src/atn/StarBlockStartState.ts
|
|
3277
|
+
var StarBlockStartState = class extends BlockStartState {
|
|
3278
|
+
static {
|
|
3279
|
+
__name(this, "StarBlockStartState");
|
|
3280
|
+
}
|
|
3281
|
+
static stateType = ATNState.STAR_BLOCK_START;
|
|
3282
|
+
};
|
|
3283
|
+
|
|
3284
|
+
// src/atn/BasicBlockStartState.ts
|
|
3285
|
+
var BasicBlockStartState = class extends BlockStartState {
|
|
3286
|
+
static {
|
|
3287
|
+
__name(this, "BasicBlockStartState");
|
|
3288
|
+
}
|
|
3289
|
+
static stateType = ATNState.BLOCK_START;
|
|
3290
|
+
};
|
|
3291
|
+
|
|
3292
|
+
// src/atn/AtomTransition.ts
|
|
3293
|
+
var AtomTransition = class extends Transition {
|
|
3294
|
+
static {
|
|
3295
|
+
__name(this, "AtomTransition");
|
|
3296
|
+
}
|
|
3297
|
+
/** The token type or character value; or, signifies special label. */
|
|
3298
|
+
labelValue;
|
|
3299
|
+
#label;
|
|
3300
|
+
constructor(target, label) {
|
|
3301
|
+
super(target);
|
|
3302
|
+
this.labelValue = label;
|
|
3303
|
+
this.#label = IntervalSet.of(label, label);
|
|
3304
|
+
}
|
|
3305
|
+
get label() {
|
|
3306
|
+
return this.#label;
|
|
3307
|
+
}
|
|
3308
|
+
get transitionType() {
|
|
3309
|
+
return Transition.ATOM;
|
|
3310
|
+
}
|
|
3311
|
+
matches(symbol) {
|
|
3312
|
+
return this.labelValue === symbol;
|
|
3313
|
+
}
|
|
3314
|
+
toString() {
|
|
3315
|
+
return this.labelValue.toString();
|
|
3316
|
+
}
|
|
3317
|
+
};
|
|
3318
|
+
|
|
3319
|
+
// src/atn/RuleTransition.ts
|
|
3320
|
+
var RuleTransition = class extends Transition {
|
|
3321
|
+
static {
|
|
3322
|
+
__name(this, "RuleTransition");
|
|
3323
|
+
}
|
|
3324
|
+
ruleIndex;
|
|
3325
|
+
precedence;
|
|
3326
|
+
followState;
|
|
3327
|
+
constructor(ruleStart, ruleIndex, precedence, followState) {
|
|
3328
|
+
super(ruleStart);
|
|
3329
|
+
this.ruleIndex = ruleIndex;
|
|
3330
|
+
this.precedence = precedence;
|
|
3331
|
+
this.followState = followState;
|
|
3332
|
+
}
|
|
3333
|
+
get isEpsilon() {
|
|
3334
|
+
return true;
|
|
3335
|
+
}
|
|
3336
|
+
get transitionType() {
|
|
3337
|
+
return Transition.RULE;
|
|
3338
|
+
}
|
|
3339
|
+
matches(_symbol, _minVocabSymbol, _maxVocabSymbol) {
|
|
3340
|
+
return false;
|
|
3341
|
+
}
|
|
3342
|
+
};
|
|
3343
|
+
|
|
3344
|
+
// src/atn/RangeTransition.ts
|
|
3345
|
+
var RangeTransition = class extends Transition {
|
|
3346
|
+
static {
|
|
3347
|
+
__name(this, "RangeTransition");
|
|
3348
|
+
}
|
|
3349
|
+
start;
|
|
3350
|
+
stop;
|
|
3351
|
+
#label = new IntervalSet();
|
|
3352
|
+
constructor(target, start, stop) {
|
|
3353
|
+
super(target);
|
|
3354
|
+
this.start = start;
|
|
3355
|
+
this.stop = stop;
|
|
3356
|
+
this.#label.addRange(start, stop);
|
|
3357
|
+
}
|
|
3358
|
+
get label() {
|
|
3359
|
+
return this.#label;
|
|
3360
|
+
}
|
|
3361
|
+
get transitionType() {
|
|
3362
|
+
return Transition.RANGE;
|
|
3363
|
+
}
|
|
3364
|
+
matches(symbol, _minVocabSymbol, _maxVocabSymbol) {
|
|
3365
|
+
return symbol >= this.start && symbol <= this.stop;
|
|
3366
|
+
}
|
|
3367
|
+
toString() {
|
|
3368
|
+
return "'" + String.fromCharCode(this.start) + "'..'" + String.fromCharCode(this.stop) + "'";
|
|
3369
|
+
}
|
|
3370
|
+
};
|
|
3371
|
+
|
|
3372
|
+
// src/atn/ActionTransition.ts
|
|
3373
|
+
var ActionTransition = class extends Transition {
|
|
3374
|
+
static {
|
|
3375
|
+
__name(this, "ActionTransition");
|
|
3376
|
+
}
|
|
3377
|
+
ruleIndex;
|
|
3378
|
+
actionIndex;
|
|
3379
|
+
isCtxDependent;
|
|
3380
|
+
constructor(target, ruleIndex, actionIndex, isCtxDependent) {
|
|
3381
|
+
super(target);
|
|
3382
|
+
this.ruleIndex = ruleIndex;
|
|
3383
|
+
this.actionIndex = actionIndex ?? -1;
|
|
3384
|
+
this.isCtxDependent = isCtxDependent ?? false;
|
|
3385
|
+
}
|
|
3386
|
+
get isEpsilon() {
|
|
3387
|
+
return true;
|
|
3388
|
+
}
|
|
3389
|
+
get transitionType() {
|
|
3390
|
+
return Transition.ACTION;
|
|
3391
|
+
}
|
|
3392
|
+
matches(_symbol, _minVocabSymbol, _maxVocabSymbol) {
|
|
3393
|
+
return false;
|
|
3394
|
+
}
|
|
3395
|
+
toString() {
|
|
3396
|
+
return "action_" + this.ruleIndex + ":" + this.actionIndex;
|
|
3397
|
+
}
|
|
3398
|
+
};
|
|
3399
|
+
|
|
3400
|
+
// src/atn/EpsilonTransition.ts
|
|
3401
|
+
var EpsilonTransition = class extends Transition {
|
|
3402
|
+
static {
|
|
3403
|
+
__name(this, "EpsilonTransition");
|
|
3404
|
+
}
|
|
3405
|
+
#outermostPrecedenceReturn;
|
|
3406
|
+
constructor(target, outermostPrecedenceReturn = -1) {
|
|
3407
|
+
super(target);
|
|
3408
|
+
this.#outermostPrecedenceReturn = outermostPrecedenceReturn;
|
|
3409
|
+
}
|
|
3410
|
+
/**
|
|
3411
|
+
* @returns the rule index of a precedence rule for which this transition is
|
|
3412
|
+
* returning from, where the precedence value is 0; otherwise, -1.
|
|
3413
|
+
*
|
|
3414
|
+
* @see ATNConfig.isPrecedenceFilterSuppressed()
|
|
3415
|
+
* @see ParserATNSimulator.applyPrecedenceFilter(ATNConfigSet)
|
|
3416
|
+
* @since 4.4.1
|
|
3417
|
+
*/
|
|
3418
|
+
get outermostPrecedenceReturn() {
|
|
3419
|
+
return this.#outermostPrecedenceReturn;
|
|
3420
|
+
}
|
|
3421
|
+
get isEpsilon() {
|
|
3422
|
+
return true;
|
|
3423
|
+
}
|
|
3424
|
+
get transitionType() {
|
|
3425
|
+
return Transition.EPSILON;
|
|
3426
|
+
}
|
|
3427
|
+
matches() {
|
|
3428
|
+
return false;
|
|
3429
|
+
}
|
|
3430
|
+
toString() {
|
|
3431
|
+
return "epsilon";
|
|
3432
|
+
}
|
|
3433
|
+
};
|
|
3434
|
+
|
|
3435
|
+
// src/atn/WildcardTransition.ts
|
|
3436
|
+
var WildcardTransition = class extends Transition {
|
|
3437
|
+
static {
|
|
3438
|
+
__name(this, "WildcardTransition");
|
|
3439
|
+
}
|
|
3440
|
+
get transitionType() {
|
|
3441
|
+
return Transition.WILDCARD;
|
|
3442
|
+
}
|
|
3443
|
+
matches(symbol, minVocabSymbol, maxVocabSymbol) {
|
|
3444
|
+
return symbol >= minVocabSymbol && symbol <= maxVocabSymbol;
|
|
3445
|
+
}
|
|
3446
|
+
toString() {
|
|
3447
|
+
return ".";
|
|
3448
|
+
}
|
|
3449
|
+
};
|
|
3450
|
+
|
|
3451
|
+
// src/atn/AbstractPredicateTransition.ts
|
|
3452
|
+
var AbstractPredicateTransition = class extends Transition {
|
|
3453
|
+
static {
|
|
3454
|
+
__name(this, "AbstractPredicateTransition");
|
|
3455
|
+
}
|
|
3456
|
+
constructor(target) {
|
|
3457
|
+
super(target);
|
|
3458
|
+
}
|
|
3459
|
+
};
|
|
3460
|
+
|
|
3461
|
+
// src/atn/PredicateTransition.ts
|
|
3462
|
+
var PredicateTransition = class extends AbstractPredicateTransition {
|
|
3463
|
+
static {
|
|
3464
|
+
__name(this, "PredicateTransition");
|
|
3465
|
+
}
|
|
3466
|
+
ruleIndex;
|
|
3467
|
+
predIndex;
|
|
3468
|
+
isCtxDependent;
|
|
3469
|
+
// e.g., $i ref in pred
|
|
3470
|
+
constructor(target, ruleIndex, predIndex, isCtxDependent) {
|
|
3471
|
+
super(target);
|
|
3472
|
+
this.ruleIndex = ruleIndex;
|
|
3473
|
+
this.predIndex = predIndex;
|
|
3474
|
+
this.isCtxDependent = isCtxDependent;
|
|
3475
|
+
}
|
|
3476
|
+
get isEpsilon() {
|
|
3477
|
+
return true;
|
|
3478
|
+
}
|
|
3479
|
+
matches(_symbol, _minVocabSymbol, _maxVocabSymbol) {
|
|
3480
|
+
return false;
|
|
3481
|
+
}
|
|
3482
|
+
get transitionType() {
|
|
3483
|
+
return Transition.PREDICATE;
|
|
3484
|
+
}
|
|
3485
|
+
getPredicate() {
|
|
3486
|
+
return new SemanticContext.Predicate(this.ruleIndex, this.predIndex, this.isCtxDependent);
|
|
3487
|
+
}
|
|
3488
|
+
toString() {
|
|
3489
|
+
return "pred_" + this.ruleIndex + ":" + this.predIndex;
|
|
3490
|
+
}
|
|
3491
|
+
};
|
|
3492
|
+
|
|
3493
|
+
// src/atn/PrecedencePredicateTransition.ts
|
|
3494
|
+
var PrecedencePredicateTransition = class extends AbstractPredicateTransition {
|
|
3495
|
+
static {
|
|
3496
|
+
__name(this, "PrecedencePredicateTransition");
|
|
3497
|
+
}
|
|
3498
|
+
precedence;
|
|
3499
|
+
constructor(target, precedence) {
|
|
3500
|
+
super(target);
|
|
3501
|
+
this.precedence = precedence;
|
|
3502
|
+
}
|
|
3503
|
+
get isEpsilon() {
|
|
3504
|
+
return true;
|
|
3505
|
+
}
|
|
3506
|
+
matches(_symbol, _minVocabSymbol, _maxVocabSymbol) {
|
|
3507
|
+
return false;
|
|
3508
|
+
}
|
|
3509
|
+
getPredicate() {
|
|
3510
|
+
return new SemanticContext.PrecedencePredicate(this.precedence);
|
|
3511
|
+
}
|
|
3512
|
+
get transitionType() {
|
|
3513
|
+
return Transition.PRECEDENCE;
|
|
3514
|
+
}
|
|
3515
|
+
toString() {
|
|
3516
|
+
return this.precedence + " >= _p";
|
|
3517
|
+
}
|
|
3518
|
+
};
|
|
3519
|
+
|
|
3520
|
+
// src/atn/LexerActionType.ts
|
|
3521
|
+
var LexerActionType = {
|
|
3522
|
+
/** The type of a {@link LexerChannelAction} action. */
|
|
3523
|
+
CHANNEL: 0,
|
|
3524
|
+
/** The type of a {@link LexerCustomAction} action */
|
|
3525
|
+
CUSTOM: 1,
|
|
3526
|
+
/** The type of a {@link LexerModeAction} action. */
|
|
3527
|
+
MODE: 2,
|
|
3528
|
+
/** The type of a {@link LexerMoreAction} action. */
|
|
3529
|
+
MORE: 3,
|
|
3530
|
+
/** The type of a {@link LexerPopModeAction} action. */
|
|
3531
|
+
POP_MODE: 4,
|
|
3532
|
+
/** The type of a {@link LexerPushModeAction} action. */
|
|
3533
|
+
PUSH_MODE: 5,
|
|
3534
|
+
/** The type of a {@link LexerSkipAction} action. */
|
|
3535
|
+
SKIP: 6,
|
|
3536
|
+
/** The type of a {@link LexerTypeAction} action. */
|
|
3537
|
+
TYPE: 7
|
|
3538
|
+
};
|
|
3539
|
+
|
|
3540
|
+
// src/atn/LexerSkipAction.ts
|
|
3541
|
+
var LexerSkipAction = class _LexerSkipAction {
|
|
3542
|
+
static {
|
|
3543
|
+
__name(this, "LexerSkipAction");
|
|
3544
|
+
}
|
|
3545
|
+
/** Provides a singleton instance of this parameter-less lexer action. */
|
|
3546
|
+
static instance = new _LexerSkipAction();
|
|
3547
|
+
actionType;
|
|
3548
|
+
isPositionDependent = false;
|
|
3549
|
+
constructor() {
|
|
3550
|
+
this.actionType = LexerActionType.SKIP;
|
|
3551
|
+
}
|
|
3552
|
+
equals(obj) {
|
|
3553
|
+
return obj === this;
|
|
3554
|
+
}
|
|
3555
|
+
hashCode() {
|
|
3556
|
+
return LexerActionType.SKIP;
|
|
3557
|
+
}
|
|
3558
|
+
execute(lexer) {
|
|
3559
|
+
lexer.skip();
|
|
3560
|
+
}
|
|
3561
|
+
toString() {
|
|
3562
|
+
return "skip";
|
|
3563
|
+
}
|
|
3564
|
+
};
|
|
3565
|
+
|
|
3566
|
+
// src/atn/LexerChannelAction.ts
|
|
3567
|
+
var LexerChannelAction = class _LexerChannelAction {
|
|
3568
|
+
static {
|
|
3569
|
+
__name(this, "LexerChannelAction");
|
|
3570
|
+
}
|
|
3571
|
+
channel;
|
|
3572
|
+
actionType;
|
|
3573
|
+
isPositionDependent = false;
|
|
3574
|
+
cachedHashCode;
|
|
3575
|
+
constructor(channel) {
|
|
3576
|
+
this.actionType = LexerActionType.CHANNEL;
|
|
3577
|
+
this.channel = channel;
|
|
3578
|
+
}
|
|
3579
|
+
/**
|
|
3580
|
+
* This action is implemented by calling {@link Lexer.setChannel} with the
|
|
3581
|
+
* value provided by {@link getChannel}.
|
|
3582
|
+
*/
|
|
3583
|
+
execute(lexer) {
|
|
3584
|
+
lexer.channel = this.channel;
|
|
3585
|
+
}
|
|
3586
|
+
hashCode() {
|
|
3587
|
+
if (this.cachedHashCode === void 0) {
|
|
3588
|
+
let hash = MurmurHash.initialize();
|
|
3589
|
+
hash = MurmurHash.update(hash, this.actionType);
|
|
3590
|
+
hash = MurmurHash.update(hash, this.channel);
|
|
3591
|
+
this.cachedHashCode = MurmurHash.finish(hash, 2);
|
|
3592
|
+
}
|
|
3593
|
+
return this.cachedHashCode;
|
|
3594
|
+
}
|
|
3595
|
+
equals(other) {
|
|
3596
|
+
if (this === other) {
|
|
3597
|
+
return true;
|
|
3598
|
+
}
|
|
3599
|
+
if (!(other instanceof _LexerChannelAction)) {
|
|
3600
|
+
return false;
|
|
3601
|
+
}
|
|
3602
|
+
return this.channel === other.channel;
|
|
3603
|
+
}
|
|
3604
|
+
toString() {
|
|
3605
|
+
return "channel(" + this.channel + ")";
|
|
3606
|
+
}
|
|
3607
|
+
};
|
|
3608
|
+
|
|
3609
|
+
// src/atn/LexerCustomAction.ts
|
|
3610
|
+
var LexerCustomAction = class _LexerCustomAction {
|
|
3611
|
+
static {
|
|
3612
|
+
__name(this, "LexerCustomAction");
|
|
3613
|
+
}
|
|
3614
|
+
ruleIndex;
|
|
3615
|
+
actionIndex;
|
|
3616
|
+
actionType;
|
|
3617
|
+
isPositionDependent = true;
|
|
3618
|
+
cachedHashCode;
|
|
3619
|
+
/**
|
|
3620
|
+
* Constructs a custom lexer action with the specified rule and action indexes.
|
|
3621
|
+
*
|
|
3622
|
+
* @param ruleIndex The rule index to use for calls to {@link Recognizer.action}.
|
|
3623
|
+
* @param actionIndex The action index to use for calls to {@link Recognizer.action}.
|
|
3624
|
+
*/
|
|
3625
|
+
constructor(ruleIndex, actionIndex) {
|
|
3626
|
+
this.actionType = LexerActionType.CUSTOM;
|
|
3627
|
+
this.ruleIndex = ruleIndex;
|
|
3628
|
+
this.actionIndex = actionIndex;
|
|
3629
|
+
}
|
|
3630
|
+
/**
|
|
3631
|
+
* Custom actions are implemented by calling {@link Lexer.action} with the
|
|
3632
|
+
* appropriate rule and action indexes.
|
|
3633
|
+
*/
|
|
3634
|
+
execute(lexer) {
|
|
3635
|
+
lexer.action(null, this.ruleIndex, this.actionIndex);
|
|
3636
|
+
}
|
|
3637
|
+
hashCode() {
|
|
3638
|
+
if (this.cachedHashCode === void 0) {
|
|
3639
|
+
let hash = MurmurHash.initialize();
|
|
3640
|
+
hash = MurmurHash.update(hash, this.actionType);
|
|
3641
|
+
hash = MurmurHash.update(hash, this.ruleIndex);
|
|
3642
|
+
hash = MurmurHash.update(hash, this.actionIndex);
|
|
3643
|
+
this.cachedHashCode = MurmurHash.finish(hash, 3);
|
|
3644
|
+
}
|
|
3645
|
+
return this.cachedHashCode;
|
|
3646
|
+
}
|
|
3647
|
+
equals(other) {
|
|
3648
|
+
if (this === other) {
|
|
3649
|
+
return true;
|
|
3650
|
+
}
|
|
3651
|
+
if (!(other instanceof _LexerCustomAction)) {
|
|
3652
|
+
return false;
|
|
3653
|
+
}
|
|
3654
|
+
return this.ruleIndex === other.ruleIndex && this.actionIndex === other.actionIndex;
|
|
3655
|
+
}
|
|
3656
|
+
};
|
|
3657
|
+
|
|
3658
|
+
// src/atn/LexerMoreAction.ts
|
|
3659
|
+
var LexerMoreAction = class _LexerMoreAction {
|
|
3660
|
+
static {
|
|
3661
|
+
__name(this, "LexerMoreAction");
|
|
3662
|
+
}
|
|
3663
|
+
static instance = new _LexerMoreAction();
|
|
3664
|
+
actionType;
|
|
3665
|
+
isPositionDependent = false;
|
|
3666
|
+
constructor() {
|
|
3667
|
+
this.actionType = LexerActionType.MORE;
|
|
3668
|
+
}
|
|
3669
|
+
equals(obj) {
|
|
3670
|
+
return obj === this;
|
|
3671
|
+
}
|
|
3672
|
+
hashCode() {
|
|
3673
|
+
return LexerActionType.MORE;
|
|
3674
|
+
}
|
|
3675
|
+
/**
|
|
3676
|
+
* This action is implemented by calling {@link Lexer.popMode}.
|
|
3677
|
+
*/
|
|
3678
|
+
execute(lexer) {
|
|
3679
|
+
lexer.more();
|
|
3680
|
+
}
|
|
3681
|
+
toString() {
|
|
3682
|
+
return "more";
|
|
3683
|
+
}
|
|
3684
|
+
};
|
|
3685
|
+
|
|
3686
|
+
// src/atn/LexerTypeAction.ts
|
|
3687
|
+
var LexerTypeAction = class _LexerTypeAction {
|
|
3688
|
+
static {
|
|
3689
|
+
__name(this, "LexerTypeAction");
|
|
3690
|
+
}
|
|
3691
|
+
type;
|
|
3692
|
+
actionType;
|
|
3693
|
+
isPositionDependent = false;
|
|
3694
|
+
cachedHashCode;
|
|
3695
|
+
constructor(type) {
|
|
3696
|
+
this.actionType = LexerActionType.TYPE;
|
|
3697
|
+
this.type = type;
|
|
3698
|
+
}
|
|
3699
|
+
execute(lexer) {
|
|
3700
|
+
lexer.type = this.type;
|
|
3701
|
+
}
|
|
3702
|
+
hashCode() {
|
|
3703
|
+
if (this.cachedHashCode === void 0) {
|
|
3704
|
+
let hash = MurmurHash.initialize();
|
|
3705
|
+
hash = MurmurHash.update(hash, this.actionType);
|
|
3706
|
+
hash = MurmurHash.update(hash, this.type);
|
|
3707
|
+
this.cachedHashCode = MurmurHash.finish(hash, 2);
|
|
3708
|
+
}
|
|
3709
|
+
return this.cachedHashCode;
|
|
3710
|
+
}
|
|
3711
|
+
equals(other) {
|
|
3712
|
+
if (this === other) {
|
|
3713
|
+
return true;
|
|
3714
|
+
}
|
|
3715
|
+
if (!(other instanceof _LexerTypeAction)) {
|
|
3716
|
+
return false;
|
|
3717
|
+
}
|
|
3718
|
+
return this.type === other.type;
|
|
3719
|
+
}
|
|
3720
|
+
toString() {
|
|
3721
|
+
return "type(" + this.type + ")";
|
|
3722
|
+
}
|
|
3723
|
+
};
|
|
3724
|
+
|
|
3725
|
+
// src/atn/LexerPushModeAction.ts
|
|
3726
|
+
var LexerPushModeAction = class _LexerPushModeAction {
|
|
3727
|
+
static {
|
|
3728
|
+
__name(this, "LexerPushModeAction");
|
|
3729
|
+
}
|
|
3730
|
+
mode;
|
|
3731
|
+
actionType;
|
|
3732
|
+
isPositionDependent = false;
|
|
3733
|
+
cachedHashCode;
|
|
3734
|
+
constructor(mode) {
|
|
3735
|
+
this.actionType = LexerActionType.PUSH_MODE;
|
|
3736
|
+
this.mode = mode;
|
|
3737
|
+
}
|
|
3738
|
+
/**
|
|
3739
|
+
* This action is implemented by calling {@link Lexer.pushMode} with the
|
|
3740
|
+
* value provided by {@link getMode}.
|
|
3741
|
+
*/
|
|
3742
|
+
execute(lexer) {
|
|
3743
|
+
lexer.pushMode(this.mode);
|
|
3744
|
+
}
|
|
3745
|
+
hashCode() {
|
|
3746
|
+
if (this.cachedHashCode === void 0) {
|
|
3747
|
+
let hash = MurmurHash.initialize();
|
|
3748
|
+
hash = MurmurHash.update(hash, this.actionType);
|
|
3749
|
+
hash = MurmurHash.update(hash, this.mode);
|
|
3750
|
+
this.cachedHashCode = MurmurHash.finish(hash, 2);
|
|
3751
|
+
}
|
|
3752
|
+
return this.cachedHashCode;
|
|
3753
|
+
}
|
|
3754
|
+
equals(other) {
|
|
3755
|
+
if (this === other) {
|
|
3756
|
+
return true;
|
|
3757
|
+
}
|
|
3758
|
+
if (!(other instanceof _LexerPushModeAction)) {
|
|
3759
|
+
return false;
|
|
3760
|
+
}
|
|
3761
|
+
return this.mode === other.mode;
|
|
3762
|
+
}
|
|
3763
|
+
toString() {
|
|
3764
|
+
return "pushMode(" + this.mode + ")";
|
|
3765
|
+
}
|
|
3766
|
+
};
|
|
3767
|
+
|
|
3768
|
+
// src/atn/LexerPopModeAction.ts
|
|
3769
|
+
var LexerPopModeAction = class _LexerPopModeAction {
|
|
3770
|
+
static {
|
|
3771
|
+
__name(this, "LexerPopModeAction");
|
|
3772
|
+
}
|
|
3773
|
+
static instance = new _LexerPopModeAction();
|
|
3774
|
+
actionType;
|
|
3775
|
+
isPositionDependent = false;
|
|
3776
|
+
constructor() {
|
|
3777
|
+
this.actionType = LexerActionType.POP_MODE;
|
|
3778
|
+
}
|
|
3779
|
+
equals(obj) {
|
|
3780
|
+
return obj === this;
|
|
3781
|
+
}
|
|
3782
|
+
hashCode() {
|
|
3783
|
+
return LexerActionType.POP_MODE;
|
|
3784
|
+
}
|
|
3785
|
+
/**
|
|
3786
|
+
* This action is implemented by calling {@link Lexer//popMode}.
|
|
3787
|
+
*/
|
|
3788
|
+
execute(lexer) {
|
|
3789
|
+
lexer.popMode();
|
|
3790
|
+
}
|
|
3791
|
+
toString() {
|
|
3792
|
+
return "popMode";
|
|
3793
|
+
}
|
|
3794
|
+
};
|
|
3795
|
+
|
|
3796
|
+
// src/atn/LexerModeAction.ts
|
|
3797
|
+
var LexerModeAction = class _LexerModeAction {
|
|
3798
|
+
static {
|
|
3799
|
+
__name(this, "LexerModeAction");
|
|
3800
|
+
}
|
|
3801
|
+
mode;
|
|
3802
|
+
actionType;
|
|
3803
|
+
isPositionDependent = false;
|
|
3804
|
+
cachedHashCode;
|
|
3805
|
+
constructor(mode) {
|
|
3806
|
+
this.actionType = LexerActionType.MODE;
|
|
3807
|
+
this.mode = mode;
|
|
3808
|
+
}
|
|
3809
|
+
/**
|
|
3810
|
+
* This action is implemented by calling {@link Lexer.mode} with the
|
|
3811
|
+
* value provided by {@link getMode}.
|
|
3812
|
+
*/
|
|
3813
|
+
execute(lexer) {
|
|
3814
|
+
lexer.mode = this.mode;
|
|
3815
|
+
}
|
|
3816
|
+
hashCode() {
|
|
3817
|
+
if (this.cachedHashCode === void 0) {
|
|
3818
|
+
let hash = MurmurHash.initialize();
|
|
3819
|
+
hash = MurmurHash.update(hash, this.actionType);
|
|
3820
|
+
hash = MurmurHash.update(hash, this.mode);
|
|
3821
|
+
this.cachedHashCode = MurmurHash.finish(hash, 2);
|
|
3822
|
+
}
|
|
3823
|
+
return this.cachedHashCode;
|
|
3824
|
+
}
|
|
3825
|
+
equals(other) {
|
|
3826
|
+
if (this === other) {
|
|
3827
|
+
return true;
|
|
3828
|
+
}
|
|
3829
|
+
if (!(other instanceof _LexerModeAction)) {
|
|
3830
|
+
return false;
|
|
3831
|
+
}
|
|
3832
|
+
return this.mode === other.mode;
|
|
3833
|
+
}
|
|
3834
|
+
toString() {
|
|
3835
|
+
return "mode(" + this.mode + ")";
|
|
3836
|
+
}
|
|
3837
|
+
};
|
|
3838
|
+
|
|
3839
|
+
// src/atn/ATNDeserializer.ts
|
|
3840
|
+
var ATNDeserializer = class _ATNDeserializer {
|
|
3841
|
+
static {
|
|
3842
|
+
__name(this, "ATNDeserializer");
|
|
3843
|
+
}
|
|
3844
|
+
static SERIALIZED_VERSION = 4;
|
|
3845
|
+
static stateTypeMapper = /* @__PURE__ */ new Map([
|
|
3846
|
+
[ATNState.INVALID_TYPE, void 0],
|
|
3847
|
+
[ATNState.BASIC, BasicState],
|
|
3848
|
+
[ATNState.RULE_START, RuleStartState],
|
|
3849
|
+
[ATNState.BLOCK_START, BasicBlockStartState],
|
|
3850
|
+
[ATNState.PLUS_BLOCK_START, PlusBlockStartState],
|
|
3851
|
+
[ATNState.STAR_BLOCK_START, StarBlockStartState],
|
|
3852
|
+
[ATNState.TOKEN_START, TokensStartState],
|
|
3853
|
+
[ATNState.RULE_STOP, RuleStopState],
|
|
3854
|
+
[ATNState.BLOCK_END, BlockEndState],
|
|
3855
|
+
[ATNState.STAR_LOOP_BACK, StarLoopbackState],
|
|
3856
|
+
[ATNState.STAR_LOOP_ENTRY, StarLoopEntryState],
|
|
3857
|
+
[ATNState.PLUS_LOOP_BACK, PlusLoopbackState],
|
|
3858
|
+
[ATNState.LOOP_END, LoopEndState]
|
|
3859
|
+
]);
|
|
3860
|
+
static lexerActionFactoryMapper = /* @__PURE__ */ new Map([
|
|
3861
|
+
[LexerActionType.CHANNEL, (data1) => {
|
|
3862
|
+
return new LexerChannelAction(data1);
|
|
3863
|
+
}],
|
|
3864
|
+
[LexerActionType.CUSTOM, (data1, data2) => {
|
|
3865
|
+
return new LexerCustomAction(data1, data2);
|
|
3866
|
+
}],
|
|
3867
|
+
[LexerActionType.MODE, (data1) => {
|
|
3868
|
+
return new LexerModeAction(data1);
|
|
3869
|
+
}],
|
|
3870
|
+
[LexerActionType.MORE, () => {
|
|
3871
|
+
return LexerMoreAction.instance;
|
|
3872
|
+
}],
|
|
3873
|
+
[LexerActionType.POP_MODE, () => {
|
|
3874
|
+
return LexerPopModeAction.instance;
|
|
3875
|
+
}],
|
|
3876
|
+
[LexerActionType.PUSH_MODE, (data1) => {
|
|
3877
|
+
return new LexerPushModeAction(data1);
|
|
3878
|
+
}],
|
|
3879
|
+
[LexerActionType.SKIP, () => {
|
|
3880
|
+
return LexerSkipAction.instance;
|
|
3881
|
+
}],
|
|
3882
|
+
[LexerActionType.TYPE, (data1) => {
|
|
3883
|
+
return new LexerTypeAction(data1);
|
|
3884
|
+
}]
|
|
3885
|
+
]);
|
|
3886
|
+
data = [];
|
|
3887
|
+
pos = 0;
|
|
3888
|
+
deserializationOptions;
|
|
3889
|
+
actionFactories;
|
|
3890
|
+
constructor(options) {
|
|
3891
|
+
if (!options) {
|
|
3892
|
+
options = { readOnly: false, verifyATN: true, generateRuleBypassTransitions: false };
|
|
3893
|
+
}
|
|
3894
|
+
this.deserializationOptions = options;
|
|
3895
|
+
}
|
|
3896
|
+
deserialize(data) {
|
|
3897
|
+
this.data = data;
|
|
3898
|
+
this.checkVersion();
|
|
3899
|
+
const atn = this.readATN();
|
|
3900
|
+
this.readStates(atn);
|
|
3901
|
+
this.readRules(atn);
|
|
3902
|
+
this.readModes(atn);
|
|
3903
|
+
const sets = [];
|
|
3904
|
+
this.readSets(atn, sets);
|
|
3905
|
+
this.readEdges(atn, sets);
|
|
3906
|
+
this.readDecisions(atn);
|
|
3907
|
+
this.readLexerActions(atn);
|
|
3908
|
+
this.markPrecedenceDecisions(atn);
|
|
3909
|
+
this.verifyATN(atn);
|
|
3910
|
+
if (this.deserializationOptions.generateRuleBypassTransitions && atn.grammarType === ATN.PARSER) {
|
|
3911
|
+
this.generateRuleBypassTransitions(atn);
|
|
3912
|
+
this.verifyATN(atn);
|
|
3913
|
+
}
|
|
3914
|
+
return atn;
|
|
3915
|
+
}
|
|
3916
|
+
checkVersion() {
|
|
3917
|
+
const version = this.data[this.pos++];
|
|
3918
|
+
if (version !== _ATNDeserializer.SERIALIZED_VERSION) {
|
|
3919
|
+
throw new Error("Could not deserialize ATN with version " + version + " (expected " + _ATNDeserializer.SERIALIZED_VERSION + ").");
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3922
|
+
readATN() {
|
|
3923
|
+
const grammarType = this.data[this.pos++];
|
|
3924
|
+
const maxTokenType = this.data[this.pos++];
|
|
3925
|
+
return new ATN(grammarType, maxTokenType);
|
|
3926
|
+
}
|
|
3927
|
+
readStates(atn) {
|
|
3928
|
+
let j;
|
|
3929
|
+
let stateNumber;
|
|
3930
|
+
const loopBackStateNumbers = [];
|
|
3931
|
+
const endStateNumbers = [];
|
|
3932
|
+
const stateCount = this.data[this.pos++];
|
|
3933
|
+
for (let i = 0; i < stateCount; i++) {
|
|
3934
|
+
const stateType = this.data[this.pos++];
|
|
3935
|
+
if (stateType === ATNState.INVALID_TYPE) {
|
|
3936
|
+
atn.addState(null);
|
|
3937
|
+
continue;
|
|
3938
|
+
}
|
|
3939
|
+
const ruleIndex = this.data[this.pos++];
|
|
3940
|
+
const s = this.stateFactory(stateType, ruleIndex);
|
|
3941
|
+
if (stateType === ATNState.LOOP_END) {
|
|
3942
|
+
const loopBackStateNumber = this.data[this.pos++];
|
|
3943
|
+
loopBackStateNumbers.push([s, loopBackStateNumber]);
|
|
3944
|
+
} else if (s instanceof BlockStartState) {
|
|
3945
|
+
const endStateNumber = this.data[this.pos++];
|
|
3946
|
+
endStateNumbers.push([s, endStateNumber]);
|
|
3947
|
+
}
|
|
3948
|
+
atn.addState(s);
|
|
3949
|
+
}
|
|
3950
|
+
for (j = 0; j < loopBackStateNumbers.length; j++) {
|
|
3951
|
+
const pair = loopBackStateNumbers[j];
|
|
3952
|
+
pair[0].loopBackState = atn.states[pair[1]] ?? void 0;
|
|
3953
|
+
}
|
|
3954
|
+
for (j = 0; j < endStateNumbers.length; j++) {
|
|
3955
|
+
const pair = endStateNumbers[j];
|
|
3956
|
+
pair[0].endState = atn.states[pair[1]];
|
|
3957
|
+
}
|
|
3958
|
+
const numNonGreedyStates = this.data[this.pos++];
|
|
3959
|
+
for (j = 0; j < numNonGreedyStates; j++) {
|
|
3960
|
+
stateNumber = this.data[this.pos++];
|
|
3961
|
+
atn.states[stateNumber].nonGreedy = true;
|
|
3962
|
+
}
|
|
3963
|
+
const numPrecedenceStates = this.data[this.pos++];
|
|
3964
|
+
for (j = 0; j < numPrecedenceStates; j++) {
|
|
3965
|
+
stateNumber = this.data[this.pos++];
|
|
3966
|
+
atn.states[stateNumber].isLeftRecursiveRule = true;
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
readRules(atn) {
|
|
3970
|
+
let i;
|
|
3971
|
+
const ruleCount = this.data[this.pos++];
|
|
3972
|
+
if (atn.grammarType === ATN.LEXER) {
|
|
3973
|
+
atn.ruleToTokenType = new Array(ruleCount);
|
|
3974
|
+
atn.ruleToTokenType.fill(0);
|
|
3975
|
+
}
|
|
3976
|
+
atn.ruleToStartState = new Array(ruleCount);
|
|
3977
|
+
atn.ruleToStartState.fill(null);
|
|
3978
|
+
for (i = 0; i < ruleCount; i++) {
|
|
3979
|
+
const s = this.data[this.pos++];
|
|
3980
|
+
atn.ruleToStartState[i] = atn.states[s];
|
|
3981
|
+
if (atn.grammarType === ATN.LEXER) {
|
|
3982
|
+
const tokenType = this.data[this.pos++];
|
|
3983
|
+
atn.ruleToTokenType[i] = tokenType;
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
atn.ruleToStopState = new Array(ruleCount);
|
|
3987
|
+
atn.ruleToStopState.fill(null);
|
|
3988
|
+
for (i = 0; i < atn.states.length; i++) {
|
|
3989
|
+
const state = atn.states[i];
|
|
3990
|
+
if (!(state instanceof RuleStopState)) {
|
|
3991
|
+
continue;
|
|
3992
|
+
}
|
|
3993
|
+
atn.ruleToStopState[state.ruleIndex] = state;
|
|
3994
|
+
atn.ruleToStartState[state.ruleIndex].stopState = state;
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
readModes(atn) {
|
|
3998
|
+
const modeCount = this.data[this.pos++];
|
|
3999
|
+
for (let i = 0; i < modeCount; i++) {
|
|
4000
|
+
const s = this.data[this.pos++];
|
|
4001
|
+
atn.modeToStartState.push(atn.states[s]);
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
readSets(atn, sets) {
|
|
4005
|
+
const m2 = this.data[this.pos++];
|
|
4006
|
+
for (let i = 0; i < m2; i++) {
|
|
4007
|
+
const intervalSet = new IntervalSet();
|
|
4008
|
+
sets.push(intervalSet);
|
|
4009
|
+
const n2 = this.data[this.pos++];
|
|
4010
|
+
const containsEof = this.data[this.pos++];
|
|
4011
|
+
if (containsEof !== 0) {
|
|
4012
|
+
intervalSet.addOne(-1);
|
|
4013
|
+
}
|
|
4014
|
+
for (let j = 0; j < n2; j++) {
|
|
4015
|
+
const i1 = this.data[this.pos++];
|
|
4016
|
+
const i2 = this.data[this.pos++];
|
|
4017
|
+
intervalSet.addRange(i1, i2);
|
|
4018
|
+
}
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
readEdges(atn, sets) {
|
|
4022
|
+
let i;
|
|
4023
|
+
let j;
|
|
4024
|
+
let state;
|
|
4025
|
+
let trans;
|
|
4026
|
+
let target;
|
|
4027
|
+
const edgeCount = this.data[this.pos++];
|
|
4028
|
+
for (i = 0; i < edgeCount; i++) {
|
|
4029
|
+
const src = this.data[this.pos++];
|
|
4030
|
+
const trg = this.data[this.pos++];
|
|
4031
|
+
const ttype = this.data[this.pos++];
|
|
4032
|
+
const arg1 = this.data[this.pos++];
|
|
4033
|
+
const arg2 = this.data[this.pos++];
|
|
4034
|
+
const arg3 = this.data[this.pos++];
|
|
4035
|
+
trans = this.edgeFactory(atn, ttype, trg, arg1, arg2, arg3, sets);
|
|
4036
|
+
const srcState = atn.states[src];
|
|
4037
|
+
srcState.addTransition(trans);
|
|
4038
|
+
}
|
|
4039
|
+
for (i = 0; i < atn.states.length; i++) {
|
|
4040
|
+
state = atn.states[i];
|
|
4041
|
+
for (j = 0; j < state.transitions.length; j++) {
|
|
4042
|
+
const t = state.transitions[j];
|
|
4043
|
+
if (!(t instanceof RuleTransition)) {
|
|
4044
|
+
continue;
|
|
4045
|
+
}
|
|
4046
|
+
let outermostPrecedenceReturn = -1;
|
|
4047
|
+
if (atn.ruleToStartState[t.target.ruleIndex].isLeftRecursiveRule) {
|
|
4048
|
+
if (t.precedence === 0) {
|
|
4049
|
+
outermostPrecedenceReturn = t.target.ruleIndex;
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
trans = new EpsilonTransition(t.followState, outermostPrecedenceReturn);
|
|
4053
|
+
atn.ruleToStopState[t.target.ruleIndex].addTransition(trans);
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
for (i = 0; i < atn.states.length; i++) {
|
|
4057
|
+
state = atn.states[i];
|
|
4058
|
+
if (state instanceof BlockStartState) {
|
|
4059
|
+
if (!state.endState) {
|
|
4060
|
+
throw new Error("IllegalState");
|
|
4061
|
+
}
|
|
4062
|
+
if (state.endState.startState) {
|
|
4063
|
+
throw new Error("IllegalState");
|
|
4064
|
+
}
|
|
4065
|
+
state.endState.startState = state;
|
|
4066
|
+
}
|
|
4067
|
+
if (state instanceof PlusLoopbackState) {
|
|
4068
|
+
for (j = 0; j < state.transitions.length; j++) {
|
|
4069
|
+
target = state.transitions[j].target;
|
|
4070
|
+
if (target instanceof PlusBlockStartState) {
|
|
4071
|
+
target.loopBackState = state;
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
} else if (state instanceof StarLoopbackState) {
|
|
4075
|
+
for (j = 0; j < state.transitions.length; j++) {
|
|
4076
|
+
target = state.transitions[j].target;
|
|
4077
|
+
if (target instanceof StarLoopEntryState) {
|
|
4078
|
+
target.loopBackState = state;
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4083
|
+
}
|
|
4084
|
+
readDecisions(atn) {
|
|
4085
|
+
const decisionCount = this.data[this.pos++];
|
|
4086
|
+
for (let i = 0; i < decisionCount; i++) {
|
|
4087
|
+
const s = this.data[this.pos++];
|
|
4088
|
+
const decState = atn.states[s];
|
|
4089
|
+
atn.decisionToState.push(decState);
|
|
4090
|
+
decState.decision = i;
|
|
4091
|
+
}
|
|
4092
|
+
}
|
|
4093
|
+
readLexerActions(atn) {
|
|
4094
|
+
if (atn.grammarType === ATN.LEXER) {
|
|
4095
|
+
const count = this.data[this.pos++];
|
|
4096
|
+
atn.lexerActions = [];
|
|
4097
|
+
for (let i = 0; i < count; i++) {
|
|
4098
|
+
const actionType = this.data[this.pos++];
|
|
4099
|
+
const data1 = this.data[this.pos++];
|
|
4100
|
+
const data2 = this.data[this.pos++];
|
|
4101
|
+
atn.lexerActions.push(this.lexerActionFactory(actionType, data1, data2));
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
generateRuleBypassTransitions(atn) {
|
|
4106
|
+
let i;
|
|
4107
|
+
const count = atn.ruleToStartState.length;
|
|
4108
|
+
for (i = 0; i < count; i++) {
|
|
4109
|
+
atn.ruleToTokenType[i] = atn.maxTokenType + i + 1;
|
|
4110
|
+
}
|
|
4111
|
+
for (i = 0; i < count; i++) {
|
|
4112
|
+
this.generateRuleBypassTransition(atn, i);
|
|
4113
|
+
}
|
|
4114
|
+
}
|
|
4115
|
+
generateRuleBypassTransition(atn, idx) {
|
|
4116
|
+
let i;
|
|
4117
|
+
let state;
|
|
4118
|
+
const bypassStart = new BasicBlockStartState();
|
|
4119
|
+
bypassStart.ruleIndex = idx;
|
|
4120
|
+
atn.addState(bypassStart);
|
|
4121
|
+
const bypassStop = new BlockEndState();
|
|
4122
|
+
bypassStop.ruleIndex = idx;
|
|
4123
|
+
atn.addState(bypassStop);
|
|
4124
|
+
bypassStart.endState = bypassStop;
|
|
4125
|
+
atn.defineDecisionState(bypassStart);
|
|
4126
|
+
bypassStop.startState = bypassStart;
|
|
4127
|
+
let excludeTransition = null;
|
|
4128
|
+
let endState = null;
|
|
4129
|
+
if (atn.ruleToStartState[idx].isLeftRecursiveRule) {
|
|
4130
|
+
endState = null;
|
|
4131
|
+
for (i = 0; i < atn.states.length; i++) {
|
|
4132
|
+
state = atn.states[i];
|
|
4133
|
+
if (this.stateIsEndStateFor(state, idx)) {
|
|
4134
|
+
endState = state;
|
|
4135
|
+
excludeTransition = state.loopBackState.transitions[0];
|
|
4136
|
+
break;
|
|
4137
|
+
}
|
|
4138
|
+
}
|
|
4139
|
+
if (excludeTransition === null) {
|
|
4140
|
+
throw new Error("Couldn't identify final state of the precedence rule prefix section.");
|
|
4141
|
+
}
|
|
4142
|
+
} else {
|
|
4143
|
+
endState = atn.ruleToStopState[idx];
|
|
4144
|
+
}
|
|
4145
|
+
for (i = 0; i < atn.states.length; i++) {
|
|
4146
|
+
state = atn.states[i];
|
|
4147
|
+
for (const transition of state.transitions) {
|
|
4148
|
+
if (transition === excludeTransition) {
|
|
4149
|
+
continue;
|
|
4150
|
+
}
|
|
4151
|
+
if (transition.target === endState) {
|
|
4152
|
+
transition.target = bypassStop;
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
}
|
|
4156
|
+
const ruleToStartState = atn.ruleToStartState[idx];
|
|
4157
|
+
while (ruleToStartState.transitions.length > 0) {
|
|
4158
|
+
const transition = ruleToStartState.removeTransition(ruleToStartState.transitions.length - 1);
|
|
4159
|
+
bypassStart.addTransition(transition);
|
|
4160
|
+
}
|
|
4161
|
+
atn.ruleToStartState[idx].addTransition(new EpsilonTransition(bypassStart));
|
|
4162
|
+
if (endState) {
|
|
4163
|
+
bypassStop.addTransition(new EpsilonTransition(endState));
|
|
4164
|
+
}
|
|
4165
|
+
const matchState = new BasicState();
|
|
4166
|
+
atn.addState(matchState);
|
|
4167
|
+
matchState.addTransition(new AtomTransition(bypassStop, atn.ruleToTokenType[idx]));
|
|
4168
|
+
bypassStart.addTransition(new EpsilonTransition(matchState));
|
|
4169
|
+
}
|
|
4170
|
+
stateIsEndStateFor(state, idx) {
|
|
4171
|
+
if (state.ruleIndex !== idx) {
|
|
4172
|
+
return null;
|
|
4173
|
+
}
|
|
4174
|
+
if (!(state instanceof StarLoopEntryState)) {
|
|
4175
|
+
return null;
|
|
4176
|
+
}
|
|
4177
|
+
const maybeLoopEndState = state.transitions[state.transitions.length - 1].target;
|
|
4178
|
+
if (!(maybeLoopEndState instanceof LoopEndState)) {
|
|
4179
|
+
return null;
|
|
4180
|
+
}
|
|
4181
|
+
if (maybeLoopEndState.epsilonOnlyTransitions && maybeLoopEndState.transitions[0].target instanceof RuleStopState) {
|
|
4182
|
+
return state;
|
|
4183
|
+
} else {
|
|
4184
|
+
return null;
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
/**
|
|
4188
|
+
* Analyze the {@link StarLoopEntryState} states in the specified ATN to set
|
|
4189
|
+
* the {@link StarLoopEntryState} field to the correct value.
|
|
4190
|
+
*
|
|
4191
|
+
* @param atn The ATN.
|
|
4192
|
+
*/
|
|
4193
|
+
markPrecedenceDecisions(atn) {
|
|
4194
|
+
for (const state of atn.states) {
|
|
4195
|
+
if (!(state instanceof StarLoopEntryState)) {
|
|
4196
|
+
continue;
|
|
4197
|
+
}
|
|
4198
|
+
if (atn.ruleToStartState[state.ruleIndex].isLeftRecursiveRule) {
|
|
4199
|
+
const maybeLoopEndState = state.transitions[state.transitions.length - 1].target;
|
|
4200
|
+
if (maybeLoopEndState instanceof LoopEndState) {
|
|
4201
|
+
if (maybeLoopEndState.epsilonOnlyTransitions && maybeLoopEndState.transitions[0].target instanceof RuleStopState) {
|
|
4202
|
+
state.precedenceRuleDecision = true;
|
|
4203
|
+
}
|
|
4204
|
+
}
|
|
4205
|
+
}
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
verifyATN(atn) {
|
|
4209
|
+
if (!this.deserializationOptions.verifyATN) {
|
|
4210
|
+
return;
|
|
4211
|
+
}
|
|
4212
|
+
for (const state of atn.states) {
|
|
4213
|
+
if (state === null) {
|
|
4214
|
+
continue;
|
|
4215
|
+
}
|
|
4216
|
+
this.checkCondition(state.epsilonOnlyTransitions || state.transitions.length <= 1);
|
|
4217
|
+
if (state instanceof PlusBlockStartState) {
|
|
4218
|
+
this.checkCondition(state.loopBackState !== null);
|
|
4219
|
+
} else if (state instanceof StarLoopEntryState) {
|
|
4220
|
+
this.checkCondition(state.loopBackState !== null);
|
|
4221
|
+
this.checkCondition(state.transitions.length === 2);
|
|
4222
|
+
if (state.transitions[0].target instanceof StarBlockStartState) {
|
|
4223
|
+
this.checkCondition(state.transitions[1].target instanceof LoopEndState);
|
|
4224
|
+
this.checkCondition(!state.nonGreedy);
|
|
4225
|
+
} else if (state.transitions[0].target instanceof LoopEndState) {
|
|
4226
|
+
this.checkCondition(state.transitions[1].target instanceof StarBlockStartState);
|
|
4227
|
+
this.checkCondition(state.nonGreedy);
|
|
4228
|
+
} else {
|
|
4229
|
+
throw new Error("IllegalState");
|
|
4230
|
+
}
|
|
4231
|
+
} else if (state instanceof StarLoopbackState) {
|
|
4232
|
+
this.checkCondition(state.transitions.length === 1);
|
|
4233
|
+
this.checkCondition(state.transitions[0].target instanceof StarLoopEntryState);
|
|
4234
|
+
} else if (state instanceof LoopEndState) {
|
|
4235
|
+
this.checkCondition(state.loopBackState !== null);
|
|
4236
|
+
} else if (state instanceof RuleStartState) {
|
|
4237
|
+
this.checkCondition(state.stopState !== null);
|
|
4238
|
+
} else if (state instanceof BlockStartState) {
|
|
4239
|
+
this.checkCondition(state.endState !== null);
|
|
4240
|
+
} else if (state instanceof BlockEndState) {
|
|
4241
|
+
this.checkCondition(state.startState !== null);
|
|
4242
|
+
} else if (state instanceof DecisionState) {
|
|
4243
|
+
this.checkCondition(state.transitions.length <= 1 || state.decision >= 0);
|
|
4244
|
+
} else {
|
|
4245
|
+
this.checkCondition(state.transitions.length <= 1 || state instanceof RuleStopState);
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
checkCondition(condition, message) {
|
|
4250
|
+
if (!condition) {
|
|
4251
|
+
if (message === void 0 || message === null) {
|
|
4252
|
+
message = "IllegalState";
|
|
4253
|
+
}
|
|
4254
|
+
throw message;
|
|
4255
|
+
}
|
|
4256
|
+
}
|
|
4257
|
+
edgeFactory(atn, type, trg, arg1, arg2, arg3, sets) {
|
|
4258
|
+
const target = atn.states[trg];
|
|
4259
|
+
switch (type) {
|
|
4260
|
+
case Transition.EPSILON:
|
|
4261
|
+
return new EpsilonTransition(target);
|
|
4262
|
+
case Transition.RANGE:
|
|
4263
|
+
return arg3 !== 0 ? new RangeTransition(target, Token.EOF, arg2) : new RangeTransition(target, arg1, arg2);
|
|
4264
|
+
case Transition.RULE:
|
|
4265
|
+
return new RuleTransition(atn.states[arg1], arg2, arg3, target);
|
|
4266
|
+
case Transition.PREDICATE:
|
|
4267
|
+
return new PredicateTransition(target, arg1, arg2, arg3 !== 0);
|
|
4268
|
+
case Transition.PRECEDENCE:
|
|
4269
|
+
return new PrecedencePredicateTransition(target, arg1);
|
|
4270
|
+
case Transition.ATOM:
|
|
4271
|
+
return arg3 !== 0 ? new AtomTransition(target, Token.EOF) : new AtomTransition(target, arg1);
|
|
4272
|
+
case Transition.ACTION:
|
|
4273
|
+
return new ActionTransition(target, arg1, arg2, arg3 !== 0);
|
|
4274
|
+
case Transition.SET:
|
|
4275
|
+
return new SetTransition(target, sets[arg1]);
|
|
4276
|
+
case Transition.NOT_SET:
|
|
4277
|
+
return new NotSetTransition(target, sets[arg1]);
|
|
4278
|
+
case Transition.WILDCARD:
|
|
4279
|
+
return new WildcardTransition(target);
|
|
4280
|
+
default:
|
|
4281
|
+
throw new Error("The specified transition type: " + type + " is not valid.");
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
stateFactory(type, ruleIndex) {
|
|
4285
|
+
const ctor = _ATNDeserializer.stateTypeMapper.get(type);
|
|
4286
|
+
if (!ctor) {
|
|
4287
|
+
throw new Error("The specified state type " + type + " is not valid.");
|
|
4288
|
+
}
|
|
4289
|
+
const s = new ctor();
|
|
4290
|
+
s.ruleIndex = ruleIndex;
|
|
4291
|
+
return s;
|
|
4292
|
+
}
|
|
4293
|
+
lexerActionFactory(type, data1, data2) {
|
|
4294
|
+
const factory = _ATNDeserializer.lexerActionFactoryMapper.get(type);
|
|
4295
|
+
if (!factory) {
|
|
4296
|
+
throw new Error("The specified lexer action type " + type + " is not valid.");
|
|
4297
|
+
}
|
|
4298
|
+
return factory(data1, data2);
|
|
4299
|
+
}
|
|
4300
|
+
};
|