Skip to content

Commit 695f54e

Browse files
committed
Bugfix: pretty() now working
1 parent d85be6b commit 695f54e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

larkjs/lark.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,20 +798,20 @@ class Tree {
798798
_pretty(level, indent_str) {
799799
if (this.children.length === 1 && !(this.children[0] instanceof Tree)) {
800800
return [
801-
indent_str * level,
801+
list_repeat(indent_str, level).join(''),
802802
this._pretty_label(),
803803
"\t",
804-
format("%s", this.children[0]),
804+
format("%s", this.children[0].value),
805805
"\n",
806806
];
807807
}
808808

809-
let l = [indent_str * level, this._pretty_label(), "\n"];
809+
let l = [list_repeat(indent_str, level).join(''), this._pretty_label(), "\n"];
810810
for (const n of this.children) {
811811
if (n instanceof Tree) {
812812
l.push(...n._pretty(level + 1, indent_str));
813813
} else {
814-
l.push(...[indent_str * (level + 1), format("%s", n), "\n"]);
814+
l.push(...[list_repeat(indent_str, level+1).join(''), format("%s", n.value), "\n"]);
815815
}
816816
}
817817

0 commit comments

Comments
 (0)