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);