on master help sign in
Test a cast after an open paren, and reword the rest's example
6b9ce23Claude
docs/spec/grammar.md+1−1
@@ -70,7 +70,7 @@ A rune's first children sit on its line, the last taking the rest of it; the oth
70- a tall `|=`, `^-` or `~&`, or a chain of them such as `^- @ud ~& x`, when the line ends where the innermost rune's last child goes. That child is the rest, a body of its own: first its local `++` and `+$`, then its expression, whose own final line may do the same;
70- a tall `|=`, `^-` or `~&`, or a chain of them such as `^- @ud ~& x`, when the line ends where the innermost rune's last child goes. That child is the rest, a body of its own: first its local `++` and `+$`, then its expression, whose own final line may do the same;
71- a `?-` that begins the line and ends it with its subject. Its arms are the rest, one per line, so nothing follows them.
71- a `?-` that begins the line and ends it with its subject. Its arms are the rest, one per line, so nothing follows them.
72
72
73−So a gate's body can be `~& msg`, then `?- msg`, then its arms, all at one depth, and adding or removing the `~&` line moves no other line. This doesn't apply on a `?-` arm's line, on a line of an open bracket, after a bracket opened earlier on the line (the subject's included), at the top level, or to a definition's own expression. So `++ inner |= y=@ud` above `(inner x)`, `[a b] ?- a` above `%.y 1`, `^- @ud ?- x` above `%.y 1` and `++ g ?- x` above `%.y 1` stay errors.
73+A gate's body can then be `~& msg`, then `?- msg`, then its arms, all at one depth, and adding or removing the `~&` line moves no other line. This doesn't apply on a `?-` arm's line, on a line of an open bracket, after a bracket opened earlier on the line (the subject's included), at the top level, or to a definition's own expression. So `++ inner |= y=@ud` above `(inner x)`, `[a b] ?- a` above `%.y 1`, `^- @ud ?- x` above `%.y 1` and `++ g ?- x` above `%.y 1` stay errors.
74
74
75Only `|=` and `$-` have wide forms: `|=(sample expr)` and `$-(mold mold)`. Their children are operands, so calls inside need parentheses.
75Only `|=` and `$-` have wide forms: `|=(sample expr)` and `$-(mold mold)`. Their children are operands, so calls inside need parentheses.
76
76
tests/golden/lex-body-rest-bad-16/about.txtnew file+3
@@ -0,0 +1,3 @@
1+source: Grammar tab, Runes, The rest of a body: "This doesn't apply on a `?-` arm's line, on a line of an open bracket, after a bracket opened earlier on the line (the subject's included), at the top level, or to a definition's own expression."
2+tests: a cast after a `(` opened earlier on its line, alone there, with its expression on the next line at the same depth
3+expect: error at 3:3 — inside the ( no rune takes the lines after it, so the cast needs its expression on its line or deeper
tests/golden/lex-body-rest-bad-16/source.jibbnew file+3
@@ -0,0 +1,3 @@
1+++ f |= x=@ud
2+ (^- @ud
3+ x)
tests/golden/lex-body-rest-bad-16/tokens.txtnew file+15
@@ -0,0 +1,15 @@
1+1:1 glyph ++
2+1:4 name f
3+1:6 glyph |=
4+1:9 name x
5+1:10 tight glyph =
6+1:11 tight aura @ud
7+2:3 INDENT
8+2:3 glyph (
9+2:4 tight glyph ^-
10+2:7 aura @ud
11+3:3 NEWLINE
12+3:3 name x
13+3:4 tight glyph )
14+3:5 DEDENT
15+3:5 NEWLINE
tests/golden/lex-body-rest-bad-16/tree.txtnew file+3
@@ -0,0 +1,3 @@
1+/tests/golden/lex-body-rest-bad-16/source.jibb:3:3: expected an expression, or a body on deeper lines, found a line at the same depth
2+ x)
3+ ^