当前位置: 首页>>代码示例>>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;未经允许,请勿转载。