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

Error in source leads to very tall tree #118

Open
casouri opened this issue Nov 24, 2022 · 1 comment
Open

Error in source leads to very tall tree #118

casouri opened this issue Nov 24, 2022 · 1 comment

Comments

@casouri
Copy link

casouri commented Nov 24, 2022

I don't know if this is fixable or should be fixed, but in the following snippet, tree-sitter-c generates a very tall tree, which makes recursively traversing the tree very expensive and overflows the call stack. Querying a tall tree is also way slower.

static hf_register_info hf[] = {
#line 1 "./asn1/rrc/packet-rrc-hfarr.c"
   { &hf_rrc_DL_DCCH_Message_PDU,
     { "DL-DCCH-Message", "rrc.DL_DCCH_Message_element",
       FT_NONE, BASE_NONE, NULL, 0,
       NULL, HFILL }},
   { &hf_rrc_cellIdentity_c_id,
      {"Cell Identifier", "rrc.cellIdentity.c_id",
      FT_UINT32, BASE_DEC, NULL, 0,
      "The Cell Identifier (C-Id) part of the Cell Identity", HFILL }}
/* ... and tens of thousands of array initializers. */
 };

Tree-sitter-c considers the closing brackets in, eg, NULL, HFILL}} errors and skips them, turning a ~10k wide tree into a ~10k tall tree.

@amaanq
Copy link
Member

amaanq commented Aug 16, 2023

It's because of the #line directive, should that be added to the grammar?

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

No branches or pull requests

2 participants