Skip to content

Improve #pragma parsing #303

Open
Open
@tamasvajk

Description

@tamasvajk

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 ....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions