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


Java IStrategoTerm.getAllSubterms方法代码示例

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


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

示例1: buildTermIterative

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
 * Builds the AST for the specified term, iteratively.
 *
 * @param root
 *            The root term.
 */
private void buildTermIterative(final PsiBuilder builder, final IStrategoTerm root,
                                final ATermAstElementTypeProvider elementTypeProvider) {
    final Stack<TermTask> tasks = new Stack<>();
    tasks.push(new TermTask(root));

    while(!tasks.empty()) {
        final TermTask task = tasks.pop();
        final IStrategoTerm term = task.term();
        @Nullable PsiBuilder.Marker marker = task.marker();
        if(marker == null) {
            // Start
            marker = buildTermStart(builder, term);
            tasks.push(new TermTask(term, marker));

            final IStrategoTerm[] subterms = term.getAllSubterms();
            for(int i = subterms.length - 1; i >= 0; i--) {
                tasks.push(new TermTask(subterms[i]));
            }
        } else {
            // End
            buildTermEnd(builder, term, marker, elementTypeProvider);
        }
    }
}
 
开发者ID:metaborg,项目名称:spoofax-intellij,代码行数:31,代码来源:AstBuilder.java

示例2: buildTermRecursive

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
 * Builds the AST for the specified term, recursively.
 *
 * @param term
 *            The term.
 */
@SuppressWarnings("unused") private void buildTermRecursive(final PsiBuilder builder, final IStrategoTerm term,
                                                            final ATermAstElementTypeProvider elementTypeProvider) {
    final PsiBuilder.Marker marker = buildTermStart(builder, term);

    final IStrategoTerm[] subterms = term.getAllSubterms();
    for(final IStrategoTerm subterm : subterms) {
        // Recurse
        buildTermRecursive(builder, subterm, elementTypeProvider);
    }

    buildTermEnd(builder, term, marker, elementTypeProvider);
}
 
开发者ID:metaborg,项目名称:spoofax-intellij,代码行数:19,代码来源:AstBuilder.java

