[comp.lang.eiffel] Eiffel syntax

bertrand@eiffel.UUCP (Bertrand Meyer) (09/04/89)

From <2644@trantor.harris-atd.com>, 
by bbadger@x102c.harris-atd.com (Badger BA 64810):

> Perhaps someone could post an abbreviated Eiffel syntax, to give us
> some of the flavor?

Here is the full syntax of Eiffel 2.2, extracted from Appendix E
of the Eiffel Reference Manual.

The syntactical notation is the same as used in ``Object-Oriented
Software Construction'', adapted for a single font.

As usual, nroff has taken its toll. In the original, keywords do not need to
be quoted because they appear in boldface; reserved identifiers such as
Current appear in italics. Here I had to go through some rather horrible
trips to sed, followed by tedious manual editing, to produce
an acceptable form. I hope the result is readable and does not suffer from
too many tool-induced bugs.  For the definitive word, get a copy of the manual.

The constructs are given in alphabetical order. Appendix D
of the manual gives the syntax in more ``logical'', or perhaps pedagogical,
order.

Because some names are quite long, this won't make much sense unless
you read or print it on an output medium at least 76 characters wide.

The numbers on the right are the chapters where each construct is
introduced and discussed in the Reference Manual.

-- Bertrand Meyer
bertrand@eiffel.com

----------------------------------------------------------------------------
                    Actual  =  Expression  |  Address                     19
           Actual_generics  =  "[" Type_list "]"                           9
               Actual_list  =  {Actual Separator ...}*                    19
                   Actuals  =  "(" Actual_list ")"                        19
                   Address  =  "@" Feature_identifier                     19
                    Anchor  =  Feature_identifier  |  Current              9
                 Assertion  =  {Assertion_clause ";" ...}*                12
          Assertion_clause  =  [Tag_mark]                                 12
                                 Unlabeled_assertion_clause
                Assignment  =  Entity ":=" Expression                     18
               Association  =  "like" Anchor                               9
                     Basic  =  "INTEGER"  |  "BOOLEAN"  |                  9
                                 "CHARACTER"  |  "REAL"  |  "DOUBLE"
                    Binary  =  "div"  |  "mod"  |  "^"  |                  6
                                 "<"  |  ">"  |  "<="  |  ">="
         Binary_expression  =  Expression Binary_or_equality Expression   20
        Binary_or_equality  =  Binary  |  Equality                        20
                Bit_string  =  BITS Integer                                9
                      Body  =  Effective_body  |  Deferred_mark           11
                 Body_mark  =  "do"  |  "once"                            11
          Boolean_constant  =  "true"  |  "false"                         20
        Boolean_expression  =  Expression                                 12
                      Call  =  [Qualifier] Unqualified_call               19
        Character_constant  =  "'" Character "'"                          20
        Character_interval  =  Character_constant ".." Character_constant 13
                     Check  =  "check" Assertion "end"                    12
         Class_declaration  =  [Indexing]                                  5
                                 Class_header
                                 [Formal_generics]
                                 [Exports]
                                 [Inheritance]
                                 [Features]
                                 [Invariant]
                                 "end" ["-- class"  Class_name]
              Class_header  =  [Deferred_mark] "class"  Class_name         5
                Class_list  =  {Class_name "," ...}*                       8
                Class_name  =  Identifier                                  5
                Class_type  =  Class_name [Actual_generics]                9
                   Clone    =  Entity ".Clone (" Expression ")"           17
                   Comment  =  "--" String                                12
                  Compound  =  {Instruction ";" ...}*                     13
               Conditional  =  "if" Then_part_list [Else_part] "end"      13
                  Constant  =  Manifest_constant  |  Constant_attribute   20
        Constant_attribute  =  Identifier                                 20
             Constant_list  =  {Constant "," ...}+                        13
       Constant_or_routine  =  Manifest_constant  |  Unique  |  Routine    6
                Constraint  =  "->" Class_type                             9
                  Create    =  Entity ".Create" [Actuals]                 17
                  Creation  =  Create  |  Clone                           17
                  Current   =  "Current"                                  16
                     Debug  =  "debug" Compound "end"                     13
          Declaration_body  =  [Formal_arguments]
                                 [Type_mark]
                                 [Feature_value_mark]
             Deferred_mark  =  "deferred"                                  5
                    Define  =  "define" Feature_list                       7
            Effective_body  =  Body_mark Compound                         11
                 Else_part  =  "else" Compound                            13
                    Entity  =  Identifier  |  "Result"                    18
