Package fri.patterns.interpreter.parsergenerator.syntax

Examples of fri.patterns.interpreter.parsergenerator.syntax.Syntax


      { "L", "'id'" },
      { "R", "L", },
    };

    try  {
      LALRParserTables p = new LALRParserTables(new Syntax(syntax));
      p.dump(System.err);
    }
    catch (Exception e)  {
      e.printStackTrace();
    }
View Full Code Here


      { "L", "'id'" },
      { "R", "L", },
    };

    try  {
      LRParserTables p = new LRParserTables(new Syntax(syntax));
      p.dump(System.err);
    }
    catch (Exception e)  {
      e.printStackTrace();
    }
View Full Code Here

    Parser parser = PRODUCTION ? (Parser) read(ensureFileName(syntaxInput, baseName)) : null;
    if (parser == null)  {
      SerializedLexer lexerFactory = newSerializedLexer();
      lexerFactory.PRODUCTION = false// do not store this lexer, it will be stored with parser
      Lexer lexer = lexerFactory.buildAndStoreLexer(syntaxInput, baseName, null, null)// null: forces syntax separation
      Syntax parserSyntax = lexerFactory.getSyntaxSeparation().getParserSyntax();
      SerializedTables tablesFactory = new SerializedTables(false)// do not store this tables, it will be stored with parser
      ParserTables tables = tablesFactory.buildAndStoreParserTables(parserType, parserSyntax, syntaxInput, baseName);
      parser = new Parser(tables);
      parser.setLexer(lexer);
     
View Full Code Here

    throws Exception
  {
    if (parserType == null)
      parserType = LALRParserTables.class;

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

    fri.util.TimeStopper ts = new fri.util.TimeStopper();
    AbstractParserTables parserTables = AbstractParserTables.construct(parserType, syntax);
    System.err.println("ParserTables scratch construction took "+ts.getTimeMillis()+" millis");
View Full Code Here

  /** 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 fri.patterns.interpreter.parsergenerator.syntax.builder.SyntaxBuilder(syntaxFile).getParserSyntax();
      fri.util.TimeStopper ts = new fri.util.TimeStopper();
      ParserTables parserTables = new SerializedTables().get(syntax, "SyntaxBuilder");
      System.err.println("ParserTables were built in "+ts.getTimeMillis()+" millis");
    }
    catch (Exception e)  {
View Full Code Here

    }
   
    if (parserTables == null)  {
      fri.util.TimeStopper ts = new fri.util.TimeStopper();

      Syntax grammar = SerializedObject.toSyntax(syntaxInput);
      parserTables = AbstractParserTables.construct(parserType, grammar);
      if (DEVELOPMENT == false)  {
        String javaFile = parserTables.toSourceFile(className);
        int ret = compile(javaFile);
        new File(javaFile).delete()// source file no more needed
View Full Code Here

  /** Test main. Building compiled ParserTables takes 1600, building from scratch takes 6000 millis. */
  public static void main(String [] args)  {
    try  {
      File syntaxFile = new File("fri/patterns/interpreter/parsergenerator/syntax/builder/examples/SyntaxBuilder.syntax");
      Syntax syntax = new fri.patterns.interpreter.parsergenerator.syntax.builder.SyntaxBuilder(syntaxFile).getParserSyntax();
      fri.util.TimeStopper ts = new fri.util.TimeStopper();
      AbstractParserTables parserTables = new CompiledTables().get(syntax, "SyntaxBuilderParserTables");
      System.err.println("ParserTables were built in "+ts.getTimeMillis()+" millis");
    }
    catch (Exception e)  {
View Full Code Here

            Token.BUTNOT, "comment" },
      { "ignored", "comment" },
      { "ignored", "spaces" },
      { "ignored", "newlines" },
    };
    Syntax syntax = new Syntax(rules);

    try  {
      fri.util.TimeStopper ts = new fri.util.TimeStopper();

      SyntaxSeparation separation = new SyntaxSeparation(syntax);
View Full Code Here

  };
 
  public static void main(String [] args)
    throws Exception
  {
    SyntaxSeparation separation = new SyntaxSeparation(new Syntax(syntax))// separate lexer and parser syntax
    LexerBuilder builder = new LexerBuilder(separation.getLexerSyntax(), separation.getIgnoredSymbols())// build a Lexer
    Lexer lexer = builder.getLexer();
    lexer.setInput("\tHello \r\n\tWorld\n")// give the lexer some very complex input :-)
    ParserTables parserTables = new SLRParserTables(separation.getParserSyntax());
    Parser parser = new Parser(parserTables);
View Full Code Here

{
  /** Test output of SyntaxBuilder syntax tree. */
  public static void main(String [] args)  {
    try  {
      Reader input = new InputStreamReader(Parser.class.getResourceAsStream("syntax/builder/examples/SyntaxBuilder.syntax"));
      Syntax syntax = new Syntax(StandardLexerRules.lexerSyntax);
      SyntaxSeparation separation = new SyntaxSeparation(syntax);
      LexerBuilder builder = new LexerBuilder(separation.getLexerSyntax(), separation.getIgnoredSymbols());
      Lexer lexer = builder.getLexer(input);
      Parser p = new Parser(new SyntaxBuilderParserTables());
      if (p.parse(lexer, new TreeBuilderSemantic()))  {
View Full Code Here

TOP

Related Classes of fri.patterns.interpreter.parsergenerator.syntax.Syntax

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.