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

bug: Treesitter unable to process __extension__ #215

Closed
2 tasks done
ashamedbit opened this issue Aug 3, 2024 · 0 comments · Fixed by #223
Closed
2 tasks done

bug: Treesitter unable to process __extension__ #215

ashamedbit opened this issue Aug 3, 2024 · 0 comments · Fixed by #223
Labels

Comments

@ashamedbit
Copy link

ashamedbit commented Aug 3, 2024

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues of tree-sitter-c

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

0.22.3

Describe the bug

Unable to get AST without error nodes for the following code which includes extension

Steps To Reproduce/Bad Parse Tree

The code that produces the bad parse tree is :
*to = (char_u)((__extension__ ({int c; c=0;})));

It produces following tree:

[translation_unit](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [1, 0]
  [expression_statement](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [0, 48]
    [assignment_expression](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [0, 45]
      left: [pointer_expression](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [0, 3]
        argument: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 1] - [0, 3]
      right: [call_expression](https://tree-sitter.github.io/tree-sitter/playground#) [0, 6] - [0, 45]
        function: [parenthesized_expression](https://tree-sitter.github.io/tree-sitter/playground#) [0, 6] - [0, 14]
          [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 7] - [0, 13]
        arguments: [argument_list](https://tree-sitter.github.io/tree-sitter/playground#) [0, 14] - [0, 45]
          [ERROR](https://tree-sitter.github.io/tree-sitter/playground#) [0, 15] - [0, 31]
            [type_qualifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 16] - [0, 29]
          [compound_statement](https://tree-sitter.github.io/tree-sitter/playground#) [0, 31] - [0, 44]
            [declaration](https://tree-sitter.github.io/tree-sitter/playground#) [0, 32] - [0, 38]
              type: [primitive_type](https://tree-sitter.github.io/tree-sitter/playground#) [0, 32] - [0, 35]
              declarator: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 36] - [0, 37]
            [expression_statement](https://tree-sitter.github.io/tree-sitter/playground#) [0, 39] - [0, 43]
              [assignment_expression](https://tree-sitter.github.io/tree-sitter/playground#) [0, 39] - [0, 42]
                left: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 39] - [0, 40]
                right: [number_literal](https://tree-sitter.github.io/tree-sitter/playground#) [0, 41] - [0, 42]
    [ERROR](https://tree-sitter.github.io/tree-sitter/playground#) [0, 45] - [0, 47]

Expected Behavior/Parse Tree

It should not have error nodes within the correct parse tree. As it is perfectly compilable code.

Repro

// Example code that causes the issue
void foo() {
  // Code that fails to parse, or causes an error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant