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


Java Nullable类代码示例

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


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

示例1: toStringTree

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
private String toStringTree(@NotNull final Tree t, @Nullable final List<String> ruleNames) {
  if (t.getChildCount() == 0) {
    return Utils.escapeWhitespace(getNodeText(t, ruleNames), true);
  }
  StringBuilder buf = new StringBuilder();
  buf.append(" ( ");
  String s = Utils.escapeWhitespace(getNodeText(t, ruleNames), true);
  buf.append(s);
  buf.append(' ');
  for (int i = 0; i < t.getChildCount(); i++) {
    if (i > 0) {
      buf.append(' ');
    }
    buf.append(toStringTree(t.getChild(i), ruleNames));
  }
  buf.append(" ) ");
  return buf.toString();
}
 
开发者ID:antlr4ide,项目名称:antlr4ide,代码行数:19,代码来源:ParseTreeCommand.java

示例2: getNodeText

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
private String getNodeText(@NotNull final Tree t, @Nullable final List<String> ruleNames) {
  if (ruleNames != null) {
    if (t instanceof RuleNode) {
      int ruleIndex = ((RuleNode) t).getRuleContext().getRuleIndex();
      String ruleName = ruleNames.get(ruleIndex);
      return ruleName;
    }
    else if (t instanceof ErrorNode) {
      return "<" + t.toString() + ">";
    }
    else if (t instanceof TerminalNode) {
      Token symbol = ((TerminalNode) t).getSymbol();
      if (symbol != null) {
        String s = symbol.getText();
        return "'" + s + "'";
      }
    }
  }
  // no recog for rule names
  Object payload = t.getPayload();
  if (payload instanceof Token) {
    return ((Token) payload).getText();
  }
  return t.getPayload().toString();
}
 
开发者ID:antlr4ide,项目名称:antlr4ide,代码行数:26,代码来源:ParseTreeCommand.java

