Google

"http://www.w3.org/TR/REC-html40/loose.dtd"> Grammar Previous Contents Next

D   Grammar





The grammar of Cyclone is derived from ISO C99. It has the following additional keywords: abstract, catch, codegen, cut, fallthru, fill, let, malloc, namespace, new, NULL, region_t, regions, rmalloc, rnew, splice, throw, try, tunion, using, xtunion. As in gcc, __attribute__ is reserved as well.

The non-terminals character-constant, floating-constant, identifier, integer-constant, string, type-var, and typedef-name are defined lexically as in C.

The start symbol is translation-unit.


Jump to: 
declaration struct-or-union-specifier tunion-specifier statement expression declarator pattern


translation-unit:
(empty)
external-declaration translation-unitopt
using identifier ; translation-unit
namespace identifier ; translation-unit
using identifier { translation-unit } translation-unit
namespace identifier { translation-unit } translation-unit
extern string { translation-unit } translation-unit
external-declaration:
function-definition
declaration
function-definition:
declaration-specifiersopt declarator
declaration-listopt compound-statement
declaration:
declaration-specifiers init-declarator-listopt ;
let pattern = expression ;
let identifier-list ;
declaration-list:
declaration
declaration-list declaration
declaration-specifiers:
storage-class-specifier declaration-specifiersopt
type-specifier declaration-specifiersopt
type-qualifier declaration-specifiersopt
function-specifier declaration-specifiersopt
storage-class-specifier: one of
auto   register   static   extern   typedef   abstract
type-specifier:
_
void
char
short
int
long
float
double
signed
unsigned
enum-specifier
struct-or-union-specifier
tunion-specifier
typedef-name type-paramsopt
type-var
type-var :: kind
$( parameter-list )
region_t < any-type-name >
kind:
identifier
typedef-name
type-qualifier: one of
const   restrict   volatile
enum-specifier:
enum identifier { enum-declaration-list }
enum identifier
enum-field:
identifier
identifier = constant-expression
enum-declaration-list:
enum-field
enum-field , enum-declaration-list
function-specifier:
inline
struct-or-union-specifier:
struct-or-union { struct-declaration-list }
struct-or-union identifier type-paramsopt { struct-declaration-list }
struct-or-union identifier type-paramsopt
type-params:
< type-name-list >
struct-or-union: one of
struct   union
struct-declaration-list:
struct-declaration
struct-declaration-list struct-declaration
init-declarator-list:
init-declarator
init-declarator-list , init-declarator
init-declarator:
declarator
declarator = initializer
struct-declaration:
specifier-qualifier-list struct-declarator-list ;
specifier-qualifier-list:
type-specifier specifier-qualifier-listopt
type-qualifier specifier-qualifier-listopt
struct-declarator-list:
struct-declarator
struct-declarator-list , struct-declarator
struct-declarator:
declarator
declaratoropt : constant-expression
tunion-specifier:
tunion-or-xtunion identifier type-paramsopt { tunionfield-list }
tunion-or-xtunion regionopt identifier type-paramsopt
tunion-or-xtunion identifier . identifier type-paramsopt
tunion-or-xtunion: one of
tunion   xtunion
tunionfield-list:
tunionfield
tunionfield ;
tunionfield , tunionfield-list
tunionfield ; tunionfield-list
tunionfield-scope: one of
extern   static
tunionfield:
tunionfield-scope identifier
tunionfield-scope identifier type-paramsopt ( parameter-list )
declarator:
pointeropt direct-declarator
direct-declarator:
identifier
( declarator )
direct-declarator [ assignment-expressionopt ]
direct-declarator ( parameter-type-list )
direct-declarator ( ; effect-set )
direct-declarator ( identifier-listopt )
direct-declarator < type-name-list >
pointer:
* rangeopt regionopt type-qualifier-listopt pointeropt
@ rangeopt regionopt type-qualifier-listopt pointeropt
? regionopt type-qualifier-listopt pointeropt
range:
{ assignment-expression }
region:
_
'H
type-var
type-var :: kind
type-qualifier-list:
type-qualifier
type-qualifier-list type-qualifier
parameter-type-list:
parameter-list
parameter-list , ...
optional-effect:
(empty)
; effect-set
optional-inject:
(empty)
identifier
effect-set:
atomic-effect
atomic-effect + effect-set
atomic-effect:
{ }
{ region-set }
type-var
type-var :: kind
region-set:
type-var
type-var , region-set
type-var :: kind
type-var :: kind , region-set
parameter-list:
parameter-declaration
parameter-list , parameter-declaration
parameter-declaration:
specifier-qualifier-list declarator
specifier-qualifier-list abstract-declaratoropt
identifier-list:
identifier
identifier-list , identifier
initializer:
assignment-expression
array-initializer
array-initializer:
{ initializer-listopt }
{ initializer-list , }
{ for identifier < expression : expression }
initializer-list:
designationopt initializer
initializer-list , designationopt initializer
designation:
designator-list =
designator-list:
designator
designator-list designator
designator:
[ constant-expression ]
. identifier
type-name:
specifier-qualifier-list abstract-declaratoropt
any-type-name:
type-name
{ }
{ region-set }
any-type-name + atomic-effect
type-name-list:
type-name
type-name-list , type-name
abstract-declarator:
pointer
pointeropt direct-abstract-declarator
direct-abstract-declarator:
( abstract-declarator )
direct-abstract-declaratoropt [ assignment-expressionopt ]
direct-abstract-declaratoropt ( parameter-type-listopt )
direct-abstract-declaratoropt ( ; effect-set )
direct-abstract-declaratoropt [ ? ]
direct-abstract-declarator < type-name-list >
statement:
labeled-statement
expression-statement
compound-statement
selection-statement
iteration-statement
jump-statement
region identifier statement
region < type-var > identifier statement
cut statement
splice statement
labeled-statement:
identifier : statement
expression-statement:
expressionopt ;
compound-statement:
{ block-item-listopt }
block-item-list:
block-item
block-item block-item-list
block-item:
declaration
statement
selection-statement:
if ( expression ) statement
if ( expression ) statement else statement
switch ( expression ) { switch-clauses }
try statement catch { switch-clauses }
switch-clauses:
(empty)
default : block-item-list
case pattern : block-item-listopt switch-clauses
case pattern && expression : block-item-listopt switch-clauses
iteration-statement:
while ( expression ) statement
do statement while ( expression ) ;
for ( expressionopt ; expressionopt ; expressionopt ) statement
for ( declaration expressionopt ; expressionopt ) statement
jump-statement:
goto identifier ;
continue ;
break ;
return ;
return expression ;
fallthru ;
fallthru ( argument-expression-listopt ) ;
pattern:
_
( pattern )
integer-constant
- integer-constant
floating-constant
character-constant
NULL
identifier
identifier type-paramsopt ( tuple-pattern-list )
$( tuple-pattern-list )
identifier type-paramsopt { }
identifier type-paramsopt { field-pattern-list }
& pattern
* identifier
tuple-pattern-list:
(empty)
pattern
tuple-pattern-list , pattern
field-pattern:
pattern
designation pattern
field-pattern-list:
field-pattern
field-pattern-list , field-pattern
expression:
assignment-expression
expression , assignment-expression
assignment-expression:
conditional-expression
unary-expression assignment-operator assignment-expression
assignment-operator: one of
=   *=   /=   %=   +=   -=   <<=   >>=   &=   ^=   |=
conditional-expression:
logical-or-expression
logical-or-expression ? expression : conditional-expression
throw conditional-expression
new array-initializer
new logical-or-expression
rnew ( expression ) array-initializer
rnew ( expression ) logical-or-expression
constant-expression:
conditional-expression
logical-or-expression:
logical-and-expression
logical-or-expression || logical-and-expression
logical-and-expression:
inclusive-or-expression
logical-and-expression && inclusive-or-expression
inclusive-or-expression:
exclusive-or-expression
inclusive-or-expression | exclusive-or-expression
exclusive-or-expression:
and-expression
exclusive-or-expression ^ and-expression
and-expression:
equality-expression
and-expression & equality-expression
equality-expression:
relational-expression
equality-expression == relational-expression
equality-expression != relational-expression
relational-expression:
shift-expression
relational-expression < shift-expression
relational-expression > shift-expression
relational-expression <= shift-expression
relational-expression >= shift-expression
shift-expression:
additive-expression
shift-expression << additive-expression
shift-expression >> additive-expression
additive-expression:
multiplicative-expression
additive-expression + multiplicative-expression
additive-expression - multiplicative-expression
multiplicative-expression:
cast-expression multiplicative-expression * cast-expression
multiplicative-expression / cast-expression
multiplicative-expression % cast-expression
cast-expression:
unary-expression
( type-name ) cast-expression
unary-expression:
postfix-expression
++ unary-expression
-- unary-expression
unary-operator cast-expression
sizeof unary-expression
sizeof ( type-name )
expression . size
unary-operator: one of
&   *   +   -   ~  !
postfix-expression:
primary-expression
postfix-expression [ expression ]
postfix-expression ( )
postfix-expression ( argument-expression-list )
postfix-expression . identifier
postfix-expression -> identifier
postfix-expression ++
postfix-expression --
( type-name ) { initializer-list }
( type-name ) { initializer-list , }
fill ( expression )
codegen ( function-definition )
primary-expression:
identifier
constant
string
( expression )
identifier <>
identifier @ < type-name-list >
$( argument-expression-list )
identifier { initializer-list }
( { block-item-list } )
argument-expression-list:
assignment-expression
argument-expression-list , assignment-expression
constant:
integer-constant
character-constant
floating-constant
NULL

Previous Contents Next