Skip to content

Parser: Add 'skipKeyword' function #1545

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

Merged
merged 1 commit into from
Oct 5, 2018

Conversation

IvanGoncharov
Copy link
Member

based on 'expectOptionalKeyword' from #1541

based on 'expectOptionalKeyword' from graphql#1541
@IvanGoncharov
Copy link
Member Author

@OlegIlyenko I had a few review comment about expectOptionalKeyword from #1541 but didn't want increase the scope of this PR so I extracted it out.
Can you please take a look?

*/
function expectKeyword(lexer: Lexer<*>, value: string): Token {
function skipKeyword(lexer: Lexer<*>, value: string): boolean {
Copy link
Member Author

Choose a reason for hiding this comment

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

Since we already have skip/expect pair with matching functionality I think we need to have skipKeyword/expectKeyword.

Copy link
Contributor

@mjmahone mjmahone left a comment

Choose a reason for hiding this comment

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

This makes sense. Thanks!

@OlegIlyenko
Copy link
Contributor

OlegIlyenko commented Oct 4, 2018

I found the terminology around "skip" a bit confusing. "skip" by itself does not imply that the token is optional. So when i saw the usage of skip function it was a bit misleading.

I personally believe that this part of code might benefit from skip + skipOptional + keyword and "expect" alternatives. Purely based on the names, I understood "expect" as something to be used in cases where I'm interested in the token value and "skip" for cases when I just want to jump over the token, but I'm not interested in its value.

Just my 2 cents.

@IvanGoncharov IvanGoncharov merged commit 26c9874 into graphql:master Oct 5, 2018
@IvanGoncharov IvanGoncharov deleted the expectOptionalKeyword branch October 5, 2018 15:38
IvanGoncharov added a commit to IvanGoncharov/graphql-js that referenced this pull request Oct 5, 2018
IvanGoncharov added a commit to IvanGoncharov/graphql-js that referenced this pull request Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants