Package org.antlr.v4.runtime.tree

Examples of org.antlr.v4.runtime.tree.ParseTree


    @Test
    public void mixedCaseOfHtmlTags()
        throws IOException
    {
        String filename = folderWithInputFiles + "/htmlTags/MixedCaseOfHtmlTags.txt";
        ParseTree generatedTree = parseJavadoc(getFileContent(new File(filename)));
        ParseTree expectedTree = ParseTreeBuilder.treeMixedCaseOfHtmlTags();
        compareTrees(expectedTree, generatedTree);
    }
View Full Code Here


    @Test
    public void htmlComments()
        throws IOException
    {
        String filename = folderWithInputFiles + "/htmlTags/Comments.txt";
        ParseTree generatedTree = parseJavadoc(getFileContent(new File(filename)));
        ParseTree expectedTree = ParseTreeBuilder.treeComments();
        compareTrees(expectedTree, generatedTree);
    }
View Full Code Here

    @Test
    public void negativeNumberInAttribute()
        throws IOException
    {
        String filename = folderWithInputFiles + "/htmlTags/NegativeNumberInAttribute.txt";
        ParseTree generatedTree = parseJavadoc(getFileContent(new File(filename)));
        ParseTree expectedTree = ParseTreeBuilder.treeNegativeNumberInAttribute();
        compareTrees(expectedTree, generatedTree);
    }
View Full Code Here

public class SerpentCompiler {

    public static String compile(String code) {
        SerpentParser parser = ParserUtils.getParser(SerpentLexer.class, SerpentParser.class,
                code);
        ParseTree tree = parser.parse();

        String result = new SerpentToAssemblyCompiler().visit(tree);
        result = result.replaceAll("\\s+", " ");
        result = result.trim();
View Full Code Here

    }

    public static String compileFullNotion(String code) {
    SerpentParser parser = ParserUtils.getParser(SerpentLexer.class,
        SerpentParser.class, code);
        ParseTree tree = parser.parse_init_code_block();

        String result = new SerpentToAssemblyCompiler().visit(tree);
        result = result.replaceAll("\\s+", " ");
        result = result.trim();
        return result;
View Full Code Here

    public static ExprTimePeriod timePeriodGetExprAllParams(EsperEPL2GrammarParser.TimePeriodContext ctx, Map<Tree, ExprNode> astExprNodeMap, VariableService variableService, StatementSpecRaw spec) {

        ExprNode nodes[] = new ExprNode[8];
        for (int i = 0; i < ctx.getChildCount(); i++) {
            ParseTree unitRoot = ctx.getChild(i);

            ExprNode valueExpr;
            if (ASTUtil.isTerminatedOfType(unitRoot.getChild(0), EsperEPL2GrammarLexer.IDENT)) {
                String ident = unitRoot.getChild(0).getText();
                valueExpr = ASTExprHelper.resolvePropertyOrVariableIdentifier(ident, variableService, spec);
            }
            else {
                final AtomicReference<ExprNode> ref = new AtomicReference<ExprNode>();
                ExprAction action = new ExprAction() {
                    public void found(ExprNode exprNode, Map<Tree, ExprNode> astExprNodeMap, Tree node) {
                        astExprNodeMap.remove(node);
                        ref.set(exprNode);
                    }
                };
                ASTExprHelper.recursiveFindRemoveChildExprNode(unitRoot.getChild(0), astExprNodeMap, action);
                valueExpr = ref.get();
            }

            if (ASTUtil.getRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_millisecondPart) {
                nodes[7] = valueExpr;
View Full Code Here

                printer.print(terminal.getSymbol().getType());
                printer.print("]");
            }

            if (node instanceof ParseTree) {
                ParseTree parseTree = (ParseTree) node;
                if (parseTree.getText() == null)
                {
                    printer.print(" (null value in text)");
                }
                else if (parseTree.getText().contains("\\"))
                {
                    int count = 0;
                    for (int i = 0; i < parseTree.getText().length(); i++)
                    {
                        if (parseTree.getText().charAt(i) == '\\')
                        {
                            count++;
                        }
                    }
                    printer.print(" (" + count + " backlashes)");
View Full Code Here

    }

    public static String getPropertyName(EsperEPL2GrammarParser.EventPropertyContext ctx, int startNode) {
        StringBuilder buf = new StringBuilder();
        for (int i = startNode; i < ctx.getChildCount(); i++) {
            ParseTree tree = ctx.getChild(i);
            buf.append(tree.getText());
        }
        return buf.toString();
    }
View Full Code Here

        InsertIntoDesc insertIntoDesc = new InsertIntoDesc(selector, eventTypeName);

        // optional columns
        if (ctx.columnList() != null) {
            for (int i = 0; i < ctx.columnList().getChildCount(); i++) {
                ParseTree node = ctx.columnList().getChild(i);
                if (ASTUtil.isTerminatedOfType(node, EsperEPL2GrammarLexer.IDENT)) {
                    insertIntoDesc.add(node.getText());
                }
            }
        }

        statementSpec.setInsertIntoDesc(insertIntoDesc);
View Full Code Here

        String code = "a=2";
        String expected = "2 0 MSTORE";

    SerpentParser parser = ParserUtils.getParser(SerpentLexer.class,
                SerpentParser.class, code);
        ParseTree tree = parser.parse();

        String result = new SerpentToAssemblyCompiler().visit(tree);
        result = result.replaceAll("\\s+", " ");
        result = result.trim();
View Full Code Here

TOP

Related Classes of org.antlr.v4.runtime.tree.ParseTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.