Examples of IStrategoTerm


Examples of org.spoofax.interpreter.terms.IStrategoTerm

 
  public static IStrategoTerm fixSDF(IStrategoTerm term, HybridInterpreter interp) throws IOException, InvalidParseTableException {
    if (term == null)
      return null;
   
    IStrategoTerm result = null;
    try {
      result = sdf_desugar_0_0.instance.invoke(interp.getCompiledContext(), term);
    }
    catch (StrategoExit e) {
      if (e.getValue() != 0 || result == null)
View Full Code Here

Examples of org.spoofax.interpreter.terms.IStrategoTerm

    if (jarfile == null)
      return newServices;
   
    String jarfilePath = jarfile.getAbsolutePath().replace("\\", "\\\\").replace("\"", "\\\"");
    IStrategoTerm builder = ATermCommands.atermFromString(
        "Builders(\"sugarj checking\", [SemanticObserver(Strategy(\"sugarj-analyze\")), SemanticProvider(\"" + jarfilePath + "\")])");
    newServices.add(builder);

    return newServices;
  }
View Full Code Here

Examples of org.spoofax.interpreter.terms.IStrategoTerm

  }


  public static IStrategoTerm pushAmbiguities(IStrategoTerm term) {
    if (isApplication(term, "amb") && term.getSubterm(0).isList() && term.getSubterm(0).getSubtermCount() == 2) {
      IStrategoTerm left = pushAmbiguities(term.getSubterm(0).getSubterm(0));
      IStrategoTerm right = pushAmbiguities(term.getSubterm(0).getSubterm(1));
     
      if (left.getTermType() == IStrategoTerm.APPL &&
          right.getTermType() == IStrategoTerm.APPL &&
          left.getSubtermCount() == right.getSubtermCount() &&
          ((IStrategoAppl) left).getConstructor().equals(((IStrategoAppl) right).getConstructor())) {
       
        IStrategoTerm[] ambKids = new IStrategoTerm[left.getSubtermCount()];
       
        for (int i = 0; i < left.getSubtermCount(); i++)
          ambKids[i] = makeAppl("amb",
                                ImploderAttachment.getElementSort(left.getSubterm(i)),
                                2,
                                makeList(ImploderAttachment.getElementSort(term.getSubterm(0)),
                                         left.getSubterm(i), right.getSubterm(i)));
       
        return makeAppl(
            ((IStrategoAppl) left).getConstructor().getName(),
            ImploderAttachment.getElementSort(left),
            left.getSubtermCount(),
View Full Code Here

Examples of org.spoofax.interpreter.terms.IStrategoTerm

   
    return term;
  }
 
  public static IStrategoTerm readPrettyPrintTable(String p) {
    IStrategoTerm ppTableFile = ATermCommands.makeString(p);
    return parse_pptable_file_0_0.instance.invoke(org.strategoxt.stratego_gpp.stratego_gpp.init(), ppTableFile);
  }
View Full Code Here

Examples of org.spoofax.interpreter.terms.IStrategoTerm

    return parse_pptable_file_0_0.instance.invoke(org.strategoxt.stratego_gpp.stratego_gpp.init(), ppTableFile);
  }

  public static String prettyPrint(IStrategoTerm ppTable, IStrategoTerm term, HybridInterpreter interp) {
    Context ctx = interp.getCompiledContext();
    IStrategoTerm ppt_list = makeList("PPTable", ppTable);
    IStrategoTerm aboxTerm = ast2abox_0_1.instance.invoke(ctx, term, ppt_list);
    if (aboxTerm == null)
      return null;
    IStrategoTerm textTerm = box2text_string_0_1.instance.invoke(ctx, aboxTerm, factory.makeInt(80));
    return ATermCommands.getString(textTerm);

  }
View Full Code Here

Examples of org.spoofax.interpreter.terms.IStrategoTerm

   */
  public static IStrategoTerm copyTokens(IStrategoTerm from, IStrategoTerm to) {
    if (from == to)
      return to;
   
    IStrategoTerm result = to;
    LinkedList<IStrategoTerm> fromStack = new LinkedList<IStrategoTerm>();
    LinkedList<IStrategoTerm> toStack = new LinkedList<IStrategoTerm>();
    fromStack.push(from);
    toStack.push(to);
   
    while (!fromStack.isEmpty()) {
      from = fromStack.pop();
      to = toStack.pop();
     
      ImploderAttachment attach = ImploderAttachment.get(from);
      if (attach != null)
        ImploderAttachment.putImploderAttachment(
            to,
            attach.isSequenceAttachment(),
            attach.isSequenceAttachment() ? attach.getElementSort() : attach.getSort(),
            attach.getLeftToken(),
            attach.getRightToken());
     
      for (int i = 0; i < from.getSubtermCount(); i++) {
        fromStack.push(from.getSubterm(i));
       
        IStrategoTerm subterm = to.getSubterm(i);
        ParentAttachment.putParent(subterm, to, null);
        toStack.push(subterm);
      }
    }
   
View Full Code Here

Examples of org.spoofax.interpreter.terms.IStrategoTerm

        "-o", toCygwinPath(tbl.getAbsolutePath()),
        "-m", module,
        "-n"
      };
   
    IStrategoTerm termArgs[] = new IStrategoTerm[cmd.length];
    for (int i = 0; i < termArgs.length; i++)
      termArgs[i] = ATermCommands.makeString(cmd[i], null);
   
    Context xtcContext = SugarJContexts.xtcContext();
    try {
View Full Code Here

Examples of org.spoofax.interpreter.terms.IStrategoTerm

  }
 
  private static ModuleKey getModuleKeyForGrammar(Path sdf, String module, Map<Path, Integer> dependentFiles, SGLR parser) throws IOException, InvalidParseTableException, TokenExpectedException, SGLRException {
    log.beginTask("Generating", "Generate module key for current grammar", Log.CACHING);
    try {
      IStrategoTerm aterm = (IStrategoTerm) parser.parse(FileCommands.readFileAsString(sdf), sdf.getAbsolutePath(), "Sdf2Module");

      IStrategoTerm imports = ATermCommands.getApplicationSubterm(aterm, "module", 1);
      IStrategoTerm body = ATermCommands.getApplicationSubterm(aterm, "module", 2);
      IStrategoTerm term = ATermCommands.makeTuple(imports, body);

      return new ModuleKey(dependentFiles, SDF_FILE_PATTERN, term);
    } catch (Exception e) {
      throw new SGLRException(parser, "could not parse SDF file " + sdf, e);
    } finally {
View Full Code Here

Examples of org.spoofax.interpreter.terms.IStrategoTerm

   * @return
   * @throws IOException
   */
  public static String prettyPrintSDF(IStrategoTerm term, HybridInterpreter interp) throws IOException {
    Context ctx = interp.getCompiledContext();
    IStrategoTerm boxTerm = pp_sdf_box_0_0.instance.invoke(ctx, term);
    if (boxTerm != null) {
      IStrategoTerm textTerm = box2text_string_0_1.instance.invoke(ctx, boxTerm, ATermCommands.factory.makeInt(80));
      if (textTerm != null)
        return ATermCommands.getString(textTerm);
    }
   
    throw new ATermCommands.PrettyPrintError(term, "pretty printing SDF AST failed");
View Full Code Here

Examples of org.spoofax.interpreter.terms.IStrategoTerm

   * @param aterm
   * @return
   * @throws IOException
   */
  public static String prettyPrintSTR(IStrategoTerm term, HybridInterpreter interp) throws IOException {
    IStrategoTerm string = pp_stratego_string_0_0.instance.invoke(interp.getCompiledContext(), term);
    if (string != null)
      return Term.asJavaString(string);
   
    throw new ATermCommands.PrettyPrintError(term, "pretty printing STR AST failed: " + ATermCommands.atermToFile(term));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.