/**
 * Module for PP to be imported within php-front. Contains the strategies
 * that must be available to the outside. 
 */
module php/pp/lib-main
  
strategies

  /**
   * @type PHP -> String
   */
  pp-php4-to-string =
    pp-php4-to-abox
  ; box2text-string(|80)

  /**
   * @type PHP -> String
   */
  pp-php5-to-string =
    pp-php5-to-abox
  ; box2text-string(|80)

strategies
  /**
   * @type PHP -> Box
   */
  pp-php5-to-abox =
    pp-php-to-abox(parenthesize-PHP5,php-to-box <+ php5-to-box)

  pp-php4-to-abox =
    pp-php-to-abox(parenthesize-PHP4,php-to-box <+ php4-to-box)

  pp-php-to-abox(parenthesize,pprules) =
    parenthesize
    ; topdown(
        try(pp-comments(pprules))
        ; repeat(pprules)
      )

strategies
  /**
   * The external interface to pretty-printing strategies.  
   * Use these when you want to pp-to-abox.
   * Maybe there is someway to export these strategies immediately?
   */
  php5-to-abox = 
   php-to-box <+ php5-to-box
  
  php4-to-abox = 
   php-to-box <+ php5-to-box

  php5-parenthesize = 
    parenthesize-PHP5

  php4-parenthesize = 
    parenthesize-PHP4

  print-comments(pprules) = 
    pp-comments(pprules)

strategies
  /**
   * Placed here because the real rules for pretty-printing are moved out.
   * We still need access to the strategies in php-front for this strategy
   * though.
   * 
   * @type PHP -> String
   */
  pp-php-to-string =
    php-choose-version(pp-php4-to-string, pp-php5-to-string)