Package tool.model.grammar

Examples of tool.model.grammar.ErrorReporter


      ToolModelActivator.showError("Cannot parse file "  + file.getName(), e);
    }
    return null;
  }
  public static ToolClass parseSource(CommonTokenStream tokens, IFile file) throws RecognitionException{
      ErrorReporter parseErrors = new ErrorReporter();
      CommonTree tree = null;
      parser.setTokenStream(tokens);
      parser.setErrorReporter(parseErrors);
      parser.setTreeAdaptor(new CommonTreeAdaptor(){
        public Object create(Token payload){
          return new CommonTree(payload);
        }
      });
      classFile_return result = parser.classFile();
      if (parser.getNumberOfSyntaxErrors() > 0){
        MessageConsole console = ToolModelActivator.findConsole(ToolModelActivator.TOOL_PARSER_OUTPUT);
        MessageConsoleStream msgStream = console.newMessageStream();
        msgStream.println(parser.getNumberOfSyntaxErrors() + " Syntax error(s) in class " + file.getName() + "\n"
            + parseErrors.toString());
      }

      tree = (CommonTree) result.getTree();
      System.out.println(tree.toStringTree());
      CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
View Full Code Here


    try {
    TextFileDocumentProvider provider = new TextFileDocumentProvider();
    provider.connect(file);
    IDocument document = provider.getDocument(file);   
    String source = document.get();
    ErrorReporter parseErrors = new ErrorReporter();
      CommonTree tree = null;
      CommonTokenStream tokens = createTokenStream(source);
      parser.setTokenStream(tokens);
      parser.setErrorReporter(parseErrors);
      parser.setTreeAdaptor(new CommonTreeAdaptor(){
        public Object create(Token payload){
          return new CommonTree(payload);
        }
      });
      project_return result = parser.project();
      if (parser.getNumberOfSyntaxErrors() > 0){
        MessageConsole console = ToolModelActivator.findConsole(ToolModelActivator.TOOL_PARSER_OUTPUT);
        MessageConsoleStream msgStream = console.newMessageStream();
        msgStream.println(parser.getNumberOfSyntaxErrors() + " Syntax error in project " + file.getName() + "\n"
            + parseErrors.toString());
      } else {
        tree = (CommonTree) result.getTree();
        CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
        nodes.setTokenStream(tokens);
        ForteAST walker = new ForteAST(file, nodes);
View Full Code Here

TOP

Related Classes of tool.model.grammar.ErrorReporter

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.