bertrand@eiffel.UUCP (Bertrand Meyer) (06/05/89)
To help users prepare for the upcoming release of version 2.2, here is a full syntax description. It replaces the previous description as given in ``Object-Oriented Software Construction'' (Appendix C) and in the Eiffel User's Manual. This includes the relatively few syntactic additions introduced by 2.2 as well as corrections of errors in the previously published grammars. The conventions used are described in the references cited. They were really designed under the assumption that the output medium supports boldface (for keywords) and italics (for other reserved words such as Result). Here of course only one font is used; there is no ambiguity for keywords (any identifier all in lower-case, e.g. deferred, is a keyword); most names beginning with a capital letter (e.g. Local_entities, Class etc.) denote non-terminals, with a few exceptions for reserved words such as Result. My apologies for the resulting ambiguities, which anyone familiar enough with Eiffel should have no trouble resolving. This grammar has been checked but errors or inconsistencies may remain. If you find one, please e-mail a comment to me; there is still some time for last-minute documentation updates. Note that this is just the grammar, with no explanation. Stay tuned for a detailed message about the innovations of 2.2. First, the 11 new reserved words: Accept BITS DOUBLE expanded implies infix inspect obsolete prefix unique xor These may no longer be used as identifiers. A clear message will be produced if they are. Now for the grammar itself: ------------------- SYNTAX OF EIFFEL, VERSION 2.2 -------------------- Copyright (C) Interactive Software Engineering Inc., 1989 Note: Eiffel is a trademark of Interactive Software Engineering Inc. Class_declaration = Class_header [Formal_generics] [Exports] [Inheritance] [Features] [Invariant] end ["--" class Class_name] Class_header = [Class_mark] class Class_name Class_mark = deferred | expanded Class_name = Identifier Formal_generics = "[" Formal_generic_list "]" Formal_generic_list = {Formal_generic ","...} Formal_generic = Formal_generic_name [Constraint] Formal_generic_name = Identifier Constraint = "->" Class_type Exports = export Export_list Export_list = {Export_item "," ...} Export_item = Exported_feature | Ancestor_exports Exported_feature = Feature_name [Restriction] Restriction = "{" Class_list "}" Class_list = {Class_name "," ...} Ancestor_exports = repeat Class_name Feature_name = Feature_identifier | Prefix | Infix Feature_identifier = Identifier Prefix = "prefix" '"' Prefix_operator '"' Infix = "infix" '"' Infix_operator '"' Prefix_operator = Unary Infix_operator = Binary | Multiary Unary = not | "+" | "-" Binary = div | mod | "^" | "<" | ">" | "<=" | ">=" Multiary = "+" | "-" | "*" | "/" | and | and then | or | or else | xor | implies Inheritance = inherit Parent_list Parent_list = {Parent ";" ...} Parent = Class_type [Renamed] [Redefined] Class_type = Bit_size | Defined_class Bit_size = BITS Integer Defined_class = Class_name [Actual_generics] Actual_generics = "[" Type_list "]" Type_list = {Type "," ...} Type = Class_type | Formal_generic_name | Association Association = like Anchor Anchor = Feature_identifier | Current Renamed = rename Rename_list Rename_list = {Rename_pair "," ...} Rename_pair = Feature_name as Feature_name Redefined = redefine Feature_list Feature_list = {Feature_name "," ...} Features = feature {Feature_declaration ";" ...} Feature_declaration = Feature_list Declaration_body Declaration_body [Formal_arguments] [Type_mark] [Feature_value_mark] Formal_arguments = "(" Entity_declaration_list ")" Entity_declaration_list = {Entity_declaration_group ";" ...} Entity_declaration_group = {Identifier "," ...}+ Type_mark Type_mark = ":" Type Feature_value_mark = [Obsolete_mark] is Constant_or_routine Obsolete_mark = obsolete Message Message = String_constant Constant_or_routine = Manifest_constant | Unique | Routine Manifest_constant = Integer_constant | Character_constant | Boolean_constant | Real_constant | String_constant Sign = "+" | "-" Integer_constant = [Sign] Integer Character_constant = "'" Character "'" Boolean_constant = true | false Real_constant = [Sign] Real String_constant = '"' String '"' Unique = unique Routine = [Precondition] [Externals] [Local_entities] Body [Postcondition] [Rescue] end ["--" Feature_name] Precondition = require Assertion Postcondition = ensure Assertion Assertion = {Assertion_clause ";" ...} Assertion_clause = [Tag_mark] Unlabeled_assertion_clause Tag_mark = Tag ":" Tag = Identifier Unlabeled_assertion_clause = Boolean_expression | Comment Boolean_expression = Expression Comment = "--" String Externals = external External_list External_list = {External_declaration ";" ...} External_declaration = Feature_name [Formal_arguments] [Type_mark] [External_name] Language Language = language String_constant External_name = name String_constant Local_entities = Entity_declaration_list Body = Explicit_body | Deferred_mark Explicit_body = Body_mark Compound Body_mark = do | once Compound = {Instruction ";" ...} Instruction = Call | Assignment | Conditional | Multi_branch | Loop | Check | Retry | Debug Call = [Qualifier] Unqualified_call Qualifier = {Unqualified_expression "." ...}+ "." Unqualified_call = Feature_identifier [Actuals] Actuals = "(" Actual_list ")" Actual_list = {Actual Separator ...} Actual = Expression | Address Address = "@" Feature_identifier Separator = "," | ";" Assignment = Entity ":=" Expression Entity = Identifier | Result Expression = [Qualifier] Unqualified_expression Unqualified_expression = Constant | Entity | Unqualified_call | Current | Old_value | Nochange | Operator_expression Old_value = old Expression Nochange = nochange Constant = Manifest_constant | Constant_attribute Constant_attribute = Identifier Operator_expression = Parenthesized | Unary_expression | Binary_expression | Multiary_expression Parenthesized = "(" Expression ")" Unary_expression = Unary Expression Binary_expression = Expression Binary_or_equality Expression Binary_or_equality = Binary | Equality Equality = "=" | "/=" Multiary_expression = {Expression Multiary ...}+ Conditional = if Then_part_list [Else_part] end Then_part_list = {Then_part elsif ...}+ Then_part = Boolean_expression then Compound Else_part = else Compound Multi_branch = inspect Expression [When_part_list] [Else_part] end When_part_list = when {When_part when ...}+ When_part = Values then Compound Values = Constant_list | Interval Constant_list = {Constant "," ...}+ Interval = Integer_interval | Character_interval Integer_interval = Integer_constant ".." Integer_constant Character_interval = Character_constant ".." Character_constant Loop = Initialization [Invariant] [Variant] Exit Loop_body end Initialization = from Compound Invariant = invariant Assertion Variant = variant [Tag_mark] Integer_expression Integer_expression = Expression Exit = until Boolean_expression Loop_body = loop Compound Check = check Assertion end Retry = retry Debug = debug Compound end Rescue = rescue Compound -- -- Bertrand Meyer bertrand@eiffel.com