[Issue 13538] New: Divide old C style syntax from D style grammar rule

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Sep 26 21:56:03 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13538

          Issue ID: 13538
           Summary: Divide old C style syntax from D style grammar rule
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P1
         Component: websites
          Assignee: nobody at puremagic.com
          Reporter: k.hara.pg at gmail.com

Current declaration grammar contains both D style syntax and C style one.

Decl:
    StorageClasses_opt BasicType Declarators ;

[snip]

Declarator:
    BasicType2_opt ( Declarator ) DeclaratorSuffixes_opt
    BasicType2_opt Identifier DeclaratorSuffixes_opt    // [x]

[snip]

DeclaratorSuffix:
    [ ]
    [ AssignExpression ]
    [ Type ]
    Parameters MemberFunctionAttributes_opt
    TemplateParameters Parameters MemberFunctionAttributes_opt Constraint_opt

The grammar [x] accept both:
   int[] var
and
   int var[]

But it's confusing, and hard to understand what the grammar will accept.
Instead of mixing C style grammar rules under the one "Declarator", I'd propose
to separate them into "AltDeclarator".

And finally we can easily say that the AltDeclarator will be deprecated.

--


More information about the Digitalmars-d-bugs mailing list