java类org.antlr.v4.runtime.ParserRuleContext的实例源码

ListenerUtil.java 文件源码 项目:athena 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Validates boolean value.
 *
 * @param booleanValue value to be validated
 * @param yangConstruct yang construct for creating error message
 * @param ctx context object of the grammar rule
 * @return boolean value either true or false
 */
public static boolean getValidBooleanValue(String booleanValue, YangConstructType yangConstruct,
        ParserRuleContext ctx) {

    String value = removeQuotesAndHandleConcat(booleanValue);
    if (value.equals(TRUE)) {
        return true;
    } else if (value.equals(FALSE)) {
        return false;
    } else {
        ParserException parserException = new ParserException("YANG file error : " +
                YangConstructType.getYangConstructType(yangConstruct) + " value " + value + " is not " +
                "valid.");
        parserException.setLine(ctx.getStart().getLine());
        parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
        throw parserException;
    }
}
JavaDDGBuilder.java 文件源码 项目:progex 阅读 21 收藏 0 点赞 0 评论 0
public DefUseVisitor(int iter, JavaClass[] classInfos, 
        DataDependenceGraph ddg, Map<ParserRuleContext, Object> pdNodes) {
    Logger.log("FILE IS: " + currentFile);
    this.ddg = ddg;
    changed = false;
    iteration = iter;
    analysisVisit = false;
    this.pdNodes = pdNodes;
    this.classInfos = classInfos;
    defList = new LinkedHashSet<>();
    useList = new LinkedHashSet<>();
    selfFlowList = new LinkedHashSet<>();
    activeClasses = new ArrayDeque<>();
    methodDefInfo = null;
    methodParams = new JavaField[0];
    localVars = new ArrayList<>();
}
ControlFlow.java 文件源码 项目:ts-swift-transpiler 阅读 23 收藏 0 点赞 0 评论 0
public IfLet(ParserRuleContext ctx, Visitor visitor) {
    SwiftParser.Condition_clauseContext conditionClause = ctx instanceof SwiftParser.If_statementContext ? ((SwiftParser.If_statementContext)ctx).condition_clause() : ((SwiftParser.Guard_statementContext)ctx).condition_clause();
    if(!(WalkerUtil.isDirectDescendant(SwiftParser.Optional_binding_conditionContext.class, conditionClause))) return;

    ArrayList<ParserRuleContext> ifLets = new ArrayList<ParserRuleContext>();
    ifLets.add(conditionClause.condition_list().condition(0).optional_binding_condition().optional_binding_head());
    if(conditionClause.condition_list().condition(0).optional_binding_condition().optional_binding_continuation_list() != null) {
        List<SwiftParser.Optional_binding_continuationContext> moreIfLets = conditionClause.condition_list().condition(0).optional_binding_condition().optional_binding_continuation_list().optional_binding_continuation();
        for(int i = 0; i < moreIfLets.size(); i++) ifLets.add(moreIfLets.get(i));
    }
    /*for(int i = 0; i < ifLets.size(); i++) {
        String varName = visitor.visitWithoutTerminals(ifLets.get(i) instanceof SwiftParser.Optional_binding_headContext ? ((SwiftParser.Optional_binding_headContext)ifLets.get(i)).pattern() : ((SwiftParser.Optional_binding_continuationContext)ifLets.get(i)).pattern()).trim();
        Expression varVal = new Expression((ifLets.get(i) instanceof SwiftParser.Optional_binding_headContext ? ((SwiftParser.Optional_binding_headContext)ifLets.get(i)).initializer() : ((SwiftParser.Optional_binding_continuationContext)ifLets.get(i)).initializer()).expression(), null, visitor);
        varNames.add(varName);
        varVals.add(varVal.code);
        varTypes.add(varVal.type);
    }*/
}
TreeNodeTest.java 文件源码 项目:Blindfold 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Test of equals method, of class TreeNode.
 *
 * @throws java.io.IOException
 */
