Release 3.3 Copyright ©1995 by NeXT Computer, Inc. All Rights Reserved.
B |
Reference Manual for the Objective C Language
This appendix presents a formal grammar for the Objective C extensions to the C language--as the Objective C language is implemented for the NEXTSTEP development environment. It adds to the grammar for ANSI standard C found in Appendix A of The C Programming Language (second edition, 1988) by Brian W. Kernighan and Dennis M. Ritchie, published by Prentice Hall, and should be read in conjunction with that book.
The Objective C extensions introduce some new symbols (such as class-interface), but also make use of symbols (such as function-definition) that are explained in the standard C grammar. The symbols mentioned but not explained here are listed below: |
compound statement | identifier | |
constant | parameter-type-list | |
declaration | string | |
declaration-list | struct-declaration-list | |
enum-specifier | struct-or-union | |
expression | typedef-name | |
function-definition | type-name |
Of these, identifier and string are undefined terminal symbols. Objective C adds no undefined terminal symbols of its own.
Two notational conventions used here differ from those used in The C Programming Language: |
![]() |
Literal symbols are shown in bold type. | |
![]() |
Brackets enclose optional elements and are in italic type. Literal brackets, like other literal symbols, are nonitalic and bold. |
Otherwise, this appendix follows the conventions of the C reference manual. Each part of the grammar consists of a symbol followed by a colon and an indented list of mutually-exclusive possibilities for expanding the symbol. For example: |
receiver:![]() ![]() ![]() |
However, there is an exception: Even though they're not mutually exclusive, the constituents of classes, categories, and protocols are listed on separate lines to clearly show the ordering of elements. For example: |
protocol-declaration:![]() ![]() ![]() ![]() |
This exception to the general rule is easily recognized since each list terminates with @end.
There are just four entry points where the Objective C language modifies the rules defined for standard C: |
![]() |
External declarations | |
![]() |
Type specifiers | |
![]() |
Type qualifiers | |
![]() |
Primary expressions |
This appendix is therefore divided into four sections corresponding to these points. Where a rule in the standard C grammar is modified by an Objective C extension, the entire rule is repeated in its modified form. |
External Declarations |
external-declaration:![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() class-interface: class-implementation: category-interface: category-implementation: protocol-declaration: class-declaration-list: class-list: protocol-reference-list: protocol-list: class-name: superclass-name: category-name: protocol-name: instance-variables: visibility-specification: interface-declaration-list: method-declaration: class-method-declaration: instance-method-declaration: implementation-definition-list: method-definition: class-method-definition: instance-method-definition: method-selector: unary-selector: keyword-selector: keyword-declarator: selector: method-type: |
Type Specifiers |
type-specifier:![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() struct-or-union-specifier: |
Type Qualifiers |
type-qualifier:![]() ![]() ![]() protocol-qualifier: |
Primary Expressions |
primary-expression:![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() message-expression: receiver: message-selector: keyword-argument-list: keyword-argument: selector-expression: selector-name: keyword-name-list: keyword-name: protocol-expression: encode-expression: |