-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix an error when str.length
is greater than length
#477
Merged
Conversation
This file contains 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
Could you add test case? |
This PR fix an error when `str.length` is greater than `length`. Reproduced by parse.y below: https://gist.github.com/ydah/70186de8a1ff14fa2cd16b338b9fc0e0
ydah
commented
Dec 7, 2024
@@ -299,6 +299,92 @@ | |||
4: digit '+' digit • | |||
STR | |||
end | |||
|
|||
context "when the grammar has a long rule name" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memo) Before the modification, the following error occurs:
❯ bundle exec rake
bundle exec racc parser.y --embedded -o lib/lrama/parser.rb -t --log-file=parser.output
/ydah/.rbenv/versions/3.4-dev/bin/ruby -I/ydah/.rbenv/versions/3.4-dev/lib/ruby/gems/3.4.0+1/gems/rspec-core-3.13.1/lib:/ydah/.rbenv/versions/3.4-dev/lib/ruby/gems/3.4.0+1/gems/rspec-support-3.13.1/lib /ydah/.rbenv/versions/3.4-dev/lib/ruby/gems/3.4.0+1/gems/rspec-core-3.13.1/exe/rspec spec/lrama/bitmap_spec.rb spec/lrama/command_spec.rb spec/lrama/context_spec.rb spec/lrama/counterexamples_spec.rb spec/lrama/diagnostics_spec.rb spec/lrama/grammar/code_spec.rb spec/lrama/grammar/rule_builder_spec.rb spec/lrama/grammar/symbol_spec.rb spec/lrama/grammar/symbols/resolver_spec.rb spec/lrama/grammar_validator_spec.rb spec/lrama/integration_spec.rb spec/lrama/lexer/location_spec.rb spec/lrama/lexer/token/user_code_spec.rb spec/lrama/lexer_spec.rb spec/lrama/option_parser_spec.rb spec/lrama/output_spec.rb spec/lrama/parser_spec.rb spec/lrama/states_spec.rb
.............F...................................................................................................................................................................................................................................
Failures:
1) Lrama::Counterexamples#compute R/R conflicts when the grammar has a long rule name build counterexamples of R/R conflicts
Failure/Error: str << " " * (length - str.length)
ArgumentError:
negative argument
# ./lib/lrama/counterexamples/derivation.rb:47:in 'String#*'
# ./lib/lrama/counterexamples/derivation.rb:47:in 'Lrama::Counterexamples::Derivation#_render_for_report'
# ./lib/lrama/counterexamples/derivation.rb:45:in 'Lrama::Counterexamples::Derivation#_render_for_report'
# ./lib/lrama/counterexamples/derivation.rb:22:in 'Lrama::Counterexamples::Derivation#render_strings_for_report'
# ./lib/lrama/counterexamples/derivation.rb:27:in 'Lrama::Counterexamples::Derivation#render_for_report'
# ./spec/lrama/counterexamples_spec.rb:381:in 'block (5 levels) in <top (required)>'
Finished in 11.89 seconds (files took 0.13841 seconds to load)
241 examples, 1 failure
@yui-knk I added a test case that reproduces the error. |
yui-knk
approved these changes
Dec 19, 2024
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.
This PR fix an error when
str.length
is greater thanlength
.Reproduced by parse.y below:
https://gist.github.com/ydah/70186de8a1ff14fa2cd16b338b9fc0e0