# See the License for the specific language governing permissions and
# limitations under the License.
+# Library used to pretty print Nit code.
+#
+# Usage:
+#
+# import parser_util
+# var tc = new ToolContext
+# var nmodule = tc.parse_something("class A\nfun toto : Int do return 5\nend")
+# var ppv = new PrettyPrinterVisitor
+# var pmodule = ppv.pretty(nmodule)
+# assert pmodule.write_to_string == """
+# class A
+# \tfun toto: Int do return 5
+# end"""
+#
+# See `nitpretty` tool for more documentation.
module pretty
import template
# Add a space.
fun adds do add " "
+ # Visit explicit receiver, implicit self will be ignored.
fun visit_recv(n_expr: AExpr) do
if not n_expr isa AImplicitSelfExpr then
visit n_expr
redef class AArrayExpr
redef fun accept_pretty_printer(v) do
v.consume "["
- v.visit_list n_exprs.n_exprs
+ v.visit_list n_exprs
v.consume "]"
end
end