本文整理汇总了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());
}
}
示例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();
}
}
示例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);
}
示例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();
}
}
示例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();
}
}
}
示例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);
}
示例7: stringValue
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public static String stringValue(IStrategoTerm t){
return t instanceof IStrategoString ? ((IStrategoString) t).stringValue() : t.toString();
}
示例8: toString
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
public static String toString(IStrategoTerm t){
return t.toString();
}
示例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);
}
示例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;
}
示例11: toCompactString
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private static String toCompactString(IStrategoTerm term) {
return term.toString(8);
}
示例12: toCompactString
import org.spoofax.interpreter.terms.IStrategoTerm; //导入方法依赖的package包/类
private static String toCompactString(IStrategoTerm term) {
return term.toString();
}