當前位置: 首頁>>代碼示例>>Java>>正文


Java ErrorNode類代碼示例

本文整理匯總了Java中org.antlr.v4.runtime.tree.ErrorNode的典型用法代碼示例。如果您正苦於以下問題:Java ErrorNode類的具體用法?Java ErrorNode怎麽用?Java ErrorNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ErrorNode類屬於org.antlr.v4.runtime.tree包,在下文中一共展示了ErrorNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: walk

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
public void walk(ParseTreeListener listener, ParseTree t) {
	if ( t instanceof ErrorNode) {
		listener.visitErrorNode((ErrorNode)t);
		return;
	}
	else if ( t instanceof TerminalNode) {
		listener.visitTerminal((TerminalNode)t);
		return;
	}
	RuleNode r = (RuleNode)t;
	enterRule(listener, r);
	int n = r.getChildCount();
	for (int i = 0; i<n; i++) {
		walk(listener, r.getChild(i));
	}
	exitRule(listener, r);

}
 
開發者ID:holycrap872,項目名稱:green-solver,代碼行數:19,代碼來源:KleeParseTreeWalker.java

示例2: visitFieldContains

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public TqlElement visitFieldContains(TqlParser.FieldContainsContext ctx) {
    LOG.debug("Visit field contains: " + ctx.getText());
    TerminalNode field = ctx.getChild(TerminalNode.class, 0);
    TqlElement fieldName = field.accept(this);
    TerminalNode valueNode = ctx.getChild(TerminalNode.class, 2);

    if (valueNode instanceof ErrorNode)
        throw new TqlException(valueNode.getText());

    String quotedValue = valueNode.getSymbol().getText();
    String value = quotedValue.substring(1, quotedValue.length() - 1);
    FieldContainsExpression fieldContainsExpression = new FieldContainsExpression(fieldName, value);
    LOG.debug("End visit field contains: " + ctx.getText());
    return fieldContainsExpression;
}
 
開發者ID:Talend,項目名稱:daikon,代碼行數:17,代碼來源:TqlExpressionVisitor.java

示例3: visitFieldMatchesRegexp

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public TqlElement visitFieldMatchesRegexp(TqlParser.FieldMatchesRegexpContext ctx) {
    LOG.debug("Visit field matches: " + ctx.getText());
    TerminalNode field = ctx.getChild(TerminalNode.class, 0);
    TqlElement fieldName = field.accept(this);
    TerminalNode regexNode = ctx.getChild(TerminalNode.class, 2);

    if (regexNode instanceof ErrorNode)
        throw new TqlException(regexNode.getText());

    String quotedRegex = regexNode.getSymbol().getText();
    String regex = quotedRegex.substring(1, quotedRegex.length() - 1);
    FieldMatchesRegex fieldMatchesRegex = new FieldMatchesRegex(fieldName, regex);
    LOG.debug("End visit field matches: " + ctx.getText());
    return fieldMatchesRegex;
}
 
開發者ID:Talend,項目名稱:daikon,代碼行數:17,代碼來源:TqlExpressionVisitor.java

示例4: visitErrorNode

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public CypherAstBase visitErrorNode(ErrorNode node) {
    throw new MemgraphException(String.format(
            "Could not parse: invalid value \"%s\" (line: %d, pos: %d)",
            node.getText(),
            node.getSymbol().getLine(),
            node.getSymbol().getCharPositionInLine()
    ));
}
 
開發者ID:mware-solutions,項目名稱:memory-graph,代碼行數:10,代碼來源:CypherCstToAstVisitor.java

示例5: visitErrorNode

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
/**
     * {@inheritDoc}
     *
     * <p>The default implementation returns the result of calling
     * {@link #visitChildren} on {@code ctx}.</p>
     */
//    @Override public Result visitNumbers(@NotNull QueryParser.NumbersContext ctx) {
//        return new Result( Result.Type.NUMBER, ctx.getText());
//    }


    @Override
    public Result visitErrorNode(@NotNull ErrorNode errorNode) {
        return null;
    }
 
開發者ID:viant,項目名稱:CacheStore,代碼行數:16,代碼來源:QueryVisitorImpl.java

示例6: visitErrorNode

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public void visitErrorNode(ErrorNode node) {
	super.visitErrorNode(node);
	if (!isGenericError(node.getText()))
		recognize(node.getSymbol(), getStop(node));

	addErrorToken(node);
	debugErrorNode(node);
}
 
開發者ID:curiosag,項目名稱:ftc,代碼行數:10,代碼來源:CursorContextListener.java

示例7: visitErrorNode

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public void visitErrorNode(ErrorNode node) {
    if(node.getSymbol().getCharPositionInLine() != -1) {
        int line = node.getSymbol().getLine();
        int rangeStart = node.getSymbol().getStartIndex();
        int rangeEnd = node.getSymbol().getStopIndex();

        log.logProblem("Error node: \"" + node.getText() + "\"", line, rangeStart, rangeEnd, Problem.Severity.CRITICAL);
    } else {
        log.logProblem("Error node with no position information: \"" + node.getText() + "\"", Problem.NO_LINE_NUM, Problem.Severity.CRITICAL);
    }
}
 
開發者ID:mbway,項目名稱:Simulizer,代碼行數:13,代碼來源:ProgramExtractor.java

