parentheses around binary exprs in source output

This commit is contained in:
Irmen de Jong 2020-09-30 16:38:54 +02:00
parent 3cd32778bb
commit a51fad3aab

View File

@ -53,12 +53,14 @@ class AstToSourceCode(val output: (text: String) -> Unit, val program: Program):
}
override fun visit(expr: BinaryExpression) {
output("(")
expr.left.accept(this)
if(expr.operator.any { it.isLetter() })
output(" ${expr.operator} ")
else
output(expr.operator)
expr.right.accept(this)
output(")")
}
override fun visit(directive: Directive) {