Package org.strategoxt.lang

Examples of org.strategoxt.lang.Context


    IStrategoTerm ppTableFile = ATermCommands.makeString(p);
    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));
View Full Code Here


    if (p == null) {
      p = Pair.create(new ArrayList<Context>(), new ArrayList<WeakReference<Context>>());
      cache.put(initType, p);
    }
   
    Context fresh = null;
    while (fresh == null && !p.b.isEmpty())
      fresh = p.b.remove(0).get();
   
    if (fresh == null)
      try {
View Full Code Here

        cmd.add("-I");
        cmd.add(FileCommands.nativePath(path.getAbsolutePath()));
      }
   
    // Pack-sdf requires a fresh context each time, because it caches grammars, which leads to a heap overflow.
    Context sdfContext = org.strategoxt.tools.tools.init();
    try {
      sdfContext.setIOAgent(packSdfIOAgent);
      sdfContext.invokeStrategyCLI(main_pack_sdf_0_0.instance, "pack-sdf", cmd.toArray(new String[cmd.size()]));
    } catch(StrategoExit e) {
      if (e.getValue() != 0) {
        throw new RuntimeException(e);
      }
    }
View Full Code Here

   
    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 {
      xtcContext.setIOAgent(sdf2tableIOAgent);
      SDFBundleCommand.getInstance().init();
      SDFBundleCommand.getInstance().invoke(xtcContext, "sdf2table", termArgs);
    } finally {
      SugarJContexts.releaseContext(xtcContext);
    }
View Full Code Here

      FileCommands.copyFile(def, permissiveDef);
      return;
    }
     
    log.beginExecution("make permissive", Log.PARSE, "-i", def.getAbsolutePath(), "-o", permissiveDef.getAbsolutePath());
    Context mpContext = SugarJContexts.makePermissiveContext();
    mpContext.setIOAgent(makePermissiveIOAgent);
    try {
      make_permissive.mainNoExit(mpContext, "-i", def.getAbsolutePath(), "-o", permissiveDef.getAbsolutePath());
    }
    catch (StrategoExit e) {
      if (e.getValue() != 0) {
View Full Code Here

   * @param aterm
   * @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);
View Full Code Here

   * @param sdf result file
   * @throws InvalidParseTableException
   */
  public static IStrategoTerm extractSDF(IStrategoTerm term) throws IOException, InvalidParseTableException {
    IStrategoTerm result = null;
    Context extractContext = SugarJContexts.extractionContext();
    try {
      result = extract_sdf_0_0.instance.invoke(extractContext, term);
    }
    catch (StrategoExit e) {
      if (e.getValue() != 0 || result == null)
View Full Code Here

   
   
    final ByteArrayOutputStream log = new ByteArrayOutputStream();

    // Strj requires a fresh context each time.
    Context ctx = org.strategoxt.strj.strj.init();
    try {
      ctx.setIOAgent(strjIOAgent);
      ctx.invokeStrategyCLI(main_strj_0_0.instance, "strj", cmd.toArray(new String[cmd.size()]));
    }
    catch (StrategoExit e) {
      if (e.getValue() != 0)
        throw new StrategoException("STRJ failed", e);
    } finally {
View Full Code Here

   * @param str result file
   * @throws InvalidParseTableException
   */
  public static IStrategoTerm extractSTR(IStrategoTerm term) throws IOException {
    IStrategoTerm result = null;
    Context extractionContext = SugarJContexts.extractionContext();
    try {
      result = extract_str_0_0.instance.invoke(extractionContext, term);
    }
    catch (StrategoExit e) {
      if (e.getValue() != 0 || result == null)
View Full Code Here

   *
   * @param term a SugarJ extension declaration.
   */
  public static IStrategoTerm extractEditor(IStrategoTerm term) throws IOException {
    IStrategoTerm result = null;
    Context extractionContext = SugarJContexts.extractionContext();
    try {
      result = extract_editor_0_0.instance.invoke(extractionContext, term);
    }
    catch (StrategoExit e) {
      if (e.getValue() != 0 || result == null)
View Full Code Here

TOP

Related Classes of org.strategoxt.lang.Context

Copyright © 2018 www.massapicom. 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.