tree-sitter / tree-sitter/tree-sitter-cpp
bug: Parsing fails when identifiers are split across lines
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 453
- Forks
- 185
- PR merge metrics
- No merged PRs in 30d
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
When splitting identifiers across multiple lines tree-sitter fails to parse them, see the example code below. (As far as I know this is technically valid C++~)
Steps To Reproduce/Bad Parse Tree
- Go to https://tree-sitter.github.io/tree-sitter/playground
- Pase the sample code
- Observe the "ERROR" node in the
declaration [1, 0] - [9, 2]
Expected Behavior/Parse Tree
As far as I know this is valid C++ code and all three major compilers compile it without any warning, I would have expected tree-sitter being able to parse it.
Repro
// https://godbolt.org/z/z5Mjjhnq1
extern "C" {
static
i\
n\
t
FOO\
Ba\
r
=
3;
int qux();
int qux() {
return FOOBar;
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduced C++ example in the tree-sitter playground and compare its parse tree with the behavior of the compilers linked in the issue. Trace how the tree-sitter-cpp grammar handles identifiers split across escaped lines; done means the sample parses without an ERROR node.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100