-
-
Notifications
You must be signed in to change notification settings - Fork 131
Description
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-cpp
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version
)
No response
Describe the bug
Using tree-sitter-cpp
to validate all functions in my repository have comments. One of the macros, causes the comments to be swallowed
Steps To Reproduce/Bad Parse Tree
In my script I find all function_declarator
and iterate through the prev_sibling
collecting all immidiate nodes of type comment
. The macro INLINE
causes the constructor to be considered declaration
and thus it swallowed the comments before the destructor.
declaration b'INLINE CWibbling3DExplosion::CWibbling3DExplosion(\n\t\tconst CVector * a2,\n\t\tchar * a3,\n\t\ti32 a4,\n\t\ti32 a5,\n\t\ ti32 a6,\n\t\ti32 a7,\n\t\ti32 a8,\n\t\ti32 a9,\n\t\ti32 a10,\n\t\ti32 a11,\n\t\ti32 a12)\n\t: C3DExplosion(a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)\n{\n\tgWibblingExpCount++;\n}\n\n// @Ok\n// @Matching'
Expected Behavior/Parse Tree
Comments not be inside the declaration
node.
Repro
// @Ok
// @Matching
INLINE CWibbling3DExplosion::CWibbling3DExplosion(
const CVector * a2,
char * a3,
i32 a4,
i32 a5,
i32 a6,
i32 a7,
i32 a8,
i32 a9,
i32 a10,
i32 a11,
i32 a12)
: C3DExplosion(a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)
{
gWibblingExpCount++;
}
// @Ok
// @Matching
CWibbling3DExplosion::~CWibbling3DExplosion(void)
{
gWibblingExpCount--;
}