Entity_declaration_group    =  {Identifier "," ...}+ Type_mark            11
   Entity_declaration_list  =  {Entity_declaration_group ";" ...}*        11
                  Equality  =  "="  |  "/="                               20
                      Exit  =  "until" Boolean_expression                 13
       Expanded_class_type  =  "expanded" Class_type                       9
             Expanded_type  =  Expanded_class_type  |  Bit_string  |       9
                                 Basic
               Export_item  =  Exported_feature  |  Repeat_parent          8
               Export_list  =  {Export_item "," ...}*                      8
          Exported_feature  =  Feature_name [Restriction]                  8
                   Exports  =  "export" Export_list                        8
                Expression  =  Constant  |  Call  |                       16
                                 Operator_expression  |  Void_test  |
                                 Current  |  Old_value  |  Nochange
      External_declaration  =  Feature_name                               11
                                 [Formal_arguments] [Type_mark]
                                 [External_name] Language
             External_list  =  {External_declaration ";" ...}*            11
             External_name  =  "name" String_constant                     11
                 Externals  =  "external" External_list                   11
       Feature_declaration  =  Feature_list Declaration_body               6
        Feature_identifier  =  Identifier                                  6
              Feature_list  =  {Feature_name "," ...}*                     6
              Feature_name  =  Feature_identifier  |  Prefix  |  Infix     6
        Feature_value_mark  =  [Obsolete_mark] "is"  Constant_or_routine   6
                  Features  =  "feature" {Feature_declaration ";" ...}*    6
                  Forget    =  Entity ".Forget"                           18
          Formal_arguments  =  "(" Entity_declaration_list ")"            11
            Formal_generic  =  Formal_generic_name [Constraint]            9
       Formal_generic_list  =  {Formal_generic ","...}*                    9
       Formal_generic_name  =  Identifier                                  9
           Formal_generics  =  "[" Formal_generic_list "]"                 9
                     Index  =  Identifier ":"                              5
              Index_clause  =  [Index] Index_terms                         5
                Index_list  =  {Index_clause ";" ...}*                     5
               Index_terms  =  {Index_value "," ...}*                      5
               Index_value  =  Identifier  |  Manifest_constant            5
                  Indexing  =  indexing Index_list                         5
                     Infix  =  "infix" '"' Infix_operator '"'              6
            Infix_operator  =  Binary  |  Multiary                         6
               Inheritance  =  "inherit" Parent_list                       7
            Initialization  =  "from" Compound                            13
               Instruction  =  Creation  |  Forget  |                     11
                                 Assignment  |
                                 Reverse_assignment_attempt  |
                                 Call  |
                                 Conditional  |  Multi_branch  |  Loop  |
                                 Debug  |  Check  |  Retry
          Integer_constant  =  [Sign] Integer                             20
          Integer_interval  =  Integer_constant ".." Integer_constant     13
                  Interval  =  Integer_interval  |  Character_interval    13
                 Invariant  =  "invariant" Assertion                      12
                  Language  =  "language" String_constant                 11
            Local_entities  =  "local" Entity_declaration_list            11
                      Loop  =  Initialization                             13
                                 [Invariant]                                13
                                 [Variant]                                  13
                                 Loop_body                                  13
                 Loop_body  =  Exit "loop" Compound                       13
         Manifest_constant  =  Integer_constant  |  Character_constant  | 20
                                 Boolean_constant  |  Real_constant  |
                                 String_constant
                   Message  =  String_constant                             6
              Multi_branch  =  "inspect" Expression                       13
                                 [When_part_list] [Else_part] "end"         13
                  Multiary  =  "+"  |  "-"  |  "*"  |  "/"  |              6
                                 "and"  |  "and then"  |  "or"  
                                 "or else"  |  "xor"  |  "implies" 
       Multiary_expression  =  Expression Multiary                        20
                                 {Expression Multiary ...}+
                Nochange    =  "Nochange"                                 16
             Obsolete_mark  =  "obsolete" Message                          6
                 Old_value  =  "old" Expression                           16
       Operator_expression  =  Parenthesized  |  Unary_expression  |      20
                                 Binary_expression  |  Multiary_expression  20
                    Parent  =  Class_type                                  7
                                 [Rename]
                                 [Redefine]
                                 [Define]
               Parent_list  =  {Parent ";" ...}*                           7
             Parenthesized  =  "(" Expression ")"                         20
             Postcondition  =  "ensure" Assertion                         12
              Precondition  =  "require" Assertion                        12
                    Prefix  =  "prefix" '"' Prefix_operator '"'            6
           Prefix_operator  =  Unary                                       6
                 Qualifier  =  {Symbolic "." ...}+ "."                    19
             Real_constant  =  [Sign] Real                                20
                  Redefine  =  "redefine" Feature_list                     7
                    Rename  =  "rename" Rename_list                        7
               Rename_list  =  {Rename_pair "," ...}*                      7
               Rename_pair  =  Feature_name "as"  Feature_name             7
             Repeat_parent  =  "repeat" Class_name                         8
                    Rescue  =  "rescue" Compound                          14
               Restriction  =  "{" Class_list "}"                          8
                     Retry  =  "retry"                                    14
Reverse_assignment_attempt  =  Entity "?=" Expression                     18
                   Routine  =   ["--" String]                             11
                                 [Precondition]
                                 [Externals]
                                 [Local_entities]
                                 Body
                                 [Postcondition]
                                 [R escue]
                                 "end" ["--" Feature_name]
                 Separator  =  ","  |  ";"                                19
                      Sign  =  "+"  |  "-"                                20
           String_constant  =  '"' String '"'                             20
                  Symbolic  =  Entity  |  Unqualified_call                19
                       Tag  =  Identifier                                 12
                  Tag_mark  =  Tag ":"                                    12
                 Then_part  =  Boolean_expression "then" Compound         13
            Then_part_list  =  {Then_part "elsif" ...}+                   13
                      Type  =  Class_type  |                               9
                                 Association  |
                                 Expanded_type  |
                                 Formal_generic_name
                 Type_list  =  {Type "," ...}*                             9
                 Type_mark  =  ":" Type                                   11
                     Unary  =  "not"  |  "+"  |  "-"                       6
          Unary_expression  =  Unary Expression                           20
                    Unique  =  "unique"                                   15
Unlabeled_assertion_clause  =  Boolean_expression  |  Comment             12
          Unqualified_call  =  Feature_identifier [Actuals]  |            19
                    Values  =  Constant_list  |  Interval                 13
                   Variant  =  "variant" [Tag_mark] Integer_expression    12
                 When_part  =  Values "then" Compound                     13
            When_part_list  =  "when" {When_part when ...}+               13
Reverse_assignment_attempt  =  Entity "?=" Expression                     18
----------------------------------------------------------------------------