tree-sitter-c
tree-sitter-c copied to clipboard
Add full support for line continuations
Right now, I don't think C line continuations are fully supported. Sure, PR #29 added line continuation to extras
, and there is code in place to support line continuations in string literals and comments. But that only captures a tiny fraction of all possible uses. For example, this is valid C code for a function that returns 42:
i\
n\
t
bar(void){
return 4\
2;
}
I don't know if it is even possible to do this in tree-sitter (at least with basic methods); when implementing a C parser "by hand" the easiest way to handle it usually is to deal with it in the code which reads the input stream before passing the data to the tokenizer/lexer (of course care has to be taken to preserve line/column information).
Of course one can also consciously decide to not support this (most syntax highlighters out there don't seem to deal with this at all). Though then I think it'd be a good idea to document this explicitly.