-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add convert_luau_numbers
rule
#257
base: main
Are you sure you want to change the base?
Conversation
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.
Hi! Thanks for submitting the PR
Before merging this, I'd like to see these:
- change the rule name to
convert_luau_numbers
- convert only binary numbers to decimal numbers because those are the compatibility issue
- for each kind of number, if they have a token, remove the token if it contains any underscores (
_
)
src/rules/mod.rs
Outdated
@@ -235,6 +237,7 @@ pub fn get_default_rules() -> Vec<Box<dyn Rule>> { | |||
Box::<RemoveNilDeclaration>::default(), | |||
Box::<RenameVariables>::default(), | |||
Box::<RemoveFunctionCallParens>::default(), | |||
Box::<RemoveNumberLiterals>::default(), |
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.
I think I would not put this rule in the default rules, at least for now
src/rules/remove_number_literals.rs
Outdated
struct Processor {} | ||
|
||
impl NodeProcessor for Processor { | ||
fn process_expression(&mut self, exp: &mut Expression) { |
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.
There is a function for number expressions you can use directly:
fn process_expression(&mut self, exp: &mut Expression) { | |
fn process_number_expression(&mut self, number: &mut NumberExpression) { |
I can't see a reason why you would want this, but it might be cool to atleast have an option for it to convert all number literals (so even hex literals like 0xFFFFFFF, like it's doing right now), instead of it only converting binary literals and removing underscores. |
… changed to convert_luau_numbers and only converts binary to decimal and removes underscores from token)
Closes #256
Changes
convert_luau_numbers
that converts luau's number literal syntax.convert_luau_numbers
.