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


Java Tools.listAt方法代码示例

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


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

示例1: termListContents

import org.spoofax.interpreter.core.Tools; //导入方法依赖的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

示例2: ruleListTerm

import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
private static IStrategoList ruleListTerm(IStrategoTerm topSpecTerm) {
	IStrategoList sections = Tools.listAt(topSpecTerm, 1);
	for (IStrategoTerm section : sections) {
		if (Tools.isTermAppl(section) && Tools.hasConstructor((IStrategoAppl) section, "Rules", 1)) {
			return Tools.listAt(section, 0);
		}
	}
	throw new InterpreterException("Malformed specification: could not find Rules section");
}
 
开发者ID:metaborg,项目名称:dynsem,代码行数:10,代码来源:RuleRegistry.java

示例3: matchApplOp

import org.spoofax.interpreter.core.Tools; //导入方法依赖的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

示例4: matchTupleOp

import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
private Results matchTupleOp(IContext env, IStrategoTuple t, IStrategoAppl p) throws InterpreterException {
    
    String c = Tools.javaStringAt(p, 0);

    // Check that the pattern p is really against a tuple 
    if(!c.equals(""))
        return null;

    IStrategoList ctorArgs = Tools.listAt(p, 1);
    
    // Check that arity of pattern equals arity of tuple
    if(ctorArgs.size() != t.size())
        return null;
    
    // Match subterms of tuple against subpatterns of pattern 
    Results r = emptyList();
    for (int i = 0; i < ctorArgs.size(); i++) {
        Results m = match(env, t.get(i),
                          (IStrategoAppl) ctorArgs
                          .getSubterm(i));
        if (m != null)
            r.addAll(m);
        else
            return null;
    }

    return r;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:29,代码来源:Match.java

示例5: matchListOp

import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
private Results matchListOp(IContext env, IStrategoList t, IStrategoAppl p) throws InterpreterException {
    
    String c = Tools.javaStringAt(p, 0);

    if(c.equals("Nil")) {
        if(t.isEmpty())
            return emptyList();
    } 
    else if(c.equals("Cons")) {
        
        if(t.size() < 1) {
            return null;
        }
            
        IStrategoTerm head = t.head();
        IStrategoList tail = t.tail();
        
        IStrategoList pattern = Tools.listAt(p, 1);
        
        Results r = match(env, head, (IStrategoAppl)pattern.getSubterm(0));
        if(r == null)
            return null;
        
        Results r2 = match(env, tail, (IStrategoAppl)pattern.getSubterm(1));
        if(r2 == null)
            return null;
        
        r.addAll(r2);
        return r;
    }
    
    return null;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:34,代码来源:Match.java

示例6: matchApplOp

import org.spoofax.interpreter.core.Tools; //导入方法依赖的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: matchApplTuple

import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
private Results matchApplTuple(IContext env, IStrategoAppl t, IStrategoAppl p) throws InterpreterException {
    String c = Tools.javaStringAt(p, 0);

    // Check that the pattern p is really against a tuple 
    if(!c.equals(""))
        return null;

    IStrategoList ctorArgs = Tools.listAt(p, 1);
    
    IStrategoTerm[] args = t.getArguments();
    
    // Check that arity of pattern equals arity of tuple
    if(ctorArgs.size() != args.length)
        return null;
    
    // Match subterms of tuple against subpatterns of pattern 
    Results r = emptyList();
    for (int i = 0; i < ctorArgs.size(); i++) {
        Results m = match(env, args[i],
                          (IStrategoAppl) ctorArgs
                          .getSubterm(i));
        if (m != null)
            r.addAll(m);
        else
            return null;
    }

    return r;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:30,代码来源:java2.java

示例8: matchListOp

import org.spoofax.interpreter.core.Tools; //导入方法依赖的package包/类
private Results matchListOp(IContext env, IStrategoList t, IStrategoAppl p) throws InterpreterException {
    
    String c = Tools.javaStringAt(p, 0);

    if(c.equals("Nil")) {
        if(t.size() == 0)
            return emptyList();
    } 
    else if(c.equals("Cons")) {
        
        if(t.size() < 1) {
            return null;
        }
            
        IStrategoTerm head = t.head();
        IStrategoList tail = t.tail();
        
        IStrategoList pattern = Tools.listAt(p, 1);
        
        Results r = match(env, head, (IStrategoAppl)pattern.get(0));
        if(r == null)
            return null;
        
        Results r2 = match(env, tail, (IStrategoAppl)pattern.get(1));
        if(r2 == null)
            return null;
        
        r.addAll(r2);
        return r;
    }
    
    return null;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:34,代码来源:java2.java


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