tree-sitter-c icon indicating copy to clipboard operation
tree-sitter-c copied to clipboard

Add full support for line continuations

Open fingolfin opened this issue 5 years ago • 0 comments

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.

fingolfin avatar Dec 18 '19 13:12 fingolfin