当前位置: 首页>>代码示例>>Java>>正文


Java ATN类代码示例

本文整理汇总了Java中org.antlr.v4.runtime.atn.ATN的典型用法代码示例。如果您正苦于以下问题:Java ATN类的具体用法?Java ATN怎么用?Java ATN使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ATN类属于org.antlr.v4.runtime.atn包,在下文中一共展示了ATN类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: optimizeStates

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
private static void optimizeStates(ATN atn) {
//		System.out.println(atn.states);
		List<ATNState> compressed = new ArrayList<ATNState>();
		int i = 0; // new state number
		for (ATNState s : atn.states) {
			if ( s!=null ) {
				compressed.add(s);
				s.stateNumber = i; // reset state number as we shift to new position
				i++;
			}
		}
//		System.out.println(compressed);
//		System.out.println("ATN optimizer removed " + (atn.states.size() - compressed.size()) + " null states.");
		atn.states.clear();
		atn.states.addAll(compressed);
	}
 
开发者ID:antlr,项目名称:codebuff,代码行数:17,代码来源:ATNOptimizer.java

示例2: StatisticsParserATNSimulator

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public StatisticsParserATNSimulator(ATN atn) {
    super(atn);
    decisionInvocations = new long[atn.decisionToState.size()];
    fullContextFallback = new long[atn.decisionToState.size()];
    nonSll = new long[atn.decisionToState.size()];
    ambiguousResult = new long[atn.decisionToState.size()];
    totalTransitions = new long[atn.decisionToState.size()];
    computedTransitions = new long[atn.decisionToState.size()];
    fullContextTransitions = new long[atn.decisionToState.size()];
    totalLookaheadSll = new long[atn.decisionToState.size()];
    totalLookaheadLl = new long[atn.decisionToState.size()];
    minLookaheadSll = new long[atn.decisionToState.size()];
    maxLookaheadSll = new long[atn.decisionToState.size()];
    minLookaheadLl = new long[atn.decisionToState.size()];
    maxLookaheadLl = new long[atn.decisionToState.size()];
    for (int i = 0; i < minLookaheadSll.length; i++) {
        minLookaheadSll[i] = Long.MAX_VALUE;
        minLookaheadLl[i] = Long.MAX_VALUE;
        maxLookaheadSll[i] = Long.MIN_VALUE;
        maxLookaheadLl[i] = Long.MIN_VALUE;
    }
}
 
开发者ID:tunnelvisionlabs,项目名称:goworks,代码行数:23,代码来源:StatisticsParserATNSimulator.java

示例3: getQidPredicate

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public static SemanticContext.Predicate getQidPredicate(@NonNull ATN atn) {
    int predicateIndex = -1;
    for (ATNState state : atn.states) {
        if (state.ruleIndex != GoParser.RULE_qualifiedIdentifier) {
            continue;
        }

        for (int i = 0; i < state.getNumberOfOptimizedTransitions(); i++) {
            Transition transition = state.getOptimizedTransition(i);
            if (transition instanceof PredicateTransition) {
                predicateIndex = ((PredicateTransition)transition).predIndex;
            }
        }
    }

    assert predicateIndex >= 0 : "Couldn't find the QID predicate transition.";
    return new SemanticContext.Predicate(GoParser.RULE_qualifiedIdentifier, predicateIndex, false);
}
 
开发者ID:tunnelvisionlabs,项目名称:goworks,代码行数:19,代码来源:GoParserFactory.java

