Package net.sf.lapg.parser.LapgTree

Examples of net.sf.lapg.parser.LapgTree.TextSource


public class SyntaxUtil {

  public static Grammar parseSyntax(String sourceName, InputStream stream, INotifier err,
      Map<String, Object> options) {
    String contents = getFileContents(stream);
    LapgTree<AstRoot> tree = LapgTree.parse(new TextSource(sourceName, contents.toCharArray(), 1));
    Grammar result = null;
    if (!tree.hasErrors()) {
      result = new LapgResolver(tree, options).resolve();
    }
    if (tree.hasErrors()) {
View Full Code Here


    }
    return ind;
  }

  public void testTextSource() {
    TextSource source = new TextSource("file", "aa\nbb\n\nc".toCharArray(), 7);
    int[] expected = new int[] { 7, 7, 7, 8, 8, 8, 9, 10 };

    for (int i = 0; i < expected.length; i++) {
      Assert.assertEquals("offset #" + i, expected[i], source.lineForOffset(i));
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.lapg.parser.LapgTree.TextSource

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.