use of mb.nabl2.stratego.StrategoBlob in project nabl by metaborg.
the class StrategoTerms method toStratego.
// to
public IStrategoTerm toStratego(ITerm term) {
IStrategoTerm strategoTerm = term.match(Terms.cases(// @formatter:off
appl -> {
List<IStrategoTerm> args = appl.getArgs().stream().map(arg -> toStratego(arg)).collect(Collectors.toList());
IStrategoTerm[] argArray = args.toArray(new IStrategoTerm[args.size()]);
return appl.getOp().equals(Terms.TUPLE_OP) ? termFactory.makeTuple(argArray) : termFactory.makeAppl(termFactory.makeConstructor(appl.getOp(), appl.getArity()), argArray);
}, list -> toStrategoList(list), string -> termFactory.makeString(string.getValue()), integer -> termFactory.makeInt(integer.getValue()), blob -> new StrategoBlob(blob.getValue()), var -> {
throw new IllegalArgumentException("Cannot convert specialized terms to Stratego.");
}));
strategoTerm = putAttachments(strategoTerm, term.getAttachments());
return strategoTerm;
}
use of mb.nabl2.stratego.StrategoBlob in project nabl by metaborg.
the class SG_get_resource_analysis method call.
@Override
public Optional<? extends IStrategoTerm> call(IScopeGraphContext<?> context, IStrategoTerm sterm, List<IStrategoTerm> sterms, ITermFactory factory) throws InterpreterException {
if (!Tools.isTermString(sterm)) {
throw new InterpreterException("Expect a resource path.");
}
String resource = Tools.asJavaString(sterm);
final IScopeGraphUnit unit = context.unit(resource);
return Optional.of(new StrategoBlob(unit));
}
Aggregations