示例4: LexerInterpreter

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public LexerInterpreter(String grammarFileName, Collection<String> tokenNames, Collection<String> ruleNames, Collection<String> modeNames, ATN atn, CharStream input) {
	super(input);

	if (atn.grammarType != ATNType.LEXER) {
		throw new IllegalArgumentException("The ATN must be a lexer ATN.");
	}

	this.grammarFileName = grammarFileName;
	this.atn = atn;
	this.tokenNames = tokenNames.toArray(new String[tokenNames.size()]);
	this.ruleNames = ruleNames.toArray(new String[ruleNames.size()]);
	this.modeNames = modeNames.toArray(new String[modeNames.size()]);

	this._decisionToDFA = new DFA[atn.getNumberOfDecisions()];
	for (int i = 0; i < _decisionToDFA.length; i++) {
		_decisionToDFA[i] = new DFA(atn.getDecisionState(i), i);
	}
	this._interp = new LexerATNSimulator(this,atn,_decisionToDFA,_sharedContextCache);
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:20,代码来源:LexerInterpreter.java

示例5: getATNWithBypassAlts

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
/**
 * The ATN with bypass alternatives is expensive to create so we create it
 * lazily.
 *
 * @throws UnsupportedOperationException if the current parser does not
 * implement the {@link #getSerializedATN()} method.
 */
@NotNull
public ATN getATNWithBypassAlts() {
	String serializedAtn = getSerializedATN();
	if (serializedAtn == null) {
		throw new UnsupportedOperationException("The current parser does not support an ATN with bypass alternatives.");
	}

	synchronized (bypassAltsAtnCache) {
		ATN result = bypassAltsAtnCache.get(serializedAtn);
		if (result == null) {
			ATNDeserializationOptions deserializationOptions = new ATNDeserializationOptions();
			deserializationOptions.setGenerateRuleBypassTransitions(true);
			result = new ATNDeserializer(deserializationOptions).deserialize(serializedAtn.toCharArray());
			bypassAltsAtnCache.put(serializedAtn, result);
		}

		return result;
	}
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:27,代码来源:Parser.java

示例6: declarationSpecifiers

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public final DeclarationSpecifiersContext declarationSpecifiers() throws RecognitionException {
	DeclarationSpecifiersContext _localctx = new DeclarationSpecifiersContext(_ctx, getState());
	enterRule(_localctx, 50, RULE_declarationSpecifiers);
	try {
		int _alt;
		enterOuterAlt(_localctx, 1);
		{
		setState(517); 
		_errHandler.sync(this);
		_alt = 1;
		do {
			switch (_alt) {
			case 1:
				{
				{
				setState(516);
				declarationSpecifier();
				}
				}
				break;
			default:
				throw new NoViableAltException(this);
			}
			setState(519); 
			_errHandler.sync(this);
			_alt = getInterpreter().adaptivePredict(_input,32,_ctx);
		} while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER );
		}
	}
	catch (RecognitionException re) {
		_localctx.exception = re;
		_errHandler.reportError(this, re);
		_errHandler.recover(this, re);
	}
	finally {
		exitRule();
	}
	return _localctx;
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:40,代码来源:CParser.java

示例7: declarationSpecifiers2

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public final DeclarationSpecifiers2Context declarationSpecifiers2() throws RecognitionException {
	DeclarationSpecifiers2Context _localctx = new DeclarationSpecifiers2Context(_ctx, getState());
	enterRule(_localctx, 52, RULE_declarationSpecifiers2);
	try {
		int _alt;
		enterOuterAlt(_localctx, 1);
		{
		setState(522); 
		_errHandler.sync(this);
		_alt = 1;
		do {
			switch (_alt) {
			case 1:
				{
				{
				setState(521);
				declarationSpecifier();
				}
				}
				break;
			default:
				throw new NoViableAltException(this);
			}
			setState(524); 
			_errHandler.sync(this);
			_alt = getInterpreter().adaptivePredict(_input,33,_ctx);
		} while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER );
		}
	}
	catch (RecognitionException re) {
		_localctx.exception = re;
		_errHandler.reportError(this, re);
		_errHandler.recover(this, re);
	}
	finally {
		exitRule();
	}
	return _localctx;
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:40,代码来源:CParser.java

示例8: selectList

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public final SelectListContext selectList() throws RecognitionException {
	SelectListContext _localctx = new SelectListContext(_ctx, getState());
	enterRule(_localctx, 38, RULE_selectList);
	try {
		int _alt;
		enterOuterAlt(_localctx, 1);
		{
			setState(416);
			selectListElem();
			setState(421);
			_errHandler.sync(this);
			_alt = getInterpreter().adaptivePredict(_input, 40, _ctx);
			while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) {
				if (_alt == 1) {
					{
						{
							setState(417);
							match(COMMA);
							setState(418);
							selectListElem();
						}
					}
				}
				setState(423);
				_errHandler.sync(this);
				_alt = getInterpreter().adaptivePredict(_input, 40, _ctx);
			}
		}
	} catch (RecognitionException re) {
		_localctx.exception = re;
		_errHandler.reportError(this, re);
		_errHandler.recover(this, re);
	} finally {
		exitRule();
	}
	return _localctx;
}
 
开发者ID:michalwojciechowski,项目名称:coherence-sql,代码行数:38,代码来源:SqlGrammarParser.java

示例9: tableSources

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public final TableSourcesContext tableSources() throws RecognitionException {
	TableSourcesContext _localctx = new TableSourcesContext(_ctx, getState());
	enterRule(_localctx, 42, RULE_tableSources);
	try {
		int _alt;
		enterOuterAlt(_localctx, 1);
		{
			setState(447);
			tableSource();
			setState(452);
			_errHandler.sync(this);
			_alt = getInterpreter().adaptivePredict(_input, 46, _ctx);
			while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) {
				if (_alt == 1) {
					{
						{
							setState(448);
							match(COMMA);
							setState(449);
							tableSource();
						}
					}
				}
				setState(454);
				_errHandler.sync(this);
				_alt = getInterpreter().adaptivePredict(_input, 46, _ctx);
			}
		}
	} catch (RecognitionException re) {
		_localctx.exception = re;
		_errHandler.reportError(this, re);
		_errHandler.recover(this, re);
	} finally {
		exitRule();
	}
	return _localctx;
}
 
