Skip to content

Introduce Action classes to refactor State transitions - #571

Merged
yui-knk merged 13 commits into
ruby:masterfrom
yui-knk:refactor_transitions
Mar 1, 2025
Merged

yui-knk merged 13 commits into
ruby:masterfrom
yui-knk:refactor_transitions

Conversation

@yui-knk

@yui-knk yui-knk commented Mar 1, 2025

Copy link
Copy Markdown
Collaborator

State::Shift managed both shift and goto actions.
However this is confusing.
This PR introduces Action::Shift, Action::Goto (and Action::Reduce) to separate classes for shift and goto actions.

`State#shifts` includes both shfit and goto then rename it.
Introduces `State::Action` to mange shift, goto and reduce.
`State::Shift` and `State::Reduce` are removed.
`State::Shift` is divided into `State::Action::Shift` and `State::Action::Goto`
then type declaration changes from `Shift` to `Action::Shift | Action::Goto`.
`State#_transitions` returns raw transitions data which can not resolve
to_state because `@items_to_state` is not set.
Therefore we should use `State#transitions`, `#term_transitions` or `#nterm_transitions`
once `@items_to_state` is set.
`nterm_transitions` changed to return `Action::Goto` instead of `State::Shift`
 then it's better to use `goto` as a variable name than `shift`.
`transitions` changed to return `Action::Goto` or `Action::Shift` instead of `State::Shift`
then it's better to use `transition` as a variable name than `shift`.
`internal_dependencies` select gotos from the same state
then `next_goto` is misleading.
`predecessor_dependencies` select gotos from the predecessor states
then `next_goto` is misleading.
@yui-knk
yui-knk merged commit 8e6cb8e into ruby:master Mar 1, 2025
@yui-knk
yui-knk deleted the refactor_transitions branch March 1, 2025 01:43
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.

1 participant