diff --git a/bnf/apyds_bnf/__init__.py b/bnf/apyds_bnf/__init__.py index 8f832e8a..e1feae79 100644 --- a/bnf/apyds_bnf/__init__.py +++ b/bnf/apyds_bnf/__init__.py @@ -22,7 +22,7 @@ def visitRule_pool(self, ctx): def visitRule(self, ctx): result = [self.visit(t) for t in ctx.term()] if len(result) == 1: - return f"----\n{result[0]}" + return f"----\n{result[0]}\n" else: conclusion = result.pop() length = max(len(premise) for premise in result) diff --git a/bnf/atsds_bnf/index.mjs b/bnf/atsds_bnf/index.mjs index 8869da12..9684e2d2 100644 --- a/bnf/atsds_bnf/index.mjs +++ b/bnf/atsds_bnf/index.mjs @@ -23,7 +23,7 @@ class ParseVisitor extends DspVisitor { visitRule(ctx) { const result = ctx.term().map((t) => this.visit(t)); if (result.length === 1) { - return `----\n${result[0]}`; + return `----\n${result[0]}\n`; } else { const conclusion = result.pop(); const length = Math.max(...result.map((premise) => premise.length)); diff --git a/bnf/tests/test_parse_unparse.mjs b/bnf/tests/test_parse_unparse.mjs index b7852b65..6c84ec35 100644 --- a/bnf/tests/test_parse_unparse.mjs +++ b/bnf/tests/test_parse_unparse.mjs @@ -12,7 +12,7 @@ test("parse_no_premises", () => { // Test parsing a rule with no premises (axiom) const dsp_input = "a"; const ds_output = parse(dsp_input); - const expected = "----\na"; + const expected = "----\na\n"; expect(ds_output).toBe(expected); }); @@ -74,7 +74,7 @@ test("unparse_simple_rule", () => { test("unparse_no_premises", () => { // Test unparsing a rule with no premises - const ds_input = "----\na"; + const ds_input = "----\na\n"; const dsp_output = unparse(ds_input); const expected = " -> a"; expect(dsp_output).toBe(expected); diff --git a/bnf/tests/test_parse_unparse.py b/bnf/tests/test_parse_unparse.py index b17a1eee..00229197 100644 --- a/bnf/tests/test_parse_unparse.py +++ b/bnf/tests/test_parse_unparse.py @@ -14,7 +14,7 @@ def test_parse_no_premises() -> None: """Test parsing a rule with no premises (axiom)""" dsp_input = "a" ds_output = parse(dsp_input) - expected = "----\na" + expected = "----\na\n" assert ds_output == expected @@ -76,7 +76,7 @@ def test_unparse_simple_rule() -> None: def test_unparse_no_premises() -> None: """Test unparsing a rule with no premises""" - ds_input = "----\na" + ds_input = "----\na\n" dsp_output = unparse(ds_input) expected = " -> a" assert dsp_output == expected diff --git a/docs/support-packages/bnf.md b/docs/support-packages/bnf.md index cad403ff..e1bb072e 100644 --- a/docs/support-packages/bnf.md +++ b/docs/support-packages/bnf.md @@ -109,7 +109,7 @@ For structured terms: | Description | Dsp Format | Ds Format | |-------------|------------|-----------| | Simple rule | `a, b -> c` | `a\nb\n----\nc` | -| Axiom | `a` | `----\na` | +| Axiom | `a` | `----\na\n` | | Function call | `f(a, b) -> c` | `(function f a b)\n----------------\nc` | | Subscript | `a[i, j] -> b` | `(subscript a i j)\n-----------------\nb` | | Binary operator | `(a + b) -> c` | `(binary + a b)\n--------------\nc` |