• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IStrategoConstructor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: readAllSymbols

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
private void readAllSymbols() throws IOException {

        for (int i = 0; i < nrUniqueSymbols; i++) {
            SymEntry e = new SymEntry();
            symbols[i] = e;

            IStrategoTerm fun = readSymbol();
            e.fun = fun;
            int arity = e.arity = fun instanceof IStrategoConstructor ? ((IStrategoConstructor) fun).getArity() : 0;

            int v = reader.readInt();
            e.nrTerms = v;
            e.termWidth = bitWidth(v);
            // FIXME: original code is inconsistent at this point!
            e.terms = (v == 0) ? null : new IStrategoTerm[v];

            if (arity == 0) {
                e.nrTopSyms = null;
                e.symWidth = null;
                e.topSyms = null;
            } else {

                e.nrTopSyms = new int[arity];
                e.symWidth = new int[arity];
                e.topSyms = new int[arity][];
            }
            for (int j = 0; j < arity; j++) {
                v = reader.readInt();
                e.nrTopSyms[j] = v;
                e.symWidth[j] = bitWidth(v);
                e.topSyms[j] = new int[v];

                for (int k = 0; k < e.nrTopSyms[j]; k++) {
                    v = reader.readInt();
                    e.topSyms[j][k] = v;
                }
            }
        }
    }
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:40,代码来源:BAFReader.java


示例17: parseGuardedLChoice

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private GuardedLChoice parseGuardedLChoice(IStrategoAppl t) throws InterpreterException {

	LinkedList<Pair<Strategy,Strategy>> s = new LinkedList<Pair<Strategy,Strategy>>();
    IStrategoConstructor ctor = context.getStrategoSignature().getGuardedLChoice();

	while (t.getConstructor().equals(ctor)) {
      s.add(new Pair<Strategy,Strategy>(parseStrategy(Tools.applAt(t, 0)), parseStrategy(Tools.applAt(t, 1))));
      t = Tools.applAt(t, 2);
	}

	s.add(new Pair<Strategy,Strategy>(parseStrategy(t), null));

    return new GuardedLChoice(s.toArray(new Pair[0]));
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:16,代码来源:StrategoCoreLoader.java


示例18: evaluate

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
/**
 * Evaluates a stratego expression. Must be fully desugared,
 * using C names in SDefTs and SCallTs.
 *
 * @see org.strategoxt.HybridInterpreter#evaluate  A variant of evaluate() with desugaring support.
 */
public boolean evaluate(IStrategoAppl s)
        throws InterpreterErrorExit, InterpreterExit, UndefinedStrategyException, InterpreterException {

    final ITermFactory factory = getFactory();
    final IStrategoConstructor sdefT = factory.makeConstructor("SDefT", 4);

    if (s.getConstructor() != sdefT)
        s = factory.makeAppl(sdefT, factory.makeString("interpreter_evaluate_dummy_0_0"), factory.makeList(), factory.makeList(), s);

    SDefT def = loader.parseSDefT(s);
    return evaluate(def);
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:19,代码来源:Interpreter.java


示例19: read

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的package包/类
public static IncrementalSortSet read(ParseTable table) {
	IStrategoConstructor incrementalFun = table.getFactory().makeConstructor("incremental", 0);
	ProductionAttributeReader reader = new ProductionAttributeReader(table.getFactory());
	Set<String> sorts = new HashSet<String>();
	
	for (int i = ParseTable.LABEL_BASE, max = table.getProductionCount(); i < max; i++) {
		IStrategoTerm prod = table.getProduction(i);
		if (isIncrementalProduction(prod, incrementalFun))
			sorts.add(reader.getSort(applAt(prod, 1)));
	}
	return create(table, true, sorts);
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:13,代码来源:IncrementalSortSet.java


示例20: isIncrementalProduction

import org.spoofax.interpreter.terms.IStrategoConstructor; //导入依赖的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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CodepageDetectorProxy类代码示例发布时间:2022-05-22
下一篇:
Java MethodDeclarationImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap