From 84911feb11e248f7d5fcfc6b23f813ea3929a0e5 Mon Sep 17 00:00:00 2001 From: Lars Willighagen Date: Wed, 29 Jan 2025 01:48:09 +0100 Subject: [PATCH] Remove mandatory node-space before slashdash and children block (#499) * Remove mandatory node-space before slashdash Fix #495 * Add tests * Fix more tests * Fix tests again --- draft-marchan-kdl2.md | 8 ++++---- tests/test_cases/expected_kdl/braces_in_bare_id.kdl | 3 +++ .../expected_kdl/zero_space_before_slashdash_arg.kdl | 1 + .../expected_kdl/zero_space_before_slashdash_children.kdl | 2 ++ .../expected_kdl/zero_space_before_slashdash_prop.kdl | 1 + .../{braces_in_bare_id_fail.kdl => braces_in_bare_id.kdl} | 0 ...h_arg_fail.kdl => zero_space_before_slashdash_arg.kdl} | 0 .../input/zero_space_before_slashdash_children.kdl | 2 ++ .../test_cases/input/zero_space_before_slashdash_prop.kdl | 1 + 9 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 tests/test_cases/expected_kdl/braces_in_bare_id.kdl create mode 100644 tests/test_cases/expected_kdl/zero_space_before_slashdash_arg.kdl create mode 100644 tests/test_cases/expected_kdl/zero_space_before_slashdash_children.kdl create mode 100644 tests/test_cases/expected_kdl/zero_space_before_slashdash_prop.kdl rename tests/test_cases/input/{braces_in_bare_id_fail.kdl => braces_in_bare_id.kdl} (100%) rename tests/test_cases/input/{zero_space_before_slashdash_arg_fail.kdl => zero_space_before_slashdash_arg.kdl} (100%) create mode 100644 tests/test_cases/input/zero_space_before_slashdash_children.kdl create mode 100644 tests/test_cases/input/zero_space_before_slashdash_prop.kdl diff --git a/draft-marchan-kdl2.md b/draft-marchan-kdl2.md index e65240f..865d13a 100644 --- a/draft-marchan-kdl2.md +++ b/draft-marchan-kdl2.md @@ -936,11 +936,11 @@ document := bom? version? nodes nodes := (line-space* node)* line-space* base-node := slashdash? type? node-space* string - (node-space+ slashdash? node-prop-or-arg)* + (node-space* (node-space | slashdash) node-prop-or-arg)* // slashdashed node-children must always be after props and args. - (node-space+ slashdash node-children)* - (node-space+ node-children)? - (node-space+ slashdash node-children)* + (node-space* slashdash node-children)* + (node-space* node-children)? + (node-space* slashdash node-children)* node-space* node := base-node node-terminator final-node := base-node node-terminator? diff --git a/tests/test_cases/expected_kdl/braces_in_bare_id.kdl b/tests/test_cases/expected_kdl/braces_in_bare_id.kdl new file mode 100644 index 0000000..8ab5eac --- /dev/null +++ b/tests/test_cases/expected_kdl/braces_in_bare_id.kdl @@ -0,0 +1,3 @@ +foo123 { + bar +} diff --git a/tests/test_cases/expected_kdl/zero_space_before_slashdash_arg.kdl b/tests/test_cases/expected_kdl/zero_space_before_slashdash_arg.kdl new file mode 100644 index 0000000..0bdec0e --- /dev/null +++ b/tests/test_cases/expected_kdl/zero_space_before_slashdash_arg.kdl @@ -0,0 +1 @@ +node string diff --git a/tests/test_cases/expected_kdl/zero_space_before_slashdash_children.kdl b/tests/test_cases/expected_kdl/zero_space_before_slashdash_children.kdl new file mode 100644 index 0000000..98f41e3 --- /dev/null +++ b/tests/test_cases/expected_kdl/zero_space_before_slashdash_children.kdl @@ -0,0 +1,2 @@ +node string +node string diff --git a/tests/test_cases/expected_kdl/zero_space_before_slashdash_prop.kdl b/tests/test_cases/expected_kdl/zero_space_before_slashdash_prop.kdl new file mode 100644 index 0000000..0bdec0e --- /dev/null +++ b/tests/test_cases/expected_kdl/zero_space_before_slashdash_prop.kdl @@ -0,0 +1 @@ +node string diff --git a/tests/test_cases/input/braces_in_bare_id_fail.kdl b/tests/test_cases/input/braces_in_bare_id.kdl similarity index 100% rename from tests/test_cases/input/braces_in_bare_id_fail.kdl rename to tests/test_cases/input/braces_in_bare_id.kdl diff --git a/tests/test_cases/input/zero_space_before_slashdash_arg_fail.kdl b/tests/test_cases/input/zero_space_before_slashdash_arg.kdl similarity index 100% rename from tests/test_cases/input/zero_space_before_slashdash_arg_fail.kdl rename to tests/test_cases/input/zero_space_before_slashdash_arg.kdl diff --git a/tests/test_cases/input/zero_space_before_slashdash_children.kdl b/tests/test_cases/input/zero_space_before_slashdash_children.kdl new file mode 100644 index 0000000..6139537 --- /dev/null +++ b/tests/test_cases/input/zero_space_before_slashdash_children.kdl @@ -0,0 +1,2 @@ +node "string"/-{} +node "string" {}/-{} diff --git a/tests/test_cases/input/zero_space_before_slashdash_prop.kdl b/tests/test_cases/input/zero_space_before_slashdash_prop.kdl new file mode 100644 index 0000000..08fed03 --- /dev/null +++ b/tests/test_cases/input/zero_space_before_slashdash_prop.kdl @@ -0,0 +1 @@ +node "string"/-foo=1