[[Property:modification_date|Tue, 30 Apr 2019 07:27:55 GMT]] [[Property:publication_date|Mon, 29 Apr 2019 14:08:51 GMT]] [[Property:title|Eiffel programming language syntax]] [[Property:link_title|Syntax]] [[Property:weight|0]] [[Property:uuid|4CB56AD5-1586-41F6-9E81-085F47E992DC]] The syntax specification shown here is a less complete and less formal version of that which is in the Eiffel ISO/ECMA 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. In the BNF-E representation, generally non-terminals which are defined in the same group of productions in which they are used are not linked. However when a non-terminal is defined outside a group in which it is used, it is linked to the group in which it is defined. __TOC__ The following section contains those non-production elements of the specification that are used later in the BNF-E specification. ==Eiffel non-production elements== ===Identifiers=== 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 no embedded new-line manifest character), possibly containing [[#Special characters|codes for special characters]]. ===Special characters=== {| border="2" |+ Special Characters and Their Codes |- ! Character ! Code ! Mnemonic name |- | @ || %A || At-sign |- | BS || %B || Backspace |- | ^ || %C || Circumflex |- | $ || %D || Dollar |- | FF || %F || Form feed |- | \ || %H || Backslash |- | ~ || %L || Tilde |- | NL (LF) || %N || Newline |- | `` ` `` || %Q || Backquote |- | CR || %R || Carriage return |- | # || %S || Sharp |- | HT || %T || Horizontal tab |- | NUL || %U || Null |- | | || %V || Vertical bar |- | % || %% || Percent |- | ' || %' || Single quote |- | " || %" || Double quote |- | [ || %( || Opening bracket |- | ] || %) || Closing bracket |- | { || %< || Opening brace |- | } || %> || Closing brace |} * `%/123/` represents the character with decimal code `123` . * And only for manifest character (for now) ** `'%/0x2200/'` represents the character with hexadecimal code U+2200 = '∀' (note `'%/0x2200/' = '%/8704/'` ) ** `'%/0c21000/'` in octal ** `'%/0b10001000000000/'` in binary ===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]] ===Class declarations === Class_declaration ::= [[[#Notes|Notes]]] [[#Class headers|Class_header]] [[[#Formal generic parameters|Formal_generics]]] [[[#Obsolete marks|Obsolete]]] [[[#Inheritance parts|Inheritance]]] [[[#Creators parts|Creators]]] [[[#Converter clauses|Converters]]] [[[#Feature parts|Features]]] [[[#Notes|Notes]]] [[[#Assertions|Invariant]]] [[[#Notes|Notes]]] end ===Notes === Notes ::= note Note_list Note_list ::= {Note_entry ";" ...}* Note_entry ::= Note_name Note_values Note_name ::= [[#Identifiers|Identifier]] ":" Note_values ::= {Note_item ","...}+ Note_item ::= [[#Identifiers|Identifier]] | [[#Manifest constants|Manifest_constant]] ===Class headers === Class_header ::= [Header_mark] class [[#Class names|Class_name]] Header_mark ::= deferred | expanded | frozen ===Obsolete marks === Obsolete ::= obsolete Message Message ::= [[#Manifest strings|Manifest_string]] ===Feature parts === Features ::= Feature_clause+ Feature_clause ::= feature [[[#Clients|Clients]]] [[[#Feature parts|Header_comment]]] Feature_declaration_list Feature_declaration_list ::= {[[#Feature declarations|Feature_declaration]] ";" ...}* Header_comment ::= [[#Comments|Comment]] ===Feature declarations === Feature_declaration ::= [[#New feature lists|New_feature_list]] Declaration_body Declaration_body ::= [[[#Formal argument and entity declarations|Formal_arguments]]] [Query_mark] [Feature_value] Query_mark ::= Type_mark [[[#Assigner marks|Assigner_mark]]] Type_mark ::= ":" [[#Types|Type]] Feature_value ::= [Explicit_value] [[[#Obsolete parts|Obsolete]]] [[[#Feature parts|Header_comment]]] [[[#Feature bodies|Attribute_or_routine]]] Explicit_value ::= "=" [[#Manifest constants|Manifest_constant]] ===New feature lists === New_feature_list ::= {New_feature "," ...}+ New_feature ::= [frozen] [[#Feature names|Extended_feature_name]] ===Feature bodies === Attribute_or_routine ::= [[[#Assertions|Precondition]]] [[[#Local variable declarations|Local_declarations]]] Feature_body [[[#Assertions|Postcondition]]] [[[#Rescue clauses|Rescue]]] end Feature_body ::= [[#Routine bodies|Deferred]] | [[#Routine bodies|Effective_routine]] | [[#Attribute bodies|Attribute]] ===Feature names === Extended_feature_name ::= Feature_name [Alias] Feature_name ::= [[#Identfiers|Identifier]] Alias ::= alias '"' Alias_name '"' [convert] Alias_name ::= [[#Operators|Operator]] | Bracket Bracket ::= "[ ]" ===Operators === Operator ::= Unary | Binary Unary ::= not | "+" | "-" | Free_unary Binary ::= "+" | "-" | "*" | "/" | "//" | "\\" | "^" | ".." | "<" | ">" | "<=" | ">=" | and | or | xor | and then | or else | implies | Free_binary {{note| Free_unary and Free_binary are free operators that are distinct from (respectively) the ''standard'' unary and binary operators (one- or two-character symbols) explicitly listed in the Unary and Binary productions. See ''Definition: Free operator'' in the standard for more precision.}} ===Assigner marks === Assigner_mark ::= assign [[#Feature names|Feature_name]] ===Inheritance parts === Inheritance ::= Inherit_clause+ Inherit_clause ::= inherit [Non_conformance] Parent_list Non_conformance ::= "{" NONE "}" Parent_list ::= {Parent ";" ...}+ Parent ::= [[#Types|Class_type]] [Feature_adaptation] Feature_adaptation ::= [[[#Undefine clauses|Undefine]]] [[[#Redefinition|Redefine]]] [[[#Rename clauses|Rename]]] [[[#Export adaptation|New_exports]]] [[[#Select clauses|Select]]] end ===Rename clauses === Rename ::= rename Rename_list Rename_list ::= {Rename_pair "," ...}+ Rename_pair ::= [[#Feature names|Feature_name]] as [[#Feature names|Extended_feature_name]] ===Clients === Clients ::= "{" Class_list "}" Class_list ::= {[[#Class names|Class_name]] "," ...}+ ===Export adaptation === New_exports ::= export New_export_list New_export_list ::= {New_export_item ";" ...}+ New_export_item ::= [[#Clients|Clients]] [[[#Feature parts|Header_comment]]] Feature_set Feature_set ::= Feature_list | all Feature_list ::= {[[#Feature names|Feature_name]] "," ...}+ ===Formal argument and entity declarations === Formal_arguments ::= "(" [[#Formal argument and entity declarations|Entity_declaration_list]] ")" Entity_declaration_list ::= {Entity_declaration_group ";" ...}+ Entity_declaration_group ::= Identifier_list [[#Feature declarations|Type_mark]] Identifier_list ::= {[[#Identfiers|Identifier]] "," ...}+ ===Routine bodies === Deferred ::= deferred Effective_routine ::= Internal | [[#External routines|External]] Internal ::= Routine_mark [[#Instructions|Compound]] Routine_mark ::= do | Once Once ::= once [ "("Key_list ")" ] Key_list ::= {[[#Manifest strings|Manifest_string]] "," ...}+ ===Local variable declarations === Local_declarations ::= local [[[#Formal argument and entity declarations|Entity_declaration_list]]] ===Instructions === Compound ::= {Instruction ";" ...}* 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" postcondition clauses|Only]]] Invariant ::= invariant Assertion Assertion ::= {Assertion_clause ";" ...}* Assertion_clause ::= [Tag_mark] Unlabeled_assertion_clause Unlabeled_assertion_clause ::= [[#Expressions|Boolean_expression]] | [[#Comments|Comment]] Tag_mark ::= Tag ":" Tag ::= [[#Identfiers|Identifier]] ==="Old" postcondition expressions === Old ::= old [[#Expressions|Expression]] ==="Only" postcondition clauses === Only ::= only [[[#Export adaptation|Feature_list]]] ===Check instructions === Check ::= check [[#Assertions|Assertion]] [[[#Notes|Notes]]] end ===Variants === Variant ::= variant [[[#Assertions|Tag_mark]]] [[#Expressions|Expression]] ===Precursor === Precursor ::= Precursor [Parent_qualification] [[[#Actual arguments|Actuals]]] Parent_qualification ::= "{" [[#Class names|Class_name]] "}" ===Redefinition === Redefine ::= redefine [[#Export adaptation|Feature_list]] ===Undefine clauses === Undefine ::= undefine [[#Export adaptation|Feature_list]] ===Types === 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 ===Actual generic parameters === Actual_generics ::= "[" Type_list "]" Type_list ::= {[[#Types|Type]] "," ...}+ ===Formal generic parameters === Formal_generics ::= "[" Formal_generic_list "]" Formal_generic_list ::= {Formal_generic ","...}+ 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 ::= [[#Types|Type]] [Renaming] Renaming ::= [[#Rename clauses|Rename]] end Multiple_constraint ::= "{" Constraint_list "}" Constraint_list ::= {Single_constraint "," ...}+ Constraint_creators ::= create [[#Export adaptation|Feature_list]] end ===Manifest arrays === Manifest_array ::= [Manifest_array_type] << Expression_list >> Manifest_array_type ::= { [[#Types|Type]] } Expression_list ::= {[[#Expressions|Expression]] , ...}* ===Tuple types === Tuple_type ::= TUPLE [Tuple_parameter_list] Tuple_parameter_list ::= "[" Tuple_parameters "]" Tuple_parameters ::= [[#Actual generic parameters|Type_list]] | [[#Formal argument and entity declarations|Entity_declaration_list]] ===Manifest tuples === Manifest_tuple ::= "[" [[#Manifest arrays|Expression_list]] "]" ===Converter clauses === Converters ::= convert Converter_list Converter_list ::= {Converter ","...}+ Converter ::= Conversion_procedure | Conversion_query Conversion_procedure ::= [[#Feature names|Feature_name]] "(" "{" [[#Actual generic parameters|Type_list]] "}" ")" Conversion_query ::= [[#Feature names|Feature_name]] ":" "{" [[#Actual generic parameters|Type_list]] "}" ===Select clauses === Select ::= select [[#Export adaptation|Feature_list]] ===Conditionals === Conditional ::= if Then_part_list [Else_part] end Then_part_list ::= {Then_part elseif ...}+ Then_part ::= [[#Expressions|Boolean_expression]] then [[#Instructions|Compound]] Else_part ::= else [[#Instructions|Compound]] Conditional_expression ::= if Then_part_expression_list else [[#Expressions|Expression]] end Then_part_expression_list ::= {Then_part_expression elseif ...}+ Then_part_expression ::= [[#Expressions|Boolean_expression]] then [[#Expressions|Expression]] ===Multi-branch instructions === 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 ::= [[#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 ::=
      [Iteration]
      [Initialization]
      [[[#Assertions|Invariant]]]
      [Exit_condition]
      Loop_body
      [[[#Variants|Variant]]]
      end Iteration ::= across [[#Expressions|Expression]] as [[#Identfiers|Identifier]] Initialization ::= from [[#Instructions|Compound]] Exit_condition ::= until [[#Expressions|Boolean_expression]] Loop_body ::=
      loop [[#Instructions|Compound]] |
      all [[#Expressions|Boolean_expression]] |
      some [[#Expressions|Boolean_expression]] ===Debug instructions === Debug ::= debug [ "("[[#Routine_bodies|Key_list]] ")" ] [[#Instructions|Compound]] end ===Attribute bodies === Attribute ::= attribute [[#Instructions|Compound]] ===Entities and variables === Entity ::= Variable | Read_only Variable ::= Variable_attribute | Local Variable_attribute ::= [[#Feature names|Feature_name]] Local ::= [[#Identfiers|Identifier]] | Result Read_only ::= Formal | Constant_attribute | Current Formal ::= [[#Identfiers|Identifier]] Constant_attribute ::= [[#Feature names|Feature_name]] ===Creators parts === Creators ::= Creation_clause+ Creation_clause ::= create [[[#Clients|Clients]]] [[[#Feature parts|Header_comment]]] Creation_procedure_list Creation_procedure_list ::= {Creation_procedure ","...}+ Creation_procedure ::= [[#Feature names|Feature_name]] ===Creation instructions === Creation_instruction ::= create [Explicit_creation_type] Creation_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 [[#Creation instructions|Explicit_creation_type]] [[[#Creation instructions|Explicit_creation_call]]] ===Equality expressions === Equality ::= [[#Expressions|Expression]] Comparison [[#Expressions|Expression]] Comparison ::= "=" | "/=" | "~" | "/~" ===Assignments === Assignment ::= [[#Entities and variables|Variable]] ":=" [[#Expressions|Expression]] ===Assigner calls === 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]] [[[#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 ::= {[[#Expressions|Expression]] "," ...}+ ===Object test === Object_test ::= "{" [[#Identfiers|Identifier]] ":" [[#Types|Type]] "}" [[#Expressions|Expression]] ===Rescue clauses === Rescue ::= rescue [[#Instructions|Compound]] Retry ::= retry ===Agents === Agent ::= Call_agent | Inline_agent 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 constants|Manifest_type]] Agent_actuals ::= "(" Agent_actual_list ")" Agent_actual_list ::= {Agent_actual "," ...}+ Agent_actual ::= [[#Expressions|Expression]] | Placeholder Placeholder ::= [[[#Manifest constants|Manifest_type]]] "?" ===Expressions === Expression ::= Basic_expression | Special_expression 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]] | [[#Conditionals|Conditional_expression]] Special_expression ::= [[#Manifest constants|Manifest_constant]] | [[#Manifest arrays|Manifest_array]] | [[#Manifest tuples|Manifest_tuple]] | [[#Agents|Agent]] | [[#Object test|Object_test]] | Once_string | Address Parenthesized ::= "(" Expression ")" Address ::= "$" [[#Entities and variables|Variable]] Once_string ::= once [[#Manifest strings|Manifest_string]] 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 ::= [[#Expressions|Expression]] [[#Operators|Binary]] [[#Expressions|Expression]] ===Bracket expressions === 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 constants|Manifest_constant]] | Constant_attribute Constant_attribute ::= [[#Feature names|Feature_name]] ===Manifest constants === Manifest_constant ::= [Manifest_type] Manifest_value Manifest_type ::= "{" [[#Types|Type]] "}" Manifest_value ::= Boolean_constant | Character_constant | Integer_constant | Real_constant | [[#Manifest strings|Manifest_string]] | Manifest_type Sign ::= "+" | "-" Integer_constant ::= [Sign] [[#Integers|Integer]] Character_constant ::= " ' " [[#Characters|Character]] " ' " Boolean_constant ::= True | False Real_constant ::= [Sign] [[#Reals|Real]] ===Manifest strings === Manifest_string ::= Basic_manifest_string | Verbatim_string Basic_manifest_string ::= ' " ' String_content ' " ' 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 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 strings|Simple_string]]] Open_bracket Verbatim_string_closer ::= Close_bracket [[[#Simple strings|Simple_string]]] ' " ' Open_bracket ::= "[" | "{" Close_bracket ::= "]" | "}" ===External routines === External ::= external External_language [External_name] External_language ::= Unregistered_language | [[#Registered languages|Registered_language]] Unregistered_language ::= [[#Manifest strings|Manifest_string]] External_name ::= alias [[#Manifest strings|Manifest_string]] {{note|If the `inline` keyword is used in the Registered_language part, then External_name part is the inline code on the specified language.}} ===Registered languages === Registered_language ::= [[#C externals|C_external]] | [[#C++ externals|C++_external]] | [[#DLL externals|DLL_external]] ===External signatures === External_signature ::= signature [External_argument_types] [: External_type] External_argument_types ::= "(" External_type_list ")" External_type_list ::= {External_type "," ...}* External_type ::= [[#Simple strings|Simple_string]] ===External file use === External_file_use ::= use External_file_list External_file_list ::= {External_file "," ... }+ External_file ::= External_user_file | External_system_file External_user_file ::= ' " ' [[#Simple strings|Simple_string]] ' " ' External_system_file ::= "<" [[#Simple strings|Simple_string]] ">" ===C externals === C_external ::= ' " ' C [inline] [ [[#External signatures |External_signature]] ] [ [[#External file use |External_file_use]] ] ' " ' ===C++ externals === C++_external ::= ' " ' C++ inline [ [[#External signatures |External_signature]] ] [ [[#External file use |External_file_use]] ] ' " ' ===DLL externals === DLL_external ::= ' " ' dll [windows] DLL_identifier [DLL_index] [[ [[#External signatures |External_signature]] ] [ [[#External file use |External_file_use]] ] ' " ' DLL_identifier ::= [[#Simple strings|Simple_string]] DLL_index ::= [[#Integers|Integer]] ===Comments === Comment ::= "- -" {[[#Simple strings|Simple_string]] Comment_break ...}* Comment_break ::= New_line [Blanks_or_tabs] "- -" ===Integers === Integer ::= [Integer_base] Digit_sequence Integer_base ::= "0" Integer_base_letter Integer_base_letter ::= "b" | "c" | "x" | "B" | "C" | "X" Digit_sequence ::= Digit+ Digit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F" | "_"