本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoAppl类的典型用法代码示例。如果您正苦于以下问题:Java IStrategoAppl类的具体用法?Java IStrategoAppl怎么用?Java IStrategoAppl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IStrategoAppl类属于org.spoofax.interpreter.terms包,在下文中一共展示了IStrategoAppl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static ListMatch create(IStrategoAppl t, FrameDescriptor fd) {
assert Tools.hasConstructor(t, "TypedList", 2) || Tools.hasConstructor(t, "TypedListTail", 3);
IStrategoList elemTs = Tools.listAt(t, 0);
final MatchPattern[] elemPatterns = new MatchPattern[elemTs.size()];
for (int i = 0; i < elemPatterns.length; i++) {
elemPatterns[i] = MatchPattern.create(Tools.applAt(elemTs, i), fd);
}
MatchPattern tailPattern = null;
if (Tools.hasConstructor(t, "TypedListTail", 3)) {
tailPattern = MatchPattern.create(Tools.applAt(t, 1), fd);
}
final String dispatchClassName = Tools.javaStringAt(t, Tools.hasConstructor(t, "TypedList", 2) ? 1 : 2);
Class<?> dispatchClass;
try {
dispatchClass = Rule.class.getClassLoader().loadClass(dispatchClassName);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not load dispatch class " + dispatchClassName);
}
return new ListMatch(SourceUtils.dynsemSourceSectionFromATerm(t), elemPatterns, tailPattern, dispatchClass);
}
开发者ID:metaborg,项目名称:dynsem,代码行数:26,代码来源:ListMatch.java
示例2: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static TupleMatch create(IStrategoAppl t, FrameDescriptor fd) {
CompilerAsserts.neverPartOfCompilation();
assert Tools.hasConstructor(t, "TypedTuple", 2);
IStrategoList childrenT = Tools.listAt(t, 0);
MatchPattern[] children = new MatchPattern[childrenT.size()];
for (int i = 0; i < children.length; i++) {
children[i] = MatchPattern.create(Tools.applAt(childrenT, i), fd);
}
final String dispatchClassName = Tools.stringAt(t, 1).stringValue();
Class<?> dispatchClass;
try {
dispatchClass = Rule.class.getClassLoader().loadClass(dispatchClassName);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not load dispatch class " + dispatchClassName);
}
return new TupleMatch(SourceUtils.dynsemSourceSectionFromATerm(t), children, dispatchClass);
}
开发者ID:metaborg,项目名称:dynsem,代码行数:22,代码来源:TupleMatch.java
示例3: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static LiteralMatchPattern create(IStrategoAppl t, FrameDescriptor fd) {
SourceSection source = SourceUtils.dynsemSourceSectionFromATerm(t);
if (Tools.hasConstructor(t, "True", 0)) {
return TrueLiteralTermMatchPatternNodeGen.create(source);
}
if (Tools.hasConstructor(t, "False", 0)) {
return FalseLiteralTermMatchPatternNodeGen.create(source);
}
if (Tools.hasConstructor(t, "Int", 1)) {
return IntLiteralTermMatchPatternNodeGen.create(Integer.parseInt(Tools.stringAt(t, 0).stringValue()),
source);
}
if (Tools.hasConstructor(t, "String", 1)) {
return StringLiteralTermMatchPatternNodeGen.create(Tools.stringAt(t, 0).stringValue(), source);
}
throw new NotImplementedException("Unsupported literal: " + t);
}
开发者ID:metaborg,项目名称:dynsem,代码行数:21,代码来源:LiteralMatchPattern.java
示例4: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static Premise create(IStrategoAppl t, FrameDescriptor fd) {
CompilerAsserts.neverPartOfCompilation();
if (Tools.hasConstructor(t, "CaseMatch", 2)) {
return CaseMatchPremise.create(t, fd);
}
IStrategoAppl premT = Tools.applAt(t, 0);
if (Tools.hasConstructor(premT, "Relation", 3)) {
return RelationPremise.create(premT, fd);
}
if (Tools.hasConstructor(premT, "RecRelation", 3)) {
return RecursiveRelationPremise.create(premT, fd);
}
if (Tools.hasConstructor(premT, "Match", 2)) {
return MatchPremise.create(premT, fd);
}
if (Tools.hasConstructor(premT, "TermEq", 2)) {
return TermEqPremise.create(premT, fd);
}
if (Tools.hasConstructor(premT, "Fails", 1)) {
return FailsPremise.create(premT, fd);
}
throw new NotImplementedException("Unsupported premise: " + t);
}
开发者ID:metaborg,项目名称:dynsem,代码行数:25,代码来源:Premise.java
示例5: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static RecursiveRelationPremise create(IStrategoAppl t, FrameDescriptor fd) {
CompilerAsserts.neverPartOfCompilation();
assert Tools.hasConstructor(t, "RecRelation", 3);
IStrategoAppl source = Tools.applAt(t, 0);
assert Tools.hasConstructor(source, "Source", 2);
TermBuild lhsNode = TermBuild.create(Tools.applAt(source, 0), fd);
IStrategoList rws = Tools.listAt(source, 1);
TermBuild[] rwNodes = new TermBuild[rws.getSubtermCount()];
for (int i = 0; i < rwNodes.length; i++) {
rwNodes[i] = TermBuild.createFromLabelComp(Tools.applAt(rws, i), fd);
}
return new RecursiveRelationPremise(SourceUtils.dynsemSourceSectionFromATerm(t), lhsNode, rwNodes);
}
开发者ID:metaborg,项目名称:dynsem,代码行数:18,代码来源:RecursiveRelationPremise.java
示例6: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static RelationPremise create(IStrategoAppl t, FrameDescriptor fd) {
CompilerAsserts.neverPartOfCompilation();
assert Tools.hasConstructor(t, "Relation", 3);
IStrategoAppl targetT = Tools.applAt(t, 2);
assert Tools.hasConstructor(targetT, "Target", 2);
MatchPattern rhsNode = MatchPattern.create(Tools.applAt(targetT, 0), fd);
IStrategoList rhsRwsT = Tools.listAt(targetT, 1);
MatchPattern[] rhsRwNodes = new MatchPattern[rhsRwsT.size()];
for (int i = 0; i < rhsRwNodes.length; i++) {
rhsRwNodes[i] = MatchPattern.createFromLabelComp(Tools.applAt(rhsRwsT, i), fd);
}
return new RelationPremise(RelationPremiseInputBuilder.create(Tools.applAt(t, 0), fd),
DispatchNode.create(Tools.applAt(t, 0), Tools.applAt(t, 1), fd), rhsNode, rhsRwNodes,
SourceUtils.dynsemSourceSectionFromATerm(t));
}
开发者ID:metaborg,项目名称:dynsem,代码行数:18,代码来源:RelationPremise.java
示例7: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static ListBuild create(IStrategoAppl t, FrameDescriptor fd) {
assert Tools.hasConstructor(t, "TypedList", 2) || Tools.hasConstructor(t, "TypedListTail", 3);
IStrategoList elemTs = Tools.listAt(t, 0);
final TermBuild[] elemNodes = new TermBuild[elemTs.size()];
for (int i = 0; i < elemNodes.length; i++) {
elemNodes[i] = TermBuild.create(Tools.applAt(elemTs, i), fd);
}
TermBuild tailNodes = null;
if (Tools.hasConstructor(t, "TypedListTail", 3)) {
tailNodes = TermBuild.create(Tools.applAt(t, 1), fd);
}
final String dispatchClassName = Tools.javaStringAt(t, Tools.hasConstructor(t, "TypedList", 2) ? 1 : 2);
Class<?> dispatchClass;
try {
dispatchClass = Rule.class.getClassLoader().loadClass(dispatchClassName);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not load dispatch class " + dispatchClassName);
}
return new ListBuild(SourceUtils.dynsemSourceSectionFromATerm(t), elemNodes, tailNodes, dispatchClass);
}
开发者ID:metaborg,项目名称:dynsem,代码行数:26,代码来源:ListBuild.java
示例8: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static TupleBuild create(IStrategoAppl t, FrameDescriptor fd) {
CompilerAsserts.neverPartOfCompilation();
assert Tools.hasConstructor(t, "TypedTuple", 2);
IStrategoList childrenT = Tools.listAt(t, 0);
TermBuild[] children = new TermBuild[childrenT.size()];
for (int i = 0; i < children.length; i++) {
children[i] = TermBuild.create(Tools.applAt(childrenT, i), fd);
}
String dispatchClassName = Tools.stringAt(t, 1).stringValue();
Class<?> dispatchClass;
try {
dispatchClass = Rule.class.getClassLoader().loadClass(dispatchClassName);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not load dispatch class " + dispatchClassName);
}
return new TupleBuild(SourceUtils.dynsemSourceSectionFromATerm(t), children, dispatchClass);
}
开发者ID:metaborg,项目名称:dynsem,代码行数:21,代码来源:TupleBuild.java
示例9: convert
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static ITTerm convert(IStrategoTerm t) {
if (t instanceof IStrategoAppl)
return convert((IStrategoAppl) t);
if (t instanceof IStrategoTuple)
return convert((IStrategoTuple) t);
if (t instanceof IStrategoList)
return convert((IStrategoList) t);
if (t instanceof IStrategoString)
return convert((IStrategoString) t);
if (t instanceof IStrategoInt)
return convert((IStrategoInt) t);
throw new UnsupportedOperationException("Unsupported aterm " + t);
}
开发者ID:metaborg,项目名称:dynsem,代码行数:19,代码来源:TermConverter.java
示例10: matchAnyExplode
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
private Results matchAnyExplode(IContext env, IStrategoTerm t,
IStrategoAppl p) throws InterpreterException {
if(DebugUtil.isDebugging()) {
DebugUtil.debug(" pattern is Explode");
}
IStrategoAppl opPattern = Tools.applAt(p, 0);
IStrategoAppl argsPattern = Tools.applAt(p, 1);
IStrategoTerm op = getTermConstructor(env, t);
IStrategoTerm args = getTermArguments(env, t);
Results opResult = match(env, op, opPattern);
Results argsResult = match(env, args, argsPattern);
if (opResult == null || argsResult == null)
return null;
opResult.addAll(argsResult);
return opResult;
}
开发者ID:metaborg,项目名称:jsglr,代码行数:23,代码来源:java2.java
示例11: wrap
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
private static IStrategoAppl wrap(InfixExpression expression) {
if(expression == null)
return None.INSTANCE;
else
return new WrappedInfixExpression(expression);
/*
InfixExpression.Operator op = expression.getOperator();
if(op == InfixExpression.Operator.PLUS)
return new WrappedPlus(expression);
if(op == InfixExpression.Operator.MINUS)
return new WrappedMinus(expression);
if(op == InfixExpression.Operator.TIMES)
return new WrappedTimes(expression);
if(op == InfixExpression.Operator.DIVIDE)
return new WrappedDivide(expression);
throw new NotImplementedException("Unknown InfixExpression Operator " + expression.getO);
*/
}
开发者ID:metaborg,项目名称:jsglr,代码行数:23,代码来源:java3.java
示例12: addInjectionsTo
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
private void addInjectionsTo(ParseTable table, String sort, boolean reverse, Set<String> results) {
ITermFactory factory = table.getFactory();
IStrategoTerm sortTerm = factory.makeAppl(sortFun, factory.makeString(sort));
for (Label l : table.getLabels()) {
if (l != null && checkProductionType(l)) {
IStrategoAppl production = l.getProduction();
IStrategoTerm sort1 = reverse ? getFromSort(production) : getToSort(production);
if (sortTerm.equals(sort1)) {
IStrategoTerm sort2 = reverse ? getToSort(production) : getFromSort(production);
if (sort2 != null)
results.add(asJavaString(termAt(sort2, 0)));
}
}
}
results.add(sort);
}
开发者ID:metaborg,项目名称:jsglr,代码行数:17,代码来源:IncrementalSortSet.java
示例13: buildAnno
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
private IStrategoTerm buildAnno(IContext env, IStrategoAppl t) throws InterpreterException {
IStrategoTerm term = buildTerm(env, applAt(t, 0));
if (term == null) return null;
IStrategoAppl annos = applAt(t, 1);
if (term.getAnnotations().size() == 0
&& "Op".equals(annos.getConstructor().getName())
&& "Nil".equals(javaStringAt(annos, 0))) {
return term;
} else {
IStrategoTerm annoList = buildTerm(env, annos);
if (annoList == null) return null;
if (annoList.getTermType() != IStrategoTerm.LIST)
annoList = env.getFactory().makeList(annoList);
if (annoList.equals(term.getAnnotations())) {
return term;
} else {
return env.getFactory().annotateTerm(term, (IStrategoList) annoList);
}
}
}
开发者ID:metaborg,项目名称:mb-exec,代码行数:23,代码来源:Build.java
示例14: getAttribute
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
/** Return the contents of a term attribute (e.g., "cons"), or null if not found. */
public IStrategoTerm getAttribute(IStrategoAppl attrs, String attrName) {
if (attrs.getConstructor() == noAttrsFun)
return null;
IStrategoList list = termAt(attrs, 0);
for (IStrategoTerm attr : iterable(list)) {
if (isTermNamed(attr)) {
IStrategoNamed namedAttr = (IStrategoNamed) attr;
if (namedAttr.getName().equals("term")) {
namedAttr = termAt(namedAttr, 0);
if (namedAttr.getName().equals(attrName))
return namedAttr.getSubtermCount() == 1 ? termAt(namedAttr, 0) : namedAttr;
}
if (namedAttr.getName().equals(attrName)) {
return namedAttr;
}
}
}
return null; // no cons found
}
开发者ID:metaborg,项目名称:jsglr,代码行数:26,代码来源:ProductionAttributeReader.java
示例15: sortConsCategory
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
private ICategory sortConsCategory(StylerFacet facet, IStrategoTerm term) {
final ImploderAttachment imploderAttachment = ImploderAttachment.get(term);
final String sort = imploderAttachment.getSort();
if(sort == null) {
return null;
}
// LEGACY: for some reason, when using concrete syntax extensions, all sorts are appended with _sort.
final String massagedSort = sort.replace("_sort", "");
if(term.getTermType() == IStrategoTerm.APPL) {
final String cons = ((IStrategoAppl) term).getConstructor().getName();
if(facet.hasSortConsStyle(massagedSort, cons)) {
return new SortConsCategory(massagedSort, cons);
} else if(facet.hasConsStyle(cons)) {
return new ConsCategory(cons);
} else if(facet.hasSortStyle(massagedSort)) {
return new SortCategory(massagedSort);
}
return null;
}
if(facet.hasSortStyle(massagedSort)) {
return new SortCategory(massagedSort);
}
return null;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:27,代码来源:CategorizerService.java
示例16: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static ConMatch create(IStrategoAppl t, FrameDescriptor fd) {
CompilerAsserts.neverPartOfCompilation();
assert Tools.hasConstructor(t, "Con", 2);
String constr = Tools.stringAt(t, 0).stringValue();
IStrategoList childrenT = Tools.listAt(t, 1);
MatchPattern[] children = new MatchPattern[childrenT.size()];
for (int i = 0; i < children.length; i++) {
children[i] = MatchPattern.create(Tools.applAt(childrenT, i), fd);
}
return new ConMatch(constr, children, SourceUtils.dynsemSourceSectionFromATerm(t));
}
开发者ID:metaborg,项目名称:dynsem,代码行数:13,代码来源:ConMatch.java
示例17: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static GenericListMatch create(IStrategoAppl t, FrameDescriptor fd) {
assert Tools.hasConstructor(t, "List_", 1) || Tools.hasConstructor(t, "ListTail", 2);
final int numHeadElems = Tools.listAt(t, 0).size();
MatchPattern tailPattern = null;
if (Tools.hasConstructor(t, "ListTail", 2)) {
tailPattern = MatchPattern.create(Tools.applAt(t, 1), fd);
}
return GenericListMatchNodeGen.create(SourceUtils.dynsemSourceSectionFromATerm(t), numHeadElems, tailPattern);
}
开发者ID:metaborg,项目名称:dynsem,代码行数:13,代码来源:GenericListMatch.java
示例18: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static DispatchNode create(IStrategoAppl source, IStrategoAppl arrow, FrameDescriptor fd) {
assert Tools.hasConstructor(arrow, "NamedDynamicEmitted", 3);
String arrowName = Tools.stringAt(arrow, 1).stringValue();
assert Tools.hasConstructor(source, "Source", 2);
return DispatchNodeGen.create(SourceUtils.dynsemSourceSectionFromATerm(source), arrowName);
}
开发者ID:metaborg,项目名称:dynsem,代码行数:8,代码来源:DispatchNode.java
示例19: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static RuleTarget create(IStrategoAppl targetT, FrameDescriptor fd) {
CompilerAsserts.neverPartOfCompilation();
assert Tools.hasConstructor(targetT, "Target", 2);
TermBuild rhsNode = TermBuild.create(Tools.termAt(targetT, 0), fd);
IStrategoList componentsT = Tools.listAt(targetT, 1);
TermBuild[] componentNodes = new TermBuild[componentsT.size()];
for (int i = 0; i < componentNodes.length; i++) {
componentNodes[i] = TermBuild.createFromLabelComp(Tools.applAt(componentsT, i), fd);
}
return new RuleTarget(rhsNode, componentNodes, SourceUtils.dynsemSourceSectionFromATerm(targetT));
}
开发者ID:metaborg,项目名称:dynsem,代码行数:14,代码来源:RuleTarget.java
示例20: create
import org.spoofax.interpreter.terms.IStrategoAppl; //导入依赖的package包/类
public static RelationPremiseInputBuilder create(IStrategoAppl source, FrameDescriptor fd) {
CompilerAsserts.neverPartOfCompilation();
assert Tools.hasConstructor(source, "Source", 2);
TermBuild lhsNode = TermBuild.create(Tools.applAt(source, 0), fd);
IStrategoList rws = Tools.listAt(source, 1);
TermBuild[] rwNodes = new TermBuild[rws.getSubtermCount()];
for (int i = 0; i < rwNodes.length; i++) {
rwNodes[i] = TermBuild.createFromLabelComp(Tools.applAt(rws, i), fd);
}
return new RelationPremiseInputBuilder(lhsNode, rwNodes, SourceUtils.dynsemSourceSectionFromATerm(source));
}
开发者ID:metaborg,项目名称:dynsem,代码行数:14,代码来源:RelationPremiseInputBuilder.java
注:本文中的org.spoofax.interpreter.terms.IStrategoAppl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论