本文整理汇总了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;
}
示例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;
}
示例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;
}
}
}
示例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>();
}
示例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;
}
示例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;
}
示例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;
}
示例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) { ; }
}
示例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>();
}
示例10: CqlLexer
import org.antlr.runtime.RecognizerSharedState; //导入依赖的package包/类
public CqlLexer(CharStream input) {
this(input, new RecognizerSharedState());
}
示例11: Cql_Parser
import org.antlr.runtime.RecognizerSharedState; //导入依赖的package包/类
public Cql_Parser(TokenStream input, CqlParser gCql) {
this(input, new RecognizerSharedState(), gCql);
}
示例12: CqlParser
import org.antlr.runtime.RecognizerSharedState; //导入依赖的package包/类
public CqlParser(TokenStream input) {
this(input, new RecognizerSharedState());
}
示例13: getState
import org.antlr.runtime.RecognizerSharedState; //导入依赖的package包/类
/**
* Allows to access the protected state of the super type.
*/
public RecognizerSharedState getState() {
return state;
}
示例14: AbstractInternalHighlightingAntlrParser
import org.antlr.runtime.RecognizerSharedState; //导入依赖的package包/类
/**
* Delegates to super constructor.
*/
protected AbstractInternalHighlightingAntlrParser(TokenStream input, RecognizerSharedState state) {
super(input, state);
}
示例15: getState
import org.antlr.runtime.RecognizerSharedState; //导入依赖的package包/类
@Override
public RecognizerSharedState getState() {
return state;
}