本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoAppl.getSubterm方法的典型用法代码示例。如果您正苦于以下问题:Java IStrategoAppl.getSubterm方法的具体用法?Java IStrategoAppl.getSubterm怎么用?Java IStrategoAppl.getSubterm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spoofax.interpreter.terms.IStrategoAppl
的用法示例。
在下文中一共展示了IStrategoAppl.getSubterm方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildOp
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private IStrategoTerm buildOp(IContext env, IStrategoAppl t, ITermFactory factory)
throws InterpreterException {
// FIXME memoize constructors
String ctr = Tools.javaStringAt(t, 0);
IStrategoList children = (IStrategoList) t.getSubterm(1);
if(ctr.length() == 0) {
return buildTuple(env, t);
} else if(children.getSubtermCount() == 0 && ctr.equals("Nil")) {
return buildNil(env);
} else if(children.getSubtermCount() == 2 && ctr.equals("Cons")) {
return buildCons(env, t, factory);
} else {
return buildOp(ctr, env, t, factory);
}
}
示例2: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public static @Nullable OutlineFacet create(IStrategoAppl esv) {
final IStrategoAppl outlineTerm = ESVReader.findTerm(esv, "OutlineView");
if(outlineTerm == null) {
return null;
}
final String strategyName = ESVReader.termContents(outlineTerm.getSubterm(0));
final int expandTo;
final IStrategoAppl expandToTerm = ESVReader.findTerm(esv, "ExpandToLevel");
if(expandToTerm == null) {
expandTo = 0;
} else {
final IStrategoTerm expandToNumberTerm = expandToTerm.getSubterm(0);
if(expandToNumberTerm instanceof IStrategoInt) {
final IStrategoInt expandToNumberIntTerm = (IStrategoInt) expandToNumberTerm;
expandTo = expandToNumberIntTerm.intValue();
} else if(expandToNumberTerm instanceof IStrategoString) {
final IStrategoString expandToNumberStringTerm = (IStrategoString) expandToNumberTerm;
expandTo = Integer.parseInt(expandToNumberStringTerm.stringValue());
} else {
expandTo = 0;
}
}
return new OutlineFacet(strategyName, expandTo);
}
示例3: type
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public static @Nullable String type(IStrategoAppl esv) {
final IStrategoAppl contextTerm = ESVReader.findTerm(esv, "Context");
if(contextTerm == null) {
return null;
}
final IStrategoAppl typeTerm = (IStrategoAppl) contextTerm.getSubterm(0);
final String name = typeTerm.getConstructor().getName();
switch(name) {
case "None":
return null;
default:
logger.warn("Unknown context type {}, defaulting to legacy context.", name);
case "Legacy":
return LegacyContextFactory.name;
case "TaskEngine":
return IndexTaskContextFactory.name;
}
}
示例4: type
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public static @Nullable String type(IStrategoAppl esv) {
final IStrategoAppl strategy = ESVReader.findTerm(esv, "SemanticObserver");
if(strategy == null) {
return null;
}
final IStrategoTerm annotations = strategy.getSubterm(1);
boolean multifile = false;
boolean constraint = false;
for(IStrategoTerm annotation : annotations) {
multifile |= Tools.hasConstructor((IStrategoAppl) annotation, "MultiFile", 0);
constraint |= Tools.hasConstructor((IStrategoAppl) annotation, "Constraint", 0);
}
if(constraint) {
return multifile ? ConstraintMultiFileAnalyzer.name : ConstraintSingleFileAnalyzer.name;
} else if(multifile) {
return TaskEngineAnalyzer.name;
}
return StrategoAnalyzer.name;
}
示例5: buildTuple
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private IStrategoTerm buildTuple(IContext env, IStrategoAppl t) throws InterpreterException {
IStrategoList children = (IStrategoList) t.getSubterm(1);
IStrategoTerm[] kids = new IStrategoTerm[children.size()];
for (int i = 0; i < children.size(); i++) {
IStrategoTerm kid = kids[i] = buildTerm(env, (IStrategoAppl) children.getSubterm(i));
if (kid == null) {
return null;
}
}
return env.getFactory().makeTuple(kids);
}
示例6: createStrategoTermAttribute
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private IStrategoTerm createStrategoTermAttribute(IStrategoAppl term) throws UnexpectedTermException {
ITermFactory termFactory = ParseTableGenerator.getTermfactory();
if(term.getConstructor().getName().equals("Appl")) {
String cons_name = ((IStrategoString) term.getSubterm(0).getSubterm(0)).stringValue();
int arity = term.getSubterm(1).getSubtermCount();
IStrategoTerm[] subterms = new IStrategoTerm[arity];
for(int i = 0; i < arity; i++) {
IStrategoTerm child = ((IStrategoList) term.getSubterm(1)).getSubterm(i);
subterms[i] = createStrategoTermAttribute((IStrategoAppl) child);
}
return termFactory .makeAppl(termFactory.makeConstructor(cons_name, arity), subterms);
} else if(term.getConstructor().getName().equals("Fun")) {
String termName = ((IStrategoString) term.getSubterm(0).getSubterm(0)).stringValue();
if(((IStrategoAppl) term.getSubterm(0)).getConstructor().getName().equals("Quoted")) {
termName = termName.replace("\\\"", "\"").replace("\\\\", "\\").replace("\\'", "\'").substring(1,
termName.length() - 1);
}
return termFactory.makeString(termName);
} else if(term.getConstructor().getName().equals("Int")) {
String svalue = ((IStrategoString) term.getSubterm(0).getSubterm(0)).stringValue();
int ivalue = Integer.parseInt(svalue);
return termFactory.makeInt(ivalue);
} else if(term.getConstructor().getName().equals("List")) {
IStrategoList term_list = (IStrategoList) term.getSubterm(0);
List<IStrategoTerm> terms = Lists.newArrayList();
for(IStrategoTerm t : term_list) {
terms.add(createStrategoTermAttribute((IStrategoAppl) t));
}
return termFactory.makeList(terms);
}
System.err.println("sdf2table : importAttribute: unknown stratego term attribute `" + term.getName() + "'.");
throw new UnexpectedTermException(term.toString());
}
示例7: toOutlineNode
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private @Nullable IOutlineNode toOutlineNode(IStrategoTerm term, @Nullable IOutlineNode parent,
FileObject location) {
if(!(term instanceof IStrategoAppl)) {
return null;
}
final IStrategoAppl appl = (IStrategoAppl) term;
if(!Tools.hasConstructor(appl, "Node", 2)) {
return null;
}
final IStrategoTerm labelTerm = appl.getSubterm(0);
final String label = label(labelTerm);
final FileObject icon = icon(labelTerm, location);
final ISourceRegion region = region(labelTerm);
final OutlineNode node = new OutlineNode(label, icon, region, parent);
final IStrategoTerm nodesTerm = appl.getSubterm(1);
for(IStrategoTerm nodeTerm : nodesTerm) {
final IOutlineNode childNode = toOutlineNode(nodeTerm, node, location);
if(childNode != null) {
node.addChild(childNode);
}
}
return node;
}
示例8: style
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private static IStyle style(IStrategoAppl attribute) {
final Color color = color((IStrategoAppl) attribute.getSubterm(0));
final Color backgroundColor = color((IStrategoAppl) attribute.getSubterm(1));
final boolean bold;
final boolean italic;
final boolean underline = false;
final boolean strikeout = false;
final IStrategoAppl fontSetting = (IStrategoAppl) attribute.getSubterm(2);
final String fontSettingCons = fontSetting.getConstructor().getName();
switch (fontSettingCons) {
case "BOLD":
bold = true;
italic = false;
break;
case "ITALIC":
bold = false;
italic = true;
break;
case "BOLD_ITALIC":
bold = true;
italic = true;
break;
default:
bold = false;
italic = false;
break;
}
return new Style(color, backgroundColor, bold, italic, underline, strikeout);
}
示例9: isLayout
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public boolean isLayout() {
if (isLayout != null)
return isLayout;
IStrategoTerm t = prod.getSubterm(1);
while (true) {
if (t.getTermType() != IStrategoTerm.APPL) {
isLayout = false;
break;
}
IStrategoAppl app = (IStrategoAppl) t;
if (Term.hasConstructor(app, "layout")) {
isLayout = true;
break;
}
if (app.getSubtermCount() == 1 &&
(Term.hasConstructor(app, "cf") ||
Term.hasConstructor(app, "lex") ||
Term.hasConstructor(app, "opt") ||
Term.hasConstructor(app, "iter")))
t = app.getSubterm(0);
else {
isLayout = false;
break;
}
}
return isLayout;
}
示例10: unwrapObject
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public Object unwrapObject(IStrategoAppl term) {
IStrategoTerm t = term.getSubterm(0);
if(!(isTermInt(t)))
return null;
return objectWrappers.get(((IStrategoInt)t).intValue());
}
示例11: isLexLayout
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public boolean isLexLayout(IStrategoAppl rhs) {
if (rhs.getSubtermCount() != 1) return false;
IStrategoTerm child = rhs.getSubterm(0);
return isTermAppl(child) && layoutFun == ((IStrategoAppl) child).getConstructor()
&& lexFun == rhs.getConstructor();
}
示例12: buildCons
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private IStrategoList buildCons(IContext env, IStrategoAppl t, ITermFactory factory) throws InterpreterException {
IStrategoList children = (IStrategoList) t.getSubterm(1);
IStrategoAppl headPattern = (IStrategoAppl) children.getSubterm(0);
IStrategoAppl tailPattern = (IStrategoAppl) children.getSubterm(1);
IStrategoList tail = buildList(env, tailPattern, factory);
IStrategoTerm head = buildTerm(env, headPattern);
if(tail == null || head == null)
return null;
return factory.makeListCons(head, tail);
}