Search in sources :

Example 1 with ParseException

use of org.whole.lang.parsers.ParseException in project whole by wholeplatform.

the class WorkflowsInterpreterVisitor method visit.

@Override
public void visit(Parse entity) {
    try {
        entity.getText().accept(this);
        CharSequence text = (CharSequence) getResultValue();
        entity.getGrammar().accept(this);
        IEntity grammarOrUri = getResult();
        if (!EntityUtils.isData(grammarOrUri)) {
            stagedVisit(grammarOrUri);
            grammarOrUri = ((Grammar) grammarOrUri).getUri();
        }
        String grammarUri = grammarOrUri.wStringValue();
        IEntity model;
        if (EntityUtils.isNotResolver(entity.getNt())) {
            entity.getNt().accept(this);
            model = GrammarsUtils.parse(text, grammarUri, getResult().wStringValue());
        } else
            model = GrammarsUtils.parse(text, grammarUri);
        setResult(entity.getModel(), model);
    } catch (ParseException e) {
        // FIXME ?
        throw e;
    } catch (Exception e) {
        throw IWholeRuntimeException.asWholeException(e, entity, getBindings());
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) ParseException(org.whole.lang.parsers.ParseException) MissingVariableException(org.whole.lang.visitors.MissingVariableException) IOException(java.io.IOException) IWholeRuntimeException(org.whole.lang.exceptions.IWholeRuntimeException) VisitException(org.whole.lang.visitors.VisitException) ParseException(org.whole.lang.parsers.ParseException) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException)

Aggregations

IOException (java.io.IOException)1 IWholeRuntimeException (org.whole.lang.exceptions.IWholeRuntimeException)1 WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)1 IEntity (org.whole.lang.model.IEntity)1 ParseException (org.whole.lang.parsers.ParseException)1 MissingVariableException (org.whole.lang.visitors.MissingVariableException)1 VisitException (org.whole.lang.visitors.VisitException)1