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


Java IStrategoTerm.STRING属性代码示例

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


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

示例1: removeAnnotations

public static IStrategoTerm removeAnnotations(IStrategoTerm inTerm, final ITermFactory factory) {
    TermTransformer trans = new TermTransformer(factory, true) {
        @Override public IStrategoTerm preTransform(IStrategoTerm term) {
            switch(term.getTermType()) {
                case IStrategoTerm.APPL:
                    return factory.makeAppl(((IStrategoAppl) term).getConstructor(), term.getAllSubterms(), null);
                case IStrategoTerm.LIST:
                    return factory.makeList(term.getAllSubterms(), null);
                case IStrategoTerm.STRING:
                    return factory.makeString(((IStrategoString) term).stringValue());
                case IStrategoTerm.TUPLE:
                    return factory.makeTuple(term.getAllSubterms(), null);
                default:
                    return term;
            }
        }
    };
    return trans.transform(inTerm);
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:19,代码来源:Term.java

示例2: dispatch

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,代码行数:26,代码来源:StrategoTermVisitee.java

示例3: getTermArguments

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,代码行数:26,代码来源:java2.java

示例4: call

@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars) {
    if (tvars[0].getTermType() != IStrategoTerm.STRING) {
        return false;
    }

    library.clearErrors();

    final String input = ((IStrategoString) tvars[0]).stringValue();
    final InputStream in = makeInputStream(env, input);

    if (in == null) {
        return false;
    }

    final IStrategoTerm result = parse(env, in);

    if (result == null) {
        return false;
    }

    env.setCurrent(result);
    return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:24,代码来源:XML_parse_base.java

示例5: getTermArguments

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,代码行数:26,代码来源:Match.java

示例6: call

@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars) {

   if (tvars[0].getTermType() != IStrategoTerm.STRING)
       return false;

   IStrategoString filename = (IStrategoString) tvars[0];
   SSLLibrary library = (SSLLibrary) env.getOperatorRegistry(SSLLibrary.REGISTRY_NAME);
   File file = library.getIOAgent().openFile(filename.stringValue());

   if (!file.isFile()) {
       return false;
   }

   env.setCurrent(env.getFactory().makeReal(file.length()));
   return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:17,代码来源:SSL_filesize.java

示例7: hover

private Hover hover(@Nullable TermWithRegion tuple) {
    if(tuple == null) {
        return null;
    }

    final IStrategoTerm output = tuple.term;
    final ISourceRegion offsetRegion = tuple.region;

    final String text;
    if(output.getTermType() == IStrategoTerm.STRING) {
        text = Tools.asJavaString(output);
    } else {
        text = output.toString();
    }
    final String massagedText = text.replace("\\\"", "\"").replace("\\n", "");

    return new Hover(offsetRegion, massagedText);
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:18,代码来源:HoverService.java

示例8: call

@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
        throws InterpreterException {
    
   if (tvars[0].getTermType() != IStrategoTerm.STRING)
       return false;

   SSLLibrary library = (SSLLibrary) env.getOperatorRegistry(SSLLibrary.REGISTRY_NAME);
   IStrategoString filename = (IStrategoString) tvars[0];
   File file = library.getIOAgent().openFile(filename.stringValue());

   if (!file.exists())
       return false;
   
   // TODO: Return filemode as an int?
   env.setCurrent(env.getFactory().makeTuple(filename, env.getFactory().makeInt(0)));
   
   return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:19,代码来源:SSL_filemode.java

示例9: match

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,代码行数:18,代码来源:StrategoTerms.java

示例10: match

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,代码行数:28,代码来源:java2.java

示例11: doSlowMatch

@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
    if(second.getTermType() != IStrategoTerm.STRING)
        return false;
    
    String value = stringValue();
    String secondValue = ((IStrategoString) second).stringValue();
    
    if (value == secondValue) {
    	// Do nothing
    } else if (value.equals(secondValue)) {
    	// Don't apply resharing here (StrategoXT/801) but maintain
    	// the string instance that may be in the string pool
    	// if (commonStorageType == SHARABLE)
    	//	this.value = secondValue;
    } else {
        return false;
    }

    IStrategoList annotations = getAnnotations();
    IStrategoList secondAnnotations = second.getAnnotations();
    if (annotations == secondAnnotations) {
        // assert annotations.isEmpty() ? this == second : true : "Maximal sharing contract broken";
    	return true;
    } else if (annotations.match(secondAnnotations)) {
    	if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
    	return true;
    } else {
    	return false;
    }
}
 
开发者ID:metaborg,项目名称:mb-rep,代码行数:31,代码来源:StrategoString.java

示例12: unpackTerm

public Object unpackTerm(IStrategoTerm term) {
	switch(term.getTermType()) {
	case IStrategoTerm.INT:
		return ((IStrategoInt)term).intValue();
	case IStrategoTerm.REAL:
		return ((IStrategoReal)term).realValue();
	case IStrategoTerm.STRING:
		return ((IStrategoString)term).stringValue();
	case IStrategoTerm.APPL:
		return unwrapObject((IStrategoAppl)term);
	default:
		return null;
	}
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:14,代码来源:JFFLibrary.java

示例13: match

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,代码行数:28,代码来源:Match.java

示例14: getDeprecationMessage

public String getDeprecationMessage(IStrategoAppl attrs) {
	IStrategoTerm deprecated = getAttribute(attrs, "deprecated");
	if(deprecated == null){
		return null;
	} else {
		final StringBuilder msg = new StringBuilder("Deprecated construct");
		if(deprecated.getTermType() == IStrategoTerm.STRING){
			msg.append(": ");
			msg.append(asJavaString(deprecated));
			return msg.toString();
		}else{
			return msg.toString();
		}
	}
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:15,代码来源:ProductionAttributeReader.java

示例15: call

@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
        throws InterpreterException {
    
    String message = tvars[0].getTermType() == IStrategoTerm.STRING
        ? asJavaString(tvars[0])
        : "(no details on this error; perror not supported)";
    
    System.err.println("ERROR: " + message);
    return true;
}
 
开发者ID:metaborg,项目名称:mb-exec,代码行数:11,代码来源:SSL_perror.java


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