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

Improve `#pragma` parsing

Open tamasvajk opened this issue 2 years ago • 0 comments

Invalid #pragma preprocessor directives produce warnings. The compiler is able to parse (and ignore) them. This is not the case currently with the tree-sitter grammar. For example the below produces an AST on sharplab.io:

#pragma warning disable 1     // Okay
#pragma warning disable CS1   // Okay
#pragma warning disable 1,2   // Okay

#pragma warning disable 1;2     // CS1696
#pragma warning suppress 1      // CS1634
#pragma                         // CS1633
#pragma anything can come here  // CS1633

;

I think these invalid directives come up fairly rarely. The only one that I've seen was #pragma warning suppress ....

tamasvajk avatar Apr 26 '23 10:04 tamasvajk