本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoAppl.getSubtermCount方法的典型用法代码示例。如果您正苦于以下问题:Java IStrategoAppl.getSubtermCount方法的具体用法?Java IStrategoAppl.getSubtermCount怎么用?Java IStrategoAppl.getSubtermCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spoofax.interpreter.terms.IStrategoAppl
的用法示例。
在下文中一共展示了IStrategoAppl.getSubtermCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findPlaceholderTerms
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private Collection<IStrategoTerm> findPlaceholderTerms(IStrategoTerm ast) {
final Collection<IStrategoTerm> placeholderTerms = Lists.newLinkedList();
final IStrategoTermVisitor visitor = new AStrategoTermVisitor() {
@Override public boolean visit(IStrategoTerm term) {
if(term instanceof IStrategoAppl) {
IStrategoAppl appl = (IStrategoAppl) term;
if(appl.getConstructor().getName().contains("-Plhdr") && appl.getSubtermCount() > 0) {
placeholderTerms.add(appl);
return false;
}
}
return true;
}
};
StrategoTermVisitee.topdown(visitor, ast);
return placeholderTerms;
}
示例2: matches
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
@Override public boolean matches(IStrategoTerm t, TypesmartContext context) {
if(t.getTermType() == IStrategoTerm.APPL) {
IStrategoAppl appl = (IStrategoAppl) t;
if("None".equals(appl.getName()) && appl.getSubtermCount() == 0) {
return true;
}
if("Some".equals(appl.getName()) && appl.getSubtermCount() == 1) {
return elemType.matches(appl.getSubterm(0), context);
}
}
return false;
}
示例3: matches
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
@Override public boolean matches(IStrategoTerm t, TypesmartContext context) {
if(t.getTermType() == 0) {
IStrategoAppl appl = (IStrategoAppl) t;
if("".equals(appl.getName()) && elemTypes.length == appl.getSubtermCount()) {
for(int i = 0; i < elemTypes.length; i++) {
if(!elemTypes[i].matches(appl.getSubterm(i), context)) {
return false;
}
}
return true;
}
}
return false;
}
示例4: matchApplOp
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
protected Results matchApplOp(IContext env, IStrategoAppl t,
IStrategoAppl p) throws InterpreterException {
String c = Tools.javaStringAt(p, 0);
if(c.equals("Cons")) {
return null; //matchApplCons(env, t, p);
} else if(c.equals("Nil")) {
return null; //matchApplNil(env, t);
}
IStrategoList ctorArgs = Tools.listAt(p, 1);
// Check if arity of the pattern matches that
// of the term
if (ctorArgs.getSubtermCount() != t.getSubtermCount())
return null;
// Check if the constructor name in the pattern
// matches that of the term
if (!t.getConstructor().getName().equals(c))
return null;
// Recursively match all arguments to term
Results r = emptyList();
for (int i = 0; i < ctorArgs.size(); i++) {
Results m = match(env, t.getSubterm(i),
(IStrategoAppl) ctorArgs
.getSubterm(i));
if (m != null)
r.addAll(m);
else
return null;
}
return r;
}
示例5: 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;
}
示例6: matchApplOp
import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
protected Results matchApplOp(IContext env, IStrategoAppl t,
IStrategoAppl p) throws InterpreterException {
String c = Tools.javaStringAt(p, 0);
if(c.equals("Cons")) {
return null; //matchApplCons(env, t, p);
} else if(c.equals("Nil")) {
return null; //matchApplNil(env, t);
} else if(c.equals("")) {
return matchApplTuple(env, t, p);
}
IStrategoList ctorArgs = Tools.listAt(p, 1);
// Check if arity of the pattern matches that
// of the term
if (ctorArgs.getSubtermCount() != t.getSubtermCount())
return null;
// Check if the constructor name in the pattern
// matches that of the term
if (!t.getConstructor().getName().equals(c))
return null;
// Recursively match all arguments to term
Results r = emptyList();
for (int i = 0; i < ctorArgs.size(); i++) {
Results m = match(env, t.getSubterm(i),
(IStrategoAppl) ctorArgs
.getSubterm(i));
if (m != null)
r.addAll(m);
else
return null;
}
return r;
}
示例7: 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();
}