Examples of ParseTreePattern


Examples of org.antlr.v4.runtime.tree.pattern.ParseTreePattern

      rawGenerateAndBuildRecognizer("X2.g4", grammar, "X2Parser", "X2Lexer", false);
    assertTrue(ok);

    ParseTreePatternMatcher m = getPatternMatcher("X2");

    ParseTreePattern t = m.compile("<ID> = <expr> ;", m.getParser().getRuleIndex("s"));
    String results = t.getPatternTree().toStringTree(m.getParser());
    String expected = "(s <ID> = (expr <expr>) ;)";
    assertEquals(expected, results);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.tree.pattern.ParseTreePattern

      rawGenerateAndBuildRecognizer("X2.g4", grammar, "X2Parser", "X2Lexer", false);
    assertTrue(ok);

    ParseTreePatternMatcher m = getPatternMatcher("X2");

    ParseTreePattern t = m.compile("<ID> = <expr> ;", m.getParser().getRuleIndex("s"));
    String results = t.getPatternTree().toStringTree(m.getParser());
    String expected = "(s <ID> = (expr <expr>) ;)";
    assertEquals(expected, results);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.tree.pattern.ParseTreePattern

      rawGenerateAndBuildRecognizer("X2.g4", grammar, "X2Parser", "X2Lexer", false);
    assertTrue(ok);

    ParseTreePatternMatcher m =  getPatternMatcher("X2");

    ParseTreePattern t = m.compile("<ID> = <ID> ;", m.getParser().getRuleIndex("s"));
    String results = t.getPatternTree().toStringTree(m.getParser());
    String expected = "(s <ID> = <ID> ;)";
    assertEquals(expected, results);
  }
View Full Code Here

Examples of org.antlr.v4.runtime.tree.pattern.ParseTreePattern

      rawGenerateAndBuildRecognizer(grammarFileName, grammar, parserName, lexerName, false);
    assertTrue(ok);

    ParseTree result = execParser(startRule, input, parserName, lexerName);

    ParseTreePattern p = getPattern(grammarName, pattern, startRule);
    ParseTreeMatch match = p.match(result);
    boolean matched = match.succeeded();
    if ( invertMatch ) assertFalse(matched);
    else assertTrue(matched);
    return match;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.