home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fchek284.zip / pointer.patch < prev    next >
Text File  |  1994-11-06  |  4KB  |  145 lines

  1. This file contains information to allow users to add minimal support
  2. for the nonstandard POINTER statement provided by many FORTRAN 77
  3. vendors.  The syntax is described below.  It is not the same as the
  4. Fortran 90 POINTER statement.  This fix does not include real checking
  5. of the statement other than basic syntax, but it keeps ftnchek from
  6. choking on it.  No guarantees accompany this fix.
  7.  
  8. To implement the fix, go to the directory containing the ftnchek
  9. source code and give the commands
  10.     $ patch < pointer.patch
  11.     $ make
  12.  
  13. Thanks go to John Dannenhoffer for working this out.  A few minor
  14. changes have been made to improve it.  The explanations following the
  15. patch code are from him.
  16.  
  17. The following is the patch code.
  18.  
  19. diff -c ./fortran.y pointer/fortran.y
  20. *** ./fortran.y    Tue Oct 25 17:25:19 1994
  21. --- pointer/fortran.y    Sun Nov  6 16:45:05 1994
  22. ***************
  23. *** 224,229 ****
  24. --- 224,230 ----
  25.   %token tok_OPEN
  26.   %token tok_PARAMETER
  27.   %token tok_PAUSE
  28. + %token tok_POINTER
  29.   %token tok_PRECISION
  30.   %token tok_PRINT
  31.   %token tok_PROGRAM
  32. ***************
  33. *** 460,465 ****
  34. --- 461,467 ----
  35.           |    external_stmt
  36.           |    intrinsic_stmt
  37.           |    save_stmt
  38. +         |       pointer_stmt
  39.           ;
  40.   
  41.   
  42. ***************
  43. *** 1440,1445 ****
  44. --- 1442,1478 ----
  45.               {
  46.                    def_intrins_name(&($3));
  47.               }
  48. +         ;
  49. +         /* constructs for POINTER(pointer=pointee) statement */
  50. + pointer_stmt    :       tok_POINTER pointer_item_list EOS
  51. +         ;
  52. + pointer_item_list:      pointer_item
  53. +         |       pointer_item_list ',' pointer_item
  54. +         ;
  55. + pointer_item    :       '(' pointer_name ',' pointee_name ')'
  56. +         ;
  57. + pointer_name    :       symbolic_name
  58. +             {
  59. +                  declare_type(&($1),type_INTEGER,local_wordsize);
  60. +             }
  61. +         ;
  62. + pointee_name    :       symbolic_name
  63. +                 {
  64. +                 /* Suppress set/used warnings since
  65. +                    often is accessed only via pointer */
  66. +                      use_lvalue(&($1));
  67. +                      use_variable(&($1));
  68. +                 }
  69. +         |       array_declarator
  70. +                 {
  71. +                      use_lvalue(&($1));
  72. +                      use_variable(&($1));
  73. +                 }
  74.           ;
  75.   
  76.   /* 26 */
  77. diff -c ./keywords.h pointer/keywords.h
  78. *** ./keywords.h    Sun Jul 10 18:56:41 1994
  79. --- pointer/keywords.h    Sun Nov  6 16:45:05 1994
  80. ***************
  81. *** 106,111 ****
  82. --- 106,112 ----
  83.   {"OPEN",    tok_OPEN,    IK | EK | MP | NA},
  84.   {"PARAMETER",    tok_PARAMETER,    IK | NI | EK | MP | NA},
  85.   {"PAUSE",    tok_PAUSE,    IK | NP | EK},
  86. + {"POINTER",     tok_POINTER,    IK | MP | NI | EK | NA},
  87.   {"PRECISION",    tok_PRECISION,    IK | NI | EK | TY},
  88.   {"PRINT",    tok_PRINT,    IK | EK},
  89.   {"PROGRAM",    tok_PROGRAM,    IK | NP | NI | EK},
  90.  
  91.  
  92. Date: 18 Nov 1993 12:37:24 -0500
  93. From: dannenho@percheron.res.utc.com (John Dannenhoffer)
  94. To: moniot@mary.fordham.EDU
  95.  
  96. Prof. Moniot,
  97.  
  98. Thank you for your help in getting me started with adding the
  99. POINTER statement to ftnchek.  With your help, I was able to
  100. successfully include the POINTER statement in my version of ftnchek.
  101. I have included the changes which I have made so that you could
  102. include them in a future release (if you want to).
  103.  
  104. The description of the POINTER statement, taken roughly from the
  105. IBM Fortran manual is:
  106.  
  107.    Syntax:
  108.       POINTER (pointer,pointee) [,(pointer,pointee)]
  109.    where:
  110.       pointer   is the name of a pointer variable
  111.       pointee   is a variable name, array declarator, or array name
  112.  
  113.    The POINTER statement allows you to specify that the value of the
  114.    variable 'pointer' should be used as the address for any reference
  115.    to 'pointee'.  The compiler does not allocate storage for the
  116.    'pointee'.  The storage is allocated at execution time by the
  117.    assignment of the address of a block of storage to the associated
  118.    pointer.  The pointer can become associated with either static or
  119.    dynamic storage.  A reference to the pointee requires that the
  120.    associated pointer be defined.
  121.  
  122.    A pointer is a variable of type INTEGER*4, and you cannot
  123.    explicitly assign a type to it.  You can use pointers in any
  124.    expression or statement in which an INTEGER*4 variable can be used.
  125.    You can assign any data type to a pointee, but you cannot assign a
  126.    storage class or initial value to a pointee.
  127.  
  128.     An actual array that appears as a pointee in a POINTER statement
  129.     is called a pointee array.  You can dimension a pointee array in
  130.     an explicit type statement, a DIMENSION statement, or in the
  131.     POINTER statement itself.
  132.  
  133.  
  134. Thanks again for all your help.
  135.  
  136. John Dannenhoffer
  137. (203) 727-7775
  138. dannenho@utrc.utc.com
  139.  
  140.