示例3: simpleAll

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public IStrategoTerm simpleAll(IStrategoTerm current) {
	int termType = current.getTermType();
	IStrategoTerm result;
	
	if (termType == LIST) {
		result = simpleMapIgnoreAnnos((IStrategoList) current);
	} else {
		IStrategoTerm[] inputs = current.getAllSubterms();
		IStrategoTerm[] results = null;

		for (int i = 0; i < inputs.length; i++) {
			IStrategoTerm arg = inputs[i];
			IStrategoTerm arg2 = transform(arg);
			if (arg2 != arg) {
				if (arg2 == null)
					return null;
				if (results == null)
					results = inputs.clone();
				results[i] = keepAttachments ? factory.copyAttachments(arg, arg2) : arg2;
			}
		}

		if (results == null)
			return current;

		switch (termType) {
			case APPL:
				result = factory.makeAppl(((IStrategoAppl) current).getConstructor(),
						results, current.getAnnotations());
				break;
			case TUPLE:
				result = factory.makeTuple(results, current.getAnnotations());
				break;
			default:
				throw new IllegalStateException("unexpected term type: " + termType + " - " + current);
		}
	}
	
	return keepAttachments ? factory.copyAttachments(current, result) : result;
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:41,代码来源:TermTransformer.java

示例4: 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

示例5: isTagElementList

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private boolean isTagElementList(IStrategoTerm term) {
    if(term instanceof IStrategoList) {
        IStrategoTerm[] kids = term.getAllSubterms();
        for(int i = 0; i < kids.length; i++)
            if(!isTagElement(kids[i]))
                return false;
    }
    return true;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:10,代码来源:java3.java

示例6: getChildren

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public static List<STermCursor> getChildren(STermCursor c) {
	IStrategoTerm term = c.getData();
	ArrayList<STermCursor> list = new ArrayList<STermCursor>();
	for(IStrategoTerm subterm : term.getAllSubterms()) {
		list.add(StrategoAdapter.termToTree(subterm));
	}
	return list;
}
 
开发者ID:nuthatchery,项目名称:nuthatch-stratego,代码行数:9,代码来源:STermAdapter.java

示例7: expandSubterms

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private List<List<IStrategoTerm>> expandSubterms(IStrategoTerm astWithSubAsts) {
    List<List<IStrategoTerm>> expandedSubAsts =
        new ArrayList<List<IStrategoTerm>>(astWithSubAsts.getSubtermCount());

    for(IStrategoTerm subAst : astWithSubAsts.getAllSubterms()) {
        expandedSubAsts.add(expand(subAst));
    }

    return expand(expandedSubAsts);
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:11,代码来源:AstUtilities.java

示例8: getSyntaxName

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private static String getSyntaxName(IStrategoTerm entries) {
    for(IStrategoTerm entry : entries.getAllSubterms()) {
        final String cons = ((IStrategoAppl) entry).getConstructor().getName();
        if(cons.equals("Syntax")) {
            return Tools.asJavaString(entry.getSubterm(0));
        }
    }
    return null;
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:10,代码来源:DialectIdentifier.java

示例9: asExtendedModifierList

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asExtendedModifierList(IStrategoTerm term) {
    IStrategoTerm[] kids = term.getAllSubterms();
    List r = new ArrayList(kids.length);
    for(IStrategoTerm k : kids) {
        r.add(asExtendedModifier(k));
    }
    return r;    
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:10,代码来源:java3.java

示例10: asTypeParameterList

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asTypeParameterList(IStrategoTerm term) {
    IStrategoTerm[] kids = term.getAllSubterms();
    List r = new ArrayList(kids.length);
    for(IStrategoTerm k : kids) {
        r.add(asTypeParameter(k));
    }
    return r;    
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:10,代码来源:java3.java

示例11: asTagElementList

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asTagElementList(IStrategoTerm term) {
    IStrategoTerm[] kids = term.getAllSubterms();
    List r = new ArrayList(kids.length);
    for(IStrategoTerm k : kids) {
        r.add(asTagElement(k));
    }
    return r;    
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:10,代码来源:java3.java

示例12: collectLeafnodes

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
/**
 * Collects the leaf nodes
 * @param trm
 * @return
 */
public static ArrayList<IStrategoTerm> collectLeafnodes(IStrategoTerm trm){
	ArrayList<IStrategoTerm> leafnodes = new ArrayList<IStrategoTerm>();
	IStrategoTerm[] subterms = trm.getAllSubterms();
	if(subterms.length == 0){
		leafnodes.add(trm);
	}
	else {
		for (int i = 0; i < subterms.length; i++) {
			leafnodes.addAll(collectLeafnodes(subterms[i]));
		}
	}
	return leafnodes;			
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:19,代码来源:HelperFunctions.java

示例13: asNameList

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asNameList(IStrategoTerm term) {
    IStrategoTerm[] kids = term.getAllSubterms();
    List r = new ArrayList(kids.length);
    for(IStrategoTerm k : kids) {
        r.add(asName(k));
    }
    return r;    
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:10,代码来源:java3.java

示例14: asSingleVariableDeclarationList

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asSingleVariableDeclarationList(IStrategoTerm term) {
    IStrategoTerm[] kids = term.getAllSubterms();
    List r = new ArrayList(kids.length);
    for(IStrategoTerm k : kids) {
        r.add(asSingleVariableDeclaration(k));
    }
    return r;    
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:10,代码来源:java3.java

示例15: asExpressionList

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Collection asExpressionList(IStrategoTerm term) {
    IStrategoTerm[] kids = term.getAllSubterms();
    List r = new ArrayList(kids.length);
    for(IStrategoTerm k : kids) {
        r.add(asExpression(k));
    }
    return r;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:10,代码来源:java3.java


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