Skip to content

Add parse_keyword_with_tokens for paring keyword and tokens combination#1141

Merged
alamb merged 2 commits intoapache:mainfrom
viirya:use_function
Feb 29, 2024
Merged

Add parse_keyword_with_tokens for paring keyword and tokens combination#1141
alamb merged 2 commits intoapache:mainfrom
viirya:use_function

Conversation

@viirya
Copy link
Copy Markdown
Member

@viirya viirya commented Feb 18, 2024

This is a simple follow up to #1134 to add a function parse_keyword_with_tokens to deal with the case that the parser expects keyword + token combination, instead of a mix of multiple peek_token, expect_keyword, expect_token calls.

Comment thread src/parser/mod.rs
match self.peek_token().token {
Token::Word(w) if expected == w.keyword => {
for (idx, token) in tokens.iter().enumerate() {
if self.peek_nth_token(idx + 1).token != *token {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a non-issue since tokens should always be small, but it seems worth noting that this is unnecessarily quadratic over the length of tokens due to the loop in peek_nth_token.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Added a note for that.

Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @viirya and @jmhain for the review

@alamb alamb merged commit f75bb4b into apache:main Feb 29, 2024
@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 8056633029

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 11 of 11 (100.0%) changed or added relevant lines in 1 file are covered.
  • 105 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.02%) to 87.671%

Files with Coverage Reduction New Missed Lines %
src/lib.rs 105 11.61%
Totals Coverage Status
Change from base Build 7915258585: -0.02%
Covered Lines: 19661
Relevant Lines: 22426

💛 - Coveralls

@viirya
Copy link
Copy Markdown
Member Author

viirya commented Feb 29, 2024

Thank you @alamb @jmhain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants