Tabnine Logo
IStrategoTerm.getTermType
Code IndexAdd Tabnine to your IDE (free)

How to use
getTermType
method
in
org.spoofax.interpreter.terms.IStrategoTerm

Best Java code snippets using org.spoofax.interpreter.terms.IStrategoTerm.getTermType (Showing top 9 results out of 315)

origin: org.metaborg/spoofax.runtime

public static boolean hasType(IStrategoTerm t, int type) {
  return t.getTermType() == type;
}
origin: org.metaborg/spoofax.runtime

private static String traceToString(IStrategoList trace) {
  final StringBuilder sb = new StringBuilder();
  sb.append("Stratego trace:");
  final int depth = trace.getSubtermCount();
  for(int i = 0; i < depth; i++) {
    final IStrategoTerm t = trace.getSubterm(depth - i - 1);
    sb.append("\n\t");
    sb.append(t.getTermType() == IStrategoTerm.STRING ? Tools.asJavaString(t) : t);
  }
  return sb.toString();
}
origin: org.metaborg/spoofax.runtime

  public static String cons(IStrategoTerm t) {
    if(t == null || t.getTermType() != APPL)
      return null;
    return ((IStrategoAppl) t).getConstructor().getName();
  }
}
origin: org.metaborg/spoofax.runtime

public static IStrategoAppl findTerm(IStrategoTerm term, String constructor) {
  if(term.getTermType() == IStrategoTerm.APPL && cons(term).equals(constructor))
    return (IStrategoAppl) term;
  IStrategoTerm[] subterms = term.getAllSubterms();
  for(int i = subterms.length - 1; i >= 0; i--) {
    IStrategoAppl result = findTerm(subterms[i], constructor);
    if(result != null)
      return result;
  }
  return null;
}
origin: org.metaborg/spoofax.runtime

private static void collectTerms(IStrategoTerm term, String constructor, ArrayList<IStrategoAppl> results) {
  if(term.getTermType() == IStrategoTerm.APPL && cons(term).equals(constructor))
    results.add((IStrategoAppl) term);
  // TODO: optimize: use TermVisitor, avoid indexed access to long lists
  for(int i = 0; i < term.getSubtermCount(); i++) {
    collectTerms(termAt(term, i), constructor, results);
  }
}
origin: org.metaborg/spoofax.runtime

private @Nullable Style termStyle(IStrategoTerm term) {
  final int termType = term.getTermType();
  if(termType != IStrategoTerm.APPL && termType != IStrategoTerm.TUPLE && termType != IStrategoTerm.LIST) {
    // Try to use the parent of terminal nodes, mimicking behavior of old Spoofax/IMP runtime.
    final IStrategoTerm parentTerm = ParentAttachment.getParent(term);
    if(parentTerm != null) {
      final Style style = sortConsStyle(parentTerm);
      if(style != null) {
        return style;
      }
    }
  }
  return sortConsStyle(term);
}
origin: org.metaborg/spoofax.runtime

@Nullable
public static String termContents(IStrategoTerm t) {
  if(t == null)
    return null;
  String result;
  if(t.getTermType() == STRING) {
    result = asJavaString(t);
  } else if(t.getSubtermCount() == 1 && "Values".equals(tryGetName(t))) {
    return concatTermStrings(Tools.listAt(t, 0));
  } else if(t.getTermType() == APPL && t.getSubtermCount() == 1 && termAt(t, 0).getTermType() == STRING) {
    result = asJavaString(termAt(t, 0));
  } else if(t.getTermType() == APPL && t.getSubtermCount() == 1) {
    return termContents(termAt(t, 0));
  } else {
    return null;
  }
  if(result.startsWith("\"") && result.endsWith("\"") && result.length() > 1)
    result = result.substring(1, result.length() - 1).replace("\\\\", "\"");
  return result;
}
origin: org.metaborg/spoofax.legacy

  public static @Nullable IStrategoAppl read(PPath file) throws ParseError, IOException {
    final ITermFactory termFactory =
      StaticSpoofaxCoreFacade.spoofax().termFactoryService.getGeneric().getFactoryWithStorageType(IStrategoTerm.MUTABLE);
    final TermReader reader = new TermReader(termFactory);
    final IStrategoTerm term = reader.parseFromStream(file.inputStream());
    if(term.getTermType() != IStrategoTerm.APPL) {
      return null;
    }
    return (IStrategoAppl) term;
  }
}
origin: org.metaborg/spoofax.runtime

if(term.getTermType() == IStrategoTerm.APPL) {
  final String cons = ((IStrategoAppl) term).getConstructor().getName();
  if(rules.hasSortConsStyle(massagedSort, cons)) {
org.spoofax.interpreter.termsIStrategoTermgetTermType

Popular methods of IStrategoTerm

  • getAllSubterms
  • getSubterm
  • getSubtermCount
  • spliterator

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSupportFragmentManager (FragmentActivity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • addToBackStack (FragmentTransaction)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now