當前位置: 首頁>>代碼示例>>Java>>正文


Java RecognizerSharedState類代碼示例

本文整理匯總了Java中org.antlr.runtime.RecognizerSharedState的典型用法代碼示例。如果您正苦於以下問題:Java RecognizerSharedState類的具體用法?Java RecognizerSharedState怎麽用?Java RecognizerSharedState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RecognizerSharedState類屬於org.antlr.runtime包,在下文中一共展示了RecognizerSharedState類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: followedBySemicolon

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
/**
 * Returns {@code true} if the set of expected follow-states includes an implicit or explicit semicolon.
 */
private static boolean followedBySemicolon(RecognizerSharedState state, Callback.RecoverySets recoverySets,
		int currentIndex) {
	int top = state._fsp;
	if (currentIndex != state.lastErrorIndex) {
		long[] array = state.following[top].toPackedArray();
		if (array.length == 1 && array[0] == (1L << Token.EOR_TOKEN_TYPE)) {
			return false;
		}
	}
	for (int i = top; i >= 0; i--) {
		BitSet localFollowSet = state.following[i];
		if (recoverySets.matches(localFollowSet)) {
			return true;
		}

	}
	return false;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:22,代碼來源:SemicolonInjectionHelper.java

示例2: applyOnce

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
public Object applyOnce(Object t, fptr whichRule) {
    if ( t==null ) return null;
    try {
        // share TreeParser object but not parsing-related state
        state = new RecognizerSharedState();
        input = new CommonTreeNodeStream(originalAdaptor, t);
        ((CommonTreeNodeStream)input).setTokenStream(originalTokenStream);
        setBacktrackingLevel(1);
        TreeRuleReturnScope r = (TreeRuleReturnScope)whichRule.rule();
        setBacktrackingLevel(0);
        if ( failed() ) return t;
        if ( showTransformations &&
             r!=null && !t.equals(r.getTree()) && r.getTree()!=null )
        {
            reportTransformation(t, r.getTree());
        }
        if ( r!=null && r.getTree()!=null ) return r.getTree();
        else return t;
    }
    catch (RecognitionException e) { ; }
    return t;
}
 
開發者ID:wittawatj,項目名稱:jtcc,代碼行數:23,代碼來源:TreeRewriter.java

示例3: promoteEOL

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
/**
 * <p>
 * Promotes EOL which may lead to an automatically inserted semicolon. This is probably the most important method
 * for automatic semicolon insertion, as it is only possible to insert a semicolon in case of line breaks (even if
 * they are hidden in a multi-line comment!).
 * </p>
 */
public static void promoteEOL(Callback callback) {
	RecognizerSharedState state = callback.getState();
	TokenStream input = callback.getInput();
	// Don't promote EOL if there was a syntax error at EOF
	if (state.lastErrorIndex == input.size()) {
		return;
	}
	// Get current token and its type (the possibly offending token).
	Token prev = input.LT(-1);
	Token next = input.LT(1);
	int la = next.getType();

	// Promoting an EOL means switching it from off channel to on channel.
	// A ML_COMMENT gets promoted when it contains an EOL.
	for (int idx = prev == null ? 0 : prev.getTokenIndex() + 1, max = la == Token.EOF ? input.size()
			: next.getTokenIndex(); idx < max; idx++) {
		Token lt = input.get(idx);
		if (lt.getChannel() == Token.DEFAULT_CHANNEL) {
			// On channel token found: stop scanning (previously promoted)
			break;
		} else if (isSemicolonEquivalent(lt)) {
			// We found our EOL: promote the token to on channel, position the input on it and reset the rule
			// start.
			lt.setChannel(Token.DEFAULT_CHANNEL);
			input.seek(idx);
			break;
		}
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:37,代碼來源:SemicolonInjectionHelper.java

示例4: BaseInternalContentAssistParser

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
public BaseInternalContentAssistParser(TokenStream input, RecognizerSharedState state) {
	super(input, state);
	this.grammarElements = new ArrayList<EObject>();
	this.localTrace = new ArrayList<EObject>();
	this.paramStack = new ArrayList<Integer>();
	this.grammarElementsWithParams = new ArrayList<Integer>();
	this.followElements = new LinkedHashSetWithoutNull<FollowElement>();
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:9,代碼來源:BaseInternalContentAssistParser.java

示例5: CobolStructureParserImpl

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
/**
 * Construct from a token stream and a shared state.
 * @param input the token stream
 * @param state the shared state
 * @param errorHandler handles error messages
 */
public CobolStructureParserImpl(
        final TokenStream input,
        final RecognizerSharedState state,
        final RecognizerErrorHandler errorHandler) {
    super(input, state);
    _errorHandler = errorHandler;
}
 
開發者ID:legsem,項目名稱:legstar-cob2xsd,代碼行數:14,代碼來源:CobolStructureParserImpl.java

示例6: CobolStructureLexerImpl

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
/**
 * Construct from a character stream and a shared state.
 * @param input the character stream
 * @param state the shared state
 * @param errorHandler handles error messages
 */
public CobolStructureLexerImpl(
        final CharStream input,
        final RecognizerSharedState state,
        final RecognizerErrorHandler errorHandler) {
    super(input, state);
    _errorHandler = errorHandler;

}
 
開發者ID:legsem,項目名稱:legstar-cob2xsd,代碼行數:15,代碼來源:CobolStructureLexerImpl.java

示例7: CobolStructureEmitterImpl

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
/**
 * Construct from a tree nodes stream and a shared state.
 * @param input the tree nodes stream
 * @param state the shared state
 * @param errorHandler handles error messages
 */
public CobolStructureEmitterImpl(
        final TreeNodeStream input,
        final RecognizerSharedState state,
        final RecognizerErrorHandler errorHandler) {
    super(input, state);
    _errorHandler = errorHandler;
}
 
開發者ID:legsem,項目名稱:legstar-cob2xsd,代碼行數:14,代碼來源:CobolStructureEmitterImpl.java

示例8: applyOnce

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
public void applyOnce(Object t, fptr whichRule) {
    if ( t==null ) return;
    try {
        // share TreeParser object but not parsing-related state
        state = new RecognizerSharedState();
        input = new CommonTreeNodeStream(originalAdaptor, t);
        ((CommonTreeNodeStream)input).setTokenStream(originalTokenStream);
        setBacktrackingLevel(1);
        whichRule.rule();
        setBacktrackingLevel(0);
    }
    catch (RecognitionException e) { ; }
}
 
開發者ID:wittawatj,項目名稱:jtcc,代碼行數:14,代碼來源:TreeFilter.java

示例9: EditorOpsParserDelegate

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
public EditorOpsParserDelegate(TokenStream input, RecognizerSharedState state,  Set<EditorOpDescr> runtimeNativeOps, Set<EditorOpDescr> runtimeUserOps) {
 super(input, runtimeNativeOps,runtimeUserOps);
    this.state = state;
    
    this.allNativeOps = aggAllOperations(runtimeNativeOps, runtimeUserOps);
    
    this.needClosingOpsStack = new LinkedList<EditorOpDescr>();
}
 
開發者ID:premiummarkets,項目名稱:pm,代碼行數:9,代碼來源:EditorOpsParserDelegate.java

示例10: CqlLexer

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
public CqlLexer(CharStream input) {
	this(input, new RecognizerSharedState());
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:4,代碼來源:CqlLexer.java

示例11: Cql_Parser

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
public Cql_Parser(TokenStream input, CqlParser gCql) {
	this(input, new RecognizerSharedState(), gCql);
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:4,代碼來源:Cql_Parser.java

示例12: CqlParser

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
public CqlParser(TokenStream input) {
	this(input, new RecognizerSharedState());
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:4,代碼來源:CqlParser.java

示例13: getState

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
/**
 * Allows to access the protected state of the super type.
 */
public RecognizerSharedState getState() {
	return state;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:7,代碼來源:CustomN4JSParser.java

示例14: AbstractInternalHighlightingAntlrParser

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
/**
 * Delegates to super constructor.
 */
protected AbstractInternalHighlightingAntlrParser(TokenStream input, RecognizerSharedState state) {
	super(input, state);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:7,代碼來源:AbstractInternalHighlightingAntlrParser.java

示例15: getState

import org.antlr.runtime.RecognizerSharedState; //導入依賴的package包/類
@Override
public RecognizerSharedState getState() {
	return state;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:5,代碼來源:InternalHighlightingParser.java


注:本文中的org.antlr.runtime.RecognizerSharedState類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。