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


Java IStrategoTerm.getSubtermCount方法代码示例

本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoTerm.getSubtermCount方法的典型用法代码示例。如果您正苦于以下问题:Java IStrategoTerm.getSubtermCount方法的具体用法?Java IStrategoTerm.getSubtermCount怎么用?Java IStrategoTerm.getSubtermCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spoofax.interpreter.terms.IStrategoTerm的用法示例。


在下文中一共展示了IStrategoTerm.getSubtermCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: topdownHasSpaces

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private static boolean topdownHasSpaces(IStrategoTerm term) {
    Iterator<IStrategoTerm> iterator = TermVisitor.tryGetListIterator(term);

    for(int i = 0, max = term.getSubtermCount(); i < max; i++) {
        IStrategoTerm child = iterator == null ? term.getSubterm(i) : iterator.next();

        if(isRangeAppl(child)) {
            int start = intAt(child, 0);
            int end = intAt(child, 1);

            if(start <= ' ' && ' ' <= end)
                return true;
        } else {
            if(topdownHasSpaces(child))
                return true;
        }
    }

    return false;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:21,代码来源:ProductionReader.java

示例2: call

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
public final boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars) {
	final IStrategoTerm location = tvars[0];
	if(!Tools.isTermTuple(location) && location.getSubtermCount() != 4)
		return false;

	final String filename = Tools.asJavaString(location.getSubterm(0));
	final int line = Tools.asJavaInt(location.getSubterm(1));
	final int column = Tools.asJavaInt(location.getSubterm(2));
	final int startOffset = Tools.asJavaInt(location.getSubterm(3));
	final int endOffset = Tools.asJavaInt(location.getSubterm(4));

	final ImploderAttachment attachment =
		ImploderAttachment.createCompactPositionAttachment(filename, line, column, startOffset, endOffset);
	env.current().putAttachment(attachment);

	return true;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:19,代码来源:OriginSetLocationOffsetPrimitive.java

示例3: call

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
        throws InterpreterException {
    
    IStrategoTerm input = tvars[0];
    
    if(!Tools.isTermAppl(input) && !isTermTuple(input))
        return false;
    
    Strategy c = svars[0];
    int arity = input.getSubtermCount();
    IStrategoTerm[] result = new IStrategoTerm[arity];
    IStrategoTerm[] applArgs = input.getAllSubterms();
    for(int i = 0; i < arity; i++) {
        env.setCurrent(applArgs[i]);
        if(!c.evaluate(env))
            return false;
        result[i] = env.current();
    }
    env.setCurrent(env.getFactory().makeList(result));
    return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:23,代码来源:SSL_get_appl_arguments_map.java

示例4: configureAmbNodes

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private void configureAmbNodes(IStrategoTerm result, boolean isBracket, boolean isCompletion,
    boolean isNestedCompletion, boolean isSinglePlaceholderCompletion) {
    for(int i = 0; i < result.getSubtermCount(); i++) {
        IStrategoTerm child = result.getSubterm(i);
        if(child instanceof IStrategoAppl) {
            if(((IStrategoAppl) child).getConstructor().getName().equals("amb")) {
                IStrategoTerm ambList = child.getSubterm(0);
                configureAmbNodes(ambList, isBracket, isCompletion, isNestedCompletion,
                    isSinglePlaceholderCompletion);
            } else {
                IToken left = getLeftToken(child);
                IToken right = getRightToken(child);
                if(ImploderAttachment.get(child).isCompletion()) {
                    configure(child, child.getAttachment(ImploderAttachment.TYPE).getSort(), left, right, false,
                        isBracket, true, false, isSinglePlaceholderCompletion);
                } else {
                    configure(child, child.getAttachment(ImploderAttachment.TYPE).getSort(), left, right, false,
                        isBracket, isCompletion, isNestedCompletion, isSinglePlaceholderCompletion);
                }
            }
        }
    }
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:24,代码来源:TermTreeFactory.java

示例5: termListContents

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Nullable
public static List<String> termListContents(IStrategoTerm t) {
    if(t == null)
        return null;

    List<String> results = Lists.newArrayList();

    if(t.getSubtermCount() == 1 && "Values".equals(tryGetName(t))) {
        IStrategoList values = Tools.listAt(t, 0);
        for(int i = 0; i < values.getSubtermCount(); i++) {
            results.add(termContents(termAt(values, i)));
        }
    } else {
        return null;
    }

    return results;
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:19,代码来源:ESVReader.java

示例6: resolveAmbiguitiesByIndentation

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public static void resolveAmbiguitiesByIndentation(IStrategoTerm node)
{
    if (node.getSubtermCount()>1)
    {
        IStrategoList contents;
        if ("amb".equals(((IStrategoNamed) node).getName())){
            contents = termAt(node, 0);
        }
        else{
            contents = termAt(node, 1);
        }
        for (int i = 0; i < contents.getSubtermCount(); i++) {
            resolveAmbiguitiesByIndentation(contents.getSubterm(i));
        }
    }

    if ("amb".equals(((IStrategoNamed) node).getName())){
        IStrategoList ambs = termAt(node, 0);
        node = ambs.getSubterm(0);
    }
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:22,代码来源:IndentationFilter.java

示例7: isIncrementalProduction

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private static boolean isIncrementalProduction(IStrategoTerm prod, IStrategoConstructor incrementalFun) {
	IStrategoTerm attrsContainer = termAt(prod, 2);
	if (attrsContainer.getSubtermCount() > 0) {
		IStrategoList attrs = termAt(attrsContainer, 0);
		while (!attrs.isEmpty()) {
			IStrategoTerm attr = attrs.head();
			if (attr.getSubtermCount() == 1)
				attr = attr.getSubterm(0);
			if (tryGetConstructor(attr) == incrementalFun)
				return true;
			attrs = attrs.tail();
		}
	}
	return false;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:16,代码来源:IncrementalSortSet.java

示例8: topdown

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public static void topdown(IStrategoTermVisitor visitor, IStrategoTerm initialTerm) {
    final Stack<IStrategoTerm> stack = new Stack<IStrategoTerm>();
    stack.push(initialTerm);
    while(!stack.empty()) {
        final IStrategoTerm term = stack.pop();
        if(!dispatch(visitor, term)) {
            continue;
        }
        for(int i = term.getSubtermCount() -1; i >= 0; --i) {
            stack.push(term.getSubterm(i));
        }
    }
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:14,代码来源:StrategoTermVisitee.java

示例9: topdownPrintMatching

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
protected void topdownPrintMatching(IStrategoTerm trm) {
	printMatching(trm);
	for (int i = 0; i < trm.getSubtermCount(); i++) {
		topdownPrintMatching(trm.getSubterm(i));
	}
		
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:8,代码来源:AbstractTestTreeDiff.java

示例10: haveSameSignature

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private boolean haveSameSignature(IStrategoTerm term, IStrategoTerm origin) {
	if(term instanceof StrategoAppl && origin instanceof StrategoAppl){
		if(!((StrategoAppl)term).getConstructor().equals(((StrategoAppl)origin).getConstructor()))
			return false;
	}
	return 	
		term.getTermType() == origin.getTermType() && 
		term.getSubtermCount() == origin.getSubtermCount();
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:10,代码来源:OriginTermFactory.java

示例11: strip

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public IStrategoTerm strip(IStrategoTerm term) {
	if (term == null)
		return null;
	
	// Kids
	boolean isRebuildNeeded = false;
	IStrategoTerm[] kids = TermFactory.EMPTY;
	if (term.getSubtermCount() > 0) {
		kids = term.getAllSubterms();
		IStrategoTerm[] newKids = tryStripKids(kids);
		if (newKids != null) {
			isRebuildNeeded = true;
			kids = newKids;
		}
	}
	
	// Annotations
	IStrategoList annos = term.getAnnotations();
	IStrategoTerm[] newAnnos = tryStripAnnos(annos);
	if (newAnnos != null) {
		isRebuildNeeded = true;
		annos = factory.makeList(newAnnos);
	}
	
	// Self
	if (!isRebuildNeeded)
		isRebuildNeeded = term.getAttachment(null) != null;
	
	return isRebuildNeeded
		? converter.convertShallow(term, kids, annos)
		: term;
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:33,代码来源:TermAttachmentStripper.java

示例12: matchTerminalsBottomUp

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
 * Traverses all terms in t2 in bottum-up order and tries to construct a matching for those.
 * @param root1
 * @param t2
 */
private void matchTerminalsBottomUp(IStrategoTerm root1, IStrategoTerm t2) {
	for (int i = 0; i < t2.getSubtermCount(); i++) {
		matchTerminalsBottomUp(root1, t2.getSubterm(i));
	}
	tryMatchTerminalNode(root1, t2);
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:12,代码来源:AbstractTreeMatcher.java

示例13: haveSameSignature

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
 * True iff one of these conditions hold:
 * 1. both are Appl with same constructor name and same number of subterms
 * 2. both are lists
 * 3. both are tuples
 * @param t1
 * @param t2
 * @return
 */
public static boolean haveSameSignature(IStrategoTerm t1, IStrategoTerm t2){
	if(t1 == null || t2 == null)
		return false;
	if(t1.getTermType() == StrategoTerm.APPL && t2.getTermType() == StrategoTerm.APPL){
		boolean sameConstructorName = haveSameConstructorName(t1, t2);
		return sameConstructorName && t1.getSubtermCount() == t2.getSubtermCount();
	}
	if (Tools.isTermList(t1) && Tools.isTermList(t2))
		return true;
	if (Tools.isTermTuple(t1) && Tools.isTermTuple(t2))
		return true;
	else
		return false;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:24,代码来源:HelperFunctions.java

示例14: countMatches

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
protected int countMatches(IStrategoTerm trm) {
	int nrOfMatches = 0;
	if(TermMatchAttachment.getMatchedTerm(trm) != null)
		nrOfMatches += 1;
	for (int i = 0; i < trm.getSubtermCount(); i++) {
		nrOfMatches += countMatches(trm.getSubterm(i));
	}
	return nrOfMatches;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:10,代码来源:AbstractTestTreeDiff.java

示例15: getRecoverCandidatesFromChildTerms

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private ArrayList<RecoverInterpretation> getRecoverCandidatesFromChildTerms(
		IStrategoTerm visitedTerm, IStrategoTerm term, IStrategoTerm parent) {
	if(visitedTerm.getSubtermCount() == 0)
		return new ArrayList<RecoverInterpretation>();
	int startIndex = 0;
	int endIndex = visitedTerm.getSubtermCount() - 1;
	ArrayList<RecoverInterpretation> candidatesFromSubterms = getRecoverCandidatesFromChildTerms(visitedTerm, startIndex, endIndex, term, parent);
	return candidatesFromSubterms;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:10,代码来源:TermEditsAnalyzer.java


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