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


Java IStrategoTerm.toString方法代码示例

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


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

示例1: processRestriction

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private void processRestriction(NormGrammar g, IStrategoTerm restriction) throws UnexpectedTermException {
    if(restriction instanceof StrategoAppl) {
        StrategoAppl res = (StrategoAppl) restriction;
        switch(res.getName()) {
            case "Follow":
                List<CharacterClass[]> restrictionLookahead = Lists.newArrayList();
                CharacterClass restrictionNoLookahead =
                    importFollowRestriction(res.getSubterm(1), restrictionLookahead);
                StrategoList subjects = (StrategoList) res.getSubterm(0);
                for(IStrategoTerm subject : subjects) {
                    Symbol s = processSymbol(g, subject);
                    s.addFollowRestriction(restrictionNoLookahead);
                    s.addFollowRestrictionsLookahead(restrictionLookahead);
                }
                break;
            default:
                throw new UnexpectedTermException(res.getName());
        }
    } else {
        throw new UnexpectedTermException(restriction.toString());
    }
}
 
开发者ID:metaborg,项目名称:sdf,代码行数:23,代码来源:GrammarReader.java

示例2: toString

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private String toString(IStrategoTerm term) {
    if(term instanceof IStrategoString) {
        final IStrategoString messageStringTerm = (IStrategoString) term;
        return messageStringTerm.stringValue();
    } else if(term instanceof IStrategoList) {
        final StringBuilder sb = new StringBuilder();
        boolean first = true;
        for(IStrategoTerm subterm : term) {
            if(!first) {
                sb.append(' ');
            }
            sb.append(toString(subterm));
            first = false;
        }
        return sb.toString();
    } else {
        return term.toString();
    }
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:20,代码来源:AnalysisCommon.java

示例3: hover

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
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,代码行数:19,代码来源:HoverService.java

示例4: label

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private String label(IStrategoTerm term) {
    if(term instanceof IStrategoString) {
        final IStrategoString stringTerm = (IStrategoString) term;
        return stringTerm.stringValue();
    } else {
        return term.toString();
    }
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:9,代码来源:OutlineService.java

示例5: toString

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override public String toString(IStrategoTerm term) {
    if(term instanceof IStrategoString) {
        return ((IStrategoString) term).stringValue();
    } else {
        final IStrategoString pp = prettyPrint(term);
        if(pp != null) {
            return pp.stringValue();
        } else {
            logger.error("Could not pretty print ATerm, falling back to non-pretty printed ATerm");
            return term.toString();
        }
    }
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:14,代码来源:StrategoCommon.java

示例6: implode

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public TNode implode(IStrategoTerm ast, String sort) throws ParseError {
	// Placeholder terms are represented as strings; must parse them and fill in their arguments
	String astString = ast.toString();
	if (astString.startsWith("\"") && astString.endsWith("\"")) {
		astString = astString.substring(1, astString.length() - 1);
		astString = astString.replace("\\\\", "\\").replace("\\\"", "\"");
		ast = termFactory.parseFromString(astString);
	}
	
	return toNode(ast, sort);
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:12,代码来源:AstAnnoImploder.java

示例7: stringValue

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public static String stringValue(IStrategoTerm t){
    return t instanceof IStrategoString ? ((IStrategoString) t).stringValue() : t.toString();
}
 
开发者ID:webdsl,项目名称:webdsl,代码行数:4,代码来源:ATerm.java

示例8: toString

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public static String toString(IStrategoTerm t){
    return t.toString();
}
 
开发者ID:webdsl,项目名称:webdsl,代码行数:4,代码来源:ATerm.java

示例9: invoke

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
@Override
public IStrategoTerm invoke(Context context, IStrategoTerm current) {
	final String str = current.toString();
	final String hash = Hashing.sha256().hashString(str, StandardCharsets.UTF_8).toString();
	return context.getFactory().makeString(hash);
}
 
开发者ID:metaborg,项目名称:dynsem,代码行数:7,代码来源:digest_term_0_0.java

示例10: processAttribute

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private IAttribute processAttribute(IStrategoTerm ta) throws UnexpectedTermException {
    if(ta instanceof StrategoAppl) {
        StrategoAppl a = (StrategoAppl) ta;
        switch(a.getName()) { // This is just to get a proper name for the attribute.
            case "Assoc":
                StrategoAppl assoc = (StrategoAppl) a.getSubterm(0);
                switch(assoc.getName()) {
                    case "Left":
                        return new GeneralAttribute("left");
                    case "Right":
                        return new GeneralAttribute("right");
                    case "Assoc":
                        return new GeneralAttribute("assoc");
                    case "NonAssoc":
                        return new GeneralAttribute("non-assoc");
                    default:
                        System.err.println("Unknown associativity: `" + assoc.getName() + "'.");
                        break;
                }
                break;
            case "Recover":
                return new GeneralAttribute("recover");
            case "Reject":
                return new GeneralAttribute("reject");
            case "Prefer":
                return new GeneralAttribute("prefer");
            case "Avoid":
                return new GeneralAttribute("avoid");
            case "Bracket":
                return new GeneralAttribute("bracket");
            case "LayoutConstraint":
                return new LayoutConstraintAttribute(a.getSubterm(0).toString());
            case "IgnoreLayout":
                return new LayoutConstraintAttribute("ignore-layout");
            case "EnforceNewLine":
                return new GeneralAttribute("enforce-newline");
            case "LongestMatch":
                return new GeneralAttribute("longest-match");
            case "CaseInsensitive":
                return new GeneralAttribute("case-insensitive");
            case "Deprecated":
                String message = "";
                if(a.getSubtermCount() > 0) {
                    message = ((StrategoString) a.getSubterm(0)).stringValue();
                }
                return new DeprecatedAttribute(message);
            case "Placeholder":
                return new GeneralAttribute("placeholder");
            case "PlaceholderInsertion":
                return new GeneralAttribute("placeholder-insertion");
            case "LiteralCompletion":
                return new GeneralAttribute("literal-completion");
            case "NewLongestMatch":
                return new GeneralAttribute("nlm");
            case "Term":
                IStrategoTerm def = a.getSubterm(0);
                IStrategoAppl term = (IStrategoAppl) def.getSubterm(0);
                try {
                    if(term.toString().equals("Fun(Unquoted(\"recover\"))")) {
                        return new GeneralAttribute("recover");
                    }
                    IStrategoTerm termAttribute = createStrategoTermAttribute(term);
                    return new TermAttribute(termAttribute, termAttribute.toString());
                } catch(Exception e) {
                    System.err
                        .println("sdf2table : importAttribute: unknown term attribute `" + a.getName() + "'.");
                    throw new UnexpectedTermException(a.toString());
                }
            default:
                System.err.println("sdf2table : importAttribute: unknown attribute `" + a.getName() + "'.");
                throw new UnexpectedTermException(a.toString());
        }

    }

    return null;
}
 
开发者ID:metaborg,项目名称:sdf,代码行数:78,代码来源:GrammarReader.java

示例11: toCompactString

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private static String toCompactString(IStrategoTerm term) {
	return term.toString(8);
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:4,代码来源:ParseTestCase.java

示例12: toCompactString

import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private static String toCompactString(IStrategoTerm term) {
  return term.toString();
}
 
开发者ID:metaborg,项目名称:jsglr,代码行数:4,代码来源:AbstractParseTestCase.java


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