On 12/25/2013 04:57 PM, "Casper Færgemand" <[email protected]>" wrote:
 From http://dlang.org/declaration.html#Parameter

Parameter:
     InOutopt BasicType Declarator
     InOutopt BasicType Declarator ...
     InOutopt BasicType Declarator = DefaultInitializerExpression
     InOutopt Type
     InOutopt Type ...

How do I add a declarator to a parameter like "char * format"? I altered
the language specification to add a "InOutopt Type Declarator", but is
there another way? The specification overall is really good, but I've
found a few missing things elsewhere, and I'm wondering if it really is
missing or I'm missing the point. :P I can't see any way to add a
parameter name to something of type Type.

The following is a parse tree for char* format:

          Parameter
         /    |    \
        /     |     \
       /      |      \
      /   BasicType   \
 InOut_opt    |        \
          BasicTypeX   Declarator
              |       /   |      \
            'char'   / Identifier \
                    /     |       DeclaratorSuffixes_opt
                   /   'format'
                  /
           BasicType2Opt
                /
          BasicType2
              /
            '*'

I consider the grammar specification (as well as some details of what is valid syntax) to be quite inelegant, unnecessarily repetitive and inconvenient for parser generators, but I am not sure if a clean-up would be welcome.

Reply via email to