Skip to content
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

grammar: use destructuring in Label #45

Merged
merged 2 commits into from
Mar 3, 2021
Merged

grammar: use destructuring in Label #45

merged 2 commits into from
Mar 3, 2021

Conversation

jcorbin
Copy link
Collaborator

@jcorbin jcorbin commented Mar 2, 2021

Adjacent to, but not blocking, eslint:recommended gate towards #15

Question about what look like a spurious / double [1] index preserved from prior @kriskowal

@jcorbin jcorbin requested a review from kriskowal March 2, 2021 04:10
grammar.js Outdated
const label = expression[1];
const [head, ...tail] = expression;
if (head === 'get') {
const label = tail[0];
Copy link
Member

Choose a reason for hiding this comment

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

Would even buy const [label] = tail.

grammar.js Outdated
const labelScope = scope.label(label);
} else if (head === 'call') {
const [label, ...args] = tail;
const labelScope = scope.label(label[1]); // XXX why the [1]?
Copy link
Member

Choose a reason for hiding this comment

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

This might be more clear with an assert(label[0] === 'get') present, since the expectation is that an expression like foo will parse into an S-expression AST like ['get', 'foo'].

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, I guess what confused me, is that the branch above is treating label there as an atom, where-as here it's deconstructed; but I guess the above branch just passes the s-expr through?

@jcorbin jcorbin merged commit f347644 into main Mar 3, 2021
@jcorbin jcorbin deleted the grammar_struct branch March 3, 2021 22:44
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.

2 participants