Search in sources :

Example 1 with IRootConsumerListener

use of org.eclipse.xtext.parser.packrat.consumers.IRootConsumerListener in project xtext-core by eclipse.

the class AbstractPackratParser method parse.

protected final IParseResult parse(INonTerminalConsumer consumer) {
    if (activeMarker != null)
        throw new IllegalStateException("cannot parse now. Active marker is already assigned.");
    IMarker rootMarker = mark();
    IRootConsumerListener listener = new RootConsumerListener();
    try {
        consumer.consumeAsRoot(listener);
        IParseResult result = getParseResultFactory().createParseResult(activeMarker, input);
        rootMarker.commit();
        if (activeMarker != null)
            throw new IllegalStateException("cannot finish parse: active marker is still present.");
        return result;
    } catch (Exception e) {
        throw new WrappedException(e);
    }
}
Also used : WrappedException(org.eclipse.emf.common.util.WrappedException) IRootConsumerListener(org.eclipse.xtext.parser.packrat.consumers.IRootConsumerListener) IRootConsumerListener(org.eclipse.xtext.parser.packrat.consumers.IRootConsumerListener) IParseResult(org.eclipse.xtext.parser.IParseResult) IOException(java.io.IOException) WrappedException(org.eclipse.emf.common.util.WrappedException)

Aggregations

IOException (java.io.IOException)1 WrappedException (org.eclipse.emf.common.util.WrappedException)1 IParseResult (org.eclipse.xtext.parser.IParseResult)1 IRootConsumerListener (org.eclipse.xtext.parser.packrat.consumers.IRootConsumerListener)1