Package fri.patterns.interpreter.parsergenerator.syntax.builder

Examples of fri.patterns.interpreter.parsergenerator.syntax.builder.SyntaxBuilder


              pkgName = pkgName.substring(0, pkgName.length() - 1);
            pkgName = pkgName.replace(File.separatorChar, '.');
          }
         
          try  {
            SyntaxBuilder builder = new SyntaxBuilder(new File(args[i]));
            if (semantic)  {
              Syntax syntax = builder.getParserSyntax();
              generateSemanticSkeleton(syntax, clsName, pkgName);
            }
            else
            if (type != null)  {
              Syntax syntax = builder.getParserSyntax();
              AbstractParserTables pt = type.equals("SLR")
                ? new SLRParserTables(syntax)
                : type.equals("LR")
                  ? new LRParserTables(syntax)
                  : new LALRParserTables(syntax);
              generateParserTable(pt, clsName, pkgName);
            }
            else  {
              Syntax syntax = builder.getSyntax();
              generateSyntaxImpl(syntax, clsName, pkgName, builder.getInitialNonterminals());
            }
          }
          catch (Exception e)  {
            e.printStackTrace();
          }
View Full Code Here


    try  {
      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.builder.SyntaxBuilder

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.