本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoTerm.getSubterm方法的典型用法代码示例。如果您正苦于以下问题:Java IStrategoTerm.getSubterm方法的具体用法?Java IStrategoTerm.getSubterm怎么用?Java IStrategoTerm.getSubterm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spoofax.interpreter.terms.IStrategoTerm
的用法示例。
在下文中一共展示了IStrategoTerm.getSubterm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
}
}
示例2: matchTermsTopdown
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private void matchTermsTopdown(IStrategoTerm root1, IStrategoTerm trm2) {
IStrategoTerm trm1 = TermMatchAttachment.getMatchedTerm(trm2);
if(HelperFunctions.haveSameSignature(trm1, trm2) && trm1.getSubtermCount() == trm2.getSubtermCount()){
for (int i = 0; i < trm2.getSubtermCount(); i++) {
IStrategoTerm trm2Child = trm2.getSubterm(i);
IStrategoTerm trm1Child = trm1.getSubterm(i);
IStrategoTerm trm2ChildPartner = TermMatchAttachment.getMatchedTerm(trm2Child);
if(trm1Child != trm2ChildPartner){
if(hasBetterOrEqualMatchingScore(trm2ChildPartner, trm1Child, trm2Child)){
//trm1Child has the same child index as trm2Child, and matched parents M(trm1,trm2)
//Therefore, trm1child is the preferred candidate for trm2Child,
//unless trm2ChildPartner is better
matchTerminalNode(root1, trm1Child, trm2Child);
}
}
}
}
for (int i = trm2.getSubtermCount()-1; i >=0; i--) {
matchTermsTopdown(root1, trm2.getSubterm(i));
}
}
示例3: topdownHasSpaces
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private static boolean topdownHasSpaces(IStrategoTerm term) {
// Return true if any character range of this contains spaces
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, RANGE_START);
int end = intAt(child, RANGE_END);
if (start <= ' ' && ' ' <= end) return true;
} else {
if (topdownHasSpaces(child)) return true;
}
}
return false;
}
示例4: processModule
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private List<String> processModule(IStrategoTerm module) {
if(module == null) {
return Collections.emptyList();
}
assert ((IStrategoAppl) module).getName().equals("Module");
List<String> imports = new ArrayList<>();
IStrategoList decls = (IStrategoList) module.getSubterm(1);
for(IStrategoTerm decl : decls) {
String declName = ((IStrategoAppl) decl).getName();
if(declName.equals("Imports")) {
extractImports(decl.getSubterm(0), imports);
} else if(declName.equals("Signature")) {
processSignature(decl.getSubterm(0));
}
}
return imports;
}
示例5: 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;
}
示例6: sourceFromTerm
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private void sourceFromTerm(IIndex index, IStrategoTerm term) throws IOException {
if(!Tools.isTermTuple(term)) {
throw new IOException("Cannot read index; partition term is not a tuple");
}
final IStrategoTerm source = term.getSubterm(0);
final IStrategoTerm entryList = term.getSubterm(1);
final Collection<IndexEntry> entries = Lists.newArrayListWithCapacity(entryList.getSubtermCount());
for(IStrategoTerm entryTerm : term.getSubterm(1)) {
entries.add(entryFactory.fromTerm(entryTerm));
}
index.addAll(source, entries);
}
示例7: fromTerm
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public IndexEntry fromTerm(IStrategoTerm term) {
final IStrategoTerm key = term.getSubterm(0);
final IStrategoTerm value = term.getSubterm(1);
final IStrategoTerm source = term.getSubterm(2);
if(term.getSubtermCount() == 3)
return new IndexEntry(key, value, source, null);
final ImploderAttachment origin = ImploderAttachment.TYPE.fromTerm((IStrategoAppl) term.getSubterm(3));
return new IndexEntry(key, value, source, origin);
}
示例8: getParentURI
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private IStrategoTerm getParentURI(IStrategoTerm uri) {
final IStrategoTerm language = uri.getSubterm(0);
final IStrategoList segments = (IStrategoList) uri.getSubterm(1);
if(segments.getSubtermCount() == 0)
return null;
return makeURI(language, segments.tail());
}
示例9: isCopy
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
static boolean isCopy(IStrategoTerm parent, IStrategoTerm[] kids) {
if (kids.length > 0) {
kids[0] = null;
IStrategoTerm subterm = parent.getSubterm(0);
if (subterm == null) return false;
kids[0] = subterm;
}
return true;
}
示例10: 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;
}
示例11: name
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private static String name(IStrategoTerm nameTerm) {
// For some reason, names in menus have different shapes of names that need to be handled:
// * ToolbarMenu: Label(String("\"Name\""))
// * Submenu: String("\"Name\"")
// * Action: String("\"Name\"")
final IStrategoTerm term;
if(Tools.hasConstructor((IStrategoAppl) nameTerm, "Label")) {
term = nameTerm.getSubterm(0);
} else {
term = nameTerm;
}
return ESVReader.termContents(term);
}
示例12: match
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public static Optional<TermIndex> match(IStrategoTerm term) {
if (!(Tools.isTermAppl(term) && Tools.hasConstructor((IStrategoAppl) term, OP, ARITY))) {
return Optional.empty();
}
IStrategoTerm resourceTerm = term.getSubterm(0);
IStrategoTerm idTerm = term.getSubterm(1);
if (!(Tools.isTermString(resourceTerm) && Tools.isTermInt(idTerm))) {
return Optional.empty();
}
return Optional.of(ImmutableTermIndex.of(Tools.asJavaString(resourceTerm), Tools.asJavaInt(idTerm)));
}
示例13: getAssociatedCoveredOffsets
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private static ArrayList<Integer> getAssociatedCoveredOffsets(IStrategoTerm term, ArrayList<Integer> offsets) {
ArrayList<Integer> associatedCoveredOffsets = getCoveredOffsets(term, offsets);
for (int i = 0; i < term.getSubtermCount(); i++) {
IStrategoTerm subterm = term.getSubterm(i);
ArrayList<Integer> subtermOffsets = getCoveredOffsets(subterm, offsets);
associatedCoveredOffsets.removeAll(subtermOffsets);
}
return associatedCoveredOffsets;
}
示例14: get
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public static IStrategoTerm get(IStrategoTerm t, int index){
return t.getSubterm(index);
}
示例15: termAt
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") // casting is inherently unsafe, but doesn't warrant a warning here
public static<T extends IStrategoTerm> T termAt(IStrategoTerm t, int i) {
return (T) t.getSubterm(i);
}