示例3: toString

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
public String toString(@Nullable List<String> ruleNames, @Nullable RuleContext stop) {
	StringBuilder buf = new StringBuilder();
	RuleContext p = this;
	buf.append("[");
	while (p != null && p != stop) {
		if (ruleNames == null) {
			if (!p.isEmpty()) {
				buf.append(p.invokingState);
			}
		}
		else {
			int ruleIndex = p.getRuleIndex();
			String ruleName = ruleIndex >= 0 && ruleIndex < ruleNames.size() ? ruleNames.get(ruleIndex) : Integer.toString(ruleIndex);
			buf.append(ruleName);
		}

		if (p.parent != null && (ruleNames != null || !p.parent.isEmpty())) {
			buf.append(" ");
		}

		p = p.parent;
	}

	buf.append("]");
	return buf.toString();
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:27,代码来源:RuleContext.java

示例4: FailedPredicateException

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
public FailedPredicateException(@NotNull Parser recognizer,
								@Nullable String predicate,
								@Nullable String message)
{
	super(formatMessage(predicate, message), recognizer, recognizer.getInputStream(), recognizer._ctx);
	ATNState s = recognizer.getInterpreter().atn.states.get(recognizer.getState());

	AbstractPredicateTransition trans = (AbstractPredicateTransition)s.transition(0);
	if (trans instanceof PredicateTransition) {
		this.ruleIndex = ((PredicateTransition)trans).ruleIndex;
		this.predicateIndex = ((PredicateTransition)trans).predIndex;
	}
	else {
		this.ruleIndex = 0;
		this.predicateIndex = 0;
	}

	this.predicate = predicate;
	this.setOffendingToken(recognizer.getCurrentToken());
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:21,代码来源:FailedPredicateException.java

示例5: toStringTree

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
/** Print out a whole tree in LISP form. {@link #getNodeText} is used on the
 *  node payloads to get the text for the nodes.  Detect
 *  parse trees and extract data appropriately.
 */
public static String toStringTree(@NotNull Tree t, @Nullable List<String> ruleNames) {
	String s = Utils.escapeWhitespace(getNodeText(t, ruleNames), false);
	if ( t.getChildCount()==0 ) return s;
	StringBuilder buf = new StringBuilder();
	buf.append("(");
	s = Utils.escapeWhitespace(getNodeText(t, ruleNames), false);
	buf.append(s);
	buf.append(' ');
	for (int i = 0; i<t.getChildCount(); i++) {
		if ( i>0 ) buf.append(' ');
		buf.append(toStringTree(t.getChild(i), ruleNames));
	}
	buf.append(")");
	return buf.toString();
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:20,代码来源:Trees.java

示例6: getNodeText

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
public static String getNodeText(@NotNull Tree t, @Nullable List<String> ruleNames) {
	if ( ruleNames!=null ) {
		if ( t instanceof RuleNode ) {
			int ruleIndex = ((RuleNode)t).getRuleContext().getRuleIndex();
			String ruleName = ruleNames.get(ruleIndex);
			return ruleName;
		}
		else if ( t instanceof ErrorNode) {
			return t.toString();
		}
		else if ( t instanceof TerminalNode) {
			Token symbol = ((TerminalNode)t).getSymbol();
			if (symbol != null) {
				String s = symbol.getText();
				return s;
			}
		}
	}
	// no recog for rule names
	Object payload = t.getPayload();
	if ( payload instanceof Token ) {
		return ((Token)payload).getText();
	}
	return t.getPayload().toString();
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:26,代码来源:Trees.java

示例7: ParseTreeMatch

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
/**
 * Constructs a new instance of {@link ParseTreeMatch} from the specified
 * parse tree and pattern.
 *
 * @param tree The parse tree to match against the pattern.
 * @param pattern The parse tree pattern.
 * @param labels A mapping from label names to collections of
 * {@link ParseTree} objects located by the tree pattern matching process.
 * @param mismatchedNode The first node which failed to match the tree
 * pattern during the matching process.
 *
 * @exception IllegalArgumentException if {@code tree} is {@code null}
 * @exception IllegalArgumentException if {@code pattern} is {@code null}
 * @exception IllegalArgumentException if {@code labels} is {@code null}
 */
public ParseTreeMatch(@NotNull ParseTree tree, @NotNull ParseTreePattern pattern, @NotNull MultiMap<String, ParseTree> labels, @Nullable ParseTree mismatchedNode) {
	if (tree == null) {
		throw new IllegalArgumentException("tree cannot be null");
	}

	if (pattern == null) {
		throw new IllegalArgumentException("pattern cannot be null");
	}

	if (labels == null) {
		throw new IllegalArgumentException("labels cannot be null");
	}

	this.tree = tree;
	this.pattern = pattern;
	this.labels = labels;
	this.mismatchedNode = mismatchedNode;
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:34,代码来源:ParseTreeMatch.java

示例8: computeStartState

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
@NotNull
protected ATNConfigSet computeStartState(@NotNull ATNState p,
									  @Nullable RuleContext ctx,
									  boolean fullCtx)
{
	// always at least the implicit call to start rule
	PredictionContext initialContext = PredictionContext.fromRuleContext(atn, ctx);
	ATNConfigSet configs = new ATNConfigSet(fullCtx);

	for (int i=0; i<p.getNumberOfTransitions(); i++) {
		ATNState target = p.transition(i).target;
		ATNConfig c = new ATNConfig(target, i+1, initialContext);
		Set<ATNConfig> closureBusy = new HashSet<ATNConfig>();
		closure(c, configs, closureBusy, true, fullCtx, false);
	}

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

示例9: getDecisionLookahead

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
/**
	 * Calculates the SLL(1) expected lookahead set for each outgoing transition
	 * of an {@link ATNState}. The returned array has one element for each
	 * outgoing transition in {@code s}. If the closure from transition
	 * <em>i</em> leads to a semantic predicate before matching a symbol, the
	 * element at index <em>i</em> of the result will be {@code null}.
	 *
	 * @param s the ATN state
	 * @return the expected symbols for each outgoing transition of {@code s}.
	 */
	@Nullable
	public IntervalSet[] getDecisionLookahead(@Nullable ATNState s) {
//		System.out.println("LOOK("+s.stateNumber+")");
		if ( s==null ) {
			return null;
		}

		IntervalSet[] look = new IntervalSet[s.getNumberOfTransitions()];
		for (int alt = 0; alt < s.getNumberOfTransitions(); alt++) {
			look[alt] = new IntervalSet();
			Set<ATNConfig> lookBusy = new HashSet<ATNConfig>();
			boolean seeThruPreds = false; // fail to get lookahead upon pred
			_LOOK(s.transition(alt).target, null, PredictionContext.EMPTY,
				  look[alt], lookBusy, new BitSet(), seeThruPreds, false);
			// Wipe out lookahead for this alternative if we found nothing
			// or we had a predicate when we !seeThruPreds
			if ( look[alt].size()==0 || look[alt].contains(HIT_PRED) ) {
				look[alt] = null;
			}
		}
		return look;
	}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:33,代码来源:LL1Analyzer.java

示例10: reportAmbiguity

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
@Override
protected void reportAmbiguity(@NotNull DFA dfa, DFAState D, int startIndex, int stopIndex, boolean exact,
							   @Nullable BitSet ambigAlts, @NotNull ATNConfigSet configs)
{
	int prediction;
	if ( ambigAlts!=null ) {
		prediction = ambigAlts.nextSetBit(0);
	}
	else {
		prediction = configs.getAlts().nextSetBit(0);
	}
	if ( configs.fullCtx && prediction != conflictingAltResolvedBySLL ) {
		// Even though this is an ambiguity we are reporting, we can
		// still detect some context sensitivities.  Both SLL and LL
		// are showing a conflict, hence an ambiguity, but if they resolve
		// to different minimum alternatives we have also identified a
		// context sensitivity.
		decisions[currentDecision].contextSensitivities.add(
				new ContextSensitivityInfo(currentDecision, configs, _input, startIndex, stopIndex)
		);
	}
	decisions[currentDecision].ambiguities.add(
		new AmbiguityInfo(currentDecision, configs, _input, startIndex, stopIndex, configs.fullCtx)
	);
	super.reportAmbiguity(dfa, D, startIndex, stopIndex, exact, ambigAlts, configs);
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:27,代码来源:ProfilingATNSimulator.java

示例11: syntaxError

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
public void syntaxError(@NotNull Recognizer<?, ?> recognizer,
		@Nullable Object offendingSymbol, int line,
		int charPositionInLine, @NotNull String msg,
		@Nullable RecognitionException e)
{
	mErrMsg = "at line " + line + ":" + charPositionInLine + " " + msg;
	throw e;
}
 
开发者ID:paypal,项目名称:digraph-parser,代码行数:9,代码来源:GraphParser.java

示例12: reportAmbiguity

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
@Override
public void reportAmbiguity(@NotNull Parser recognizer,
							@NotNull DFA dfa,
							int startIndex,
							int stopIndex,
							boolean exact,
							@Nullable BitSet ambigAlts,
							@NotNull ATNConfigSet configs)
{
}
 
开发者ID:paypal,项目名称:digraph-parser,代码行数:11,代码来源:GraphParser.java

示例13: reportAttemptingFullContext

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
@Override
public void reportAttemptingFullContext(@NotNull Parser recognizer,
										@NotNull DFA dfa,
										int startIndex,
										int stopIndex,
										@Nullable BitSet conflictingAlts,
										@NotNull ATNConfigSet configs)
{
}
 
开发者ID:paypal,项目名称:digraph-parser,代码行数:10,代码来源:GraphParser.java

示例14: syntaxError

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p/>
 * The method is overridden to throw an exception if the parsed input has an invalid syntax.
 */
@Override
public void syntaxError(Recognizer<?, ?> recognizer, @Nullable Object offendingSymbol, int line,
        int charPositionInLine, String msg, @Nullable RecognitionException e) {

    String errorMessage = msg;
    if (e instanceof InputMismatchException && msg.endsWith(" expecting VALUE")) {
        errorMessage += ". Please make sure that all values are surrounded by double quotes.";
    }

    throw new IllegalArgumentException(errorMessage);
}
 
开发者ID:osiam,项目名称:resource-server,代码行数:17,代码来源:OsiamAntlrErrorListener.java

示例15: getNodeText

import org.antlr.v4.runtime.misc.Nullable; //导入依赖的package包/类
private static String getNodeText(@NotNull Tree t, @Nullable List<String> ruleNames, @Nullable List<String> tokenNames) {

        if (t instanceof RuleNode) {
            int ruleIndex = ((RuleNode) t).getRuleContext().getRuleIndex();
            return ruleNames.get(ruleIndex);
        }

        if (t instanceof ErrorNode) {
            return t.toString();
        }

        if (t instanceof TerminalNode) {
            Token symbol = ((TerminalNode) t).getSymbol();
            if (symbol != null) {
                return tokenNames.get(symbol.getType());
            }
        }

        // no recog for rule names
        Object payload = t.getPayload();

        if (payload instanceof Token) {
            return ((Token) payload).getText();
        }

        return t.getPayload().toString();

    }
 
开发者ID:jasonmoo,项目名称:myne,代码行数:29,代码来源:Node.java


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