Skip to content

[core][doc] Refactor parse-related functions by adding new shared helpers and a unified parse loop + Add a document on parsing algorithm#55

Merged
forfudan merged 5 commits into
mainfrom
dev
May 2, 2026
Merged

[core][doc] Refactor parse-related functions by adding new shared helpers and a unified parse loop + Add a document on parsing algorithm#55
forfudan merged 5 commits into
mainfrom
dev

Conversation

@forfudan

@forfudan forfudan commented May 2, 2026

Copy link
Copy Markdown
Owner

This PR refactors Command parsing to reduce duplication by extracting a shared lexing/dispatch loop and common storage helpers, aiming to keep parse_arguments() and parse_known_arguments() aligned.

Changes:

  • Replaces the inline parse loop in parse_arguments() with a shared _run_parse_loop(...).
  • Updates parse_known_arguments() to use _run_parse_loop(...) and limits its post-parse phases (no prompting/confirmation).
  • Extracts repeated parsing/storage logic into helpers (_store_scalar_value, _increment_count, _consume_nargs, _find_remainder_slot).

Co-authored-by: Copilot <copilot@github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors Command parsing to reduce duplication by extracting a shared lexing/dispatch loop and common storage helpers, aiming to keep parse_arguments() and parse_known_arguments() aligned.

Changes:

  • Replaces the inline parse loop in parse_arguments() with a shared _run_parse_loop(...).
  • Updates parse_known_arguments() to use _run_parse_loop(...) and limits its post-parse phases (no prompting/confirmation).
  • Extracts repeated parsing/storage logic into helpers (_store_scalar_value, _increment_count, _consume_nargs, _find_remainder_slot).

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

Comment thread src/argmojo/command.mojo Outdated
Comment thread src/argmojo/command.mojo Outdated
Comment thread src/argmojo/command.mojo
Comment thread src/argmojo/command.mojo Outdated
Co-authored-by: Copilot <copilot@github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


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

Comment thread src/argmojo/command.mojo Outdated
Comment thread tests/test_options.mojo Outdated
Comment thread src/argmojo/command.mojo Outdated
forfudan and others added 2 commits May 2, 2026 23:52
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@forfudan forfudan changed the title [core] Refactor parse-related functions by adding new shared helpers and a unified parse loop [core][doc] Refactor parse-related functions by adding new shared helpers and a unified parse loop + Add a document on parsing algorithm May 2, 2026
@forfudan forfudan requested a review from Copilot May 2, 2026 22:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


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

Comment thread src/argmojo/command.mojo Outdated
Comment thread docs/parsing_algorithm.md
Co-authored-by: Copilot <copilot@github.com>
@forfudan forfudan merged commit 3bde543 into main May 2, 2026
5 checks passed
@forfudan forfudan deleted the dev branch May 2, 2026 22:50
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.

2 participants