Package org.antlr.v4.runtime.tree.pattern

Examples of org.antlr.v4.runtime.tree.pattern.ParseTreePatternMatcher$StartRuleDoesNotConsumeFullPattern


    String result = m.split("<<ID>> = <<expr>> ;$<< ick $>>").toString();
    assertEquals("[ID, ' = ', expr, ' ;<< ick >>']", result);
  }

  @Test public void testInvertedTags() throws Exception {
    ParseTreePatternMatcher m= new ParseTreePatternMatcher(null, null);
    String result = null;
    try {
      m.split(">expr<");
    }
    catch (IllegalArgumentException iae) {
      result = iae.getMessage();
    }
    String expected = "tag delimiters out of order in pattern: >expr<";
View Full Code Here


    String expected = "tag delimiters out of order in pattern: >expr<";
    assertEquals(expected, result);
  }

  @Test public void testUnclosedTag() throws Exception {
    ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
    String result = null;
    try {
      m.split("<expr hi mom");
    }
    catch (IllegalArgumentException iae) {
      result = iae.getMessage();
    }
    String expected = "unterminated tag in pattern: <expr hi mom";
View Full Code Here

    String expected = "unterminated tag in pattern: <expr hi mom";
    assertEquals(expected, result);
  }

  @Test public void testExtraClose() throws Exception {
    ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
    String result = null;
    try {
      m.split("<expr> >");
    }
    catch (IllegalArgumentException iae) {
      result = iae.getMessage();
    }
    String expected = "missing start tag in pattern: <expr> >";
View Full Code Here

      "WS : [ \\r\\n\\t]+ -> skip ;\n";
    boolean ok =
      rawGenerateAndBuildRecognizer("X1.g4", grammar, "X1Parser", "X1Lexer", false);
    assertTrue(ok);

    ParseTreePatternMatcher m = getPatternMatcher("X1");

    List<? extends Token> tokens = m.tokenize("<ID> = <expr> ;");
    String results = tokens.toString();
    String expected = "[ID:3, [@-1,1:1='=',<1>,1:1], expr:7, [@-1,1:1=';',<2>,1:1]]";
    assertEquals(expected, results);
  }
View Full Code Here

      "WS : [ \\r\\n\\t]+ -> skip ;\n";
    boolean ok =
      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

      "WS : [ \\r\\n\\t]+ -> skip ;\n";
    boolean ok =
      rawGenerateAndBuildRecognizer("X2.g4", grammar, "X2Parser", "X2Lexer", false);
    assertTrue(ok);

    ParseTreePatternMatcher m = getPatternMatcher("X2");

    boolean failed = false;
    try {
      m.compile("<ID> = <expr> ; extra", m.getParser().getRuleIndex("s"));
    }
    catch (ParseTreePatternMatcher.StartRuleDoesNotConsumeFullPattern e) {
      failed = true;
    }
    assertTrue(failed);
View Full Code Here

      "WS : [ \\r\\n\\t]+ -> skip ;\n";
    boolean ok =
      rawGenerateAndBuildRecognizer("X2.g4", grammar, "X2Parser", "X2Lexer", false);
    assertTrue(ok);

    ParseTreePatternMatcher m = getPatternMatcher("X2");

    boolean failed = false;
    try {
      m.compile("<ID> ;", m.getParser().getRuleIndex("s"));
    }
    catch (InputMismatchException e) {
      failed = true;
    }
    assertTrue(failed);
View Full Code Here

      "WS : [ \\r\\n\\t]+ -> skip ;\n";
    boolean ok =
      rawGenerateAndBuildRecognizer("X2.g4", grammar, "X2Parser", "X2Lexer", false);
    assertTrue(ok);

    ParseTreePatternMatcher m = getPatternMatcher("X2");

    boolean failed = false;
    try {
      m.compile("<ID> <ID> ;", m.getParser().getRuleIndex("s"));
    }
    catch (NoViableAltException e) {
      failed = true;
    }
    assertTrue(failed);
View Full Code Here

      "WS : [ \\r\\n\\t]+ -> channel(HIDDEN) ;\n";
    boolean ok =
      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

      "WS : [ \\r\\n\\t]+ -> skip ;\n";
    boolean ok =
      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

TOP

Related Classes of org.antlr.v4.runtime.tree.pattern.ParseTreePatternMatcher$StartRuleDoesNotConsumeFullPattern

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.