本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoTuple类的典型用法代码示例。如果您正苦于以下问题:Java IStrategoTuple类的具体用法?Java IStrategoTuple怎么用?Java IStrategoTuple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IStrategoTuple类属于org.spoofax.interpreter.terms包,在下文中一共展示了IStrategoTuple类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convert
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的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
示例2: dispatch
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
private static boolean dispatch(IStrategoTermVisitor visitor, IStrategoTerm term) {
switch(term.getTermType()) {
case IStrategoTerm.APPL:
return visitor.visit((IStrategoAppl) term);
case IStrategoTerm.LIST:
return visitor.visit((IStrategoList) term);
case IStrategoTerm.TUPLE:
return visitor.visit((IStrategoTuple) term);
case IStrategoTerm.INT:
visitor.visit((IStrategoInt) term);
return false;
case IStrategoTerm.REAL:
visitor.visit((IStrategoReal) term);
return false;
case IStrategoTerm.STRING:
visitor.visit((IStrategoString) term);
return false;
case IStrategoTerm.REF:
visitor.visit((IStrategoRef) term);
return false;
case IStrategoTerm.PLACEHOLDER:
return visitor.visit((IStrategoPlaceholder) term);
default:
return visitor.visit(term);
}
}
开发者ID:metaborg,项目名称:mb-rep,代码行数:27,代码来源:StrategoTermVisitee.java
示例3: getTermArguments
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
private IStrategoTerm getTermArguments(IContext env, IStrategoTerm t) throws InterpreterException {
switch(t.getTermType()) {
case IStrategoTerm.INT:
case IStrategoTerm.REAL:
return env.getFactory().makeList();
case IStrategoTerm.APPL:
IStrategoAppl a = (IStrategoAppl)t;
if (Tools.isNil(a, env) || Tools.isCons(a, env))
return t;
else
return env.getFactory().makeList(a.getAllSubterms());
case IStrategoTerm.LIST:
return t;
case IStrategoTerm.STRING:
return env.getFactory().makeList();
case IStrategoTerm.TUPLE:
IStrategoTuple tup = (IStrategoTuple) t;
IStrategoTerm[] args = new IStrategoTerm[tup.getSubtermCount()];
for(int i = 0; i < args.length; i++)
args[i] = tup.get(i);
return env.getFactory().makeList(args);
}
throw new InterpreterException("Unknown term '" + t + "'");
}
开发者ID:metaborg,项目名称:mb-exec,代码行数:27,代码来源:Match.java
示例4: match
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
public static <T> T match(IStrategoTerm term, ICases<T> cases) {
switch(term.getTermType()) {
case IStrategoTerm.APPL:
return cases.caseAppl((IStrategoAppl) term);
case IStrategoTerm.LIST:
return cases.caseList((IStrategoList) term);
case IStrategoTerm.TUPLE:
return cases.caseTuple((IStrategoTuple) term);
case IStrategoTerm.INT:
return cases.caseInt((IStrategoInt) term);
case IStrategoTerm.REAL:
return cases.caseReal((IStrategoReal) term);
case IStrategoTerm.STRING:
return cases.caseString((IStrategoString) term);
default:
throw new IllegalArgumentException("Unsupported Stratego term type " + term.getTermType());
}
}
开发者ID:metaborg,项目名称:nabl,代码行数:19,代码来源:StrategoTerms.java
示例5: getTermArguments
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
private IStrategoTerm getTermArguments(IContext env, IStrategoTerm t) throws InterpreterException {
switch(t.getTermType()) {
case IStrategoTerm.INT:
case IStrategoTerm.REAL:
return env.getFactory().makeList();
case IStrategoTerm.APPL:
IStrategoAppl a = (IStrategoAppl)t;
if (Tools.isNil(a, env) || Tools.isCons(a, env))
return t;
else
return env.getFactory().makeList(a.getArguments());
case IStrategoTerm.LIST:
return t;
case IStrategoTerm.STRING:
return env.getFactory().makeList();
case IStrategoTerm.TUPLE:
IStrategoTuple tup = (IStrategoTuple) t;
IStrategoTerm[] args = new IStrategoTerm[tup.getSubtermCount()];
for(int i = 0; i < args.length; i++)
args[i] = tup.get(i);
return env.getFactory().makeList(args);
}
throw new InterpreterException("Unknown term '" + t + "'");
}
开发者ID:metaborg,项目名称:jsglr,代码行数:27,代码来源:java2.java
示例6: call
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
@Override
public IStrategoTerm call(IContext env, IStrategoTerm origin) {
ITokens tokenizer=getTokenizer(origin);
int startIndex=getLeftToken(origin).getIndex();
int endIndex = getRightToken(origin).getIndex();
ArrayList<IStrategoTerm> tokenTuples=new ArrayList<IStrategoTerm>();
for (int i = startIndex; i <= endIndex; i++) {
if(tokenizer.getTokenAt(i).getKind() != IToken.TK_EOF){
IStrategoTerm tokenText = env.getFactory().makeString(tokenizer.getTokenAt(i).toString());
IStrategoTerm tokenSort = env.getFactory().makeInt(tokenizer.getTokenAt(i).getKind());
IStrategoTerm tokenIndex = env.getFactory().makeInt(i);
IStrategoTuple tokenInfo = env.getFactory().makeTuple(tokenIndex, tokenText, tokenSort);
IStrategoTerm nodeOfToken = OriginAttachment.getOrigin(tokenizer.getTokenAt(i).getAstNode());
if(nodeOfToken != null)
OriginAttachment.setOrigin(tokenInfo, nodeOfToken);
tokenTuples.add(tokenInfo);
}
}
return env.getFactory().makeList(tokenTuples);
}
开发者ID:metaborg,项目名称:jsglr,代码行数:21,代码来源:OriginTokenStreamPrimitive.java
示例7: stop
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
public IStrategoTuple stop() {
sourceInCollection = null;
// Use reflection to choose right method to call, because in Guava 18 the type of the second argument of the
// removeOccurrences was changed.
final Method method = getRemoveOccurrencesMethod();
try {
method.invoke(null, addedEntries, oldEntries);
} catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new RuntimeException("Could not invoke remove occurrences", e);
}
// TODO: Use an IStrategoList implementation that iterates over the collections instead of constructing it.
return termFactory.makeTuple(entryFactory.toKeyTerms(removedEntries), entryFactory.toKeyTerms(addedEntries));
}
开发者ID:metaborg,项目名称:mb-rep,代码行数:16,代码来源:IndexCollector.java
示例8: size
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
public int size() {
switch(getTermType()) {
case LIST:
return ((IStrategoList) getWrapped()).size();
case TUPLE:
return ((IStrategoTuple) getWrapped()).size();
default:
throw new TermWrapperException("Called size() on a term that is not a LIST or TUPLE");
}
}
开发者ID:metaborg,项目名称:mb-rep,代码行数:11,代码来源:LazyTerm.java
示例9: doSlowMatch
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
if (second.getTermType() != IStrategoTerm.TUPLE)
return false;
IStrategoTuple snd = (IStrategoTuple) second;
if (size() != snd.size())
return false;
IStrategoTerm[] kids = this.kids;
IStrategoTerm[] secondKids = snd.getAllSubterms();
if (kids != secondKids) {
for (int i = 0, sz = kids.length; i < sz; i++) {
IStrategoTerm kid = kids[i];
IStrategoTerm secondKid = secondKids[i];
if (kid != secondKid && !kid.match(secondKid)) {
if (commonStorageType == SHARABLE && i != 0)
System.arraycopy(secondKids, 0, kids, 0, i);
return false;
}
}
if (commonStorageType == SHARABLE)
this.kids = secondKids;
}
IStrategoList annotations = getAnnotations();
IStrategoList secondAnnotations = second.getAnnotations();
if (annotations == secondAnnotations) {
return true;
} else if (annotations.match(secondAnnotations)) {
if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
return true;
} else {
return false;
}
}
开发者ID:metaborg,项目名称:mb-rep,代码行数:38,代码来源:StrategoTuple.java
示例10: size
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
public int size() {
switch (getTermType()) {
case LIST:
return ((IStrategoList) wrapped).size();
case TUPLE:
return ((IStrategoTuple) wrapped).size();
default:
throw new TermWrapperException("Called size() on a term that is not a LIST or TUPLE");
}
}
开发者ID:metaborg,项目名称:mb-rep,代码行数:11,代码来源:StrategoWrapped.java
示例11: visit
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
/**
* nathan: added
*/
protected void visit(IStrategoTerm term) {
switch (term.getTermType()) {
case APPL:
voidVisitAppl((IStrategoAppl) term);
break;
case INT:
voidVisitInt((IStrategoInt) term);
break;
case LIST:
voidVisitList((IStrategoList) term);
break;
case REAL:
voidVisitReal((IStrategoReal) term);
break;
case STRING:
voidVisitString((IStrategoString) term);
break;
case TUPLE:
voidVisitTuple((IStrategoTuple) term);
break;
default:
throw new RuntimeException("Could not serializate term of type "
+ term.getClass().getName() + " to SAF format.");
}
}
开发者ID:metaborg,项目名称:mb-rep,代码行数:31,代码来源:SAFWriter.java
示例12: call
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
@Override
public boolean call(IContext context, Strategy[] svars, IStrategoTerm[] tvars) {
IStrategoTerm current = context.current();
if(!(current instanceof IStrategoTuple))
return false;
IStrategoTuple t = (IStrategoTuple) current;
if(t.getSubtermCount() < 2)
return false;
if(!(t.get(0) instanceof IStrategoString))
return false;
IStrategoString fileName = (IStrategoString) t.get(0);
if(!(t.get(1) instanceof IStrategoString))
return false;
IStrategoString mode = (IStrategoString) t.get(1);
try {
RandomAccessFile raf = new RandomAccessFile(new File(fileName.stringValue()), mode.stringValue());
context.setCurrent(new GenericWrappedTerm("FileChannel", raf.getChannel()));
return true;
} catch(IOException e) {
return JFFLibrary.invokeExceptionHandler(context, e);
}
}
开发者ID:metaborg,项目名称:mb-exec,代码行数:32,代码来源:JFF_open_file_channel_0_0.java
示例13: call
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
@Override
public boolean call(IContext context, Strategy[] svars, IStrategoTerm[] tvars) {
IStrategoTerm current = context.current();
if (!(current instanceof IStrategoTuple))
return false;
IStrategoTuple t = (IStrategoTuple) current;
if (t.getSubtermCount() < 2)
return false;
if (t.getSubtermCount() < 2)
return false;
if (!(t.get(0) instanceof IStrategoInt))
return false;
IStrategoInt bufferSize = (IStrategoInt) t.get(0);
if (!(t.get(1) instanceof IStrategoInt))
return false;
IStrategoInt direct = (IStrategoInt) t.get(1);
ByteBuffer buf = null;
if (direct.intValue() == 1)
buf = ByteBuffer.allocateDirect(bufferSize.intValue());
else
buf = ByteBuffer.allocate(bufferSize.intValue());
context.setCurrent(new GenericWrappedTerm("ByteBuffer", buf));
return true;
}
开发者ID:metaborg,项目名称:mb-exec,代码行数:36,代码来源:JFF_make_byte_buffer_0_0.java
示例14: match
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
public Results match(IContext env, IStrategoTerm t, IStrategoAppl p)
throws InterpreterException {
if (t == null) {
throw new InterpreterException("Null term while matching: term library or one of the primitives is defective");
}
switch (t.getTermType()) {
case IStrategoTerm.APPL:
return matchAppl(env, (IStrategoAppl) t, p);
case IStrategoTerm.INT:
return matchInt(env, (IStrategoInt) t, p);
case IStrategoTerm.REAL:
return matchReal(env, (IStrategoReal) t, p);
case IStrategoTerm.STRING:
return matchString(env, (IStrategoString) t, p);
case IStrategoTerm.LIST:
return matchList(env, (IStrategoList) t, p);
case IStrategoTerm.TUPLE:
return matchTuple(env, (IStrategoTuple) t, p);
case IStrategoTerm.REF:
return matchRef(env, (IStrategoRef)t, p);
case IStrategoTerm.BLOB:
return matchBlob(env, t, p);
default:
throw new InterpreterException("Unsupported term type : "
+ t.getClass().toString() + " [" + t.getTermType() + "]");
}
}
开发者ID:metaborg,项目名称:mb-exec,代码行数:29,代码来源:Match.java
示例15: matchTuple
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
private Results matchTuple(IContext env, IStrategoTuple t, IStrategoAppl p) throws InterpreterException {
if (DebugUtil.isDebugging()) {
debug("term is Tuple");
}
if (Tools.isAnno(p, env)) {
return matchAnyAnno(env, t, p);
}
else if (Tools.isInt(p, env)) {
return null;
}
else if (Tools.isReal(p, env)) {
return null;
}
else if (Tools.isVar(p, env)) {
return matchAnyVar(t, p);
}
else if (Tools.isOp(p, env)) {
return matchTupleOp(env, t, p);
}
else if (Tools.isWld(p, env)) {
return matchAnyWld(p);
}
else if (Tools.isAs(p, env)) {
return matchCompoundAs(env, t, p);
}
else if (Tools.isExplode(p, env)) {
return matchAnyExplode(env, t, p);
}
else if (Tools.isStr(p, env)) {
return null;
}
throw new InterpreterException("Unknown Tuple case '" + p + "'");
}
开发者ID:metaborg,项目名称:mb-exec,代码行数:35,代码来源:Match.java
示例16: matchTupleOp
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的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
示例17: call
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
throws InterpreterException {
switch(tvars[0].getTermType()) {
case IStrategoTerm.APPL:
IStrategoAppl a = (IStrategoAppl) tvars[0];
env.setCurrent(env.getFactory().makeList(a.getAllSubterms()));
return true;
case IStrategoTerm.INT:
case IStrategoTerm.STRING:
case IStrategoTerm.REAL:
case IStrategoTerm.BLOB:
env.setCurrent(env.getFactory().makeList());
return true;
case IStrategoTerm.LIST:
env.setCurrent(tvars[0]);
return true;
case IStrategoTerm.TUPLE:
IStrategoTuple tuple = (IStrategoTuple) tvars[0];
env.setCurrent(env.getFactory().makeList(tuple.getAllSubterms()));
return true;
case IStrategoTerm.PLACEHOLDER:
IStrategoPlaceholder placeholder = (IStrategoPlaceholder) tvars[0];
env.setCurrent(env.getFactory().makeList(placeholder.getTemplate()));
return true;
default:
throw new IllegalStateException("SSL_get_arguments failed for " + tvars[0]);
}
}
开发者ID:metaborg,项目名称:mb-exec,代码行数:30,代码来源:SSL_get_arguments.java
示例18: call
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
@Override protected IStrategoTerm call(IStrategoTerm current, Strategy[] svars, IStrategoTerm[] tvars,
ITermFactory factory, IContext context) throws MetaborgException, IOException {
IStrategoList list = factory.makeList();
for(ILanguageComponent component : context.language().components()) {
final LanguageIdentifier id = component.id();
final IStrategoString groupIdTerm = factory.makeString(id.groupId);
final IStrategoString idTerm = factory.makeString(id.id);
final IStrategoString versionTerm = factory.makeString(id.version.toString());
final IStrategoString locationTerm = factory.makeString(component.location().getName().getURI());
final IStrategoTuple tuple = factory.makeTuple(groupIdTerm, idTerm, versionTerm, locationTerm);
list = factory.makeListCons(tuple, list);
}
return list;
}
开发者ID:metaborg,项目名称:spoofax,代码行数:15,代码来源:LanguageComponentsPrimitive.java
示例19: match
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
public Results match(IContext env, IStrategoTerm t, IStrategoAppl p)
throws InterpreterException {
if (t == null) {
throw new InterpreterException("Null term while matching: term library is defective");
}
switch (t.getTermType()) {
case IStrategoTerm.APPL:
return matchAppl(env, (IStrategoAppl) t, p);
case IStrategoTerm.INT:
return matchInt(env, (IStrategoInt) t, p);
case IStrategoTerm.REAL:
return matchReal(env, (IStrategoReal) t, p);
case IStrategoTerm.STRING:
return matchString(env, (IStrategoString) t, p);
case IStrategoTerm.LIST:
return matchList(env, (IStrategoList) t, p);
case IStrategoTerm.TUPLE:
return matchTuple(env, (IStrategoTuple) t, p);
case IStrategoTerm.REF:
return matchRef(env, (IStrategoRef)t, p);
case IStrategoTerm.BLOB:
return matchBlob(env, t, p);
default:
throw new InterpreterException("Unsupported term type : "
+ t.getClass().toString() + " [" + t.getTermType() + "]");
}
}
开发者ID:metaborg,项目名称:jsglr,代码行数:29,代码来源:java2.java
示例20: stopCollection
import org.spoofax.interpreter.terms.IStrategoTuple; //导入依赖的package包/类
@Override public IStrategoTuple stopCollection(IStrategoTerm source) {
addAll(source, collector.getAddedEntries());
return collector.stop();
}
开发者ID:metaborg,项目名称:mb-rep,代码行数:5,代码来源:Index.java
注:本文中的org.spoofax.interpreter.terms.IStrategoTuple类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论