-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: PromQL Rust Lexer #12
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #12 +/- ##
============================================
+ Coverage 47.80% 85.65% +37.85%
============================================
Files 11 11
Lines 341 1464 +1123
============================================
+ Hits 163 1254 +1091
- Misses 178 210 +32
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
I think I need a few days to review this PR, as I also need to compare this with the lexer in go. Does the title need to follow the conventional commits rules? We have an action for it. |
Yeah. I have integrated this action in #13 |
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 haven't checked the details of the lexer, so most comments are related to the code structure and styles.
This repo might need a |
Actually comments from @evenyag is greatly helpful. 👍 |
I planed to do the parse mod with unit test this week, leave the warning here will remind me to cover it. |
- func in token mod, directly use match arms - use char default method, instead of a hashmap - use for loop to asset_eq!(left, right) instead of assert!(all) reviewer: @evenyag
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.
Sorry for the delay. I've skimmed the code and tests. They are very concrete and look good to me 👍
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 haven't compared the codes with the Go version line by line, as I think we should guarantee it by adding more test cases to ensure we have the same behavior as the promql's lexer. Thus I decide to approve this PR.
* feat(lex): skeleton * refactor(lexer): use enum instead of trait object * lex: keyword_or_identifier * fix(ctx): pos, start, peek logic * refactor: fn -> Fn * refactor: move shift into Lexer * lexer: accept_string * lexer: duration, lable_selector * example: make example work with lexer * test: common test done * test(lex): more test cases * test(lex): unbalanced parentheses * test(lexer): subquery * test(lexer): more cases * test: token and production fn * misc(lex): modification based on review comments - don't expose some public methods - refactor test cases Reviewer: @evenyag Refs: #14 #15 * misc(lex): revision based on review comment - func in token mod, directly use match arms - use char default method, instead of a hashmap - use for loop to asset_eq!(left, right) instead of assert!(all) reviewer: @evenyag * misc(lex): use const instead of lazy_static * perf(token): use hashmap instead of match on &str * fix(lex): potential panic try to dec depth when depth is less than 1 * misc(lex): use usize instead of u8 for paren_depth * feat(lex): to check if backup is at the beginning of input * comment(lex): typo
Sorry, but this is a huge PR, and it's hard to review. Most of the work is to convert PromQL Lexer Go version into idiomatic Rust version.
What's included
What't to do next