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


Java IStrategoAppl.getSubterm方法代码示例

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


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

示例1: buildOp

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private IStrategoTerm buildOp(IContext env, IStrategoAppl t, ITermFactory factory)
        throws InterpreterException {
    // FIXME memoize constructors
    
    String ctr = Tools.javaStringAt(t, 0);
    IStrategoList children = (IStrategoList) t.getSubterm(1);
    
    if(ctr.length() == 0) {
        return buildTuple(env, t);
    } else if(children.getSubtermCount() == 0 && ctr.equals("Nil")) {
        return buildNil(env);
    } else if(children.getSubtermCount() == 2 && ctr.equals("Cons")) {
        return buildCons(env, t, factory);
    } else {
        return buildOp(ctr, env, t, factory);
    }
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:18,代码来源:Build.java

示例2: create

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public static @Nullable OutlineFacet create(IStrategoAppl esv) {
    final IStrategoAppl outlineTerm = ESVReader.findTerm(esv, "OutlineView");
    if(outlineTerm == null) {
        return null;
    }
    final String strategyName = ESVReader.termContents(outlineTerm.getSubterm(0));

    final int expandTo;
    final IStrategoAppl expandToTerm = ESVReader.findTerm(esv, "ExpandToLevel");
    if(expandToTerm == null) {
        expandTo = 0;
    } else {
        final IStrategoTerm expandToNumberTerm = expandToTerm.getSubterm(0);
        if(expandToNumberTerm instanceof IStrategoInt) {
            final IStrategoInt expandToNumberIntTerm = (IStrategoInt) expandToNumberTerm;
            expandTo = expandToNumberIntTerm.intValue();
        } else if(expandToNumberTerm instanceof IStrategoString) {
            final IStrategoString expandToNumberStringTerm = (IStrategoString) expandToNumberTerm;
            expandTo = Integer.parseInt(expandToNumberStringTerm.stringValue());
        } else {
            expandTo = 0;
        }
    }

    return new OutlineFacet(strategyName, expandTo);
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:27,代码来源:OutlineFacetFromESV.java

示例3: type

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public static @Nullable String type(IStrategoAppl esv) {
    final IStrategoAppl contextTerm = ESVReader.findTerm(esv, "Context");
    if(contextTerm == null) {
        return null;
    }
    final IStrategoAppl typeTerm = (IStrategoAppl) contextTerm.getSubterm(0); 

    final String name = typeTerm.getConstructor().getName();
    switch(name) {
        case "None":
            return null;
        default:
            logger.warn("Unknown context type {}, defaulting to legacy context.", name);
        case "Legacy":
            return LegacyContextFactory.name;
        case "TaskEngine":
            return IndexTaskContextFactory.name;
    }
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:20,代码来源:ContextFacetFromESV.java

示例4: type

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public static @Nullable String type(IStrategoAppl esv) {
    final IStrategoAppl strategy = ESVReader.findTerm(esv, "SemanticObserver");
    if(strategy == null) {
        return null;
    }
    final IStrategoTerm annotations = strategy.getSubterm(1);
    boolean multifile  = false;
    boolean constraint = false;
    for(IStrategoTerm annotation : annotations) {
        multifile  |= Tools.hasConstructor((IStrategoAppl) annotation, "MultiFile", 0);
        constraint |= Tools.hasConstructor((IStrategoAppl) annotation, "Constraint", 0);
    }
    if(constraint) {
        return multifile ? ConstraintMultiFileAnalyzer.name : ConstraintSingleFileAnalyzer.name;
    } else if(multifile) {
        return TaskEngineAnalyzer.name;
    }
    return StrategoAnalyzer.name;
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:20,代码来源:AnalysisFacetFromESV.java

示例5: buildTuple

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private IStrategoTerm buildTuple(IContext env, IStrategoAppl t) throws InterpreterException {
    
    IStrategoList children = (IStrategoList) t.getSubterm(1);
    IStrategoTerm[] kids = new IStrategoTerm[children.size()];

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

    return env.getFactory().makeTuple(kids);
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:15,代码来源:Build.java

示例6: createStrategoTermAttribute

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private IStrategoTerm createStrategoTermAttribute(IStrategoAppl term) throws UnexpectedTermException {
    ITermFactory termFactory = ParseTableGenerator.getTermfactory();
    if(term.getConstructor().getName().equals("Appl")) {
        String cons_name = ((IStrategoString) term.getSubterm(0).getSubterm(0)).stringValue();
        int arity = term.getSubterm(1).getSubtermCount();
        IStrategoTerm[] subterms = new IStrategoTerm[arity];
        for(int i = 0; i < arity; i++) {
            IStrategoTerm child = ((IStrategoList) term.getSubterm(1)).getSubterm(i);
            subterms[i] = createStrategoTermAttribute((IStrategoAppl) child);
        }
        return termFactory .makeAppl(termFactory.makeConstructor(cons_name, arity), subterms);
    } else if(term.getConstructor().getName().equals("Fun")) {
        String termName = ((IStrategoString) term.getSubterm(0).getSubterm(0)).stringValue();
        if(((IStrategoAppl) term.getSubterm(0)).getConstructor().getName().equals("Quoted")) {
            termName = termName.replace("\\\"", "\"").replace("\\\\", "\\").replace("\\'", "\'").substring(1,
                termName.length() - 1);
        }
        return termFactory.makeString(termName);
    } else if(term.getConstructor().getName().equals("Int")) {
        String svalue = ((IStrategoString) term.getSubterm(0).getSubterm(0)).stringValue();
        int ivalue = Integer.parseInt(svalue);
        return termFactory.makeInt(ivalue);
    } else if(term.getConstructor().getName().equals("List")) {
        IStrategoList term_list = (IStrategoList) term.getSubterm(0);
        List<IStrategoTerm> terms = Lists.newArrayList();
        for(IStrategoTerm t : term_list) {
            terms.add(createStrategoTermAttribute((IStrategoAppl) t));
        }
        return termFactory.makeList(terms);
    }
    System.err.println("sdf2table : importAttribute: unknown stratego term attribute `" + term.getName() + "'.");
    throw new UnexpectedTermException(term.toString());
}
 
开发者ID:metaborg,项目名称:sdf,代码行数:34,代码来源:GrammarReader.java

示例7: toOutlineNode

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private @Nullable IOutlineNode toOutlineNode(IStrategoTerm term, @Nullable IOutlineNode parent,
    FileObject location) {
    if(!(term instanceof IStrategoAppl)) {
        return null;
    }
    final IStrategoAppl appl = (IStrategoAppl) term;
    if(!Tools.hasConstructor(appl, "Node", 2)) {
        return null;
    }

    final IStrategoTerm labelTerm = appl.getSubterm(0);
    final String label = label(labelTerm);
    final FileObject icon = icon(labelTerm, location);
    final ISourceRegion region = region(labelTerm);

    final OutlineNode node = new OutlineNode(label, icon, region, parent);

    final IStrategoTerm nodesTerm = appl.getSubterm(1);
    for(IStrategoTerm nodeTerm : nodesTerm) {
        final IOutlineNode childNode = toOutlineNode(nodeTerm, node, location);
        if(childNode != null) {
            node.addChild(childNode);
        }
    }

    return node;
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:28,代码来源:OutlineService.java

示例8: style

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private static IStyle style(IStrategoAppl attribute) {
    final Color color = color((IStrategoAppl) attribute.getSubterm(0));
    final Color backgroundColor = color((IStrategoAppl) attribute.getSubterm(1));
    final boolean bold;
    final boolean italic;
    final boolean underline = false;
    final boolean strikeout = false;
    final IStrategoAppl fontSetting = (IStrategoAppl) attribute.getSubterm(2);
    final String fontSettingCons = fontSetting.getConstructor().getName();
    switch (fontSettingCons) {
        case "BOLD":
            bold = true;
            italic = false;
            break;
        case "ITALIC":
            bold = false;
            italic = true;
            break;
        case "BOLD_ITALIC":
            bold = true;
            italic = true;
            break;
        default:
            bold = false;
            italic = false;
            break;
    }
    return new Style(color, backgroundColor, bold, italic, underline, strikeout);
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:30,代码来源:StylerFacetFromESV.java

示例9: isLayout

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public boolean isLayout() {
  if (isLayout != null)
    return isLayout;
  
  IStrategoTerm t = prod.getSubterm(1);
  
  while (true) {
    if (t.getTermType() != IStrategoTerm.APPL) {
      isLayout = false;
      break;
    }
    
    IStrategoAppl app = (IStrategoAppl) t;
    
    if (Term.hasConstructor(app, "layout")) {
      isLayout = true;
      break;
    }
    
    if (app.getSubtermCount() == 1 &&
        (Term.hasConstructor(app, "cf") ||
         Term.hasConstructor(app, "lex") ||
         Term.hasConstructor(app, "opt") ||
         Term.hasConstructor(app, "iter")))
      t = app.getSubterm(0);
    else {
      isLayout = false;
      break;
    }
  }
  
  return isLayout;
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:34,代码来源:Label.java

示例10: unwrapObject

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public Object unwrapObject(IStrategoAppl term) {
	IStrategoTerm t = term.getSubterm(0);
	if(!(isTermInt(t)))
		return null;
	return objectWrappers.get(((IStrategoInt)t).intValue());
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:7,代码来源:JFFLibrary.java

示例11: isLexLayout

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
public boolean isLexLayout(IStrategoAppl rhs) {
	if (rhs.getSubtermCount() != 1) return false;
	IStrategoTerm child = rhs.getSubterm(0);
	return isTermAppl(child) && layoutFun == ((IStrategoAppl) child).getConstructor()
		&& lexFun == rhs.getConstructor();
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:7,代码来源:ProductionAttributeReader.java

示例12: buildCons

import org.spoofax.interpreter.terms.IStrategoAppl; //导入方法依赖的package包/类
private IStrategoList buildCons(IContext env, IStrategoAppl t, ITermFactory factory) throws InterpreterException {

        IStrategoList children = (IStrategoList) t.getSubterm(1);
        
        IStrategoAppl headPattern = (IStrategoAppl) children.getSubterm(0);
        IStrategoAppl tailPattern = (IStrategoAppl) children.getSubterm(1);
        
        IStrategoList tail = buildList(env, tailPattern, factory); 
        IStrategoTerm head = buildTerm(env, headPattern);
        
        if(tail == null || head == null)
            return null;
        
        return factory.makeListCons(head, tail);
    }
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:16,代码来源:Build.java


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