Skip to content

Add trailing newline to axiom rule format for consistency - #118

Merged
hzhangxyz merged 2 commits into
mainfrom
copilot/update-bnf-rule-string-format
Dec 16, 2025
Merged

Add trailing newline to axiom rule format for consistency#118
hzhangxyz merged 2 commits into
mainfrom
copilot/update-bnf-rule-string-format

Conversation

Copilot AI commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

Axiom rules (rules with no premises) were inconsistent with multi-premise rules - they lacked a trailing newline after the conclusion.

Changes

  • Python (bnf/apyds_bnf/__init__.py): Changed f"----\n{result[0]}" to f"----\n{result[0]}\n" in ParseVisitor.visitRule()
  • JavaScript (bnf/atsds_bnf/index.mjs): Changed `----\n${result[0]}` to `----\n${result[0]}\n` in ParseVisitor.visitRule()
  • Tests: Updated expectations for axiom parsing/unparsing tests in both languages
  • Documentation: Updated syntax table to reflect new axiom format: ----\na\n

Example

# Before: axiom had no trailing newline
parse("a") == "----\na"

# After: consistent trailing newline
parse("a") == "----\na\n"

# Multi-premise rules always had trailing newline (unchanged)
parse("a, b -> c") == "a\nb\n----\nc\n"
Original prompt

This section details on the original issue you should resolve

<issue_title>bnf中 的 rule 变字符串 需要更新</issue_title>
<issue_description>return f"----\n{result[0]}"
应该是
return f"----\n{result[0]}\n"

上面是python这边的, javascript那边也需要更新, 然后就是/bnf/tests/下面的文件可能也需要更新</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Updated both Python and JavaScript implementations to add a trailing newline
after the conclusion in axiom rules (rules with no premises), making the format
consistent with rules that have premises. Updated all related tests and documentation.

Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
Copilot AI changed the title [WIP] Update rule string format in BNF implementation Add trailing newline to axiom rule format for consistency Dec 16, 2025
Copilot AI requested a review from hzhangxyz December 16, 2025 10:02
@hzhangxyz
hzhangxyz marked this pull request as ready for review December 16, 2025 10:03
Copilot AI review requested due to automatic review settings December 16, 2025 10:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a trailing newline to axiom rules (rules with no premises) to ensure consistency with multi-premise rules. Previously, axioms returned ----\na while multi-premise rules ended with \n. Now all rules consistently end with a trailing newline.

Key Changes:

  • Modified the axiom formatting logic in both Python and JavaScript implementations to append \n
  • Updated all test expectations for axiom parsing and unparsing in both languages
  • Updated documentation table in docs/support-packages/bnf.md to reflect the new format

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
bnf/apyds_bnf/init.py Added trailing newline to axiom rule format in ParseVisitor.visitRule()
bnf/atsds_bnf/index.mjs Added trailing newline to axiom rule format in ParseVisitor.visitRule()
bnf/tests/test_parse_unparse.py Updated test expectations for axiom parsing/unparsing to include trailing newline
bnf/tests/test_parse_unparse.mjs Updated test expectations for axiom parsing/unparsing to include trailing newline
docs/support-packages/bnf.md Updated syntax comparison table to show new axiom format with trailing newline

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

|-------------|------------|-----------|
| Simple rule | `a, b -> c` | `a\nb\n----\nc` |
| Axiom | `a` | `----\na` |
| Axiom | `a` | `----\na\n` |

Copilot AI Dec 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The axiom format in the bnf/README.md file also needs to be updated to match this change. Line 119 of bnf/README.md still shows ----\na instead of ----\na\n.

Copilot uses AI. Check for mistakes.
@hzhangxyz
hzhangxyz merged commit c9d5dc1 into main Dec 16, 2025
113 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bnf中 的 rule 变字符串 需要更新

3 participants