-
Notifications
You must be signed in to change notification settings - Fork 362
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
improve number lexer #1646
improve number lexer #1646
Conversation
- reduce the number of regex rules to detect a number - use only one channel to detect numbers - improve #1415
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.
Reviewed 2 of 2 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @guwirth, @jmecosta, and @SonarOpenCommunityAdmin)
cxx-squid/src/main/java/org/sonar/cxx/lexer/CxxLexer.java, line 45 at r1 (raw file):
private static final String HEX_PREFIX = "0[xX]"; private static final String EXPONENT = "([Ee][+-]?+[0-9_]([']?+[0-9_]++)*+)";
Your change is valid. However the original regexp is not really clear to me. Does it make sense to have *
followed by +
? Wouldn’t +
be sufficient?
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @guwirth, @jmecosta, and @SonarOpenCommunityAdmin)
cxx-squid/src/main/java/org/sonar/cxx/lexer/CxxLexer.java, line 58 at r1 (raw file):
private static final String BINDIGIT_SEQUENCE = "[01]([']?+[01]++)*+"; private static final String POINT = "\\.";
Trailing whitespaces.
@guwirth Your change looks good to me (although I am not sure, that I understand it in detail). I am not available for reviews until the the 2nd week of January. I wish you happy new year! My best wishes to all contributors too! |
Good explanation is here: https://docs.oracle.com/javase/tutorial/essential/regex/quant.html. public static String opt(String regexpPiece) {
return regexpPiece + "?+";
}
public static String one2n(String regexpPiece) {
return regexpPiece + "++";
}
public static String o2n(String regexpPiece) {
return regexpPiece + "*+";
} |
This change is