wrong affinity of pointer-star in function type #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
source
actual parse tree
actual affinity:
void (* some_function)expected affinity:
(void *) some_functionactual vs expected parse tree
same bug in tree-sitter-cpp, see playground
expected parse tree per clang
This BNF grammar also seems to group the
*under the declarator, so I'm not sure this is a bug as such.then that grammar is wrong too.
other grammars:
for my case (cpp2js transpiler) i also care about semantics, so i use the
clangparser as referenceparsing the example code
void* some_function() {}as "pointer declarator" does not make sensean actual "pointer declarator" should be called "function pointer declarator"
declaration and call need parens for
(*function_name)That seems like a very blunt dismissal of a generally respected resource. I don't see the structure you are proposing in https://github.com/antlr/grammars-v4/tree/master/cpp either. C++ is extremely weird to parse, so the parse tree and the abstract syntax tree in Clang differing is not terribly surprising. I don't have the expertise on this language to make a definite call here, but I am not prepared to merge this change without a much more solid rationale for it.
these are simple function-pointers in C
thats because im 100% sure (edit: at least im sure that cpp.lezer is wrong here)
if you remove the parens around
(*funcion_name)in my examplethen the pointer-star is left-associative, and compilation fails:
is an error, because in a
structC expects a function-pointerso ...
problem: pointer-star is right-associative
expected: pointer-star is left-associative
I'm going to decline this until you can provide a (somewhat authoritative) grammar that works this way, on the assumption that deviating from the grammars we were working from is certainly going to cause obscure regressions.
your decision was correct, also confirmed by https://github.com/tree-sitter/tree-sitter-c/issues/129#issuecomment-2113033597
apparently
clangalso does some semantic processing, not just parsing