Skip to content

Add --state option for state machine inspection - #34

Merged
ehwan merged 3 commits into
mainfrom
exec_command
Sep 22, 2025
Merged

Add --state option for state machine inspection#34
ehwan merged 3 commits into
mainfrom
exec_command

Conversation

@ehwan

@ehwan ehwan commented Sep 22, 2025

Copy link
Copy Markdown
Owner

Add --state %d option to the executable for direct state machine inspection

@ehwan
ehwan requested a review from Copilot September 22, 2025 13:57

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 new --state option to the rustylr executable for inspecting specific parser states. This feature enables developers to debug and understand parser state machines by examining production rules, shift/goto mappings, reduce actions, and state transitions for any given state.

Key changes:

  • Added --state command-line argument to specify a state index for inspection
  • Implemented detailed state inspection logic that displays production rules, transitions, and source states
  • Updated documentation to explain the new feature with examples

Reviewed Changes

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

Show a summary per file
File Description
rusty_lr_executable/src/arg.rs Added state field to Args struct for the new command-line option
rusty_lr_executable/src/main.rs Implemented state inspection logic with formatted output of state details
rusty_lr_buildscript/src/output.rs Added grammar field to Output struct to expose grammar data
rusty_lr_buildscript/src/lib.rs Updated Output construction to include grammar field
rusty_lr_executable/README.md Added documentation section explaining the --state option with example usage
README.md Reordered installation methods and updated recommendation text

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread rusty_lr_executable/src/main.rs
Comment on lines +66 to +70
let rule = out.grammar.builder.rules[rule.rule]
.rule
.clone()
.map(&term_class_map, &nonterm_map)
.into_shifted(rule.shifted);

Copilot AI Sep 22, 2025

Copy link

Choose a reason for hiding this comment

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

The .clone() operation on line 68 creates unnecessary copies of rule data. Consider using references or borrowing instead of cloning for better performance, especially when processing large grammars with many rules.

Copilot uses AI. Check for mistakes.
.map(|rule| {
out.grammar.builder.rules[*rule]
.rule
.clone()

Copilot AI Sep 22, 2025

Copy link

Choose a reason for hiding this comment

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

Another unnecessary .clone() operation that duplicates rule data. This compounds the performance issue since it occurs within a loop over rules, potentially creating many unnecessary allocations.

Suggested change
.clone()

Copilot uses AI. Check for mistakes.
@ehwan
ehwan merged commit a5151fb into main Sep 22, 2025
1 check passed
@ehwan
ehwan deleted the exec_command branch September 22, 2025 13:59
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