Java 类org.antlr.v4.runtime.ParserRuleContext 实例源码

项目:athena    文件:ListenerUtil.java   
/**
 * 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;
    }
}
项目:progex    文件:JavaDDGBuilder.java   
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<>();
}
项目:ts-swift-transpiler    文件:ControlFlow.java   
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);
    }*/
}
项目:Blindfold    文件:TreeNodeTest.java   
/**
 * 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);
}
项目:rockscript    文件:Location.java   
public Location(ParserRuleContext parserRuleContext) {
  Token start = parserRuleContext.getStart();
  this.start = start.getStartIndex();
  Token stop = parserRuleContext.getStop();
  end = stop.getStopIndex();
  line = start.getLine();
}
项目:ETUmulator    文件:Linker.java   
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;
}
项目:rainbow    文件:TypeCalculation.java   
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)");
    }
}
项目:rainbow    文件:AstBuilder.java   
private <T> List<T> visit(List<? extends ParserRuleContext> contexts, Class<T> clazz)
{
    return contexts.stream()
            .map(this::visit)
            .map(clazz::cast)
            .collect(toList());
}
项目:progex    文件:JavaCFGBuilder.java   
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;
}
项目:rainbow    文件:TypeCalculation.java   
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;
}
项目:progex    文件:JavaDDGBuilder.java   
/**
 * 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);
}
项目:rest-modeling-framework    文件:AbstractConstructor.java   
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;
}
项目:Blindfold    文件:TreeNode.java   
public TreeNode(ParserRuleContext context) {
    this.children = new ArrayList<>(8);
    this.context = context;
}
项目:Blindfold    文件:TreeNode.java   
public ParserRuleContext getContext() {
    return this.context;
}
项目:rapidminer    文件:ExpressionParsingException.java   
/**
 * @return the error context, can be {@code null}
 */
public ParserRuleContext getErrorContext() {
    return ctx;
}
项目:oscm    文件:FWPolicyParser.java   
public Source_portContext(ParserRuleContext parent, int invokingState,
        FWPolicy p) {
    super(parent, invokingState);
    this.p = p;
}
项目:pgcodekeeper    文件:AntlrParser.java   
@Override
public void enterEveryRule(ParserRuleContext ctx) {
    //no imp
}
项目:rainbow    文件:AstBuilder.java   
private static ParsingException parseError(String message, ParserRuleContext context)
{
    return new ParsingException(message, null, context.getStart().getLine(), context.getStart().getCharPositionInLine());
}
项目:athena    文件:TreeWalkListener.java   
@Override
public void enterEveryRule(ParserRuleContext parserRuleContext) {
    // do nothing.
}
项目:oscm    文件:FWPolicyParser.java   
public PolicyContext(ParserRuleContext parent, int invokingState,
        List<FWPolicy> pList) {
    super(parent, invokingState);
    this.pList = pList;
}
项目:oscm    文件:FWPolicyParser.java   
public Dest_portContext(ParserRuleContext parent, int invokingState,
        FWPolicy p) {
    super(parent, invokingState);
    this.p = p;
}
项目:oscm    文件:FWPolicyParser.java   
public Dest_zoneContext(ParserRuleContext parent, int invokingState,
        FWPolicy p) {
    super(parent, invokingState);
    this.p = p;
}
项目:oscm    文件:FWPolicyParser.java   
public Dest_zoneContext(ParserRuleContext parent, int invokingState) {
    super(parent, invokingState);
}
项目:dragoman    文件:SelectClauseParser.java   
@Override
protected ParserRuleContext getParserContext(SQLParser parser) {
  // this is the entry point for a map clause
  return parser.select_list();
}
项目:urule    文件:CriteriaContextBuilder.java   
@Override
public boolean support(ParserRuleContext context) {
    return context instanceof SingleConditionContext;
}
项目:oscm    文件:FWPolicyParser.java   
public Dest_ipContext(ParserRuleContext parent, int invokingState,
        FWPolicy p) {
    super(parent, invokingState);
    this.p = p;
}
项目:beaker-notebook-archive    文件:AutocompleteResult.java   
public static int getStartIndex(ParserRuleContext ctx) {
  return ctx.getStop().getStartIndex();
}
项目:elasticsearch_my    文件:Walker.java   
private Location location(ParserRuleContext ctx) {
    return new Location(sourceName, ctx.getStart().getStartIndex());
}
项目:oscm    文件:FWPolicyParser.java   
public Source_zoneContext(ParserRuleContext parent, int invokingState) {
    super(parent, invokingState);
}
项目:SQLParser    文件:MyListener.java   
@Override
public void enterEveryRule(ParserRuleContext arg0) {
    // Logger.log(Logger.DEBUG,"enterEveryRule" + arg0.getText());

}
项目:oscm-app    文件:FWPolicyParser.java   
public PoliciesContext(ParserRuleContext parent, int invokingState) {
    super(parent, invokingState);
}
项目:oscm    文件:FWPolicyParser.java   
public Source_ipContext(ParserRuleContext parent, int invokingState,
        FWPolicy p) {
    super(parent, invokingState);
    this.p = p;
}
项目:oscm-app    文件:FWPolicyParser.java   
public Source_zoneContext(ParserRuleContext parent, int invokingState) {
    super(parent, invokingState);
}
项目:oscm-app    文件:FWPolicyParser.java   
public Source_ipContext(ParserRuleContext parent, int invokingState) {
    super(parent, invokingState);
}
项目:pgcodekeeper    文件:CustomSQLParserListener.java   
static AntlrError handleCreationException(ObjectCreationException ex, ParserRuleContext ctx) {
    Token t = ctx.getStart();
    Log.log(Log.LOG_WARNING, ex.getMessage(), ex);
    return new AntlrError(t, t.getLine(), t.getCharPositionInLine(),  ex.getMessage());
}
项目:oscm-app    文件:FWPolicyParser.java   
public Source_portContext(ParserRuleContext parent, int invokingState) {
    super(parent, invokingState);
}
项目:oscm-app    文件:FWPolicyParser.java   
public Source_portContext(ParserRuleContext parent, int invokingState,
        FWPolicy p) {
    super(parent, invokingState);
    this.p = p;
}
项目:oscm    文件:FWPolicyParser.java   
public Dest_serviceContext(ParserRuleContext parent, int invokingState) {
    super(parent, invokingState);
}
项目:oscm-app    文件:FWPolicyParser.java   
public Dest_serviceContext(ParserRuleContext parent, int invokingState,
        FWPolicy p) {
    super(parent, invokingState);
    this.p = p;
}
项目:oscm-app    文件:FWPolicyParser.java   
public Dest_ipContext(ParserRuleContext parent, int invokingState) {
    super(parent, invokingState);
}