@Override protected IStatus run(IProgressMonitor monitor) { monitor.beginTask("Parsing", 105); try { handler.clearMessages(); IGTD<IConstructor, IConstructor, ISourceLocation> gtd = new ClojureParser(); parseTree = (IConstructor) gtd.parse( START_SORT, URI.create(path.toString()), input.toCharArray(), new DefaultNodeFlattener<IConstructor, IConstructor, ISourceLocation>(), new UPTRNodeFactory()); } catch (ParseError pe) { int offset = pe.getOffset(); if (offset == input.length()) --offset; handler.handleSimpleMessage( "parse error", offset, offset + pe.getLength(), pe.getBeginColumn(), pe.getEndColumn(), pe.getBeginLine() + 1, pe.getEndLine() + 1); } catch (Throw e) { IValue exc = e.getException(); if (exc.getType() == RuntimeExceptionFactory.Exception) { if (((IConstructor) exc).getConstructorType() == RuntimeExceptionFactory.ParseError) { ISourceLocation loc = (ISourceLocation) ((IConstructor) e.getException()).get(0); handler.handleSimpleMessage( "parse error: " + loc, loc.getOffset(), loc.getOffset() + loc.getLength(), loc.getBeginColumn(), loc.getEndColumn(), loc.getBeginLine(), loc.getEndLine()); } else { Activator.getInstance().logException(e.getMessage(), e); } } } catch (Throwable e) { Activator.getInstance().logException("parsing failed: " + e.getMessage(), e); } finally { monitor.done(); } return Status.OK_STATUS; }
@Override public Object parse(String input, IProgressMonitor arg1) { parseTree = null; try { job.initialize(input); job.schedule(); job.join(); parseTree = job.parseTree; return parseTree; } catch (InterruptedException e) { Activator.getInstance().logException("parser interrupted", e); } return null; }