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


Java IStrategoConstructor类代码示例

本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoConstructor的典型用法代码示例。如果您正苦于以下问题:Java IStrategoConstructor类的具体用法?Java IStrategoConstructor怎么用?Java IStrategoConstructor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: doBuildExplode

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
private IStrategoTerm doBuildExplode(ITermFactory factory, IStrategoTerm actualCtor, IStrategoTerm actualArgs) throws InterpreterException {
    if (!(Tools.isTermList(actualArgs))) {
        throw new InterpreterException("Not a list: " + actualArgs);
    }

    String n = ((IStrategoString)actualCtor).stringValue();
    IStrategoTerm[] realArgs = ((IStrategoList)actualArgs).getAllSubterms();
    
    if (n.equals(""))
        return factory.makeTuple(realArgs);
    
    boolean quoted = false;
    if (n.length() > 1 && n.charAt(0) == '"') {
        n = n.substring(1, n.length() - 1);
        quoted = true;
    }

    if(quoted && realArgs.length == 0) {
        return factory.makeString(n);
    }
    
    IStrategoConstructor afun = factory.makeConstructor(n, realArgs.length);
    return factory.makeAppl(afun, realArgs);
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:25,代码来源:Build.java

示例2: buildOp

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
private IStrategoTerm buildOp(String ctr, IContext env, IStrategoAppl t, ITermFactory factory) 
throws  InterpreterException {
    
    IStrategoList children = (IStrategoList) t.getSubterm(1);

    IStrategoConstructor ctor = factory.makeConstructor(ctr, children.size());
    IStrategoTerm[] kids = new IStrategoTerm[children.size()];

    for (int i = children.size() -1 ; i >= 0; i--) {
        IStrategoTerm kid = buildTerm(env, (IStrategoAppl) children.getSubterm(i));
        if (kid == null) {
            return null;
        }
        kids[i] = kid;
    }

    return factory.makeAppl(ctor, kids);
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:19,代码来源:Build.java

示例3: makeAppl

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
private boolean makeAppl(IContext env, IStrategoString nameTerm, IStrategoTerm argsTerm) {
    if (argsTerm.getTermType() != IStrategoTerm.LIST)
        return false;
    
    String name = nameTerm.stringValue();
    for (int i = 0; i < name.length(); i++) {
        char c = name.charAt(i);
        if (!(Character.isLetterOrDigit(c) || c == '_' || c == '-'
            || c == '+' || c == '*' || c == '$')) {
            name = name.substring(0, i);
            break;
        }
    }
    
    IStrategoList args = (IStrategoList) argsTerm;
    
    if (name.length() == 0) { // tuple
        env.setCurrent(env.getFactory().makeTuple(args.getAllSubterms()));
    } else {
        IStrategoConstructor cons = env.getFactory().makeConstructor(name, args.size());
        env.setCurrent(env.getFactory().makeAppl(cons, args.getAllSubterms()));
    }        
    return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:25,代码来源:SSL_mkterm.java

示例4: KeywordRecognizer

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
protected KeywordRecognizer(ParseTable table) {
	if (table != null) {
		IStrategoConstructor litFun = table.getFactory().makeConstructor("lit", 1);
		for (Label l : table.getLabels()) {
			if (l != null) {
				IStrategoTerm rhs = termAt(l.getProduction(), 1);
				if (isTermAppl(rhs) && ((IStrategoAppl) rhs).getConstructor() == litFun) {
					IStrategoNamed lit = termAt(rhs, 0);
					String litString = lit.getName();
					if (isPotentialKeyword(litString))
						keywords.add(litString);
				}
			}
		}
	}
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:17,代码来源:KeywordRecognizer.java

示例5: tryGetSort

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
/** 
 * Get the RTG sort name of a pattern.
 */
public String tryGetSort(IStrategoAppl currentAppl) {
	IStrategoConstructor cons = currentAppl.getConstructor();
	if (cons == cfFun)
		return tryGetSort(applAt(currentAppl, 0));
	if (cons == lexFun)
		return tryGetSort(applAt(currentAppl, 0));
	if (cons == sortFun)
		return javaString(termAt(currentAppl, 0));
	if (cons == parameterizedSortFun)
		return getParameterizedSortName(currentAppl);
	if (cons == charClassFun)
		return null;
	if (cons == altFun)
		return getAltSortName(currentAppl);
	return null;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:20,代码来源:ProductionAttributeReader.java

示例6: isList

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
public boolean isList(IStrategoAppl rhs, IStrategoAppl attrs) {
	IStrategoAppl details = rhs;
	
	if (details.getConstructor() == varsymFun)
		details = termAt(details, 0);
	
	if (details.getConstructor() == cfFun)
		details = termAt(details, 0);
	              	
  	if (details.getConstructor() == optFun)
  		details = termAt(details, 0);
  	
	IStrategoConstructor fun = details.getConstructor();
	
	 // FIXME: Spoofax/159: AsfixImploder creates tuples instead of lists for seqs
	if (isIterFun(fun) || seqFun == fun)
	  return true;
	
  return isFlatten(rhs, attrs);
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:21,代码来源:ProductionAttributeReader.java

示例7: makeAppl

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
public IStrategoAppl makeAppl(IStrategoConstructor ctr, IStrategoTerm... kids) {
    IStrategoAppl t = constructASTNode(ctr, kids);
    if(t == null) {
        if(DebugUtil.isDebugging()) {
            System.err.println("Generic fallback for:");
            System.err.println("Construct: " + ctr.getName() + "/" + ctr.getArity() + " with " + kids.length + " kids");
            for(int i = 0; i < kids.length; i++) {
                if(kids[i] instanceof WrappedASTNodeList) {
                    WrappedASTNodeList l = (WrappedASTNodeList)kids[i];
                    if(!l.isEmpty()) 
                        System.err.println("  [" + l.get(0) + "]");
                    else
                        System.err.println("  " + l + " - empty");
                } else
                    System.err.println("  " + kids[i]);
            }
        }
        return ctr.instantiate(this, kids);
    }
    return t;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:22,代码来源:java3.java

示例8: tryGetSort

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
private static String tryGetSort(IStrategoAppl appl) {
    IStrategoConstructor cons = appl.getConstructor();

    if("sort".equals(cons.getName()))
        return javaString(termAt(appl, 0));
    else if("cf".equals(cons.getName()) || "lex".equals(cons.getName()))
        return tryGetSort(applAt(appl, 0));
    else if("parameterized-sort".equals(cons.getName()))
        return getParameterizedSortName(appl);
    else if("char-class".equals(cons.getName()))
        return null;
    else if("alt".equals(cons.getName()))
        return getAltSortName(appl);
    else
        return null;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:17,代码来源:ProductionReader.java

示例9: makeAppl

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
@Override public IStrategoAppl makeAppl(IStrategoConstructor ctr, IStrategoTerm[] kids, IStrategoList annotations) {
    IStrategoAppl term = super.makeAppl(ctr, kids, annotations);

    SortType[] sorts = checkConstruction(ctr, kids, term, null);
    if(sorts != null)
        TypesmartSortAttachment.put(term, sorts);
    return term;
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:9,代码来源:TypesmartTermFactory.java

示例10: replaceAppl

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
/**
 * Recheck invariant of typesmart constrcutor.
 */
@Override public IStrategoAppl replaceAppl(IStrategoConstructor ctr, IStrategoTerm[] kids, IStrategoAppl old) {
    IStrategoAppl term = super.makeAppl(ctr, kids, old.getAnnotations());

    SortType[] sorts = checkConstruction(ctr, kids, term, old.getAllSubterms());
    if(sorts != null)
        TypesmartSortAttachment.put(term, sorts);
    return term;
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:12,代码来源:TypesmartTermFactory.java

示例11: makeAppl

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
@Override public IStrategoAppl makeAppl(IStrategoConstructor ctr, IStrategoTerm[] terms,
    IStrategoList annotations) {
    int storageType = defaultStorageType;
    storageType = min(storageType, getStorageType(terms));
    if(storageType != 0)
        storageType = min(storageType, getStorageType(annotations));
    assert ctr.getArity() == terms.length;
    return new StrategoAppl(ctr, terms, annotations, storageType);
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:10,代码来源:TermFactory.java

示例12: StrategoAppl

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
public StrategoAppl(IStrategoConstructor ctor, IStrategoTerm[] kids, IStrategoList annotations, int storageType) {
    super(annotations, storageType);
    this.ctor = ctor;
    this.kids = kids;
    
    if (storageType != MUTABLE) initImmutableHashCode();
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:8,代码来源:StrategoAppl.java

示例13: replaceAppl

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
@Override
public IStrategoAppl replaceAppl(IStrategoConstructor constructor, IStrategoTerm[] kids,
		IStrategoAppl oldTerm) {
	
	IStrategoList annos = oldTerm.getAnnotations();
	IStrategoAppl result = makeAppl(constructor, ensureChildLinks(kids, oldTerm), annos);
	//TODO: child links only when same signature
	return (IStrategoAppl) ensureLink(result, oldTerm, false);
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:10,代码来源:OriginTermFactory.java

示例14: makeAppl

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
@Override
public IStrategoAppl makeAppl(IStrategoConstructor constructor, IStrategoTerm[] kids, IStrategoList annotations) {
	IStrategoAppl result = baseFactory.makeAppl(constructor, kids, annotations);
	assert ParentAttachment.get(result) == null :
		"Unexpected parent attachment; doubly wrapped term factory?";
	configure(result, kids);
	return result;
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:9,代码来源:ParentTermFactory.java

示例15: doSlowMatch

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
	if (second == this)
		return true;
	if (second == null || second.getTermType() != CTOR)
		return false;
	
	IStrategoConstructor other = (IStrategoConstructor) second;
	
    return name.equals(other.getName()) && arity == other.getArity();
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:12,代码来源:StrategoConstructor.java


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