Function declaration
Timon Gehr
timon.gehr at gmx.ch
Wed Dec 25 14:28:05 PST 2013
On 12/25/2013 04:57 PM, "Casper Færgemand" <shorttail at hotmail.com>" 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.
More information about the Digitalmars-d-learn
mailing list