Skip to content

Commit

Permalink
Make line-space a superset of node-space (#440)
Browse files Browse the repository at this point in the history
* Allow escline everywhere

* escline tests
  • Loading branch information
tjol authored Dec 17, 2024
1 parent 6906771 commit 23918bd
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -910,14 +910,14 @@ unicode-space := See Table (All White_Space unicode characters which are not `ne
single-line-comment := '//' ^newline* (newline | eof)
multi-line-comment := '/*' commented-block
commented-block := '*/' | (multi-line-comment | '*' | '/' | [^*/]+) commented-block
slashdash := '/-' (node-space | line-space)*
slashdash := '/-' line-space*
// Whitespace
ws := unicode-space | multi-line-comment
escline := '\\' ws* (single-line-comment | newline | eof)
newline := See Table (All Newline White_Space)
// Whitespace where newlines are allowed.
line-space := newline | ws | single-line-comment
line-space := node-space | newline | single-line-comment
// Whitespace within nodes, where newline-ish things must be esclined.
node-space := ws* escline ws* | ws+
```
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cases/expected_kdl/escline_after_semicolon.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node
node
1 change: 1 addition & 0 deletions tests/test_cases/expected_kdl/escline_empty_line.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node
4 changes: 4 additions & 0 deletions tests/test_cases/expected_kdl/escline_in_child_block.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parent {
child
child
}
1 change: 1 addition & 0 deletions tests/test_cases/expected_kdl/escline_node_type.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(type)node
1 change: 1 addition & 0 deletions tests/test_cases/expected_kdl/escline_slashdash.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node
2 changes: 2 additions & 0 deletions tests/test_cases/input/escline_after_semicolon.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node; \
node
3 changes: 3 additions & 0 deletions tests/test_cases/input/escline_empty_line.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
\

node
5 changes: 5 additions & 0 deletions tests/test_cases/input/escline_in_child_block.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parent {
child
\ // comment
child
}
2 changes: 2 additions & 0 deletions tests/test_cases/input/escline_node_type.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
\
(type)node
4 changes: 4 additions & 0 deletions tests/test_cases/input/escline_slashdash.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node
\
/-
node

0 comments on commit 23918bd

Please sign in to comment.