-- | A pretty printer for the JS.
ppStatement :: Statement -> PP ()
ppStatement s =
  case s of
    Declaration i pos e ->
      do maybe (return ()) (mapping i) pos
         write "var "
         ppIdentifier i
         write " = "
         ppExpression e
         write ";"
         newline
    Return e ->
      do write "return ("
         ppExpression e
         write ");"
    Throw loc e ->
      do mapFrom loc
         write "throw ("
         ppExpression e
         write ");"

-- | Pretty print expressions.
ppStatement :: Statement -> PP ()
ppStatement s =
  case s of
    Declaration i pos e ->
      do maybe (return ()) (mapping i) pos
         write "var "
         ppIdentifier i
         write " = "
         ppExpression e
         write ";"
         newline
    Return e ->
      do write "return ("
         ppExpression e
         write ");"
    Throw loc e ->
      do mapFrom loc
         write "throw ("
         ppExpression e
         write ");"

-- | Pretty print expressions.
ppStatement s =
  case s of
    Declaration i pos e ->
      do maybe (return ()) (mapping i) pos
         write "var "
         ppIdentifier i
         write " = "
         ppExpression e
         write ";"
         newline
    Return e ->
      do write "return ("
         ppExpression e
         write ");"
    Throw loc e ->
      do mapFrom loc
         write "throw ("
         ppExpression e
         write ");"

-- | Pretty print expressions.