Package fri.patterns.interpreter.parsergenerator.syntax

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


      System.out.println("Input is: "+(args.length > 0 ? args[0] : "SyntaxBuilder.syntax"));
      InputStreamReader in = args.length <= 0
          ? new InputStreamReader(Example.class.getResourceAsStream("SyntaxBuilder.syntax"))
          : new InputStreamReader(new FileInputStream(args[0]));
      SyntaxBuilder builder = new SyntaxBuilder(in);
      Syntax syntax = builder.getSyntax();
      System.out.println("Resolved syntax rules are: ==============");
      System.out.println(syntax.toString());

      // now lets see if we can parse the syntax specification text with its own syntax
      in = args.length <= 0
          ? new InputStreamReader(Example.class.getResourceAsStream("SyntaxBuilder.syntax"))
          : new InputStreamReader(new FileInputStream(args[0]));
      Lexer lexer = builder.getLexer();
      lexer.setInput(in);
      lexer.setDebug(true);
      Syntax parserSyntax = builder.getParserSyntax();
      ParserTables parserTables = new LALRParserTables(parserSyntax);
      Parser parser = new Parser(parserTables);
      boolean ok = parser.parse(lexer);
      if (ok == false)
        throw new Exception("Failed parsing syntax specification text!");
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.