module regular-xtc-tools
imports
  pp-rtg
  libstratego-sglr

strategies

  xtc-pp-abstract-stratego =
    xtc-transform(!"pp-stratego", !["--abstract" | <pass-verbose> ()])

  /**
   * @type FILE -> RTG
   */
  xtc-rtg-front-end =
    xtc-ensure-file
    ; ?FILE(<id>)
    ; parse-rtg-file
    ; rtg-reduce
    ; rtg-group-productions


  /**
   * @type RTG -> FILE
   */
  xtc-pp-rtg =
    where(f := <xtc-new-file>)
    ; pp-rtg-file(|f)
    ; !FILE(f)

/**
 * Bootstrap problem
 */
strategies

  my-parse-rtg-file =
    where(tbl := <my-get-rtg-parse-table>)
    ; parse-file(|tbl)
    ; rtg-parsefix

  my-get-rtg-parse-table =
    MyMemoRTGParseTable
    <+ get-rtg-parse-table
       ; open-parse-table
       ; ?tbl
       ; rules(MyMemoRTGParseTable: _ -> tbl)

  external STRRTG-get-rtg-parsetable(|)
