use of org.spoofax.interpreter.terms.IStrategoString in project spoofax by metaborg.
the class StrategoCommon method locationTerm.
@Override
public IStrategoString locationTerm(FileObject location) {
final ITermFactory termFactory = termFactoryService.getGeneric();
final String locationURI = location.getName().getURI();
final IStrategoString locationTerm = termFactory.makeString(locationURI);
return locationTerm;
}
use of org.spoofax.interpreter.terms.IStrategoString in project spoofax by metaborg.
the class StrategoCommon method prettyPrint.
@Override
public IStrategoString prettyPrint(IStrategoTerm term) {
final Context context = strategoRuntimeService.genericRuntime().getCompiledContext();
final ITermFactory termFactory = termFactoryService.getGeneric();
org.strategoxt.stratego_aterm.Main.init(context);
term = aterm_escape_strings_0_0.instance.invoke(context, term);
term = pp_aterm_box_0_0.instance.invoke(context, term);
term = box2text_string_0_1.instance.invoke(context, term, termFactory.makeInt(120));
return (IStrategoString) term;
}
use of org.spoofax.interpreter.terms.IStrategoString in project spoofax by metaborg.
the class LanguageComponentsPrimitive method call.
@Override
protected IStrategoTerm call(IStrategoTerm current, Strategy[] svars, IStrategoTerm[] tvars, ITermFactory factory, IContext context) throws MetaborgException, IOException {
IStrategoList list = factory.makeList();
for (ILanguageComponent component : context.language().components()) {
final LanguageIdentifier id = component.id();
final IStrategoString groupIdTerm = factory.makeString(id.groupId);
final IStrategoString idTerm = factory.makeString(id.id);
final IStrategoString versionTerm = factory.makeString(id.version.toString());
final IStrategoString locationTerm = factory.makeString(component.location().getName().getURI());
final IStrategoTuple tuple = factory.makeTuple(groupIdTerm, idTerm, versionTerm, locationTerm);
list = factory.makeListCons(tuple, list);
}
return list;
}
use of org.spoofax.interpreter.terms.IStrategoString in project spoofax by metaborg.
the class LanguageImplementationPrimitive method call.
@Override
protected IStrategoTerm call(IStrategoTerm current, Strategy[] svars, IStrategoTerm[] tvars, ITermFactory factory, IContext context) throws MetaborgException, IOException {
final ILanguageImpl langImpl = context.language();
final LanguageIdentifier langId = langImpl.id();
final IStrategoString groupIdTerm = factory.makeString(langId.groupId);
final IStrategoString idTerm = factory.makeString(langId.id);
final IStrategoString versionTerm = factory.makeString(langId.version.toString());
return factory.makeTuple(groupIdTerm, idTerm, versionTerm);
}
use of org.spoofax.interpreter.terms.IStrategoString in project spoofax by metaborg.
the class LocalPathPrimitive method call.
@Override
protected IStrategoTerm call(IStrategoTerm current, Strategy[] svars, IStrategoTerm[] tvars, ITermFactory factory, IContext context) {
if (!(current instanceof IStrategoString)) {
return null;
}
final IStrategoString currentStr = (IStrategoString) current;
final String path = currentStr.stringValue();
final FileObject resource = resourceService.resolve(path);
final File localPath = resourceService.localPath(resource);
if (localPath == null) {
return null;
}
return factory.makeString(localPath.getPath());
}
Aggregations