Formation the D programming language specification

Cours the D programming language specification, tutoriel & guide de travaux pratiques en pdf.

Grammar

Here is a grammar for D.
program ::= function-def | program function-def
function-def ::= int id ( ) { statements }
| int id ( parameters ) { statements }
| int id ( ) { declarations statements }
| int id ( parameters ) { declarations statements } parameters ::= parameter | parameters , parameter parameter ::= int id
declarations ::= declaration | declarations declaration declaration ::= int id ;
statements ::= statement | statements statement statement ::= id = exp ; | return exp ; | { statements }
| if ( bool-exp ) statement | if ( bool-exp ) statement else statement | while ( bool-exp ) statement
bool-exp ::= rel-exp | ! ( rel-exp )
rel-exp ::= exp == exp | exp > exp
exp ::= term | exp + term | exp – term
term ::= factor | term * factor
factor ::= id | int | ( exp ) | id ( ) | id ( exps )
exps ::= exp | exps , exp

Language Notes

A program consists of one or more function definitions, all of which must have distinct names, and one of which must be named main. A program is executed by evaluating main().
Comments, blanks, and other whitespace are ignored except as needed to separate adjacent syntactic tokens. A comment begins with the token // and continues to the end of the line.
There are two undefined nonterminals in the grammar: id and int. An integer, int , consists of 1 or more digits (0-9) and denotes a decimal integer. An identifier, id, must begin with a letter, and consists of 1 or more letters, digits, and underscores. Upper- and lower-case letters are distinct, thus aa, AA, Aa, and aA are four different identifiers.
The keywords in the grammar (int, if, etc.) are reserved and may not be used as identifiers.
All integer values are 32-bit, two’s complement numbers.
D includes binary arithmetic operators +, -, and *. There is no division operator or unary + or – operators. The value -n can be computed by evaluating 0-n.

Cours gratuitTélécharger le cours complet

Télécharger aussi :

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *