当前位置: 首页>>代码示例>>Java>>正文


Java IStrategoAppl.getSubtermCount方法代码示例

本文整理汇总了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;
    }
 
开发者ID:metaborg,项目名称:spoofax,代码行数:21,代码来源:JSGLRCompletionService.java

示例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;
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:13,代码来源:TOption.java

示例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;
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:15,代码来源:TTuple.java

示例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;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:38,代码来源:Match.java

示例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;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:34,代码来源:Label.java

示例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;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:40,代码来源:java2.java

示例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();
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:7,代码来源:ProductionAttributeReader.java


注:本文中的org.spoofax.interpreter.terms.IStrategoAppl.getSubtermCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。