Skip to content

Commit baaf522

Browse files
committed
Allow -Xprint:parser option to print parse trees
`parser` is strictly speaking not a phase, but it makes sense to allow parsed trees being printed. Before this was only possible if the `typr` printer was enabled, but this was cumbersome, non-intuitive, and did too much.
1 parent 08e8802 commit baaf522

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/dotty/tools/dotc/typer/FrontEnd.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class FrontEnd extends Phase {
2828
unit.untpdTree =
2929
if (unit.isJava) new JavaParser(unit.source).parse()
3030
else new Parser(unit.source).parse()
31-
typr.println("parsed:\n" + unit.untpdTree.show)
31+
val printer = if (ctx.settings.Xprint.value.contains("parser")) default else typr
32+
printer.println("parsed:\n" + unit.untpdTree.show)
3233
}
3334

3435
def enterSyms(implicit ctx: Context) = monitor("indexing") {

0 commit comments

Comments
 (0)