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

Examples of org.antlr.v4.runtime.tree.pattern.ParseTreePatternMatcher.split()


import static org.junit.Assert.assertTrue;

public class TestParseTreeMatcher extends BaseTest {
  @Test public void testChunking() throws Exception {
    ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
    assertEquals("[ID, ' = ', expr, ' ;']", m.split("<ID> = <expr> ;").toString());
    assertEquals("[' ', ID, ' = ', expr]", m.split(" <ID> = <expr>").toString());
    assertEquals("[ID, ' = ', expr]", m.split("<ID> = <expr>").toString());
    assertEquals("[expr]", m.split("<expr>").toString());
    assertEquals("['<x> foo']", m.split("\\<x\\> foo").toString());
    assertEquals("['foo <x> bar ', tag]", m.split("foo \\<x\\> bar <tag>").toString());
View Full Code Here


public class TestParseTreeMatcher extends BaseTest {
  @Test public void testChunking() throws Exception {
    ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
    assertEquals("[ID, ' = ', expr, ' ;']", m.split("<ID> = <expr> ;").toString());
    assertEquals("[' ', ID, ' = ', expr]", m.split(" <ID> = <expr>").toString());
    assertEquals("[ID, ' = ', expr]", m.split("<ID> = <expr>").toString());
    assertEquals("[expr]", m.split("<expr>").toString());
    assertEquals("['<x> foo']", m.split("\\<x\\> foo").toString());
    assertEquals("['foo <x> bar ', tag]", m.split("foo \\<x\\> bar <tag>").toString());
  }
View Full Code Here

public class TestParseTreeMatcher extends BaseTest {
  @Test public void testChunking() throws Exception {
    ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
    assertEquals("[ID, ' = ', expr, ' ;']", m.split("<ID> = <expr> ;").toString());
    assertEquals("[' ', ID, ' = ', expr]", m.split(" <ID> = <expr>").toString());
    assertEquals("[ID, ' = ', expr]", m.split("<ID> = <expr>").toString());
    assertEquals("[expr]", m.split("<expr>").toString());
    assertEquals("['<x> foo']", m.split("\\<x\\> foo").toString());
    assertEquals("['foo <x> bar ', tag]", m.split("foo \\<x\\> bar <tag>").toString());
  }
View Full Code Here

  @Test public void testChunking() throws Exception {
    ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
    assertEquals("[ID, ' = ', expr, ' ;']", m.split("<ID> = <expr> ;").toString());
    assertEquals("[' ', ID, ' = ', expr]", m.split(" <ID> = <expr>").toString());
    assertEquals("[ID, ' = ', expr]", m.split("<ID> = <expr>").toString());
    assertEquals("[expr]", m.split("<expr>").toString());
    assertEquals("['<x> foo']", m.split("\\<x\\> foo").toString());
    assertEquals("['foo <x> bar ', tag]", m.split("foo \\<x\\> bar <tag>").toString());
  }

  @Test public void testDelimiters() throws Exception {
View Full Code Here

    ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
    assertEquals("[ID, ' = ', expr, ' ;']", m.split("<ID> = <expr> ;").toString());
    assertEquals("[' ', ID, ' = ', expr]", m.split(" <ID> = <expr>").toString());
    assertEquals("[ID, ' = ', expr]", m.split("<ID> = <expr>").toString());
    assertEquals("[expr]", m.split("<expr>").toString());
    assertEquals("['<x> foo']", m.split("\\<x\\> foo").toString());
    assertEquals("['foo <x> bar ', tag]", m.split("foo \\<x\\> bar <tag>").toString());
  }

  @Test public void testDelimiters() throws Exception {
    ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
View Full Code Here

    assertEquals("[ID, ' = ', expr, ' ;']", m.split("<ID> = <expr> ;").toString());
    assertEquals("[' ', ID, ' = ', expr]", m.split(" <ID> = <expr>").toString());
    assertEquals("[ID, ' = ', expr]", m.split("<ID> = <expr>").toString());
    assertEquals("[expr]", m.split("<expr>").toString());
    assertEquals("['<x> foo']", m.split("\\<x\\> foo").toString());
    assertEquals("['foo <x> bar ', tag]", m.split("foo \\<x\\> bar <tag>").toString());
  }

  @Test public void testDelimiters() throws Exception {
    ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
    m.setDelimiters("<<", ">>", "$");
View Full Code Here

  }

  @Test public void testDelimiters() throws Exception {
    ParseTreePatternMatcher m = new ParseTreePatternMatcher(null, null);
    m.setDelimiters("<<", ">>", "$");
    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);
View Full Code Here

  @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

  @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

  @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

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.