@Test
public void testEquals() throws IOException {
    Object object = null;
    TreeNode instance = new TreeNode(new ParserRuleContext());
    boolean expResult = false;
    boolean result = instance.equals(object);
    assertEquals("equals method, of class TreeNode's expected result is wrong.", expResult,
            result);

    object = new Object();
    expResult = false;
    result = instance.equals(object);
    assertEquals("equals method, of class TreeNode's expected result is wrong.", expResult,
            result);

    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource(SAMPLE_CLASS_PATH).getFile());
    byte[] encoded = Files.readAllBytes(Paths.get(file.getAbsolutePath()));
    String code = new String(encoded, Charset.defaultCharset());

    Forest forest1 = TreeViewGenerator.generate(code);
    Forest forest2 = TreeViewGenerator.generate(code);

    expResult = true;
    object = forest1.getTree(0).getRoot();
    instance = forest2.getTree(0).getRoot();
    result = instance.equals(object);
    assertEquals("equals method, of class TreeNode's expected result is wrong.", expResult,
            result);
}
Location.java 文件源码 项目:rockscript 阅读 61 收藏 0 点赞 0 评论 0
public Location(ParserRuleContext parserRuleContext) {
  Token start = parserRuleContext.getStart();
  this.start = start.getStartIndex();
  Token stop = parserRuleContext.getStop();
  end = stop.getStopIndex();
  line = start.getLine();
}
Linker.java 文件源码 项目:ETUmulator 阅读 28 收藏 0 点赞 0 评论 0
private void replaceLabelAddress(ParserRuleContext ctx, TerminalNode terminalNode) {
    if(!secondPass) {
        return;
    }
    String label = terminalNode.getText();
    if(!definedBranches.containsKey(label)) {
        throw new LabelError("\"" + label + "\" is not defined.");
    }
    int lineNumber = ctx.start.getLine() - 1;
    String temp = new String(code[lineNumber]);
    String address = Integer.toString(definedBranches.get(label));
    temp = temp.replace(label, address);
    code[lineNumber] = temp;
}
TypeCalculation.java 文件源码 项目:rainbow 阅读 33 收藏 0 点赞 0 评论 0
public static Long calculateLiteralValue(
        String calculation,
        Map<String, Long> inputs)
{
    try {
        ParserRuleContext tree = parseTypeCalculation(calculation);
        CalculateTypeVisitor visitor = new CalculateTypeVisitor(inputs);
        BigInteger result = visitor.visit(tree);
        return result.longValueExact();
    }
    catch (StackOverflowError e) {
        throw new ParsingException("Type calculation is too large (stack overflow while parsing)");
    }
}
AstBuilder.java 文件源码 项目:rainbow 阅读 24 收藏 0 点赞 0 评论 0
private <T> List<T> visit(List<? extends ParserRuleContext> contexts, Class<T> clazz)
{
    return contexts.stream()
            .map(this::visit)
            .map(clazz::cast)
            .collect(toList());
}
JavaCFGBuilder.java 文件源码 项目:progex 阅读 21 收藏 0 点赞 0 评论 0
public ControlFlowVisitor(ControlFlowGraph cfg, String propKey, Map<ParserRuleContext, Object> ctxProps) {
    preNodes = new ArrayDeque<>();
    preEdges = new ArrayDeque<>();
    loopBlocks = new ArrayDeque<>();
    labeledBlocks = new ArrayList<>();
    tryBlocks = new ArrayDeque<>();
    casesQueue = new ArrayDeque<>();
    classNames = new ArrayDeque<>();
    dontPop = false;
    this.cfg = cfg;
    //
    this.propKey = propKey;
    contexutalProperties = ctxProps;
}
TypeCalculation.java 文件源码 项目:rainbow 阅读 19 收藏 0 点赞 0 评论 0
private static ParserRuleContext parseTypeCalculation(String calculation)
{
    TypeCalculationLexer lexer = new TypeCalculationLexer(new CaseInsensitiveStream(new ANTLRInputStream(calculation)));
    CommonTokenStream tokenStream = new CommonTokenStream(lexer);
    TypeCalculationParser parser = new TypeCalculationParser(tokenStream);

    lexer.removeErrorListeners();
    lexer.addErrorListener(ERROR_LISTENER);

    parser.removeErrorListeners();
    parser.addErrorListener(ERROR_LISTENER);

    ParserRuleContext tree;
    try {
        // first, try parsing with potentially faster SLL mode
        parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
        tree = parser.typeCalculation();
    }
    catch (ParseCancellationException ex) {
        // if we fail, parse with LL mode
        tokenStream.reset(); // rewind input stream
        parser.reset();

        parser.getInterpreter().setPredictionMode(PredictionMode.LL);
        tree = parser.typeCalculation();
    }
    return tree;
}
JavaDDGBuilder.java 文件源码 项目:progex 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Get the original program text for the given parser-rule context.
 * This is required for preserving whitespaces.
 */
