tree-sitter / tree-sitter-c-sharp

C# Grammar for tree-sitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve `#pragma` parsing

tamasvajk opened this issue · 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 ....