Add trailing newline to axiom rule format for consistency - #118
Merged
Conversation
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
hzhangxyz
marked this pull request as ready for review
December 16, 2025 10:03
hzhangxyz
approved these changes
Dec 16, 2025
Contributor
There was a problem hiding this comment.
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.mdto 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` | |
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Axiom rules (rules with no premises) were inconsistent with multi-premise rules - they lacked a trailing newline after the conclusion.
Changes
bnf/apyds_bnf/__init__.py): Changedf"----\n{result[0]}"tof"----\n{result[0]}\n"inParseVisitor.visitRule()bnf/atsds_bnf/index.mjs): Changed`----\n${result[0]}`to`----\n${result[0]}\n`inParseVisitor.visitRule()----\na\nExample
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.