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

Fix multi-statements in for initializer and update parts #27

Merged
merged 2 commits into from
Jul 2, 2019

Conversation

calixteman
Copy link
Contributor

echo 'void f() {
    int i, j, k, l;
    for (i = 0, j = 0, k = 0, l = 0; i < 1; i++, j++, k++, l++) { }
}' | gcc -x c -c -

is working

grammar.js Outdated
),
field('condition', optional($._expression)), ';',
field('update', optional(choice($._expression, $.comma_expression))),
field('update', commaSep($._expression)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Did comma_expression not work here? I would have thought it would work. I would also think that it would work for the initializer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right: I misread the recursive comma_expression.
And I thought it was better to have a "list" of initiliazers but when dumping the ast from clang, ',' is really a bin operator.

echo 'void f() {
    int i, j, k, l;
    for (i = 0, j = 0, k = 0, l = 0; i < 1; i++, j++, k++, l++) { }
}' | clang-9 -Xclang -ast-dump -x c -c -

So I'll update my patch.

@maxbrunsfeld maxbrunsfeld merged commit c578638 into tree-sitter:master Jul 2, 2019
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