BNF Grammar for Tutorial D Language - Revision 3 ================================================ --p This is a provisional BNF grammar for the new version of the Tutorial D language. It is based on a draft of 'Databases, Types, and the Relational Model' by C J Date and H Darwen. This transcription uses text names for operators in place of these mathematical symbols: --/p --## --tr --th Text name --/th --th Unicode code point --/th --tr --tr --td SUBSET OF --/td --td U+2286 --/td --/tr --tr --td PROPER SUBSET OF --/td --td U+2282 --/td --/tr --tr --td SUPERSET OF --/td --td U+2287 --/td --/tr --tr --td PROPER SUPERSET OF --/td --td U+2283 --/td --/tr --tr --td ELEMENT OF --/td --td U+220A --/td --/tr --/table --p For details of the Unicode code points, see: --## http://www.unicode.org/charts/PDF/U2200.pdf --## . The Unicode names for these symbols are different from the names used above. For example, U+2287 is officially 'SUPERSET OF OR EQUAL TO'. --/p --p The plain text version of this file is available as --## d3.bnf . --/p --hr --h2 Key D Statements and Fragments --/h2 --bl --li Statement --li Update Operations --li Substitute Operations --/bl --hr --p Undefined terms include: --bl --li --li --li --li --li --li --li (tentative definition provided) --li (tentative definition provided) --/bl --hr --p Unreferenced terms include: --bl --li --li - which contains the only reference to --li - which contains the only reference to --li - which contains the only reference to --li --/bl --hr ::= CONSTRAINT ::= '(' [ ',' ] [ ',' ] ')' ::= COUNT | COUNTD | SUM | SUMD | AVG | AVGD | MAX | MIN | AND | OR | XOR | EXACTLY | EXACTLYD | UNION | D_UNION | INTERSECT ::= VAR ::= ::= COUNT '(' ')' ::= ::= VAR ARRAY ::= | | ::= ::= ::= FROM ::= ::= | ::= IS_ '(' ')' | IS_SAME_TYPE_AS '(' ',' ')' ::= '(' ')' ::= TREAT_AS_ '(' ')' | TREAT_AS_SAME_TYPE_AS '(' ',' ')' ::= BEGIN TRANSACTION ::= | | | | | ::= | | | | | | ::= !! Operations such as add, subtract, multiply, divide, concatenate, etc. ::= INTEGER | RATIONAL | CHARACTER | CHAR | BOOLEAN ::= | | | | | | ::= CALL ::= KEY '{' '}' ::= CASE ';' [ ELSE ] END CASE ::= COMMIT ::= COMPOSE ::= BEGIN ';' END ::= CONSTRAINT ::= DROP CONSTRAINT ::= | ::= '=' ::= POSSREP [ ] '{' '}' ::= ASC | DESC ::= DIVIDEBY ::= [ ':' ] DO ':=' TO ';' END DO ::= D_UNION ::= INTERSECT ::= JOIN ::= | | | | | | | | | ::= | ::= JOIN ::= UNION ::= | | ::= EXTEND ADD '(' ')' ::= AS ::= ':' ::= GROUP '(' ')' ::= '{' [ ALL BUT ] '}' AS ::= '{' '}' ::= IF THEN [ ELSE ] END IF ::= | ::= LEAVE ::= MINUS ::= | ::= | ::= | | | | | | | | | | ::= | | | | | ::= IS '{' '}' ::= D_UNION [ ] '{' '}' ::= INTERSECT [ ] '{' '}' ::= JOIN '{' '}' ::= | | | ::= ::= JOIN '{' '}' ::= UNION [ ] '{' '}' ::= AS ::= !! ... an empty string ::= ::= ::= '(' [ ',' ] ')' ::= | BY '{' [ ALL BUT ] '}' ::= [ ] ::= ::= | ::= CONSTRAINT ::= POSSREP [ ] '{' [ ] '}' ::= '(' ')' ::= | | | | | | | | | | | | | ::= PRIVATE | PUBLIC ::= '{' [ ALL BUT ] '}' ::= VAR REAL ::= ':=' | | | ::= ::= '=' | '!=' | SUBSET OF | SUPERSET OF | PROPER SUBSET OF | PROPER SUPERSET OF ::= DELETE [ WHERE ] ::= | ::= LOAD FROM ORDER '(' ')' ::= INSERT ::= | | '(' ')' ::= | ::= RELATION [ ] '{' '}' | TABLE_DUM | TABLE_DEE ::= LOAD FROM ::= | ::= '(' ')' ::= TREAT_AS_SAME_TYPE_AS '(' ')' | ::= | SAME_TYPE_AS '(' ')' | RELATION SAME_HEADING_AS '(' ')' ::= RELATION ::= | INIT '(' ')' ::= UPDATE [ WHERE ] '{' '}' ::= ':=' ::= | ::= DROP VAR ::= ::= WITH ':' ::= RENAME '(' ')' ::= AS | PREFIX AS | SUFFIX AS ::= RETURN [ ] ::= ROLLBACK ::= ':=' | ::= ::= '=' | '!=' | '<' |'<=' | '>' | '>=' ::= | ::= | | '(' ')' ::= | ::= | ::= '(' ')' ::= TREAT_AS_ '(' ')' | TREAT_AS_SAME_TYPE_AS '(' ',' ')' ::= | SAME_TYPE_AS '(' ')' ::= | ::= | INIT '(' ')' ::= UPDATE '{' '}' ::= ':=' ::= VAR ::= ::= WITH ':' ::= | | ::= SEMIJOIN ::= SEMIMINUS ::= IS '{' [ ] '}' ::= ';' ::= | | | | | | | | | | | | ::= UPDATE '{' '}' ::= SUMMARIZE [ ] ADD '(' ')' ::= AS ::= '(' [ ',' ] [ ] ')' ::= COUNT | COUNTD | SUM | SUMD | AVG | AVGD | MAX | MIN | AND | OR | XOR | EXACTLY | EXACTLYD | UNION | D_UNION | INTERSECT ::= SYNONYMS '{' '}' ::= TCLOSE ::= '(' ')' ::= ':=' | ::= | ELEMENT OF ::= '=' | '!=' ::= ::= COMPOSE ::= | | '(' ')' ::= EXTEND ADD '(' ')' ::= TUPLE FROM ::= | | '(' ')' ::= | ::= '{' [ ALL BUT ] '}' ::= RENAME '(' ')' ::= TUPLE '{' '}' ::= UPDATE '{' '}' ::= | ::= '(' ')' ::= TREAT_AS_SAME_TYPE_AS '(' ',' ')' | ::= | SAME_TYPE_AS '(' ')' | TUPLE SAME_HEADING_AS '(' ')' ::= TUPLE ::= | INIT '(' ')' ::= UNWRAP '(' ')' ::= UPDATE '{' '}' ::= VAR ::= ::= WITH ':' ::= WRAP '(' ')' ::= | | ::= IS_ '(' ')' | IS_SAME_TYPE_AS '(' ',' ')' ::= UNGROUP '(' ')' ::= ::= UNWRAP '(' ')' ::= ::= | ::= DROP OPERATOR ::= '(' ')' ::= OPERATOR '(' ')' RETURNS [ ] [ VERSION ] ';' [ ] END OPERATOR ::= TYPE [ ORDINAL ] [ UNION ] ::= TYPE [ ORDINAL ] [ UNION ] ::= | ::= DROP TYPE ::= OPERATOR '(' ')' UPDATES '{' '}' [ ] [ VERSION ] ';' [ ] END OPERATOR ::= VAR VIRTUAL '(' ')' ::= WHEN THEN ::= WHERE ::= [ ':' ] WHILE ';' END WHILE ::= WRAP '(' ')' ::= '{' [ ALL BUT ] '}' AS --hr --p The material from here down is not explicitly included in Appendix J, but are plausible rules inferred from the grammar there. This material does not supply the rules for the undefined references or rules that reference the unreferenced rules. --/p --h2 Object names --/h2 --p These are object names that are not given any further expansion in the Tutorial D grammar. It is assumed that they all map to identifiers, with the probable exception of that is more likely to map to a string or number. Note that the and values are constrained to start with 'THE_' and no other identifier is permitted to start with 'THE_'. Note too that the grammar contains a couple of references to each of TREAT_AS_ and IS_. These should be treated similarly to ; the values are constrained to start with the prefix and no other identifier is permitted to start with either 'IS_' or 'TREAT_AS_'. --/p ::= ::= ::= ::= ::= ::= ::= ::= ::= ::= ::= ::= ::= ::= ::= ::= !! See syntax rules --hr --h2 Comma lists --/h2 --p These are all non-empty lists of non-terminals where the different items are separated by commas. The book does not include these - it implies that they are available. --/p ::= | ',' ::= | | ',' ::= | ',' ::= | ',' ::= | ',' ::= | ',' ::= | ',' ::= | ',' POSSREP [ ] '{' '}' ::= | ',' ::= | ',' ::= | ',' ::= | ',' ::= | ',' ::= | ',' ::= | ',' ::= | ',' ::= | ',' ::= | . ',' ::= | ',' ::= | ',' ::= | ',' ::= | ',' ::= | ',' ::= | ',' --hr --h2 Non-comma lists --/h2 --p These are all non-empty lists of non-terminals where the different items are not separated by commas. The book does not include these - it implies that they are available. --/p ::= | ::= | ::= | ::= | ::= | --h2 --h2 Start Symbol --/h2 ::= ::= | --hr --h2 END OF TUTORIAL D GRAMMAR --/h2