Skip to content

Cannot parse multi catch statement when catch keyword written after \n #724

Answered by maxbrunsfeld
QthCN asked this question in Q&A
Discussion options

You must be logged in to vote

This isn't a bug in Tree-sitter. It is correct to give you a \n token when it sees a newline after the catch block, because a \n token is valid in that position.

I'm not very familiar with kotlin, or its statement-termination rules. Is there any simple rule for determining when a newline should be interpreted as a statement-terminator? Allowing an optional \n between catch blocks might be a fine solution. Alternatively, you may need to define an external scanner that applies some arbitrary C code for deciding whether or not to create a \n token. That is what tree-sitter-javascript does, for example.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@QthCN
Comment options

Answer selected by QthCN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #724 on November 03, 2020 20:12.