PIPS
gram.y
Go to the documentation of this file.
1 /*
2 
3  $Id: gram.y 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25  /* PIPS project: syntactic analyzer
26  *
27  * Remi Triolet
28  *
29  * Warning: do not use user_error() when processing must be interrupted,
30  * but ParserError() which fixes global variables and leaves a consistent
31  * symbol table. Use user_warning() to display additional information if
32  * ParserError() is too terse.
33  *
34  * Bugs:
35  * - IO control info list should be checked; undected errors are likely
36  * to induce core dumps in effects computation; Francois Irigoin;
37  * - Type declarations are not enforced thoroughly: the syntax for characters
38  * is extended to other types; for instance REAL*4 X*40 is syntactically
39  * accepted but "*40" is ignored; Francois Irigoin;
40  *
41  * Modifications:
42  * - bug correction for REWIND, BACKSPACE and ENDFILE; improved error
43  * detection in IO statement; Francois Irigoin;
44  * - add DOUBLE PRECISION as a type; Francois Irigoin;
45  * - update length declaration computation for CHARACTER type; the second
46  * length declaration was ignored; for instance:
47  * CHARACTER*3 X*56, Y
48  * was interpreted as the declaration of two strings of 3 characters;
49  * two variables added: CurrentType and CurrentTypeSize
50  * Francois Irigoin
51  * - bug with EXTERNAL: CurrentType was not reset to type_undefined
52  * - Complex constants were not recognized; the rule for expression
53  * were modified and a new rule, sous-expression, was added, as well
54  * as a rule for complex constants; Francois Irigoin, 9 January 1992
55  * - global variables should be allocated whenever possible in a different
56  * name space than local variables; their package name should be the
57  * top level name; that would let us accept variables and commons
58  * with the same name and that would make the link edit step easier;
59  * lots of things have to be changed:
60  *
61  * global_entity_name: should produce a global entity
62  *
63  * common_name: should allocate the blank common in the global space
64  *
65  * call_inst: has to refer to a global entity
66  *
67  * module_name: has to be allocated in the global space
68  *
69  * intrinsic_inst: has to require global_entity_name(s) as parameters
70  *
71  * external inst: has to require global_entity_name(s) as parameters
72  *
73  * This implies that COMMON are globals to all procedure. The SAVE
74  * statement on COMMONs is meaningless
75  * - add common_size_table to handle COMMONs as global variables;
76  * see declarations.c (Francois Irigoin, 22 January 1992)
77  * - remove complex constant detection because this conflicts with
78  * IO statements
79  */
80 
81 %type <chain> latom
82 %type <dimension> dim_tableau
83 %type <entity> icon
84 %type <entity> entity_name
85 %type <entity> global_entity_name
86 %type <entity> functional_entity_name
87 /* %type <entity> module_name */
88 %type <string> module_name
89 %type <entity> common_name
90 %type <entity> declaration
91 %type <entity> common_inst
92 %type <entity> oper_rela
93 %type <entity> unsigned_const_simple
94 %type <expression> const_simple
95 %type <expression> sous_expression
96 %type <expression> expression
97 %type <expression> io_expr
98 %type <expression> unpar_io_expr
99 %type <expression> io_elem
100 %type <expression> io_f_u_id
101 %type <expression> opt_expression
102 %type <instruction> inst_exec
103 %type <instruction> format_inst
104 %type <instruction> data_inst
105 %type <instruction> assignment_inst
106 %type <instruction> goto_inst
107 %type <instruction> arithmif_inst
108 %type <instruction> logicalif_inst
109 %type <instruction> blockif_inst
110 %type <instruction> elseif_inst
111 %type <instruction> else_inst
112 %type <instruction> endif_inst
113 %type <instruction> enddo_inst
114 %type <instruction> do_inst
115 %type <instruction> bdo_inst
116 %type <instruction> wdo_inst
117 %type <instruction> continue_inst
118 %type <instruction> stop_inst
119 %type <instruction> pause_inst
120 %type <instruction> call_inst
121 %type <instruction> return_inst
122 %type <instruction> io_inst
123 %type <instruction> entry_inst
124 %type <integer> io_keyword
125 %type <integer> ival
126 %type <integer> opt_signe
127 %type <integer> psf_keyword
128 %type <integer> iobuf_keyword
129 %type <integer> signe
130 %type <liste> decl_tableau
131 %type <liste> indices
132 %type <liste> parameters
133 %type <liste> arguments
134 %type <liste> lci
135 %type <liste> ci
136 %type <liste> ldim_tableau
137 %type <liste> ldataval
138 %type <liste> ldatavar
139 %type <liste> lexpression
140 %type <liste> lformalparameter
141 %type <liste> licon
142 %type <liste> lio_elem
143 %type <liste> opt_lformalparameter
144 %type <liste> opt_lio_elem
145 %type <range> do_plage
146 %type <string> label
147 %type <string> name
148 %type <string> global_name
149 %type <syntax> atom
150 %type <tag> fortran_basic_type
151 %type <type> fortran_type
152 %type <type> opt_fortran_type
153 %type <value> lg_fortran_type
154 %type <character> letter
155 %type <expression> dataconst
156 %type <expression> dataval
157 %type <expression> datavar
158 %type <expression> dataidl
159 
160 %{
161 #ifdef HAVE_CONFIG_H
162  #include "pips_config.h"
163 #endif
164 #include <stdio.h>
165 #include <string.h>
166 #include <stdlib.h>
167 
168 #include "genC.h"
169 #include "parser_private.h"
170 #include "linear.h"
171 #include "ri.h"
172 #include "ri-util.h"
173 
174 #include "misc.h"
175 #include "properties.h"
176 
177 #include "syntax.h"
178 
179 #define YYERROR_VERBOSE 1 /* much clearer error messages with bison */
180 
181  /* local variables */
182  int ici; /* to count control specifications in IO statements */
183  type CurrentType = type_undefined; /* the type in a type or dimension
184  or common statement */
185  intptr_t CurrentTypeSize; /* number of bytes to store a value of that type */
186 
187 /* functions for DATA */
188 
189 static expression MakeDataValueSet(expression n, expression c)
190  {
191  expression repeat_factor = expression_undefined;
192  expression value_set = expression_undefined;
193  entity repeat_value = FindEntity(TOP_LEVEL_MODULE_NAME,
194  REPEAT_VALUE_NAME);
195  value vc = value_undefined;
196 
197  pips_assert("Function repeat value is defined", !entity_undefined_p(repeat_value));
198 
199  vc = EvalExpression(c);
200  if (! value_constant_p(vc)) {
201  if(!complex_constant_expression_p(c)) {
202  ParserError("MakeDataValueSet", "data value must be a constant\n");
203  }
204  }
205 
206  if(expression_undefined_p(n)) {
207  value_set = c;
208  }
209  else {
210  repeat_factor = (n == expression_undefined) ? int_to_expression(1) : n;
211  value_set = make_call_expression(repeat_value,
212  CONS(EXPRESSION, repeat_factor,
213  CONS(EXPRESSION, c, NIL)));
214  }
215 
216  return value_set;
217  }
218 %}
219 
220 /* Specify precedences and associativies. */
221 %left TK_COMMA
222 %nonassoc TK_COLON
223 %right TK_EQUALS
224 %left TK_EQV TK_NEQV
225 %left TK_OR
226 %left TK_AND
227 %left TK_NOT
228 %nonassoc TK_LT TK_GT TK_LE TK_GE TK_EQ TK_NE
229 %left TK_CONCAT
230 %left TK_PLUS TK_MINUS
231 %left TK_STAR TK_SLASH
232 %right TK_POWER
233 
234 %token TK_IOLPAR
235 
236 %union {
237  basic basic;
238  chain chain;
239  char character;
240  cons * liste;
241  dataval dataval;
242  datavar datavar;
243  dimension dimension;
244  entity entity;
245  expression expression;
246  instruction instruction;
247  int integer;
248  range range;
249  string string;
250  syntax syntax;
251  tag tag;
252  type type;
253  value value;
254 }
255 
256 %%
257 
258 lprg_exec: prg_exec
259  | lprg_exec prg_exec
260  { FatalError("parser",
261  "Multiple modules in one file! Check fsplit!");}
262  ;
263 
264 prg_exec: begin_inst {reset_first_statement();} linstruction { check_first_statement();} end_inst
265  | begin_inst {reset_first_statement(); check_first_statement();} end_inst
266  ;
267 
268 begin_inst: opt_fortran_type psf_keyword module_name
269  opt_lformalparameter TK_EOS
270  {
271  MakeCurrentFunction($1, $2, $3, $4);
272  }
273  ;
274 
275 entry_inst: TK_ENTRY entity_name opt_lformalparameter
276  {
277  /* In case the entry is a FUNCTION, you want to recover its type.
278  * You cannot use entity_functional_name as second rule element.
279  */
280  if(get_bool_property("PARSER_SUBSTITUTE_ENTRIES")) {
281  $$ = MakeEntry($2, $3);
282  }
283  else {
284  ParserError("Syntax", "ENTRY are not directly processed. "
285  "Set property PARSER_SUBSTITUTE_ENTRIES to allow "
286  "entry substitutions");
287  }
288  }
289  ;
290 
291 end_inst: TK_END TK_EOS
292  { EndOfProcedure(); }
293  ;
294 
295 linstruction: TK_EOS
296  | instruction TK_EOS
297  | linstruction instruction TK_EOS
298  ;
299 
300 instruction:
301  data_inst
302  { /* can appear anywhere in specs and execs! */
303  if (first_executable_statement_seen())
304  {
305  /* the DATA string to be added to declarations...
306  * however, the information is not really available.
307  * as a hack, I'll try to append the Stmt buffer, but it
308  * has already been processed, thus it is quite far
309  * from the initial statement, and may be incorrect.
310  * I think that this parser is a mess;-) FC.
311  */
312  pips_user_warning(
313  "DATA as an executable statement, moved up...\n");
314  append_data_current_stmt_buffer_to_declarations();
315  }
316 
317  /* See if we could save the DATA statements somewhere */
318  /* dump_current_statement(); */
319 
320  }
321  | { check_in_declarations();} inst_spec
322  | { check_first_statement();} inst_exec
323  {
324  if ($2 != instruction_undefined)
325  LinkInstToCurrentBlock($2, true);
326  }
327  | format_inst
328  {
329  LinkInstToCurrentBlock($1, true);
330  }
331  ;
332 
333 inst_spec: parameter_inst
334  | implicit_inst
335  | dimension_inst
336  | pointer_inst
337  | equivalence_inst
338  | common_inst {}
339  | type_inst
340  | external_inst
341  | intrinsic_inst
342  | save_inst
343  ;
344 
345 inst_exec: assignment_inst
346  { $$ = $1; }
347  | goto_inst
348  { $$ = $1; }
349  | arithmif_inst
350  { $$ = $1; }
351  | logicalif_inst
352  { $$ = $1; }
353  | blockif_inst
354  { $$ = $1; }
355  | elseif_inst
356  { $$ = $1; }
357  | else_inst
358  { $$ = instruction_undefined; }
359  | endif_inst
360  { $$ = instruction_undefined; }
361  | enddo_inst
362  { $$ = instruction_undefined; }
363  | do_inst
364  { $$ = instruction_undefined; }
365  | bdo_inst
366  { $$ = instruction_undefined; }
367  | wdo_inst
368  { $$ = instruction_undefined; }
369  | continue_inst
370  { $$ = $1; }
371  | stop_inst
372  { $$ = $1; }
373  | pause_inst
374  { $$ = $1; }
375  | call_inst
376  { $$ = $1; }
377  | return_inst
378  { $$ = $1; }
379  | io_inst
380  { $$ = $1; }
381  | entry_inst
382  { $$ = $1; }
383  ;
384 
385 return_inst: TK_RETURN opt_expression
386  { $$ = MakeReturn($2); }
387  ;
388 
389 call_inst: tk_call functional_entity_name
390  { $$ = MakeCallInst($2, NIL); reset_alternate_returns();}
391  |
392  tk_call functional_entity_name parameters
393  { $$ = MakeCallInst($2, $3); reset_alternate_returns(); }
394  ;
395 
396 tk_call: TK_CALL
397  { set_alternate_returns();}
398  ;
399 
400 parameters: TK_LPAR TK_RPAR
401  { $$ = NULL; }
402  | TK_LPAR arguments TK_RPAR
403  { $$ = $2; }
404  ;
405 
406 arguments: expression
407  {
408  $$ = CONS(EXPRESSION, $1, NIL);
409  }
410  | arguments TK_COMMA expression
411  {
412  $$ = gen_nconc($1, CONS(EXPRESSION, $3, NIL));
413  }
414  | TK_STAR TK_ICON
415  {
416  add_alternate_return($2);
417  $$ = CONS(EXPRESSION,
418  generate_string_for_alternate_return_argument($2),
419  NIL);
420  }
421  | arguments TK_COMMA TK_STAR TK_ICON
422  {
423  add_alternate_return($4);
424  $$ = gen_nconc($1, CONS(EXPRESSION,
425  generate_string_for_alternate_return_argument($4),
426  NIL));
427  }
428  ;
429 
430 
431 io_inst: io_keyword io_f_u_id /* io_keyword io_f_u_id */
432  {
433  $$ = MakeSimpleIoInst1($1, $2);
434  }
435  | io_keyword io_f_u_id TK_COMMA opt_lio_elem
436  {
437  $$ = MakeSimpleIoInst2($1, $2, $4);
438  }
439  | io_keyword TK_LPAR lci TK_RPAR opt_virgule opt_lio_elem
440  { $$ = MakeIoInstA($1, $3, $6); }
441  | iobuf_keyword TK_LPAR io_f_u_id TK_COMMA io_f_u_id TK_RPAR
442  TK_LPAR unpar_io_expr TK_COMMA unpar_io_expr TK_RPAR
443  { $$ = MakeIoInstB($1, $3, $5, $8, $10); }
444  ;
445 
446 io_f_u_id: unpar_io_expr
447  | TK_STAR
448  { $$ = MakeNullaryCall(CreateIntrinsic(LIST_DIRECTED_FORMAT_NAME)); }
449  ;
450 
451 lci: ci
452  { $$ = $1; }
453  | lci TK_COMMA ci
454  {
455  /*
456  CDR(CDR($3)) = $1;
457  $$ = $3;
458  */
459  $$ = gen_nconc($1, $3);
460  }
461  ;
462 
463 /* ci: name TK_EQUALS io_f_u_id */
464 ci: name TK_EQUALS unpar_io_expr
465  {
466  char buffer[20];
467  (void) strcpy(buffer, $1);
468  free($1);
469 
470  if(strcmp(buffer,"END")==0||strcmp(buffer,"ERR")==0) {
471  ;
472  }
473 
474  (void) strcat(buffer, "=");
475 
476  $$ = CONS(EXPRESSION,
477  MakeCharacterConstantExpression(buffer),
478  CONS(EXPRESSION, $3, NULL));
479  ici += 2;
480  }
481  | name TK_EQUALS TK_STAR
482  {
483  char buffer[20];
484  (void) strcpy(buffer, $1);
485  free($1);
486 
487  if(strcmp(buffer,"UNIT")!=0 && strcmp(buffer,"FMT")!=0) {
488  ParserError("parser",
489  "Illegal default option '*' in IO control list\n");
490  }
491 
492  (void) strcat(buffer, "=");
493 
494  $$ = CONS(EXPRESSION,
495  MakeCharacterConstantExpression(buffer),
496  CONS(EXPRESSION,
497  MakeNullaryCall(CreateIntrinsic(LIST_DIRECTED_FORMAT_NAME))
498  , NULL));
499  ici += 2;
500  }
501  | io_f_u_id
502  {
503  if(ici==1 || ici==2) {
504  $$ = CONS(EXPRESSION,
505  MakeCharacterConstantExpression(ici == 1 ?
506  "UNIT=" :
507  "FMT="),
508  CONS(EXPRESSION, $1, NULL));
509  }
510  else {
511  ParserError("Syntax", "The unit identifier and the format identifier"
512  " must be first and second in the control info list (standard Page F-12)");
513  }
514  ici += 1;
515  }
516 
517  ;
518 
519 opt_lio_elem:
520  { $$ = NULL; }
521  | lio_elem
522  { $$ = MakeIoList($1); }
523  ;
524 
525 lio_elem: io_elem
526  { $$ = CONS(EXPRESSION, $1, NULL); }
527  | lio_elem TK_COMMA io_elem
528  { $$ = CONS(EXPRESSION, $3, $1); }
529  ;
530 
531 io_elem: expression
532  { $$ = $1; }
533  ;
534 
535 pause_inst: TK_PAUSE opt_expression
536  { $$ = MakeZeroOrOneArgCallInst("PAUSE", $2); }
537  ;
538 
539 stop_inst: TK_STOP opt_expression
540  { $$ = MakeZeroOrOneArgCallInst("STOP", $2); }
541  ;
542 
543 continue_inst: TK_CONTINUE
544  { $$ = MakeZeroOrOneArgCallInst("CONTINUE", expression_undefined);}
545  ;
546 
547 do_inst: TK_DO label opt_virgule atom do_plage
548  {
549  MakeDoInst($4, $5, $2);
550  $$ = instruction_undefined;
551  }
552  ;
553 
554 bdo_inst: TK_DO atom do_plage
555  {
556  MakeDoInst($2, $3, "BLOCKDO");
557  $$ = instruction_undefined;
558  }
559  ;
560 
561 wdo_inst: TK_DO TK_WHILE TK_LPAR expression TK_RPAR
562  {
563  if(expression_implied_do_p($4))
564  ParserError("Syntax", "Unexpected implied DO\n");
565  MakeWhileDoInst($4, "BLOCKDO");
566  $$ = instruction_undefined;
567  }
568  | TK_DO label TK_WHILE TK_LPAR expression TK_RPAR
569  {
570  if(expression_implied_do_p($5))
571  ParserError("Syntax", "Unexpected implied DO\n");
572  MakeWhileDoInst($5, $2);
573  $$ = instruction_undefined;
574  }
575  ;
576 
577 do_plage: TK_EQUALS expression TK_COMMA expression
578  {
579  if(expression_implied_do_p($2) || expression_implied_do_p($4))
580  ParserError("Syntax", "Unexpected implied DO\n");
581  $$ = make_range($2, $4, int_to_expression(1));
582  }
583  | TK_EQUALS expression TK_COMMA expression TK_COMMA expression
584  {
585  if(expression_implied_do_p($2) || expression_implied_do_p($4)
586  || expression_implied_do_p($6))
587  ParserError("Syntax", "Unexpected implied DO\n");
588  $$ = make_range($2, $4, $6);
589  }
590  ;
591 
592 endif_inst: TK_ENDIF
593  { MakeEndifInst(); }
594  ;
595 
596 enddo_inst: TK_ENDDO
597  { MakeEnddoInst(); }
598  ;
599 
600 else_inst: TK_ELSE
601  { MakeElseInst(true); }
602  ;
603 
604 elseif_inst: TK_ELSEIF TK_LPAR expression TK_RPAR TK_THEN
605  {
606  int elsifs = MakeElseInst(false);
607 
608  if(expression_implied_do_p($3))
609  ParserError("Syntax", "Unexpected implied DO\n");
610  MakeBlockIfInst( $3, elsifs+1 );
611  $$ = instruction_undefined;
612  }
613  ;
614 
615 blockif_inst: TK_IF TK_LPAR expression TK_RPAR TK_THEN
616  {
617  if(expression_implied_do_p($3))
618  ParserError("Syntax", "Unexpected implied DO\n");
619  MakeBlockIfInst($3,0);
620  $$ = instruction_undefined;
621  }
622  ;
623 
624 logicalif_inst: TK_IF TK_LPAR expression TK_RPAR inst_exec
625  {
626  if(expression_implied_do_p($3))
627  ParserError("Syntax", "Unexpected implied DO\n");
628  $$ = MakeLogicalIfInst($3, $5);
629  }
630  ;
631 
632 arithmif_inst: TK_IF TK_LPAR expression TK_RPAR
633  label TK_COMMA label TK_COMMA label
634  {
635  if(expression_implied_do_p($3))
636  ParserError("Syntax", "Unexpected implied DO\n");
637  $$ = MakeArithmIfInst($3, $5, $7, $9);
638  }
639  ;
640 
641 goto_inst: TK_GOTO label
642  {
643  $$ = MakeGotoInst($2);
644  }
645  | TK_GOTO TK_LPAR licon TK_RPAR opt_virgule expression
646  {
647  if(expression_implied_do_p($6))
648  ParserError("Syntax", "Unexpected implied DO\n");
649  $$ = MakeComputedGotoInst($3, $6);
650  }
651  | TK_GOTO entity_name opt_virgule TK_LPAR licon TK_RPAR
652  {
653  if(get_bool_property("PARSER_SUBSTITUTE_ASSIGNED_GOTO")) {
654  $$ = MakeAssignedGotoInst($5, $2);
655  }
656  else {
657  ParserError("parser", "assigned goto statement prohibited"
658  " unless property PARSER_SUBSTITUTE_ASSIGNED_GOTO is set\n");
659  }
660  }
661  | TK_GOTO entity_name
662  {
663  if(get_bool_property("PARSER_SUBSTITUTE_ASSIGNED_GOTO")) {
664  ParserError("parser", "assigned goto statement cannot be"
665  " desugared without a target list\n");
666  }
667  else {
668  ParserError("parser", "assigned goto statement prohibited\n");
669  }
670  }
671  ;
672 
673 licon: label
674  {
675  $$ = CONS(STRING, $1, NIL);
676  }
677  | licon TK_COMMA label
678  {
679  $$ = CONS(STRING, $3, $1);
680  }
681  ;
682 
683 assignment_inst: TK_ASSIGN icon TK_TO atom
684  {
685  if(get_bool_property("PARSER_SUBSTITUTE_ASSIGNED_GOTO")) {
686  expression e = entity_to_expression($2);
687  $$ = MakeAssignInst($4, e);
688  }
689  else {
690  ParserError("parser", "ASSIGN statement prohibited by PIPS"
691  " unless property PARSER_SUBSTITUTE_ASSIGNED_GOTO is set\n");
692  }
693  }
694  | atom TK_EQUALS expression
695  {
696  syntax s = $1;
697  syntax new_s = syntax_undefined;
698 
699  if(expression_implied_do_p($3))
700  ParserError("Syntax", "Unexpected implied DO\n");
701 
702  new_s = CheckLeftHandSide(s);
703 
704  $$ = MakeAssignInst(new_s, $3);
705  }
706  ;
707 
708 format_inst: TK_FORMAT
709  {
710  set_first_format_statement();
711  $$ = MakeZeroOrOneArgCallInst("FORMAT",
712  MakeCharacterConstantExpression(FormatValue));
713  }
714  ;
715 
716 save_inst: TK_SAVE
717  { save_all_entities(); }
718  | TK_SAVE lsavename
719  | TK_STATIC lsavename
720  ;
721 
722 lsavename: savename
723  | lsavename TK_COMMA savename
724  ;
725 
726 savename: entity_name
727  { ProcessSave($1); }
728  | common_name
729  { SaveCommon($1); }
730  ;
731 
732 intrinsic_inst: TK_INTRINSIC global_entity_name
733  {
734  (void) DeclareIntrinsic($2);
735  }
736  | intrinsic_inst TK_COMMA global_entity_name
737  {
738  (void) DeclareIntrinsic($3);
739  }
740  ;
741 
742 external_inst: TK_EXTERNAL functional_entity_name
743  {
744  CurrentType = type_undefined;
745  (void) DeclareExternalFunction($2);
746  }
747  | external_inst TK_COMMA functional_entity_name
748  {
749  (void) DeclareExternalFunction($3);
750  }
751  ;
752 
753 type_inst: fortran_type declaration
754  {}
755  | type_inst TK_COMMA declaration
756  ;
757 
758 declaration: entity_name decl_tableau lg_fortran_type
759  {
760  /* the size returned by lg_fortran_type should be
761  consistent with CurrentType unless it is of type string
762  or undefined */
763  type t = CurrentType;
764 
765  if(t != type_undefined) {
766  basic b;
767 
768  if(!type_variable_p(CurrentType))
769  FatalError("yyparse", "ill. type for CurrentType\n");
770 
771  b = variable_basic(type_variable(CurrentType));
772 
773  /* character [*len1] foo [*len2]:
774  * if len2 is "default" then len1
775  */
776  if(basic_string_p(b))
777  t = value_intrinsic_p($3)? /* ??? default */
778  copy_type(t):
779  MakeTypeVariable
780  (make_basic(is_basic_string, $3), NIL);
781 
782  DeclareVariable($1, t, $2,
783  storage_undefined, value_undefined);
784 
785  if(basic_string_p(b))
786  free_type(t);
787  }
788  else
789  DeclareVariable($1, t, $2,
790  storage_undefined, value_undefined);
791 
792  $$ = $1;
793  }
794  ;
795 
796 decl_tableau:
797  {
798  $$ = NULL;
799  }
800  | TK_LPAR ldim_tableau TK_RPAR
801  {
802  $$ = $2;
803  }
804  ;
805 
806 ldim_tableau: dim_tableau
807  {
808  $$ = CONS(DIMENSION, $1, NULL);
809  }
810  | dim_tableau TK_COMMA ldim_tableau
811  {
812  $$ = CONS(DIMENSION, $1, $3);
813  }
814  ;
815 
816 dim_tableau: expression
817  {
818  expression e = $1;
819  type t = expression_to_type(e);
820  if(scalar_integer_type_p(t))
821  $$ = make_dimension(int_to_expression(1), e, NIL);
822  else // Not OK with gfortran, maybe OK with f77
823  ParserError("Syntax",
824  "Array sized with a non-integer expression");
825  free_type(t);
826  }
827  | TK_STAR
828  {
829  $$ = make_dimension(int_to_expression(1),
830  MakeNullaryCall(CreateIntrinsic(UNBOUNDED_DIMENSION_NAME)),
831  NIL);
832  }
833  | expression TK_COLON TK_STAR
834  {
835  $$ = make_dimension($1,
836  MakeNullaryCall(CreateIntrinsic(UNBOUNDED_DIMENSION_NAME)),
837  NIL);
838  }
839  | expression TK_COLON expression
840  {
841  expression e1 = $1;
842  type t1 = expression_to_type(e1);
843  expression e2 = $3;
844  type t2 = expression_to_type(e2);
845  if(scalar_integer_type_p(t1) && scalar_integer_type_p(t2))
846  $$ = make_dimension(e1, e2, NIL);
847  else // Not OK with gfortran, maybe OK with f77
848  ParserError("Syntax",
849  "Array sized with a non-integer expression");
850  free_type(t1), free_type(t2);
851  }
852  ;
853 
854 common_inst: common declaration
855  {
856  $$ = NameToCommon(BLANK_COMMON_LOCAL_NAME);
857  AddVariableToCommon($$, $2);
858  }
859  | common common_name declaration
860  {
861  $$ = $2;
862  AddVariableToCommon($$, $3);
863  }
864  | common_inst TK_COMMA declaration
865  {
866  $$ = $1;
867  AddVariableToCommon($$, $3);
868  }
869  | common_inst opt_virgule common_name declaration
870  {
871  $$ = $3;
872  AddVariableToCommon($$, $4);
873  }
874  ;
875 
876 
877 common: TK_COMMON
878  {
879  CurrentType = type_undefined;
880  }
881  ;
882 
883 common_name: TK_CONCAT
884  {
885  $$ = NameToCommon(BLANK_COMMON_LOCAL_NAME);
886  }
887  | TK_SLASH global_name TK_SLASH
888  {
889  $$ = NameToCommon($2);
890  }
891  ;
892 
893 pointer_inst: TK_POINTER TK_LPAR entity_name TK_COMMA entity_name decl_tableau TK_RPAR
894  {
895  DeclarePointer($3, $5, $6);
896  }
897  ;
898 
899 equivalence_inst: TK_EQUIVALENCE lequivchain
900  ;
901 
902 lequivchain: equivchain
903  | lequivchain TK_COMMA equivchain
904  ;
905 
906 equivchain: TK_LPAR latom TK_RPAR
907  { StoreEquivChain($2); }
908  ;
909 
910 latom: atom
911  {
912  $$ = make_chain(CONS(ATOM, MakeEquivAtom($1), (cons*) NULL));
913  }
914  | latom TK_COMMA atom
915  {
916  chain_atoms($1) = CONS(ATOM, MakeEquivAtom($3),
917  chain_atoms($1));
918  $$ = $1;
919  }
920  ;
921 
922 dimension_inst: dimension declaration
923  {
924  }
925  | dimension_inst TK_COMMA declaration
926  {
927  }
928  ;
929 
930 dimension: TK_DIMENSION
931  {
932  CurrentType = type_undefined;
933  }
934  ;
935 
936 data_inst: TK_DATA ldatavar TK_SLASH ldataval TK_SLASH
937  {
938  /* AnalyzeData($2, $4); */
939  MakeDataStatement($2, $4);
940  }
941  | data_inst opt_virgule ldatavar TK_SLASH ldataval TK_SLASH
942  {
943  /* AnalyzeData($3, $5); */
944  MakeDataStatement($3, $5);
945  }
946  ;
947 
948 ldatavar: datavar
949  {
950  $$ = CONS(EXPRESSION, $1, NIL);
951  }
952  | ldatavar TK_COMMA datavar
953  {
954  $$ = gen_nconc($1, CONS(EXPRESSION, $3, NIL));
955  }
956  ;
957 
958 /* rule reversal because of a stack overflow; bug hit.f */
959 ldataval: dataval
960  {
961  $$ = CONS(EXPRESSION, $1, NIL);
962  }
963  | ldataval TK_COMMA dataval
964  {
965  $$ = gen_nconc($1, CONS(EXPRESSION, $3, NIL));
966  }
967  ;
968 
969 dataval: dataconst
970  {
971  $$ = MakeDataValueSet(expression_undefined, $1);
972  }
973  | dataconst TK_STAR dataconst
974  {
975  $$ = MakeDataValueSet($1, $3);
976  }
977  ;
978 
979 dataconst: const_simple /* expression -> shift/reduce conflicts */
980  {
981  $$ = $1;
982  }
983  | TK_LPAR const_simple TK_COMMA const_simple TK_RPAR
984  {
985  $$ = MakeComplexConstantExpression($2, $4);
986  }
987  | entity_name
988  {
989  /* Cachan bug 4: there should be a check about the entity
990  * returned as $1 because MakeDatVal() is going to try
991  * to evaluate that expression. The entity must be a
992  * parameter.
993  */
994  if(symbolic_constant_entity_p($1)) {
995  $$ = make_expression(make_syntax(is_syntax_call,
996  make_call($1, NIL)),
997  normalized_undefined);
998  }
999  else {
1000  user_warning("gram", "Symbolic constant expected: %s\n",
1001  entity_local_name($1));
1002  if(strcmp("Z", entity_local_name($1))==0) {
1003  user_warning("gram",
1004  "Might be a non supported hexadecimal constant\n");
1005  }
1006  ParserError("gram", "Error in initializer");
1007  }
1008  }
1009 /*
1010  | entity_name TK_LPAR const_simple TK_COMMA const_simple TK_RPAR
1011  {
1012  bool simple = ENTITY_IMPLIED_CMPLX_P($1);
1013  pips_assert("is implied complex",
1014  simple || ENTITY_IMPLIED_DCMPLX_P($1) );
1015  $$ = MakeBinaryCall(CreateIntrinsic
1016  (simple? IMPLIED_COMPLEX_NAME: IMPLIED_DCOMPLEX_NAME), $3, $5);
1017  }
1018  */
1019  ;
1020 
1021 datavar: atom
1022  {
1023  $$ = make_expression($1, normalized_undefined);
1024  }
1025  | dataidl
1026  { $$ = $1; }
1027  ;
1028 
1029 dataidl: TK_LPAR ldatavar TK_COMMA entity_name do_plage TK_RPAR
1030  {
1031  /* $$ = MakeDataVar($2, $5); */
1032  reference r = make_reference($4, NIL);
1033  syntax s = make_syntax(is_syntax_reference, r);
1034  $$ = MakeImpliedDo(s, $5, $2);
1035  }
1036  ;
1037 
1038 implicit_inst: TK_IMPLICIT limplicit
1039  {
1040  /* Formal parameters have inherited default implicit types */
1041  retype_formal_parameters();
1042  }
1043  ;
1044 
1045 limplicit: implicit
1046  {
1047  }
1048  | limplicit TK_COMMA implicit
1049  {
1050  }
1051  ;
1052 
1053 implicit: fortran_type TK_LPAR l_letter_letter TK_RPAR
1054  {
1055  }
1056  ;
1057 
1058 l_letter_letter: letter_letter
1059  {
1060  }
1061  | l_letter_letter TK_COMMA letter_letter
1062  {
1063  }
1064  ;
1065 
1066 letter_letter: letter
1067  {
1068  basic b;
1069 
1070  pips_assert("gram.y", type_variable_p(CurrentType));
1071  b = variable_basic(type_variable(CurrentType));
1072 
1073  cr_implicit(basic_tag(b), SizeOfElements(b), $1, $1);
1074  }
1075  | letter TK_MINUS letter
1076  {
1077  basic b;
1078 
1079  pips_assert("gram.y", type_variable_p(CurrentType));
1080  b = variable_basic(type_variable(CurrentType));
1081 
1082  cr_implicit(basic_tag(b), SizeOfElements(b), $1, $3);
1083  }
1084  ;
1085 
1086 letter: TK_NAME
1087  {
1088  $$ = $1[0]; free($1);
1089  }
1090  ;
1091 
1092 parameter_inst: TK_PARAMETER TK_LPAR lparametre TK_RPAR
1093  ;
1094 
1095 lparametre: parametre
1096  | lparametre TK_COMMA parametre
1097  ;
1098 
1099 parametre: entity_name TK_EQUALS expression
1100  {
1101  AddEntityToDeclarations(MakeParameter($1, $3), get_current_module_entity());
1102  }
1103  ;
1104 
1105 entity_name: name
1106  {
1107  /* malloc_verify(); */
1108  /* if SafeFind were always used, intrinsic would mask local
1109  variables, either when the module declarations are not
1110  available or when a new entity still has to be
1111  declared. See Validation/capture01.f */
1112  /* Let's try not to search intrinsics in SafeFindOrCreateEntity(). */
1113  /* Do not declare undeclared variables, because it generates
1114  a problem when processing entries. */
1115  /* $$ = SafeFindOrCreateEntity(CurrentPackage, $1); */
1116 
1117  if(!entity_undefined_p(get_current_module_entity())) {
1118  $$ = SafeFindOrCreateEntity(CurrentPackage, $1);
1119  /* AddEntityToDeclarations($$, get_current_module_entity()); */
1120  }
1121  else
1122  $$ = FindOrCreateEntity(CurrentPackage, $1);
1123  free($1);
1124  }
1125  ;
1126 
1127 name: TK_NAME
1128  { $$ = $1; }
1129  ;
1130 
1131 module_name: global_name
1132  {
1133  /* $$ = FindOrCreateEntity(CurrentPackage, $1); */
1134  /* $$ = FindOrCreateEntity(TOP_LEVEL_MODULE_NAME, $1); */
1135  CurrentPackage = strdup($1);
1136  BeginingOfProcedure();
1137  free($1);
1138  $$ = (char*)CurrentPackage;
1139  }
1140  ;
1141 
1142 global_entity_name: global_name
1143  {
1144  /* $$ = FindOrCreateEntity(CurrentPackage, $1); */
1145  $$ = FindOrCreateEntity(TOP_LEVEL_MODULE_NAME, $1);
1146  free($1);
1147  }
1148  ;
1149 
1150 functional_entity_name: name
1151  {
1152  /* This includes BLOCKDATA modules because of EXTERNAL */
1153  $$ = NameToFunctionalEntity($1);
1154  free($1);
1155  }
1156  ;
1157 
1158 global_name: TK_NAME
1159  { $$ = $1; }
1160  ;
1161 
1162 opt_lformalparameter:
1163  {
1164  $$ = NULL;
1165  }
1166  | TK_LPAR TK_RPAR
1167  {
1168  $$ = NULL;
1169  }
1170  | TK_LPAR lformalparameter TK_RPAR
1171  {
1172  /* Too early: the current module is still unknown */
1173  /* $$ = add_formal_return_code($2); */
1174  $$ = $2;
1175  }
1176  ;
1177 
1178 lformalparameter: entity_name
1179  {
1180  $$ = CONS(ENTITY, $1, NULL);
1181  }
1182  | TK_STAR
1183  {
1184  uses_alternate_return(true);
1185  $$ = CONS(ENTITY,
1186  generate_pseudo_formal_variable_for_formal_label
1187  (CurrentPackage, get_current_number_of_alternate_returns()),
1188  NIL);
1189  }
1190  | lformalparameter TK_COMMA entity_name
1191  {
1192  $$ = gen_nconc($1, CONS(ENTITY, $3, NIL));
1193  }
1194  | lformalparameter TK_COMMA TK_STAR
1195  {
1196  uses_alternate_return(true);
1197  $$ = gen_nconc($1, CONS(ENTITY,
1198  generate_pseudo_formal_variable_for_formal_label
1199  (CurrentPackage, get_current_number_of_alternate_returns()),
1200  NIL));
1201  }
1202  ;
1203 
1204 opt_fortran_type: fortran_type
1205  {
1206  $$ = CurrentType = $1 ;
1207  }
1208  |
1209  {
1210  $$ = CurrentType = type_undefined;
1211  }
1212  ;
1213 
1214 fortran_type: fortran_basic_type lg_fortran_type
1215  {
1216  if (value_intrinsic_p($2)) /* ??? default! */
1217  {
1218  free_value($2);
1219  $2 = make_value_constant(
1220  make_constant_int( CurrentTypeSize));
1221  }
1222 
1223  $$ = CurrentType = MakeFortranType($1, $2);
1224  }
1225  ;
1226 
1227 fortran_basic_type: TK_INTEGER
1228  {
1229  $$ = is_basic_int;
1230  CurrentTypeSize = DEFAULT_INTEGER_TYPE_SIZE;
1231  }
1232  | TK_REAL
1233  {
1234  $$ = is_basic_float;
1235  CurrentTypeSize = DEFAULT_REAL_TYPE_SIZE;
1236  }
1237  | TK_DOUBLEPRECISION
1238  {
1239  $$ = is_basic_float;
1240  CurrentTypeSize = DEFAULT_DOUBLEPRECISION_TYPE_SIZE;
1241  }
1242  | TK_LOGICAL
1243  {
1244  $$ = is_basic_logical;
1245  CurrentTypeSize = DEFAULT_LOGICAL_TYPE_SIZE;
1246  }
1247  | TK_COMPLEX
1248  {
1249  $$ = is_basic_complex;
1250  CurrentTypeSize = DEFAULT_COMPLEX_TYPE_SIZE;
1251  }
1252  | TK_DOUBLECOMPLEX
1253  {
1254  $$ = is_basic_complex;
1255  CurrentTypeSize = DEFAULT_DOUBLECOMPLEX_TYPE_SIZE;
1256  }
1257  | TK_CHARACTER
1258  {
1259  $$ = is_basic_string;
1260  CurrentTypeSize = DEFAULT_CHARACTER_TYPE_SIZE;
1261  }
1262  ;
1263 
1264 lg_fortran_type:
1265  {
1266  $$ = make_value(is_value_intrinsic, UU); /* ??? default! */
1267  /* was: $$ = make_value(is_value_constant,
1268  * make_constant(is_constant_int, CurrentTypeSize));
1269  * then how to differentiate character*len1 foo[*len2]
1270  * if len2 is 1 or whatever... the issue is that
1271  * there should be two lg_..., one for the default that
1272  * would change CurrentTypeSize at ival, and the other not...
1273  * FC, 13/06/96
1274  */
1275  }
1276  | TK_STAR TK_LPAR TK_STAR TK_RPAR /* CHARACTER *(*) */
1277  {
1278  $$ = make_value_unknown();
1279  }
1280  | TK_STAR TK_LPAR expression TK_RPAR
1281  {
1282  $$ = MakeValueSymbolic($3);
1283  }
1284  | TK_STAR ival
1285  {
1286  $$ = make_value_constant(make_constant_int($2));
1287  }
1288  ;
1289 
1290 atom: entity_name
1291  {
1292  $$ = MakeAtom($1, NIL, expression_undefined,
1293  expression_undefined, false);
1294  }
1295  | entity_name indices
1296  {
1297  $$ = MakeAtom($1, $2, expression_undefined,
1298  expression_undefined, true);
1299  }
1300  | entity_name TK_LPAR opt_expression TK_COLON opt_expression TK_RPAR
1301  {
1302  $$ = MakeAtom($1, NIL, $3, $5, true);
1303  }
1304  | entity_name indices TK_LPAR opt_expression TK_COLON opt_expression TK_RPAR
1305  {
1306  $$ = MakeAtom($1, $2, $4, $6, true);
1307  }
1308  ;
1309 
1310 indices: TK_LPAR TK_RPAR
1311  { $$ = NULL; }
1312  | TK_LPAR lexpression TK_RPAR
1313  { $$ = FortranExpressionList($2); }
1314  ;
1315 
1316 lexpression: expression
1317  {
1318  $$ = CONS(EXPRESSION, $1, NULL);
1319  }
1320  | lexpression TK_COMMA expression
1321  {
1322  $$ = gen_nconc($1, CONS(EXPRESSION, $3, NIL));
1323  }
1324  ;
1325 
1326 opt_expression: expression
1327  {
1328  if(expression_implied_do_p($1))
1329  ParserError("Syntax", "Unexpected implied DO\n");
1330  $$ = $1;
1331  }
1332  |
1333  { $$ = expression_undefined; }
1334  ;
1335 
1336 expression: sous_expression
1337  { $$ = $1; }
1338  | TK_LPAR expression TK_RPAR
1339  { $$ = $2; }
1340  | TK_LPAR expression TK_COMMA expression TK_RPAR
1341  {
1342  expression c = MakeComplexConstantExpression($2, $4);
1343 
1344  if(expression_undefined_p(c))
1345  ParserError("Syntax", "Illegal complex constant\n");
1346 
1347  $$ = c;
1348  }
1349  | TK_LPAR expression TK_COMMA atom do_plage TK_RPAR
1350  { $$ = MakeImpliedDo($4, $5, CONS(EXPRESSION, $2, NIL)); }
1351  | TK_LPAR expression TK_COMMA lexpression TK_COMMA atom do_plage TK_RPAR
1352  { $$ = MakeImpliedDo($6, $7, CONS(EXPRESSION, $2, $4)); }
1353  ;
1354 
1355 sous_expression: atom
1356  {
1357  $$ = make_expression($1, normalized_undefined);
1358  }
1359  | unsigned_const_simple
1360  {
1361  $$ = MakeNullaryCall($1);
1362  }
1363  | signe expression %prec TK_STAR
1364  {
1365  if ($1 == -1)
1366  $$ = MakeFortranUnaryCall(CreateIntrinsic("--"), $2);
1367  else
1368  $$ = $2;
1369  }
1370  | expression TK_PLUS expression
1371  {
1372  $$ = MakeFortranBinaryCall(CreateIntrinsic("+"), $1, $3);
1373  }
1374  | expression TK_MINUS expression
1375  {
1376  $$ = MakeFortranBinaryCall(CreateIntrinsic("-"), $1, $3);
1377  }
1378  | expression TK_STAR expression
1379  {
1380  $$ = MakeFortranBinaryCall(CreateIntrinsic("*"), $1, $3);
1381  }
1382  | expression TK_SLASH expression
1383  {
1384  $$ = MakeFortranBinaryCall(CreateIntrinsic("/"), $1, $3);
1385  }
1386  | expression TK_POWER expression
1387  {
1388  $$ = MakeFortranBinaryCall(CreateIntrinsic("**"),
1389  $1, $3);
1390  }
1391  | expression oper_rela expression %prec TK_EQ
1392  {
1393  $$ = MakeFortranBinaryCall($2, $1, $3);
1394  }
1395  | expression TK_EQV expression
1396  {
1397  $$ = MakeFortranBinaryCall(CreateIntrinsic(".EQV."),
1398  $1, $3);
1399  }
1400  | expression TK_NEQV expression
1401  {
1402  $$ = MakeFortranBinaryCall(CreateIntrinsic(".NEQV."),
1403  $1, $3);
1404  }
1405  | expression TK_OR expression
1406  {
1407  $$ = MakeFortranBinaryCall(CreateIntrinsic(".OR."),
1408  fix_if_condition($1),
1409  fix_if_condition($3));
1410  }
1411  | expression TK_AND expression
1412  {
1413  $$ = MakeFortranBinaryCall(CreateIntrinsic(".AND."),
1414  fix_if_condition($1),
1415  fix_if_condition($3));
1416  }
1417  | TK_NOT expression
1418  {
1419  $$ = MakeFortranUnaryCall(CreateIntrinsic(".NOT."),
1420  fix_if_condition($2));
1421  }
1422  | expression TK_CONCAT expression
1423  {
1424  $$ = MakeFortranBinaryCall(CreateIntrinsic("//"),
1425  $1, $3);
1426  }
1427  ;
1428 
1429 io_expr: unpar_io_expr
1430  | TK_LPAR io_expr TK_RPAR
1431  { $$ = $2; }
1432  ;
1433 
1434 unpar_io_expr: atom
1435  {
1436  $$ = make_expression($1, normalized_undefined);
1437  }
1438 /* | const_simple */
1439  | unsigned_const_simple
1440  {
1441  $$ = MakeNullaryCall($1);
1442  }
1443  | signe io_expr %prec TK_STAR
1444  {
1445  if ($1 == -1)
1446  $$ = MakeFortranUnaryCall(CreateIntrinsic("--"), $2);
1447  else
1448  $$ = $2;
1449  }
1450  | io_expr TK_PLUS io_expr
1451  {
1452  $$ = MakeFortranBinaryCall(CreateIntrinsic("+"), $1, $3);
1453  }
1454  | io_expr TK_MINUS io_expr
1455  {
1456  $$ = MakeFortranBinaryCall(CreateIntrinsic("-"), $1, $3);
1457  }
1458  | io_expr TK_STAR io_expr
1459  {
1460  $$ = MakeFortranBinaryCall(CreateIntrinsic("*"), $1, $3);
1461  }
1462  | io_expr TK_SLASH io_expr
1463  {
1464  $$ = MakeFortranBinaryCall(CreateIntrinsic("/"), $1, $3);
1465  }
1466  | io_expr TK_POWER io_expr
1467  {
1468  $$ = MakeFortranBinaryCall(CreateIntrinsic("**"),
1469  $1, $3);
1470  }
1471  | io_expr TK_CONCAT io_expr
1472  {
1473  $$ = MakeFortranBinaryCall(CreateIntrinsic("//"),
1474  $1, $3);
1475  }
1476  ;
1477 
1478 const_simple: opt_signe unsigned_const_simple
1479  {
1480  if ($1 == -1)
1481  $$ = MakeUnaryCall(CreateIntrinsic("--"),
1482  MakeNullaryCall($2));
1483  else
1484  $$ = MakeNullaryCall($2);
1485  }
1486  ;
1487 
1488 unsigned_const_simple: TK_TRUE
1489  {
1490  $$ = SafeMakeConstant(".TRUE.", is_basic_logical, ParserError);
1491  }
1492  | TK_FALSE
1493  {
1494  $$ = SafeMakeConstant(".FALSE.", is_basic_logical, ParserError);
1495  }
1496  | icon
1497  {
1498  $$ = $1;
1499  }
1500  | TK_DCON
1501  {
1502  $$ = make_Fortran_constant_entity($1, is_basic_float,
1503  DEFAULT_DOUBLEPRECISION_TYPE_SIZE);
1504  free($1);
1505  }
1506  | TK_SCON
1507  {
1508  $$ = SafeMakeConstant($1, is_basic_string, ParserError);
1509  free($1);
1510  }
1511  | TK_RCON
1512  {
1513  $$ = SafeMakeConstant($1, is_basic_float, ParserError);
1514  free($1);
1515  }
1516  ;
1517 
1518 icon: TK_ICON
1519  {
1520  $$ = SafeMakeConstant($1, is_basic_int, ParserError);
1521  free($1);
1522  }
1523  ;
1524 
1525 label: TK_ICON
1526  {
1527  $$ = $1;
1528  }
1529  ;
1530 
1531 ival: TK_ICON
1532  {
1533  $$ = atoi($1);
1534  free($1);
1535  }
1536  ;
1537 
1538 opt_signe:
1539  {
1540  $$ = 1;
1541  }
1542  | signe
1543  {
1544  $$ = $1;
1545  }
1546  ;
1547 
1548 signe: TK_PLUS
1549  {
1550  $$ = 1;
1551  }
1552  | TK_MINUS
1553  {
1554  $$ = -1;
1555  }
1556  ;
1557 
1558 oper_rela: TK_EQ
1559  {
1560  $$ = CreateIntrinsic(".EQ.");
1561  }
1562  | TK_NE
1563  {
1564  $$ = CreateIntrinsic(".NE.");
1565  }
1566  | TK_LT
1567  {
1568  $$ = CreateIntrinsic(".LT.");
1569  }
1570  | TK_LE
1571  {
1572  $$ = CreateIntrinsic(".LE.");
1573  }
1574  | TK_GE
1575  {
1576  $$ = CreateIntrinsic(".GE.");
1577  }
1578  | TK_GT
1579  {
1580  $$ = CreateIntrinsic(".GT.");
1581  }
1582  ;
1583 
1584 io_keyword: TK_PRINT
1585  { $$ = TK_PRINT; ici = 1; }
1586  | TK_WRITE
1587  { $$ = TK_WRITE; ici = 1; }
1588  | TK_READ
1589  { $$ = TK_READ; ici = 1; }
1590  | TK_CLOSE
1591  { $$ = TK_CLOSE; ici = 1; }
1592  | TK_OPEN
1593  { $$ = TK_OPEN; ici = 1; }
1594  | TK_ENDFILE
1595  { $$ = TK_ENDFILE; ici = 1; }
1596  | TK_BACKSPACE
1597  { $$ = TK_BACKSPACE; ici = 1; }
1598  | TK_REWIND
1599  { $$ = TK_REWIND; ici = 1; }
1600  | TK_INQUIRE
1601  { $$ = TK_INQUIRE; ici = 1; }
1602  ;
1603 
1604 iobuf_keyword: TK_BUFFERIN
1605  { $$ = TK_BUFFERIN; ici = 1; }
1606  | TK_BUFFEROUT
1607  { $$ = TK_BUFFEROUT ; ici = 1; }
1608  ;
1609 
1610 psf_keyword: TK_PROGRAM
1611  { $$ = TK_PROGRAM; init_ghost_variable_entities(); }
1612  | TK_SUBROUTINE
1613  { $$ = TK_SUBROUTINE; init_ghost_variable_entities();
1614  set_current_number_of_alternate_returns();}
1615  | TK_FUNCTION
1616  { $$ = TK_FUNCTION; init_ghost_variable_entities();
1617  set_current_number_of_alternate_returns();}
1618  | TK_BLOCKDATA
1619  { $$ = TK_BLOCKDATA; init_ghost_variable_entities(); }
1620  ;
1621 
1622 opt_virgule:
1623  | TK_COMMA
1624  ;
1625 %%