diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/compiler/differences-between-standard-ecma-367-and-eiffel-software-implementation.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/compiler/differences-between-standard-ecma-367-and-eiffel-software-implementation.wiki index fe5f1ef8..5533df0c 100644 --- a/documentation/current/eiffelstudio/eiffelstudio-reference/compiler/differences-between-standard-ecma-367-and-eiffel-software-implementation.wiki +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/compiler/differences-between-standard-ecma-367-and-eiffel-software-implementation.wiki @@ -45,6 +45,22 @@ | Yes |} +==Design by Contract== +{| +|- +|
'''Feature'''
+|
'''Example'''
+|
'''ETL2'''
+|
'''ECMA-367'''
+|
'''EiffelStudio'''
+|- +| Only postcondition clauses +| ensure only a, b +| No +| Yes +| No +|} + ==Genericity== {| |- diff --git a/documentation/current/method/quick-reference-eiffel-programming-language/eiffel-programming-language-syntax.wiki b/documentation/current/method/quick-reference-eiffel-programming-language/eiffel-programming-language-syntax.wiki index af9400e4..2060b10f 100644 --- a/documentation/current/method/quick-reference-eiffel-programming-language/eiffel-programming-language-syntax.wiki +++ b/documentation/current/method/quick-reference-eiffel-programming-language/eiffel-programming-language-syntax.wiki @@ -7,21 +7,63 @@ -The syntax specification is shown here as it is in the standard document. The format is BNF-E. The Language Specification section of the standard document includes an overview of BNF-E. +The syntax specification is shown here as a less complete and formal version of that which is in the standard document. The format is BNF-E. The Language Specification section of the standard document includes an overview of BNF-E. +There are a few parts of the syntax that are either non-production or non-representable in BNF-E. Some of these have been omitted from the following specification. These omitted parts of the syntax definition add to the precision of the specification, but knowledge of them is not always vital for developers. -==Eiffel Syntax== +__TOC__ -There are a few parts of the syntax that are either non-production or non-representable in BNF-E which have been omitted from the following specification. These omitted parts of the syntax definition add to the precision of the specification, but knowledge of them is not always vital for developers. +The following section contains those non-production elements of the specification that are used later in the BNF-E specification. -Probably the most important to developers is the definition of an ''identifier'': +==Eiffel non-production elements== ===Identifiers=== -An '''identifier''' is a sequence of one or more alpha_numeric characters of which the first is a letter. +An '''identifier''' is a sequence of one or more alphanumeric [[#Characters|characters]] of which the first is a letter. The definition is augmented by the rule that Identifiers are not valid if they are the same as one of the language's reserved words. +===Characters=== + +Characters are either: + +* All 32-bit, corresponding to Unicode and to the Eiffel type CHARACTER_32. +* All 8-bit, corresponding to 8-bit extended ASCII and to the Eiffel type CHARACTER_8 + +===Reals=== + +A real -- specimen of Real -- is made of the following elements, in the order given: + +* An optional decimal [[#Integers|Integer]], giving the integral part. +* A required "." (dot). +* An optional decimal [[#Integers|Integer]], giving the fractional part. +* An optional exponent, which is the letter ''e'' or ''E'' followed by an optional [[#Manifest constants|Sign]] and a decimal [[#Integers|Integer]]. + +No intervening character (blank or otherwise) is permitted between these elements. The integral and fractional parts may not both be absent. + +===Strings=== + +A string -- specimen of construct String -- is a sequence of zero or more manifest characters. + +===Simple strings=== + +A simple string -- specimen of Simple_string -- is a [[#Strings|String]] consisting of at most one line (that is to say, containing now embedded new-line manifest character). + +===Line wrapping parts=== + +A sequence of characters consisting of the following, in order: +* % (percent character) +* Zero or more blanks or tabs +* New line (Line feed) +* Zero or more blanks or tabs +* % (percent character) + +Line wrapping parts are used as separators between one [[#Simple strings|Simple_string]] and the next in a [[#Manifest strings|Basic_manifest_string]] so that the string can be split across lines. + + + +==Eiffel BNF-E Syntax== + ===Class names === Class_name ::= [[#Identfiers|Identifier]]

@@ -70,7 +112,7 @@ Feature_value ::= [Explicit_value]
[[[#Obsolete parts|Obsolete]]]
[[[#Feature parts|Header_comment]]]
[[[#Feature bodies|Attribute_or_routine]]]
-Explicit_value ::= "=" Manifest_constant
+Explicit_value ::= "=" [[#Manifest constants|Manifest_constant]]


===New feature lists === @@ -168,23 +210,23 @@ Local_declarations ::= local [[[#Formal argument a
===Instructions === Compound ::= {Instruction ";" …}*
-Instruction ::= [[#Creation instructions|Creation_instruction]] | [[#Feature calls|Call]] | Assignment | Assigner_call | Conditional | Multi_branch
-| Loop | Debug | Precursor | Check | Retry
+Instruction ::= [[#Creation instructions|Creation_instruction]] | [[#Feature calls|Call]] | [[#Assignments|Assignment]] | [[#Assigner calls|Assigner_call]] | [[#Conditionals|Conditional]] | [[#Multi-branch instructions|Multi_branch]]
+| [[#Loops|Loop]] | [[#Debug instructions|Debug]] | [[#Precursor|Precursor]] | [[#Check instructions|Check]] | [[#Rescue clauses|Retry]]


===Assertions === -Precondition ::= require [else] Assertion
-Postcondition ::= ensure [then] Assertion [Only]
+Precondition ::= require [else] Assertion
+Postcondition ::= ensure [then] Assertion [[[#"Only" postcondition clauses|Only]]]
Invariant ::= invariant Assertion
Assertion ::= {Assertion_clause ";" …}*
Assertion_clause ::= [Tag_mark] Unlabeled_assertion_clause
-Unlabeled_assertion_clause ::= Boolean_expression | Comment
+Unlabeled_assertion_clause ::= [[#Expressions|Boolean_expression]] | [[#Comments|Comment]]
Tag_mark ::= Tag ":"
Tag ::= [[#Identfiers|Identifier]]


===“Old” postcondition expressions === -Old ::= old Expression
+Old ::= old [[#Expressions|Expression]]


===“Only” postcondition clauses === @@ -192,15 +234,15 @@ Only ::= only [[[#Export adaptation|Feature_list]]

===Check instructions === -Check ::= check Assertion [Notes] end
+Check ::= check [[#Assertions|Assertion]] [[[#Notes|Notes]]] end


===Variants === -Variant ::= variant [Tag_mark] Expression
+Variant ::= variant [[[#Assertions|Tag_mark]]] [[#Expressions|Expression]]


===Precursor === -Precursor ::= Precursor [Parent_qualification] [Actuals]
+Precursor ::= Precursor [Parent_qualification] [[[#Actual arguments|Actuals]]]
Parent_qualification ::= "{" [[#Class names|Class_name]] "}"


@@ -213,53 +255,53 @@ Undefine ::= undefine [[#Export adaptation|Feature_list]]


===Types === -Type ::= Class_or_tuple_type | Formal_generic_name | Anchored
-Class_or_tuple_type ::= Class_type | Tuple_type
-Class_type ::= [Attachment_mark] [[#Class names|Class_name]] [Actual_generics]
+Type ::= Class_or_tuple_type | [[#Formal generic parameters|Formal_generic_name]] | Anchored
+Class_or_tuple_type ::= Class_type | [[#Tuple types|Tuple_type]]
+Class_type ::= [Attachment_mark] [[#Class names|Class_name]] [[[#Actual generic parameters|Actual_generics]]]
Attachment_mark ::= "?" | "!"
Anchored ::= [Attachment_mark] like Anchor
-Anchor ::= [[#Feature names|Feature_name]] | Current
+Anchor ::= [[#Feature names|Feature_name]] | Current


===Actual generic parameters === Actual_generics ::= "[" Type_list "]"
-Type_list ::= {Type "," …}+
+Type_list ::= {[[#Types|Type]] "," …}+


===Formal generic parameters === Formal_generics ::= "[" Formal_generic_list "]"
Formal_generic_list ::= {Formal_generic ","…}+
-Formal_generic ::= [frozen] Formal_generic_name [Constraint]
+Formal_generic ::= [frozen] Formal_generic_name [[[#Generic constraints|Constraint]]]
Formal_generic_name ::= [?] [[#Identfiers|Identifier]]


===Generic constraints === Constraint ::= "–>" Constraining_types [Constraint_creators]
Constraining_types ::= Single_constraint | Multiple_constraint
-Single_constraint ::= Type [Renaming]
-Renaming ::= [[#Rename clauses|Rename]] end
+Single_constraint ::= [[#Types|Type]] [Renaming]
+Renaming ::= [[#Rename clauses|Rename]] end
Multiple_constraint ::= "{" Constraint_list "}"
Constraint_list ::= {Single_constraint "," …}+
-Constraint_creators ::= create [[#Export adaptation|Feature_list]] end
+Constraint_creators ::= create [[#Export adaptation|Feature_list]] end


===Tuple types === Tuple_type ::= TUPLE [Tuple_parameter_list]
Tuple_parameter_list ::= "[" Tuple_parameters "]"
-Tuple_parameters ::= Type_list | [[#Formal argument and entity declarations|Entity_declaration_list]]
+Tuple_parameters ::= [[#Actual generic parameters|Type_list]] | [[#Formal argument and entity declarations|Entity_declaration_list]]


===Manifest tuples === Manifest_tuple ::= "[" Expression_list "]"
-Expression_list ::= {Expression "," …}*
+Expression_list ::= {[[#Expressions|Expression]] "," …}*


===Converter clauses === Converters ::= convert Converter_list
Converter_list ::= {Converter ","…}+
Converter ::= Conversion_procedure | Conversion_query
-Conversion_procedure ::= [[#Feature names|Feature_name]] "(" "{" Type_list "}" ")"
-Conversion_query ::= [[#Feature names|Feature_name]] ":" "{" Type_list "}"
+Conversion_procedure ::= [[#Feature names|Feature_name]] "(" "{" [[#Actual generic parameters|Type_list]] "}" ")"
+Conversion_query ::= [[#Feature names|Feature_name]] ":" "{" [[#Actual generic parameters|Type_list]] "}"


===Select clauses === @@ -269,34 +311,34 @@ Select ::= select [[#Export adaptation|Feature_list]]
===Conditionals === Conditional ::= if Then_part_list [Else_part] end
Then_part_list ::= {Then_part elseif …}+
-Then_part ::= Boolean_expression then [[#Instructions|Compound]]
+Then_part ::= [[#Expressions|Boolean_expression]] then [[#Instructions|Compound]]
Else_part ::= else [[#Instructions|Compound]]


===Multi-branch instructions === -Multi_branch ::= inspect Expression [When_part_list] [Else_part] end
+Multi_branch ::= inspect [[#Expressions|Expression]] [When_part_list] [Else_part] end
When_part_list ::= When_part+
When_part ::= when Choices then [[#Instructions|Compound]]
Choices ::= {Choice "," …}+
-Choice ::= Constant | Manifest_type | Constant_interval | Type_interval
-Constant_interval ::= Constant ".." Constant
-Type_interval ::= Manifest_type ".." Manifest_type
+Choice ::= [[#Constants|Constant]] | [[#Manifest constants|Manifest_type]] | Constant_interval | Type_interval
+Constant_interval ::= [[#Constants|Constant]] ".." [[#Constants|Constant]]
+Type_interval ::= [[#Manifest constants|Manifest_type]] ".." [[#Manifest constants|Manifest_type]]


===Loops === Loop ::= Initialization
-[Invariant]
+[[[#Assertions|Invariant]]]
Exit_condition
Loop_body
-[Variant]
+[[[#Variants|Variant]]]
end
Initialization ::= from [[#Instructions|Compound]]
-Exit_condition ::= until Boolean_expression
+Exit_condition ::= until [[#Expressions|Boolean_expression]]
Loop_body ::= loop [[#Instructions|Compound]]


===Debug instructions === -Debug ::= debug [ "("Key_list ")" ] [[#Instructions|Compound]] end
+Debug ::= debug [ "("[[#Routine_bodies|Key_list]] ")" ] [[#Instructions|Compound]] end


===Attribute bodies === @@ -322,99 +364,99 @@ Creation_procedure ::= [[#Feature names|Feature_name]]

===Creation instructions === Creation_instruction ::= create [Explicit_creation_type] Creation_call
-Explicit_creation_type ::= "{" Type "}"
-Creation_call ::= Variable [Explicit_creation_call]
-Explicit_creation_call ::= "." Unqualified_call
+Explicit_creation_type ::= "{" [[#Types|Type]] "}"
+Creation_call ::= [[#Entities and variables|Variable]] [Explicit_creation_call]
+Explicit_creation_call ::= "." [[#Feature calls|Unqualified_call]]


===Creation expressions === -Creation_expression ::= create Explicit_creation_type [Explicit_creation_call]
+Creation_expression ::= create [[#Creation instructions|Explicit_creation_type]] [[[#Creation instructions|Explicit_creation_call]]]


===Equality expressions === -Equality ::= Expression Comparison Expression
+Equality ::= [[#Expressions|Expression]] Comparison [[#Expressions|Expression]]
Comparison ::= "=" | "/=" | "~" | "/~"


===Assignments === -Assignment ::= Variable ":=" Expression
+Assignment ::= [[#Entities and variables|Variable]] ":=" [[#Expressions|Expression]]


===Assigner calls === -Assigner_call ::= Expression ":=" Expression
+Assigner_call ::= [[#Expressions|Expression]] ":=" [[#Expressions|Expression]]


===Feature calls === Call ::= Object_call | Non_object_call
Object_call ::= [Target "."] Unqualified_call
-Unqualified_call ::= [[#Feature names|Feature_name]] [Actuals]
-Target ::= Local | Read_only | Call | Parenthesized_target
-Parenthesized_target ::= "( |" Expression "| )"
-Non_object_call ::= "{" Type "}" "." Unqualified_call
+Unqualified_call ::= [[#Feature names|Feature_name]] [[[#Actual arguments|Actuals]]]
+Target ::= [[#Entities and variables|Local]] | [[#Entities and variables|Read_only]] | Call | Parenthesized_target
+Parenthesized_target ::= "( |" [[#Expressions|Expression]] "| )"
+Non_object_call ::= "{" [[#Types|Type]] "}" "." Unqualified_call


===Actual arguments === Actuals ::= "(" Actual_list ")"
-Actual_list ::= {Expression "," …}+
+Actual_list ::= {[[#Expressions|Expression]] "," …}+


===Object test === -Object_test ::= "{" [[#Identfiers|Identifier]] ":" Type "}" Expression
+Object_test ::= "{" [[#Identfiers|Identifier]] ":" [[#Types|Type]] "}" [[#Expressions|Expression]]


===Rescue clauses === Rescue ::= rescue [[#Instructions|Compound]]
-Retry ::= retry
+Retry ::= retry


===Agents === Agent ::= Call_agent | Inline_agent
-Call_agent ::= agent Call_agent_body
-Inline_agent ::= agent [[[#Formal argument and entity declarations|Formal_arguments]]] [[[#Feature declarations|Type_mark]]] [[[#Feature bodies|Attribute_or_routine]]] [Agent_actuals]
+Call_agent ::= agent [[#Call agent bodies|Call_agent_body]]
+Inline_agent ::= agent [[[#Formal argument and entity declarations|Formal_arguments]]] [[[#Feature declarations|Type_mark]]] [[[#Feature bodies|Attribute_or_routine]]] [[[#Call agent bodies|Agent_actuals]]]


===Call agent bodies === Call_agent_body ::= Agent_qualified | Agent_unqualified
Agent_qualified ::= Agent_target ". " Agent_unqualified
Agent_unqualified ::= [[#Feature names|Feature_name]] [Agent_actuals]
-Agent_target ::= Entity | Parenthesized | Manifest_type
+Agent_target ::= Entity | Parenthesized | [[#Manifest constants|Manifest_type]]
Agent_actuals ::= "(" Agent_actual_list ")"
Agent_actual_list ::= {Agent_actual "," …}+
-Agent_actual ::= Expression | Placeholder
-Placeholder ::= [Manifest_type] "?"
+Agent_actual ::= [[#Expressions|Expression]] | Placeholder
+Placeholder ::= [[[#Manifest constants|Manifest_type]]] "?"


===Expressions === Expression ::= Basic_expression | Special_expression
-Basic_expression ::= Read_only | Local | [[#Feature calls|Call]] | Precursor | Equality | Parenthesized | Old |
-Operator_expression | Bracket_expression | Creation_expression
-Special_expression ::= Manifest_constant | Manifest_tuple | Agent | Object_test | Once_string |
+Basic_expression ::= [[#Entities and variables|Read_only]] | [[#Entities and variables|Local]] | [[#Feature calls|Call]] | [[#Precursor|Precursor]] | [[#Equality expressions|Equality]] | Parenthesized | [[#"Old" postcondition expressions|Old]] |
+[[#Operator expressions|Operator_expression]] | [[#Bracket expressions|Bracket_expression]] | [[#Creation expression|Creation_expression]]
+Special_expression ::= [[#Manifest constants|Manifest_constant]] | [[#Manifest tuples|Manifest_tuple]] | [[#Agents|Agent]] | [[#Object test|Object_test]] | Once_string |
Address
Parenthesized ::= "(" Expression ")"
-Address ::= "$" Variable
+Address ::= "$" [[#Entities and variables|Variable]]
Once_string ::= once [[#Manifest strings|Manifest_string]]
-Boolean_expression ::= Basic_expression | Boolean_constant | Object_test
+Boolean_expression ::= Basic_expression | [[#Manifest constants|Boolean_constant]] | [[#Object test|Object_test]]


===Operator expressions === Operator_expression ::= Unary_expression | Binary_expression
Unary_expression ::= Unary Expression
-Binary_expression ::= Expression Binary Expression
+Binary_expression ::= [[#Expressions|Expression]] [[#Operators|Binary]] [[#Expressions|Expression]]


===Bracket expressions === -Bracket_expression ::= Bracket_target "[" Actuals "]"
-Bracket_target ::= Target | Once_string | Manifest_constant | Manifest_tuple
+Bracket_expression ::= Bracket_target "[" [[#Actual arguments|Actuals]] "]"
+Bracket_target ::= [[#Feature calls|Target]] | [[#Expressions|Once_string]] | [[#Manifest constants|Manifest_constant]] | [[#Manifest tuples|Manifest_tuple]]


===Constants === -Constant ::= Manifest_constant | Constant_attribute
+Constant ::= [[#Manifest constants|Manifest_constant]] | Constant_attribute
Constant_attribute ::= [[#Feature names|Feature_name]]


===Manifest constants === Manifest_constant ::= [Manifest_type] Manifest_value
-Manifest_type ::= "{" Type "}"
+Manifest_type ::= "{" [[#Types|Type]] "}"
Manifest_value ::= Boolean_constant |
Character_constant |
Integer_constant |
@@ -422,23 +464,23 @@ Real_constant |
[[#Manifest strings|Manifest_string]] |
Manifest_type
Sign ::= "+" | "–"
-Integer_constant ::= [Sign] Integer
-Character_constant ::= " ' " Character " ' "
+Integer_constant ::= [Sign] [[#Integers|Integer]]
+Character_constant ::= " ' " [[#Characters|Character]] " ' "
Boolean_constant ::= True | False
-Real_constant ::= [Sign] Real
+Real_constant ::= [Sign] [[#Reals|Real]]


===Manifest strings === Manifest_string ::= Basic_manifest_string | Verbatim_string
Basic_manifest_string ::= ' " ' String_content ' " '
-String_content ::= {Simple_string Line_wrapping_part …}+
+String_content ::= {[[#Simple strings|Simple_string]] [[#Line wrapping parts|Line_wrapping_part]] …}+
Verbatim_string ::= Verbatim_string_opener Line_sequence Verbatim_string_closer
-Verbatim_string_opener ::= ' " ' [Simple_string] Open_bracket
-Verbatim_string_closer ::= Close_bracket [Simple_string] ' " '
+Verbatim_string_opener ::= ' " ' [[[#Simple strings|Simple_string]]] Open_bracket
+Verbatim_string_closer ::= Close_bracket [[[#Simple strings|Simple_string]]] ' " '
Open_bracket ::= "[" | "{"
Close_bracket ::= "]" | "}"Verbatim_string ::= Verbatim_string_opener Line_sequence Verbatim_string_closer
-Verbatim_string_opener ::= ' " ' [Simple_string] Open_bracket
-Verbatim_string_closer ::= Close_bracket [Simple_string] ' " '
+Verbatim_string_opener ::= ' " ' [[[#Simple strings|Simple_string]]] Open_bracket
+Verbatim_string_closer ::= Close_bracket [[[#Simple strings|Simple_string]]] ' " '
Open_bracket ::= "[" | "{"
Close_bracket ::= "]" | "}"

@@ -451,7 +493,7 @@ External_name ::= alias [[#Manifest strings|Manifest_string]]


===Registered languages === -Registered_language ::= C_external | C++_external | DLL_external
+Registered_language ::= [[#C externals|C_external]] | [[#C++ externals|C++_external]] | [[#DLL externals|DLL_external]]


===External signatures === @@ -493,7 +535,7 @@ DLL_identifier
[External_file_use]
' " '
DLL_identifier ::= Simple_string
-DLL_index ::= Integer
+DLL_index ::= [[#Integers|Integer]]


===Comments ===