private String getOriginalCodeText(ParserRuleContext ctx) {
    int start = ctx.start.getStartIndex();
    int stop = ctx.stop.getStopIndex();
    Interval interval = new Interval(start, stop);
    return ctx.start.getInputStream().getText(interval);
}
AbstractConstructor.java 文件源码 项目:rest-modeling-framework 阅读 22 收藏 0 点赞 0 评论 0
protected EObject createAndCopy(final EObject eObject, final ParserRuleContext ruleContext) {
    final EClass eClass = eObject.eClass();
    final EObject newEObject = create(eClass, ruleContext);
    final Consumer<EAttribute> copyAttribute = attribute -> newEObject.eSet(attribute, eObject.eGet(attribute));
    eClass.getEAllAttributes().forEach(copyAttribute);

    return newEObject;
}
TreeNode.java 文件源码 项目:Blindfold 阅读 27 收藏 0 点赞 0 评论 0
public TreeNode(ParserRuleContext context) {
    this.children = new ArrayList<>(8);
    this.context = context;
}
TreeNode.java 文件源码 项目:Blindfold 阅读 20 收藏 0 点赞 0 评论 0
public ParserRuleContext getContext() {
    return this.context;
}
ExpressionParsingException.java 文件源码 项目:rapidminer 阅读 19 收藏 0 点赞 0 评论 0
/**
 * @return the error context, can be {@code null}
 */
public ParserRuleContext getErrorContext() {
    return ctx;
}
FWPolicyParser.java 文件源码 项目:oscm 阅读 20 收藏 0 点赞 0 评论 0
public Source_portContext(ParserRuleContext parent, int invokingState,
        FWPolicy p) {
    super(parent, invokingState);
    this.p = p;
}
AntlrParser.java 文件源码 项目:pgcodekeeper 阅读 22 收藏 0 点赞 0 评论 0
@Override
public void enterEveryRule(ParserRuleContext ctx) {
    //no imp
}
AstBuilder.java 文件源码 项目:rainbow 阅读 27 收藏 0 点赞 0 评论 0
private static ParsingException parseError(String message, ParserRuleContext context)
{
    return new ParsingException(message, null, context.getStart().getLine(), context.getStart().getCharPositionInLine());
}
TreeWalkListener.java 文件源码 项目:athena 阅读 19 收藏 0 点赞 0 评论 0
@Override
public void enterEveryRule(ParserRuleContext parserRuleContext) {
    // do nothing.
}
FWPolicyParser.java 文件源码 项目:oscm 阅读 27 收藏 0 点赞 0 评论 0
public PolicyContext(ParserRuleContext parent, int invokingState,
        List<FWPolicy> pList) {
    super(parent, invokingState);
    this.pList = pList;
}
FWPolicyParser.java 文件源码 项目:oscm 阅读 20 收藏 0 点赞 0 评论 0
public Dest_portContext(ParserRuleContext parent, int invokingState,
        FWPolicy p) {
    super(parent, invokingState);
    this.p = p;
}
FWPolicyParser.java 文件源码 项目:oscm 阅读 24 收藏 0 点赞 0 评论 0
public Dest_zoneContext(ParserRuleContext parent, int invokingState,
        FWPolicy p) {
    super(parent, invokingState);
    this.p = p;
}
FWPolicyParser.java 文件源码 项目:oscm 阅读 25 收藏 0 点赞 0 评论 0
public Dest_zoneContext(ParserRuleContext parent, int invokingState) {
    super(parent, invokingState);
}
SelectClauseParser.java 文件源码 项目:dragoman 阅读 21 收藏 0 点赞 0 评论 0
@Override
protected ParserRuleContext getParserContext(SQLParser parser) {
  // this is the entry point for a map clause
  return parser.select_list();
}
CriteriaContextBuilder.java 文件源码 项目:urule 阅读 24 收藏 0 点赞 0 评论 0
@Override
public boolean support(ParserRuleContext context) {
    return context instanceof SingleConditionContext;
}
FWPolicyParser.java 文件源码 项目:oscm 阅读 22 收藏 0 点赞 0 评论 0
public Dest_ipContext(ParserRuleContext parent, int invokingState,
        FWPolicy p) {
    super(parent, invokingState);
    this.p = p;
}
AutocompleteResult.java 文件源码 项目:beaker-notebook-archive 阅读 21 收藏 0 点赞 0 评论 0
public static int getStartIndex(ParserRuleContext ctx) {
  return ctx.getStop().getStartIndex();
}
Walker.java 文件源码 项目:elasticsearch_my 阅读 21 收藏 0 点赞 0 评论 0
private Location location(ParserRuleContext ctx) {
    return new Location(sourceName, ctx.getStart().getStartIndex());
}
FWPolicyParser.java 文件源码 项目:oscm 阅读 53 收藏 0 点赞 0 评论 0
public Source_zoneContext(ParserRuleContext parent, int invokingState) {
    super(parent, invokingState);
}
MyListener.java 文件源码 项目:SQLParser 阅读 21 收藏 0 点赞 0 评论 0
@Override
public void enterEveryRule(ParserRuleContext arg0) {
    // Logger.log(Logger.DEBUG,"enterEveryRule" + arg0.getText());

}


问题


面经


文章

微信
公众号

扫码关注公众号