开发者ID:michalwojciechowski,项目名称:coherence-sql,代码行数:38,代码来源:SqlGrammarParser.java

示例10: tableSourceItemJoined

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public final TableSourceItemJoinedContext tableSourceItemJoined() throws RecognitionException {
	TableSourceItemJoinedContext _localctx = new TableSourceItemJoinedContext(_ctx, getState());
	enterRule(_localctx, 46, RULE_tableSourceItemJoined);
	try {
		int _alt;
		enterOuterAlt(_localctx, 1);
		{
			setState(462);
			tableSourceItem();
			setState(466);
			_errHandler.sync(this);
			_alt = getInterpreter().adaptivePredict(_input, 48, _ctx);
			while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) {
				if (_alt == 1) {
					{
						{
							setState(463);
							joinPart();
						}
					}
				}
				setState(468);
				_errHandler.sync(this);
				_alt = getInterpreter().adaptivePredict(_input, 48, _ctx);
			}
		}
	} catch (RecognitionException re) {
		_localctx.exception = re;
		_errHandler.reportError(this, re);
		_errHandler.recover(this, re);
	} finally {
		exitRule();
	}
	return _localctx;
}
 
开发者ID:michalwojciechowski,项目名称:coherence-sql,代码行数:36,代码来源:SqlGrammarParser.java

示例11: namespace

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public final NamespaceContext namespace() throws RecognitionException {
    NamespaceContext _localctx = new NamespaceContext(_ctx, getState());
    enterRule(_localctx, 164, RULE_namespace);
    try {
        int _alt;
        enterOuterAlt(_localctx, 1);
        {
            setState(1399);
            _errHandler.sync(this);
            _alt = getInterpreter().adaptivePredict(_input,249,_ctx);
            while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
                if ( _alt==1 ) {
                    {
                        {
                            setState(1394);
                            symbolicName();
                            setState(1395);
                            match(T__23);
                        }
                    }
                }
                setState(1401);
                _errHandler.sync(this);
                _alt = getInterpreter().adaptivePredict(_input,249,_ctx);
            }
        }
    } catch (RecognitionException re) {
        _localctx.exception = re;
        _errHandler.reportError(this, re);
        _errHandler.recover(this, re);
    } finally {
        exitRule();
    }
    return _localctx;
}
 
开发者ID:DTG-FRESCO,项目名称:cyp2sql,代码行数:36,代码来源:CypherParser.java

示例12: GrammarParserInterpreter

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public GrammarParserInterpreter(Grammar g,
								String grammarFileName,
								Vocabulary vocabulary,
								Collection<String> ruleNames,
								ATN atn,
								TokenStream input) {
	super(grammarFileName, vocabulary, ruleNames, atn, input);
	this.g = g;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:10,代码来源:GrammarParserInterpreter.java

示例13: getATN

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public ATN getATN() {
	if ( atn==null ) {
		ParserATNFactory factory = new ParserATNFactory(this);
		atn = factory.createATN();
	}
	return atn;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:8,代码来源:Grammar.java

示例14: createLexerInterpreter

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
public LexerInterpreter createLexerInterpreter(CharStream input) {
	if (this.isParser()) {
		throw new IllegalStateException("A lexer interpreter can only be created for a lexer or combined grammar.");
	}

	if (this.isCombined()) {
		return implicitLexer.createLexerInterpreter(input);
	}

	char[] serializedAtn = ATNSerializer.getSerializedAsChars(atn);
	ATN deserialized = new ATNDeserializer().deserialize(serializedAtn);
	return new LexerInterpreter(fileName, getVocabulary(), Arrays.asList(getRuleNames()), ((LexerGrammar)this).modes.keySet(), deserialized, input);
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:14,代码来源:Grammar.java

示例15: createGrammarParserInterpreter

import org.antlr.v4.runtime.atn.ATN; //导入依赖的package包/类
/** @since 4.5.1 */
public GrammarParserInterpreter createGrammarParserInterpreter(TokenStream tokenStream) {
	if (this.isLexer()) {
		throw new IllegalStateException("A parser interpreter can only be created for a parser or combined grammar.");
	}
	char[] serializedAtn = ATNSerializer.getSerializedAsChars(atn);
	ATN deserialized = new ATNDeserializer().deserialize(serializedAtn);
	return new GrammarParserInterpreter(this, deserialized, tokenStream);
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:10,代码来源:Grammar.java


注:本文中的org.antlr.v4.runtime.atn.ATN类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。