Skip to content

Commit cf16ddc

Browse files
committed
Add flags to error node printing
Here we can distinguish `(error-t)` from `(error)`
1 parent e238fde commit cf16ddc

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/syntax_tree.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ end
150150
function _show_syntax_node_sexpr(io, node)
151151
if !haschildren(node)
152152
if is_error(node)
153-
print(io, "(error)")
153+
print(io, "(", untokenize(head(node)), ")")
154154
else
155155
print(io, node.val isa Symbol ? string(node.val) : repr(node.val))
156156
end

test/parser.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ tests = [
5656
"a ? b :\nc" => "(if a b c)"
5757
"a ? b : c:d" => "(if a b (call-i c : d))"
5858
# Following are errors but should recover
59-
"a? b : c" => "(if a (error) b c)"
60-
"a ?b : c" => "(if a (error) b c)"
61-
"a ? b: c" => "(if a b (error) c)"
62-
"a ? b :c" => "(if a b (error) c)"
63-
"a ? b c" => "(if a b (error) c)"
59+
"a? b : c" => "(if a (error-t) b c)"
60+
"a ?b : c" => "(if a (error-t) b c)"
61+
"a ? b: c" => "(if a b (error-t) c)"
62+
"a ? b :c" => "(if a b (error-t) c)"
63+
"a ? b c" => "(if a b (error-t) c)"
6464
],
6565
JuliaSyntax.parse_arrow => [
6666
"x → y" => "(call-i x → y)"
@@ -142,8 +142,8 @@ tests = [
142142
"(x-1)y" => "(call-i (call-i x - 1) * y)"
143143
"0xenomorph" => "0x0e" # ie, not juxtoposition
144144
# errors
145-
"\"a\"\"b\"" => "(call-i \"a\" * (error) \"b\")"
146-
"\"a\"x" => "(call-i \"a\" * (error) x)"
145+
"\"a\"\"b\"" => "(call-i \"a\" * (error-t) \"b\")"
146+
"\"a\"x" => "(call-i \"a\" * (error-t) x)"
147147
],
148148
JuliaSyntax.parse_unary => [
149149
"+2" => "2"
@@ -587,7 +587,7 @@ tests = [
587587
"[x \n\n for a in as]" => "(comprehension (generator x (= a as)))"
588588
# parse_generator
589589
"[x for a = as for b = bs if cond1 for c = cs if cond2]" => "(comprehension (flatten x (= a as) (filter (= b bs) cond1) (filter (= c cs) cond2)))"
590-
"[(x)for x in xs]" => "(comprehension (generator x (error) (= x xs)))"
590+
"[(x)for x in xs]" => "(comprehension (generator x (error-t) (= x xs)))"
591591
"(a for x in xs if cond)" => "(generator a (filter (= x xs) cond))"
592592
"(xy for x in xs for y in ys)" => "(flatten xy (= x xs) (= y ys))"
593593
"(xy for x in xs for y in ys for z in zs)" => "(flatten xy (= x xs) (= y ys) (= z zs))"
@@ -700,7 +700,7 @@ tests = [
700700
"\"\"" => "\"\""
701701
"\"\"\"\n \"\"\"" => "\"\""
702702
# Missing delimiter
703-
"\"str" => "\"str\" (error)"
703+
"\"str" => "\"str\" (error-t)"
704704
# String interpolations
705705
"\"\$x\$y\$z\"" => "(string x y z)"
706706
"\"\$(x)\"" => "(string x)"

0 commit comments

Comments
 (0)