Beispiel #1
0
  public AbstractParserTables buildAndStoreParserTables(
      Class parserType, Syntax parserSyntax, Object syntaxInput, String baseName) throws Exception {
    if (parserType == null) parserType = LALRParserTables.class;

    Syntax syntax = parserSyntax == null ? toSyntax(syntaxInput) : parserSyntax;

    com.martijndashorst.runcc.util.TimeStopper ts =
        new com.martijndashorst.runcc.util.TimeStopper();
    AbstractParserTables parserTables = AbstractParserTables.construct(parserType, syntax);
    System.err.println("ParserTables scratch construction took " + ts.getTimeMillis() + " millis");

    if (PRODUCTION) write(ensureFileName(syntaxInput, baseName), parserTables);

    return parserTables;
  }
Beispiel #2
0
 /**
  * Test main. Building serialized ParserTables takes 170, building from scratch takes 59 millis
  * !!!
  */
 public static void main(String[] args) {
   try {
     File syntaxFile =
         new File(
             "fri/patterns/interpreter/parsergenerator/syntax/builder/examples/SyntaxBuilder.syntax");
     Syntax syntax =
         new com.martijndashorst.runcc.patterns.interpreter.parsergenerator.syntax.builder
                 .SyntaxBuilder(syntaxFile)
             .getParserSyntax();
     com.martijndashorst.runcc.util.TimeStopper ts =
         new com.martijndashorst.runcc.util.TimeStopper();
     ParserTables parserTables = new SerializedTables().get(syntax, "SyntaxBuilder");
     System.err.println("ParserTables were built in " + ts.getTimeMillis() + " millis");
   } catch (Exception e) {
     e.printStackTrace();
   }
 }