Package dtool.tests.utils

Examples of dtool.tests.utils.SimpleParser


 
  protected static final String[] splitKeywords = { "#:HEADER", "Ⓗ", "#:SPLIT", "━━", "▂▂", "▃▃"};
 
  public static boolean isTSPSourceStart(Reader reader) throws IOException {
    String sourceIntro = new String(StreamUtil.readCharAmountFromReader(reader, 10));
    SimpleParser parser = new SimpleParser(sourceIntro);
    return parser.tryConsume(splitKeywords) > 0;
  }
View Full Code Here


    SimpleParser parser = new SimpleParser(sourceIntro);
    return parser.tryConsume(splitKeywords) > 0;
  }
 
  public void splitSourceCases(String defaultMarker, String fileSource) throws TemplatedSourceException {
    SimpleParser parser = new SimpleParser(fileSource);
   
    do {
      boolean isHeader = false;
      String keyMarker = defaultMarker;
     
      int alt = parser.tryConsume(splitKeywords);
      if(alt != SimpleParser.EOF) {
        if(alt == 0 || alt == 1) {
          isHeader = true;
        }
        if(parser.seekToNewLine() == false) {
          handleError(new TemplatedSourceException(parser.getSourcePosition()));
        }
        Matcher matcher = Pattern.compile("→(.)").matcher(parser.getLastConsumedString());
        if(matcher.find()) {
          keyMarker = matcher.group(1);
        }
      } else {
        assertTrue(parser.getSourcePosition() == 0);
      }
     
      parser.consumeUntilAny(splitKeywords);
     
      String unprocessedCaseSource = parser.getLastConsumedString();
      processSplitCaseSource(unprocessedCaseSource, isHeader, keyMarker);
    } while(!parser.lookaheadIsEOF());
  }
View Full Code Here

  }
 
  protected ArrayList<TspElement> parseSource(String unprocessedSource) throws TemplatedSourceException {
    ArrayList<TspElement> unprocessedSourceElements = new ArrayList<TspElement>();
   
    SimpleParser parser = new SimpleParser(unprocessedSource);
    while(true) {
      TspElement tspElem = parseElement(parser);
      if(tspElem == null) {
        break;
      }
View Full Code Here

    }
    throw assertFail();
  }
 
  protected NamedNodeElement[] parseExpectedStructure(String source) {
    SimpleParser parser = new SimpleParser(source);
    NamedNodeElement[] namedElements = readNamedElementsList(parser);
    assertTrue(parser.lookaheadIsEOF() || parser.lookAhead() == '$');
    return namedElements;
  }
View Full Code Here

TOP

Related Classes of dtool.tests.utils.SimpleParser

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.