示例8: checkNode

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
private static <T> T checkNode(ParseTree node, Class<T> clazz) {
    if (node instanceof ErrorNode) {
        throw new IndexRQLParseError(node.getText());
    } else if (node instanceof TerminalNode) {
        return null;
    } else if (clazz.isInstance(node)) {
        return (T) node;
    }
    return null;
}
 
開發者ID:shunfei,項目名稱:indexr,代碼行數:11,代碼來源:IndexRQL.java

示例9: visitErrorNode

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
    public void visitErrorNode(ErrorNode node) {
//        if (builder.length() > 0) {
//            builder.append(' ');
//        }
//
//        builder.append(Utils.escapeWhitespace(Trees.getNodeText(node, ruleNames), false));
//        builder.append(System.lineSeparator());
    }
 
開發者ID:cmedved,項目名稱:Teradata-SQL-Parser,代碼行數:10,代碼來源:TeradataTreeListener.java

示例10: visitErrorNode

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public void visitErrorNode(ErrorNode node) {
    if (builder.length() > 0) {
        builder.append(' ');
    }

    builder.append(Utils.escapeWhitespace(Trees.getNodeText(node, ruleNames), false));
}
 
開發者ID:TransputerSystems,項目名稱:TSS,代碼行數:9,代碼來源:ParseTreePretty.java

示例11: visitErrorNode

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public CypherAstBase visitErrorNode(ErrorNode node) {
    throw new VertexiumException(String.format(
            "Could not parse: invalid value \"%s\" (line: %d, pos: %d)",
            node.getText(),
            node.getSymbol().getLine(),
            node.getSymbol().getCharPositionInLine()
    ));
}
 
開發者ID:visallo,項目名稱:vertexium,代碼行數:10,代碼來源:CypherCstToAstVisitor.java

示例12: visitErrorNode

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public void visitErrorNode(ErrorNode node) {
	if (logger.isDebugEnabled()) {
		logger.debug("visitErrorNode(ErrorNode) - start"); //$NON-NLS-1$
	}
	
	super.visitErrorNode(node);

	if (logger.isDebugEnabled()) {
		logger.debug("visitErrorNode(ErrorNode) - end"); //$NON-NLS-1$
	}
}
 
開發者ID:rpgleparser,項目名稱:rpgleparser,代碼行數:13,代碼來源:LoggingListener.java

示例13: getNodeText

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
protected String getNodeText(Tree tree, List<String> ruleNames) {
	if (ruleNames != null) {
        if(tree instanceof RuleNode) {
            int ruleIndex = ((RuleNode)tree).getRuleContext().getRuleIndex();
            String ruleName = (String)ruleNames.get(ruleIndex);
            return ruleName;
        }
        
        if(tree instanceof ErrorNode)
            return tree.toString();
        
        if(tree instanceof TerminalNode) {
            Token symbol = ((TerminalNode)tree).getSymbol();
            if(symbol != null) {
                String s = symbol.getText();
                return s;
            }
        }
    }
	
	Object payload = tree.getPayload();
	
	if(payload instanceof Token)
        return ((Token)payload).getText();
    else
        return tree.getPayload().toString();
}
 
開發者ID:processquerying,項目名稱:PQL,代碼行數:28,代碼來源:AbstractPQLQuery.java

示例14: visitFieldCompliesPattern

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public TqlElement visitFieldCompliesPattern(TqlParser.FieldCompliesPatternContext ctx) {
    LOG.debug("Visit field complies: " + ctx.getText());
    TqlElement fieldName = ctx.getChild(0).accept(this);
    ParseTree patternNode = ctx.getChild(2);

    if (patternNode instanceof ErrorNode)
        throw new TqlException(patternNode.getText());

    String quotedPattern = patternNode.getText();
    String pattern = quotedPattern.substring(1, quotedPattern.length() - 1);
    FieldCompliesPattern fieldCompliesPattern = new FieldCompliesPattern(fieldName, pattern);
    LOG.debug("End visit field complies: " + ctx.getText());
    return fieldCompliesPattern;
}
 
開發者ID:Talend,項目名稱:daikon,代碼行數:16,代碼來源:TqlExpressionVisitor.java

示例15: visitFieldIn

import org.antlr.v4.runtime.tree.ErrorNode; //導入依賴的package包/類
@Override
public TqlElement visitFieldIn(TqlParser.FieldInContext ctx) {
    LOG.debug("Visit field in: " + ctx.getText());
    TerminalNode field = ctx.getChild(TerminalNode.class, 0);
    TqlElement fieldName = field.accept(this);
    // All children which are not terminal values are the needed literal values (see syntax)
    LiteralValue[] literalValues = ctx.children.stream().filter(c -> c instanceof TqlParser.LiteralValueContext
            || c instanceof TqlParser.BooleanValueContext || c instanceof ErrorNode).map(c -> (LiteralValue) c.accept(this))
            .toArray(LiteralValue[]::new);
    FieldInExpression fieldIn = new FieldInExpression(fieldName, literalValues);
    LOG.debug("End visit field in: " + ctx.getText());
    return fieldIn;
}
 
開發者ID:Talend,項目名稱:daikon,代碼行數:14,代碼來源:TqlExpressionVisitor.java


注:本文中的org.antlr.v4.runtime.tree.ErrorNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。