next up previous
Next: Type names Up: Declarations Previous: Enumeration specifiers

Declarators

Each declarator declares one identifier in the member or ordinary identifier name space (Section 6.1.2.3 of the standard). An ordinary identifier may be either a type identifier or an identifier denoting an object or function. All three of these possibilities are given distinct contexts because they have distinct semantics.

The declarator may also create a type for the identifier it is declaring by modifying the type described by the Specifier in the containing declaration. Type creation is represented in the tree by the pointer_declarator, array_declarator, and function_declarator contexts.

Two contexts are distinguished for prarmeters: those definitely belonging to a function prototype, and those possibly belonging to a function definition. Parameters possible belonging to a function definition have different scopes than those belonging to a function prototype, and also parameters belonging to a function definition may be simple identifiers rather than declarations.

AST nodes[13]:

RULE: declarator      ::= TypeIdDef                                      END;
RULE: declarator      ::= IdDef                                          END;
RULE: declarator      ::= pointer_declarator                             END;
RULE: declarator      ::= array_declarator                               END;
RULE: declarator      ::= function_declarator                            END;

RULE: pointer_declarator  ::= '*' Specifiers declarator                  END;
RULE: array_declarator    ::= declarator '[' constant_expression ']'     END;
RULE: function_declarator ::= declarator '(' parameter_type_list ')'     END;
RULE: function_declarator ::= declarator '(' parameters ')'              END;

RULE: parameter_type_list       LISTOF ParameterType  | DotDotDot END;
RULE: parameters LISTOF parameter_id | ParameterType  | DotDotDot END;

RULE: ParameterType         ::= parameter_declaration                    END;

RULE: parameter_declaration ::= Specifiers ParameterDecl                 END;
RULE: parameter_declaration ::= Specifiers abstract_declarator           END;
RULE: parameter_declaration ::= Specifiers                               END;
RULE: DotDotDot             ::= '...'                                    END;
RULE: ParameterDecl         ::= declarator                               END;
This macro is defined in definitions 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, and 18.
This macro is invoked in definition 1.


next up previous
Next: Type names Up: Declarations Previous: Enumeration specifiers
2008-08-30