-
Notifications
You must be signed in to change notification settings - Fork 198
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
Feature request: Method to test for valid literal method name. #213
Labels
Comments
@whitequark Thx. Just to be sure we are on the same page: Will this account for the fact when part of the name to check is interpreted as a comment? |
Sure, it checks that the name that the parser returned is the same as the input. |
k, thx. Closing this. |
This was referenced Mar 16, 2016
Parsing rspec descriptions results in, invalid byte sequence in UTF-8 (ArgumentError)
mbj/mutant#546
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a feature in mutant I need to be able to determine if a given string is a valid literal method name.
While I could simply generate source and attempt to parse it, like:
Parser::CurrentRuby.parse("def #{candidate_method_name}; end")
It would be a horrible use of ad-hoc code generation + parsing:
Input candidate method names like:
'valid_method; end # invalid_crap'
would easily bypass the check, as only the prefix of the candidate is checked for validity. Lots of other edge cases like this could be constructed. Its true the resulting AST could be checked for additional nodes, comments being parsed but still: Ugly.I realize that this feature request could be out of scope of this project. The source of truth for "valid literal method names" is already present in the lexer + parser components, so it might be exposable for the general public, without huge complexity increase.
Or it might even be present in a semi-public API where I'd be happy to use it. Calling into the lexer with a pre set-up state?
The text was updated successfully, but these errors were encountered: