dotnet / csharpstandard

Working space for ECMA-TC49-TG2, the C# standard committee.
Creative Commons Attribution 4.0 International
724 stars 86 forks source link

Misleading preprocessor specification with mandatory whitespace. #298

Open miniwolf opened 5 years ago

miniwolf commented 5 years ago

Following this specification as seen in here: https://github.com/dotnet/csharplang/blob/master/spec/lexical-structure.md For preprocessor directive it is specified that this is the specification:

pp_if_section
    : whitespace? '#' whitespace? 'if' whitespace pp_expression pp_new_line conditional_section?
    ;

This must mean that something like: #if(ANDROID) && !(WINDOWS) Should not be correct as '(' is not defined in whitespace, which is mandatory in the specification:

whitespace
    : '<Any character with Unicode class Zs>'
    | '<Horizontal tab character (U+0009)>'
    | '<Vertical tab character (U+000B)>'
    | '<Form feed character (U+000C)>'
    ;

However this will pass in the .NET compiler.

So it seems like an : whitespace? '#' whitespace? 'if' can be followed by a '!', '(' or a whitespace.

BillWagner commented 3 years ago

Moving to dotnet/csharpstandard