New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 10725 for vendors/AGRIF/CMEMS_2020/LEX/fortran.y – NEMO

Ignore:
Timestamp:
2019-02-27T14:55:54+01:00 (5 years ago)
Author:
rblod
Message:

Update agrif library and conv see ticket #2129

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendors/AGRIF/CMEMS_2020/LEX/fortran.y

    r9140 r10725  
    4242 
    4343extern int line_num_input; 
    44 extern char *fortran_text; 
    4544 
    4645char c_selectorname[LONG_M]; 
     
    5049int c_selectorgiven=0; 
    5150listvar *curlistvar; 
     51int in_select_case_stmt=0; 
    5252typedim c_selectordim; 
    5353listcouple *coupletmp; 
    5454int removeline=0; 
     55int token_since_endofstmt = 0; 
     56int increment_nbtokens = 1; 
     57int in_complex_literal = 0; 
     58int close_or_connect = 0; 
     59int in_io_control_spec = 0; 
     60int intent_spec = 0; 
     61long int my_position; 
     62long int my_position_before; 
     63int suborfun = 0; 
     64int indeclaration = 0; 
     65int endoffile = 0; 
     66int in_inquire = 0; 
     67int in_char_selector = 0; 
     68int in_kind_selector =0; 
     69int char_length_toreset = 0; 
     70 
     71typedim my_dim; 
     72 
    5573listvar *test; 
     74 
     75char linebuf1[1024]; 
     76char linebuf2[1024]; 
    5677 
    5778int fortran_error(const char *s) 
    5879{ 
    59     printf("%s line %d, file %s motclef = |%s|\n", s, line_num_input, cur_filename, fortran_text); 
     80  if (endoffile == 1)  
     81  { 
     82  endoffile = 0; 
     83  return 0; 
     84  } 
     85    printf("%s line %d, file %s culprit = |%s|\n", s, line_num_input, cur_filename, strcat(linebuf1, linebuf2)); 
    6086    exit(1); 
    6187} 
     
    94120%token TOK_PROGRAM 
    95121%token TOK_FUNCTION 
    96 %token TOK_FORMAT 
     122%token TOK_LABEL_FORMAT 
     123%token TOK_LABEL_CONTINUE 
     124%token TOK_LABEL_END_DO 
    97125%token TOK_MAX 
    98126%token TOK_TANH 
     127%token TOK_COMMENT 
    99128%token TOK_WHERE 
    100129%token TOK_ELSEWHEREPAR 
     
    109138%token TOK_SELECTCASE 
    110139%token TOK_FILE 
     140%token TOK_REC 
     141%token TOK_NAME_EQ 
     142%token TOK_IOLENGTH 
     143%token TOK_ACCESS 
     144%token TOK_ACTION 
     145%token TOK_FORM 
     146%token TOK_RECL 
     147%token TOK_STATUS 
    111148%token TOK_UNIT 
     149%token TOK_OPENED 
    112150%token TOK_FMT 
    113151%token TOK_NML 
    114152%token TOK_END 
    115153%token TOK_EOR 
     154%token TOK_EOF 
    116155%token TOK_ERR 
     156%token TOK_POSITION 
     157%token TOK_IOSTAT 
     158%token TOK_IOMSG 
    117159%token TOK_EXIST 
    118160%token TOK_MIN 
    119161%token TOK_FLOAT 
    120162%token TOK_EXP 
     163%token TOK_LEN 
    121164%token TOK_COS 
    122165%token TOK_COSH 
     
    139182%token TOK_MAXLOC 
    140183%token TOK_EXIT 
     184%token TOK_KIND 
     185%token TOK_MOLD 
     186%token TOK_SOURCE 
     187%token TOK_ERRMSG 
    141188%token TOK_MINVAL 
    142189%token TOK_PUBLIC 
     
    150197%token TOK_PRINT 
    151198%token TOK_PLAINGOTO 
    152 %token TOK_LOGICALIF 
     199%token <na> TOK_LOGICALIF 
     200%token <na> TOK_LOGICALIF_PAR 
    153201%token TOK_PLAINDO 
    154202%token TOK_CONTAINS 
     
    162210%token TOK_CLOSE 
    163211%token TOK_INQUIRE 
     212%token TOK_WRITE_PAR 
    164213%token TOK_WRITE 
    165 %token TOK_FLUSH 
     214%token <na> TOK_FLUSH 
     215%token TOK_READ_PAR 
    166216%token TOK_READ 
    167217%token TOK_REWIND 
     
    192242%token TOK_PROCEDURE 
    193243%token TOK_STOP 
    194 %token TOK_REAL8 
    195244%token TOK_FOURDOTS 
    196245%token <na> TOK_HEXA 
     
    214263%token <na> TOK_NOT 
    215264%token <na> TOK_AND 
     265%token <na> TOK_EQUALEQUAL 
     266%token <na> TOK_SLASHEQUAL 
     267%token <na> TOK_INFEQUAL 
     268%token <na> TOK_SUPEQUAL 
    216269%token <na> TOK_TRUE 
    217270%token <na> TOK_FALSE 
    218271%token <na> TOK_LABEL 
     272%token <na> TOK_LABEL_DJVIEW 
     273%token <na> TOK_PLAINDO_LABEL_DJVIEW 
     274%token <na> TOK_PLAINDO_LABEL 
    219275%token <na> TOK_TYPE 
    220276%token <na> TOK_TYPEPAR 
    221277%token <na> TOK_ENDTYPE 
     278%token TOK_COMMACOMPLEX 
    222279%token <na> TOK_REAL 
    223280%token <na> TOK_INTEGER 
     
    246303%token '>' 
    247304%type <l> dcl 
    248 %type <l> after_type 
    249305%type <l> dimension 
     306%type <l> array-name-spec-list 
    250307%type <l> paramlist 
    251308%type <l> args 
     309%type <na> declaration-type-spec 
    252310%type <l> arglist 
    253311%type <lc> only_list 
     312%type <lc> only-list 
     313%type <lc> opt-only-list 
     314%type <lc> only 
    254315%type <lc> only_name 
    255 %type <lc> rename_list 
    256 %type <lc> rename_name 
     316%type <lc> rename-list 
     317%type <lc> opt-rename-list 
     318%type <lc> rename 
    257319%type <d> dims 
    258320%type <d> dimlist 
     
    261323%type <na> comblock 
    262324%type <na> name_routine 
     325%type <na> type-param-value 
    263326%type <na> opt_name 
     327%type <na> constant-expr 
     328%type <na> ac-implied-do 
     329%type <na> subroutine-name 
     330%type <l> opt-dummy-arg-list-par 
     331%type <l> opt-dummy-arg-list 
     332%type <l> dummy-arg-list 
     333%type <l> named-constant-def-list 
     334%type <v> named-constant-def 
     335%type <na> ac-do-variable 
     336%type <na> data-i-do-variable 
     337%type <na> data-stmt-constant 
     338%type <na> do-variable 
     339%type <na> ac-implied-do-control 
     340%type <na> label 
     341%type <na> opt-label 
     342%type <na> label-djview 
     343%type <na> opt-label-djview 
    264344%type <na> type 
    265 %type <na> word_endsubroutine 
    266 %type <na> word_endfunction 
    267 %type <na> word_endprogram 
    268 %type <na> word_endunit 
     345%type <na> real-literal-constant 
     346%type <l> type-declaration-stmt 
     347%type <d> array-spec 
     348%type <d> assumed-shape-spec-list 
     349%type <d> deferred-shape-spec-list 
     350%type <d> assumed-size-spec 
     351%type <d> implied-shape-spec-list 
    269352%type <na> typespec 
     353%type <na> null-init 
     354%type <na> initial-data-target 
     355%type <na> intent-spec 
    270356%type <na> string_constant 
     357%type <na> access-id 
     358%type <na> dummy-arg-name 
     359%type <na> common-block-name 
     360%type <na> function-name 
     361%type <na> dummy-arg 
     362%type <na> lower-bound 
     363%type <na> upper-bound 
     364%type <na> scalar-constant-subobject 
     365%type <na> opt-data-stmt-star 
    271366%type <na> simple_const 
     367%type <na> opt-char-selector 
     368%type <na> char-selector 
    272369%type <na> ident 
    273370%type <na> intent_spec 
     371%type <na> kind-param 
    274372%type <na> signe 
     373%type <na> scalar-int-constant-expr 
    275374%type <na> opt_signe 
     375%type <dim1> explicit-shape-spec 
     376%type <d> explicit-shape-spec-list 
     377%type <dim1> assumed-shape-spec 
     378%type <dim1> deferred-shape-spec 
    276379%type <na> filename 
    277380%type <na> attribute 
     
    279382%type <na> begin_array 
    280383%type <na> clause 
     384%type <na> only-use-name 
     385%type <na> generic-spec 
    281386%type <na> arg 
     387%type <d> opt-array-spec-par 
     388%type <d> opt-explicit-shape-spec-list-comma 
     389%type <d> explicit-shape-spec-list-comma 
    282390%type <na> uexpr 
     391%type <na> section_subscript_ambiguous 
    283392%type <na> minmaxlist 
     393%type <na> subscript 
     394%type <na> subscript-triplet 
     395%type <na> vector-subscript 
    284396%type <na> lhs 
    285 %type <na> vec 
    286397%type <na> outlist 
    287398%type <na> other 
     399%type <na> int-constant-expr 
    288400%type <na> dospec 
    289401%type <na> expr_data 
     
    298410%type <na> opt_expr 
    299411%type <na> optexpr 
     412%type <v> entity-decl 
     413%type <l> entity-decl-list 
    300414%type <lnn> data_stmt_value_list 
     415%type <lnn> data-stmt-value-list 
     416%type <lnn> access-id-list 
     417%type <lnn> opt-access-id-list 
     418%type <na> data-stmt-value 
     419%type <l> data-stmt-object-list 
     420%type <l> data-i-do-object-list 
     421%type <v> data-stmt-object 
     422%type <v> data-i-do-object 
    301423%type <lnn> datanamelist 
    302424%type <na> after_slash 
    303425%type <na> after_equal 
    304426%type <na> predefinedfunction 
     427%type <na> equiv-op 
     428%type <na> or-op 
     429%type <na> and-op 
     430%type <na> not-op 
     431%type <na> equiv-operand 
     432%type <na> or-operand 
     433%type <na> and-operand 
     434%type <na> mult-operand 
     435%type <na> rel-op 
     436%type <na> concat-op 
     437%type <na> add-operand 
     438%type <na> add-op 
     439%type <na> power-op 
     440%type <na> section-subscript-list 
     441%type <na> opt-lower-bound-2points 
     442%type <na> mult-op 
     443%type <na> array-constructor 
    305444%type <na> expr 
     445%type <na> function-reference 
     446%type <na> literal-constant 
     447%type <na> named-constant 
     448%type <na> ac-value-list 
     449%type <na> ac-value 
     450%type <na> intrinsic-type-spec 
     451%type <na> opt-kind-selector 
     452%type <na> char-literal-constant 
     453%type <na> logical-literal-constant 
     454%type <na> real-part 
     455%type <na> imag-part 
     456%type <na> sign 
     457%type <na> signed-int-literal-constant 
     458%type <na> int-literal-constant 
     459%type <na> signed-real-literal-constant 
     460%type <na> complex-literal-constant 
     461%type <na> actual-arg-spec-list 
     462%type <na> procedure-designator 
     463%type <na> constant 
     464%type <na> data-ref 
     465%type <v> structure-component 
     466%type <v> scalar-structure-component 
     467%type <na> int-expr 
     468%type <na> ac-spec 
     469%type <na> type-spec 
     470%type <na> derived-type-spec 
     471%type <v> part-ref 
     472%type <na> opt-part-ref 
     473%type <na> actual-arg-spec 
     474%type <na> kind-selector 
     475%type <na> actual-arg 
     476%type <na> section-subscript 
     477%type <na> keyword 
     478%type <na> primary 
     479%type <na> specification-expr 
     480%type <v> variable 
     481%type <v> data-implied-do 
     482%type <na> substring-range 
     483%type <v> designator 
     484%type <na> object-name 
     485%type <na> object-name-noident 
     486%type <na> array-element 
     487%type <na> array-section 
     488%type <na> scalar-variable-name 
     489%type <na> scalar-constant 
     490%type <na> variable-name 
     491%type <na> opt-subscript  
     492%type <na> stride 
     493%type <na> opt-scalar-int-expr 
     494%type <na> scalar-int-expr 
     495%type <na> level-1-expr 
     496%type <na> level-2-expr 
     497%type <na> level-3-expr 
     498%type <na> level-4-expr 
     499%type <na> level-5-expr 
    306500%type <na> ubound 
    307501%type <na> operation 
     
    311505 
    312506%% 
    313 input : 
     507/* R201 : program */ 
     508/*program: line-break 
     509     | program-unit 
     510     | program program-unit 
     511     ; 
     512*/ 
     513 
     514input: 
    314515      | input line 
    315516      ; 
    316 line :  line-break 
     517line:  line-break 
    317518      | suite_line_list 
    318       | TOK_LABEL suite_line_list 
    319519      | error {yyerrok;yyclearin;} 
    320520      ; 
    321 line-break: 
    322         '\n' fin_line 
     521line-break: '\n' fin_line 
     522      {token_since_endofstmt = 0; increment_nbtokens = 0;} 
    323523      | TOK_SEMICOLON 
     524      | TOK_EOF 
    324525      | line-break '\n' fin_line 
    325526      | line-break TOK_SEMICOLON 
    326       | line-break TOK_LABEL 
    327527      ; 
    328528suite_line_list : 
     
    331531      | suite_line_list TOK_SEMICOLON suite_line 
    332532      ; 
    333 suite_line : 
    334         entry fin_line     /* subroutine, function, module                    */ 
    335       | spec fin_line      /* declaration                                     */ 
     533suite_line:program-unit 
    336534      | TOK_INCLUDE filename fin_line 
    337535        { 
     
    342540            } 
    343541        } 
     542      | TOK_COMMENT 
     543      ; 
     544/* 
     545suite_line: 
     546        entry fin_line     subroutine, function, module                     
     547      | spec fin_line       declaration                                      
     548      | TOK_INCLUDE filename fin_line 
     549        { 
     550            if (inmoduledeclare == 0 ) 
     551            { 
     552                pos_end = setposcur(); 
     553                RemoveWordSET_0(fortran_out,pos_curinclude,pos_end-pos_curinclude); 
     554            } 
     555        } 
    344556      | execution-part-construct 
    345557      ; 
    346  
    347 fin_line : { pos_cur = setposcur(); } 
    348       ; 
    349  
     558*/ 
     559 
     560fin_line: { pos_cur = setposcur(); } 
     561      ; 
     562 
     563/* R202 : program-unit */ 
     564program-unit: main-program 
     565     | external-subprogram 
     566     | module 
     567     ; 
     568  
     569/*R203 : external-subprogram */ 
     570external-subprogram: function-subprogram 
     571     | subroutine-subprogram 
     572     ; 
     573      
    350574opt_recursive :         { isrecursive = 0; } 
    351575      | TOK_RECURSIVE   { isrecursive = 1; } 
     
    356580      ; 
    357581 
    358 entry : opt_recursive TOK_SUBROUTINE name_routine arglist 
    359         { 
    360             insubroutinedeclare = 1; 
    361             if ( firstpass ) 
    362                 Add_SubroutineArgument_Var_1($4); 
    363             else 
    364                 WriteBeginof_SubLoop(); 
    365         } 
    366       | TOK_PROGRAM name_routine 
    367         { 
    368             insubroutinedeclare = 1; 
    369             inprogramdeclare = 1; 
    370             /* in the second step we should write the head of       */ 
    371             /*    the subroutine sub_loop_<subroutinename>          */ 
    372             if ( ! firstpass ) 
    373                 WriteBeginof_SubLoop(); 
    374         } 
    375       | opt_recursive TOK_FUNCTION name_routine arglist opt_result 
    376         { 
    377             insubroutinedeclare = 1; 
    378             strcpy(DeclType, ""); 
    379             /* we should to list of the subroutine argument the  */ 
    380             /*    name of the function which has to be defined   */ 
    381             if ( firstpass ) 
    382             { 
    383                 Add_SubroutineArgument_Var_1($4); 
    384                 if ( ! is_result_present ) 
    385                     Add_FunctionType_Var_1($3); 
    386             } 
    387             else 
    388             /* in the second step we should write the head of    */ 
    389             /*    the subroutine sub_loop_<subroutinename>       */ 
    390                 WriteBeginof_SubLoop(); 
    391         } 
    392       | TOK_MODULE TOK_NAME 
    393         { 
    394             GlobalDeclaration = 0; 
    395             strcpy(curmodulename,$2); 
    396             strcpy(subroutinename,""); 
    397             Add_NameOfModule_1($2); 
    398             if ( inmoduledeclare == 0 ) 
    399             { 
    400                 /* To know if there are in the module declaration    */ 
    401                 inmoduledeclare = 1; 
    402                 /* to know if a module has been met                  */ 
    403                 inmodulemeet = 1; 
    404                 /* to know if we are after the keyword contains      */ 
    405                 aftercontainsdeclare = 0 ; 
    406             } 
    407         } 
    408       ; 
    409  
    410 /* R312 : label */ 
    411 label: TOK_CSTINT 
    412      | label TOK_CSTINT 
    413      ; 
    414  
    415582name_routine :  TOK_NAME    { strcpy($$, $1); strcpy(subroutinename, $1); } 
    416583      ; 
     
    419586arglist :               { if ( firstpass ) $$=NULL; } 
    420587      | '(' ')'         { if ( firstpass ) $$=NULL; } 
    421       | '(' args ')'    { if ( firstpass ) $$=$2; } 
     588      | '(' {in_complex_literal=0;} args ')'    { if ( firstpass ) $$=$3; } 
    422589      ; 
    423590arglist_after_result: 
    424591      | '(' ')' 
    425       | '(' args ')'    { if ( firstpass ) Add_SubroutineArgument_Var_1($2); } 
     592      | '(' {in_complex_literal=0;} args ')'    { if ( firstpass ) Add_SubroutineArgument_Var_1($3); } 
    426593      ; 
    427594args :  arg 
     
    452619      | '*'     { strcpy($$,"*"); } 
    453620      ; 
    454 spec :  type after_type 
    455       | TOK_TYPE opt_spec opt_sep opt_name  { inside_type_declare = 1; } 
    456       | TOK_ENDTYPE opt_name                { inside_type_declare = 0; } 
    457       | TOK_POINTER list_couple 
    458       | before_parameter '(' paramlist ')' 
    459         { 
    460             if ( ! inside_type_declare ) 
    461             { 
    462                 if ( firstpass ) 
    463                 { 
    464                     if ( insubroutinedeclare )  Add_Parameter_Var_1($3); 
    465                     else                        Add_GlobalParameter_Var_1($3); 
    466                 } 
    467                 else 
    468                 { 
    469                     pos_end = setposcur(); 
    470                     RemoveWordSET_0(fortran_out, pos_cur_decl, pos_end-pos_cur_decl); 
    471                 } 
    472             } 
    473             VariableIsParameter =  0 ; 
    474         } 
    475       | before_parameter paramlist 
    476         { 
    477             if ( ! inside_type_declare ) 
    478             { 
    479                 if ( firstpass ) 
    480                 { 
    481                     if ( insubroutinedeclare )  Add_Parameter_Var_1($2); 
    482                     else                        Add_GlobalParameter_Var_1($2); 
    483                 } 
    484                 else 
    485                 { 
    486                     pos_end = setposcur(); 
    487                     RemoveWordSET_0(fortran_out,pos_cur_decl,pos_end-pos_cur_decl); 
    488                 } 
    489             } 
    490             VariableIsParameter =  0 ; 
    491         } 
    492       | common 
    493       | save 
    494         { 
    495             pos_end = setposcur(); 
    496             RemoveWordSET_0(fortran_out,pos_cursave,pos_end-pos_cursave); 
    497         } 
    498       | implicit 
    499       | dimension 
    500         { 
    501             /* if the variable is a parameter we can suppose that is   */ 
    502             /*    value is the same on each grid. It is not useless to */ 
    503             /*    create a copy of it on each grid                     */ 
    504             if ( ! inside_type_declare ) 
    505             { 
    506                 if ( firstpass ) 
    507                 { 
    508                     Add_Globliste_1($1); 
    509                     /* if variableparamlists has been declared in a subroutine   */ 
    510                     if ( insubroutinedeclare )     Add_Dimension_Var_1($1); 
    511                 } 
    512                 else 
    513                 { 
    514                     pos_end = setposcur(); 
    515                     RemoveWordSET_0(fortran_out,pos_curdimension,pos_end-pos_curdimension); 
    516                 } 
    517             } 
    518             PublicDeclare = 0; 
    519             PrivateDeclare = 0; 
    520             ExternalDeclare = 0; 
    521             strcpy(NamePrecision,""); 
    522             c_star = 0; 
    523             InitialValueGiven = 0 ; 
    524             strcpy(IntentSpec,""); 
    525             VariableIsParameter =  0 ; 
    526             Allocatabledeclare = 0 ; 
    527             Targetdeclare = 0 ; 
    528             SaveDeclare = 0; 
    529             pointerdeclare = 0; 
    530             optionaldeclare = 0 ; 
    531             dimsgiven=0; 
    532             c_selectorgiven=0; 
    533             strcpy(nameinttypename,""); 
    534             strcpy(c_selectorname,""); 
    535         } 
    536       | public 
    537         { 
    538             if (firstpass == 0) 
    539             { 
    540                 if ($1) 
    541                 { 
    542                     removeglobfromlist(&($1)); 
    543                     pos_end = setposcur(); 
    544                     RemoveWordSET_0(fortran_out,pos_cur,pos_end-pos_cur); 
    545                     writelistpublic($1); 
    546                 } 
    547             } 
    548         } 
    549       | private 
    550       | use_stat 
    551       | module_proc_stmt 
    552       | namelist 
    553       | TOK_BACKSPACE '(' expr ')' 
    554       | TOK_EXTERNAL opt_sep use_name_list 
    555       | TOK_INTRINSIC opt_sep use_intrinsic_list 
    556       | TOK_EQUIVALENCE list_expr_equi 
    557       | data_stmt '\n' 
    558         { 
    559             /* we should remove the data declaration                */ 
    560             pos_end = setposcur(); 
    561             RemoveWordSET_0(fortran_out,pos_curdata,pos_end-pos_curdata); 
    562  
    563             if ( aftercontainsdeclare == 1  && firstpass == 0 ) 
    564             { 
    565                 ReWriteDataStatement_0(fortran_out); 
    566                 pos_end = setposcur(); 
    567             } 
    568         } 
    569       ; 
     621 
    570622opt_spec : 
    571623      | access_spec 
     
    619671      | list_expr_equi1 ',' ident dims 
    620672      ; 
    621 list_expr : 
     673list_expr: 
    622674                      expr 
    623675      | list_expr ',' expr 
    624676      ; 
    625 opt_sep : 
     677opt_sep: 
    626678      | TOK_FOURDOTS 
    627679      ; 
    628 after_type : 
    629         dcl nodimsgiven 
    630         { 
    631             /* if the variable is a parameter we can suppose that is*/ 
    632             /*    value is the same on each grid. It is not useless */ 
    633             /*    to create a copy of it on each grid               */ 
    634             if ( ! inside_type_declare ) 
    635             { 
    636                 pos_end = setposcur(); 
    637                 RemoveWordSET_0(fortran_out,pos_cur_decl,pos_end-pos_cur_decl); 
    638                 ReWriteDeclarationAndAddTosubroutine_01($1); 
    639                 pos_cur_decl = setposcur(); 
    640                 if ( firstpass == 0 && GlobalDeclaration == 0 
    641                                     && insubroutinedeclare == 0 ) 
    642                 { 
    643                     fprintf(fortran_out,"\n#include \"Module_Declar_%s.h\"\n", curmodulename); 
    644                     sprintf(ligne, "Module_Declar_%s.h", curmodulename); 
    645                     module_declar = open_for_write(ligne); 
    646                     GlobalDeclaration = 1 ; 
    647                     pos_cur_decl = setposcur(); 
    648                 } 
    649                 $$ = $1; 
    650  
    651                 if ( firstpass ) 
    652                 { 
    653                     Add_Globliste_1($1); 
    654                     if ( insubroutinedeclare ) 
    655                     { 
    656                         if ( pointerdeclare ) Add_Pointer_Var_From_List_1($1); 
    657                         Add_Parameter_Var_1($1); 
    658                     } 
    659                     else 
    660                         Add_GlobalParameter_Var_1($1); 
    661  
    662                     /* If there's a SAVE declaration in module's subroutines we should    */ 
    663                     /*    remove it from the subroutines declaration and add it in the    */ 
    664                     /*    global declarations                                             */ 
    665                     if ( aftercontainsdeclare && SaveDeclare ) 
    666                     { 
    667                         if ( inmodulemeet ) Add_SubroutineDeclarationSave_Var_1($1); 
    668                         else                Add_Save_Var_dcl_1($1); 
    669                     } 
    670                 } 
    671             } 
    672             else 
    673             { 
    674                 $$ = (listvar *) NULL; 
    675             } 
    676             PublicDeclare = 0; 
    677             PrivateDeclare = 0; 
    678             ExternalDeclare = 0; 
    679             strcpy(NamePrecision,""); 
    680             c_star = 0; 
    681             InitialValueGiven = 0 ; 
    682             strcpy(IntentSpec,""); 
    683             VariableIsParameter =  0 ; 
    684             Allocatabledeclare = 0 ; 
    685             Targetdeclare = 0 ; 
    686             SaveDeclare = 0; 
    687             pointerdeclare = 0; 
    688             optionaldeclare = 0 ; 
    689             dimsgiven=0; 
    690             c_selectorgiven=0; 
    691             strcpy(nameinttypename,""); 
    692             strcpy(c_selectorname,""); 
    693             GlobalDeclarationType = 0; 
    694         } 
    695       | before_function name_routine arglist 
    696         { 
    697             insubroutinedeclare = 1; 
    698  
    699             if ( firstpass ) 
    700             { 
    701                 Add_SubroutineArgument_Var_1($3); 
    702                 Add_FunctionType_Var_1($2); 
    703             } 
    704             else 
    705                 WriteBeginof_SubLoop(); 
    706  
    707             strcpy(nameinttypename,""); 
    708         } 
    709       ; 
     680 
    710681before_function :   TOK_FUNCTION    { functiondeclarationisdone = 1; } 
    711682      ; 
    712 before_parameter :  TOK_PARAMETER   { VariableIsParameter = 1; pos_curparameter = setposcur()-9; } 
     683before_parameter :  TOK_PARAMETER   {VariableIsParameter = 1; pos_curparameter = setposcur()-9; } 
    713684      ; 
    714685 
     
    750721      ; 
    751722 
    752 save :  before_save varsave 
     723save:  before_save varsave 
    753724      | before_save comblock varsave 
    754725      | save opt_comma comblock opt_comma varsave 
    755726      | save ',' varsave 
    756727      ; 
    757 before_save : 
     728before_save: 
    758729        TOK_SAVE        { pos_cursave = setposcur()-4; } 
    759730      ; 
     
    896867            strcpy(curvar->v_subroutinename,subroutinename); 
    897868            strcpy(curvar->v_modulename,curmodulename); 
    898             strcpy(curvar->v_initialvalue,$3); 
     869            curvar->v_initialvalue=Insertname(curvar->v_initialvalue,$3,0); 
    899870            strcpy(curvar->v_commoninfile,cur_filename); 
    900871            Save_Length($3,14); 
     
    919890            } 
    920891        } 
    921       | TOK_IMPLICIT TOK_REAL8 
    922       ; 
    923 dcl :   options TOK_NAME dims lengspec initial_value 
     892      ; 
     893dcl:   options TOK_NAME dims lengspec initial_value 
    924894        { 
    925895            if ( ! inside_type_declare ) 
     
    970940nodimsgiven : { dimsgiven = 0; } 
    971941      ; 
    972 type :  typespec selector               { strcpy(DeclType,$1);  } 
     942type:  typespec selector               { strcpy(DeclType,$1);} 
    973943      | before_character c_selector     { strcpy(DeclType,"character");  } 
    974944      | typespec '*' TOK_CSTINT         { strcpy(DeclType,$1); strcpy(nameinttypename,$3);  } 
     
    993963      | TOK_COMPLEX         { strcpy($$,"complex"); pos_cur_decl = setposcur()-7; } 
    994964      | TOK_DOUBLECOMPLEX   { strcpy($$,"double complex"); pos_cur_decl = setposcur()-14; } 
    995       | TOK_DOUBLEPRECISION { pos_cur_decl = setposcur()-16; strcpy($$,"real"); strcpy(nameinttypename,"8"); } 
     965      | TOK_DOUBLEPRECISION { pos_cur_decl = setposcur()-16; strcpy($$,"real"); strcpy(nameinttypename,"8"); printf("OK1\n");} 
    996966      ; 
    997967lengspec : 
     
    10321002      | ',' TOK_NAME clause 
    10331003      ; 
    1034 options : 
     1004options: 
    10351005      | TOK_FOURDOTS 
    10361006      | ',' attr_spec_list TOK_FOURDOTS 
    10371007      ; 
    1038 attr_spec_list : attr_spec 
     1008attr_spec_list: attr_spec 
    10391009      | attr_spec_list ',' attr_spec 
    10401010      ; 
     
    10461016      | TOK_EXTERNAL        { ExternalDeclare = 1; } 
    10471017      | TOK_INTENT '(' intent_spec ')' 
    1048                             { strcpy(IntentSpec,$3); } 
     1018                            { strcpy(IntentSpec,$3); intent_spec = 0;} 
    10491019      | TOK_INTRINSIC 
    10501020      | TOK_OPTIONAL        { optionaldeclare = 1 ; } 
     
    10631033      ; 
    10641034dims :  { $$ = (listdim*) NULL; } 
    1065       | '(' dimlist ')' 
     1035      | '(' {in_complex_literal=0;} dimlist ')' 
    10661036        { 
    10671037            $$ = (listdim*) NULL; 
    10681038            if ( inside_type_declare ) break; 
    1069             if ( created_dimensionlist == 1 || agrif_parentcall == 1 )  $$=$2; 
     1039            if ( created_dimensionlist == 1 || agrif_parentcall == 1 )  $$=$3; 
    10701040        } 
    10711041      ; 
     
    10941064      | expr                { strcpy($$,$1);  } 
    10951065      ; 
    1096 expr :  uexpr               { strcpy($$,$1); } 
     1066/* 
     1067expr:  uexpr               { strcpy($$,$1); } 
    10971068      | complex_const       { strcpy($$,$1); } 
    10981069      | predefinedfunction  { strcpy($$,$1); } 
    10991070      | '(' expr ')'        { sprintf($$,"(%s)",$2); } 
    11001071      ; 
    1101  
     1072*/ 
    11021073predefinedfunction : 
    11031074        TOK_SUM minmaxlist ')'          { sprintf($$,"SUM(%s)",$2);} 
     
    11331104uexpr : lhs                     { strcpy($$,$1); } 
    11341105      | simple_const            { strcpy($$,$1); } 
    1135       | vec                     { strcpy($$,$1); } 
    11361106      | expr operation          { sprintf($$,"%s%s",$1,$2); } 
    11371107      | signe expr %prec '*'    { sprintf($$,"%s%s",$1,$2); } 
     
    11941164        begin_array                                         { strcpy($$,$1); if ( incalldeclare == 0 ) inagrifcallargument = 0;   } 
    11951165      | begin_array substring                               { sprintf($$," %s %s ",$1,$2); } 
    1196       | structure_component '(' funarglist ')'              { sprintf($$," %s ( %s )",$1,$3); } 
    1197       | structure_component '(' funarglist ')' substring    { sprintf($$," %s ( %s ) %s ",$1,$3,$5); } 
    1198       ; 
    1199 begin_array : 
    1200         ident '(' funarglist ')' 
     1166      | structure_component '(' {in_complex_literal=0;} funarglist ')'              { sprintf($$," %s ( %s )",$1,$4); } 
     1167      | structure_component '(' {in_complex_literal=0;} funarglist ')' substring    { sprintf($$," %s ( %s ) %s ",$1,$4,$6); } 
     1168      ; 
     1169begin_array : TOK_LOGICALIF 
     1170      |  ident '(' {in_complex_literal=0;} funarglist ')' 
    12011171        { 
    12021172            if ( inside_type_declare ) break; 
    1203             sprintf($$," %s ( %s )",$1,$3); 
    1204             ModifyTheAgrifFunction_0($3); 
     1173            sprintf($$," %s ( %s )",$1,$4); 
     1174            ModifyTheAgrifFunction_0($4); 
    12051175            agrif_parentcall = 0; 
    12061176        } 
     
    12131183        } 
    12141184      ; 
     1185/* 
    12151186vec : 
    12161187        TOK_LEFTAB outlist TOK_RIGHTAB   { sprintf($$,"(/%s/)",$2); } 
    12171188      ; 
     1189*/ 
    12181190funarglist : 
    12191191        beforefunctionuse           { strcpy($$," "); } 
     
    12371209      | ':'                     {  sprintf($$,":");} 
    12381210      ; 
    1239 ident : TOK_NAME 
    1240         { 
     1211ident: TOK_NAME 
     1212        { 
     1213       //  if (indeclaration == 1) break; 
    12411214            if ( afterpercent == 0 ) 
    12421215            { 
     
    13021275      | substring   { strcpy($$,$1);} 
    13031276      ; 
     1277/* 
    13041278substring : 
    13051279        '(' optexpr ':' optexpr ')' { sprintf($$,"(%s :%s)",$2,$4);} 
    13061280      ; 
     1281*/ 
    13071282optexpr :           { strcpy($$," ");} 
    13081283      | expr        { strcpy($$,$1);} 
    13091284      ; 
    1310 opt_expr : 
    1311         '\n'        { strcpy($$," ");} 
     1285opt_expr :          { strcpy($$," ");} 
    13121286      | expr        { strcpy($$,$1);} 
    13131287      ; 
    1314 initial_value :     { InitialValueGiven = 0; } 
     1288initial_value:     { InitialValueGiven = 0; } 
    13151289      | '=' expr 
    13161290        { 
     
    13291303        '(' uexpr ',' uexpr ')' {sprintf($$,"(%s,%s)",$2,$4); } 
    13301304      ; 
    1331 use_stat : 
    1332         word_use TOK_NAME 
    1333         { 
    1334             /* if variables has been declared in a subroutine       */ 
    1335             sprintf(charusemodule, "%s", $2); 
    1336             if ( firstpass ) 
    1337             { 
    1338                 Add_NameOfModuleUsed_1($2); 
     1305 
     1306only_list : 
     1307        only_name   {  $$ = $1; } 
     1308      | only_list ',' only_name 
     1309        { 
     1310            /* insert the variable in the list $1                 */ 
     1311            $3->suiv = $1; 
     1312            $$ = $3; 
     1313        } 
     1314      ; 
     1315only_name : 
     1316        TOK_NAME TOK_POINT_TO TOK_NAME 
     1317        { 
     1318            coupletmp = (listcouple *)calloc(1,sizeof(listcouple)); 
     1319            strcpy(coupletmp->c_namevar,$1); 
     1320            strcpy(coupletmp->c_namepointedvar,$3); 
     1321            coupletmp->suiv = NULL; 
     1322            $$ = coupletmp; 
     1323            pointedvar = 1; 
     1324            Add_UsedInSubroutine_Var_1($1); 
     1325        } 
     1326      | TOK_NAME 
     1327        { 
     1328            coupletmp = (listcouple *)calloc(1,sizeof(listcouple)); 
     1329            strcpy(coupletmp->c_namevar,$1); 
     1330            strcpy(coupletmp->c_namepointedvar,""); 
     1331            coupletmp->suiv = NULL; 
     1332            $$ = coupletmp; 
     1333        } 
     1334      ; 
     1335 
     1336/* R204 : specification-part */ 
     1337/* opt-implicit-part removed but implicit-stmt and format-stmt added to declaration-construct */ 
     1338specification-part: opt-use-stmt-list opt-declaration-construct-list 
     1339     ; 
     1340 
     1341opt-use-stmt-list: 
     1342     |use-stmt-list 
     1343     ; 
     1344      
     1345opt-implicit-part: 
     1346     |implicit-part 
     1347     ; 
     1348 
     1349implicit-part: opt-implicit-part-stmt-list implicit-stmt 
     1350     ; 
     1351      
     1352opt-implicit-part-stmt-list: 
     1353     | implicit-part-stmt-list 
     1354     ; 
     1355      
     1356implicit-part-stmt-list: implicit-part-stmt 
     1357     | implicit-part-stmt-list implicit-part-stmt 
     1358     ; 
     1359      
     1360/* R206: implicit-part-stmt */ 
     1361implicit-part-stmt: implicit-stmt 
     1362     | parameter-stmt 
     1363     | format-stmt 
     1364     ; 
     1365 
     1366 
     1367opt-declaration-construct-list: 
     1368     |declaration-construct-list 
     1369     ; 
     1370      
     1371declaration-construct-list: 
     1372        declaration-construct 
     1373      | declaration-construct-list declaration-construct 
     1374      ; 
     1375      
     1376/* R207 : declaration-construct */ 
     1377/* stmt-function-stmt replaced by assignment-stmt due to reduce conflicts */ 
     1378/* because assignment-stmt has been added  */ 
     1379/* Every statement that begins with a variable should be added */ 
     1380/* This include : */ 
     1381/* pointer-assignment-stmt, do-construct */ 
     1382/* implicit-stmt and format-stmt added since implicit-part-stmt has been removed due to conflicts (see R204) */ 
     1383/* ANOTHER SOLUTION TO THE PROBLEM OF STMT-FUNCTION IS NEEDED !!!! */ 
     1384/* BECAUSE ALMOST ALL ACTION-STMT SHOULD BE INCLUDED HERE !!! */ 
     1385 
     1386declaration-construct: derived-type-def 
     1387     | parameter-stmt 
     1388     | format-stmt 
     1389     | implicit-stmt 
     1390     | other-specification-stmt 
     1391     | type-declaration-stmt 
     1392     | assignment-stmt 
     1393     | pointer-assignment-stmt 
     1394     | do-construct 
     1395     | if-construct 
     1396     | continue-stmt 
     1397     | return-stmt 
     1398     | print-stmt 
     1399     ; 
     1400 
     1401opt-execution-part: 
     1402     | execution-part 
     1403     ; 
     1404 
     1405/* R208 : execution-part */ 
     1406execution-part: executable-construct opt-execution-part-construct-list 
     1407     ; 
     1408 
     1409opt-execution-part-construct-list: 
     1410     |execution-part-construct-list 
     1411     ; 
     1412 
     1413execution-part-construct-list: 
     1414        execution-part-construct 
     1415      | execution-part-construct-list execution-part-construct 
     1416      ; 
     1417 
     1418/* R209 : execution-part-construct */ 
     1419execution-part-construct: executable-construct 
     1420      | format-stmt 
     1421      ; 
     1422 
     1423opt-internal-subprogram-part: 
     1424     | internal-subprogram-part 
     1425     ; 
     1426      
     1427/* R120 : internal-subprogram-part */ 
     1428internal-subprogram-part: TOK_CONTAINS line-break 
     1429      opt-internal-subprogram 
     1430     ; 
     1431 
     1432opt-internal-subprogram: 
     1433     | internal-subprogram-list 
     1434     ; 
     1435 
     1436internal-subprogram-list: internal-subprogram 
     1437     | internal-subprogram-list internal-subprogram 
     1438     ; 
     1439 
     1440/* R211 : internal-subprogram */ 
     1441internal-subprogram: function-subprogram 
     1442     | subroutine-subprogram 
     1443     ; 
     1444 
     1445/* R212 : other-specification-stmt */ 
     1446other-specification-stmt: access-stmt 
     1447     | common-stmt 
     1448     | data-stmt 
     1449     | dimension-stmt 
     1450     | equivalence-stmt 
     1451     | external-stmt 
     1452     | intrinsic-stmt 
     1453     | namelist-stmt 
     1454     | save-stmt 
     1455     ; 
     1456 
     1457/* R213 : executable-construct */ 
     1458executable-construct: 
     1459        action-stmt 
     1460      | do-construct 
     1461      | case-construct 
     1462      | if-construct 
     1463      | where-construct 
     1464      ; 
     1465 
     1466/* R214 : action-stmt */ 
     1467 
     1468/* normal action-stmt */ 
     1469 
     1470action-stmt: 
     1471      allocate-stmt 
     1472      | assignment-stmt 
     1473      | call-stmt 
     1474      | close-stmt 
     1475      | continue-stmt 
     1476      | cycle-stmt 
     1477      | deallocate-stmt 
     1478      | goto-stmt 
     1479      | exit-stmt 
     1480      | flush-stmt 
     1481      | TOK_CYCLE opt_expr 
     1482      | TOK_NULLIFY '(' pointer_name_list ')' 
     1483      | TOK_ENDMODULE opt_name 
     1484        { 
     1485            /* if we never meet the contains keyword               */ 
     1486            if ( firstpass == 0 ) 
     1487            { 
     1488                RemoveWordCUR_0(fortran_out, strlen($2)+11);    // Remove word "end module" 
     1489                if ( inmoduledeclare && ! aftercontainsdeclare ) 
     1490                { 
     1491                    Write_Closing_Module(1); 
     1492                } 
     1493                fprintf(fortran_out,"\n      end module %s\n", curmodulename); 
     1494                if ( module_declar && insubroutinedeclare == 0 ) 
     1495                { 
     1496                    fclose(module_declar); 
     1497                } 
     1498            } 
     1499            inmoduledeclare = 0 ; 
     1500            inmodulemeet = 0 ; 
     1501            aftercontainsdeclare = 1; 
     1502            strcpy(curmodulename, ""); 
     1503            GlobalDeclaration = 0 ; 
     1504        } 
     1505      | if-stmt 
     1506      | inquire-stmt 
     1507      | open-stmt 
     1508      | pointer-assignment-stmt 
     1509      | print-stmt 
     1510      | read-stmt 
     1511      | return-stmt 
     1512      | rewind-stmt 
     1513      | stop-stmt 
     1514      | where-stmt 
     1515      | write-stmt 
     1516      | arithmetic-if-stmt 
     1517      ; 
     1518 
     1519/* R215 : keyword */ 
     1520keyword: ident 
     1521     ; 
     1522 
     1523scalar-constant: constant 
     1524    ; 
     1525 
     1526/* R304 : constant */ 
     1527 
     1528constant: literal-constant 
     1529     | named-constant 
     1530     ; 
     1531      
     1532/* R305 : literal-constant */ 
     1533literal-constant: int-literal-constant 
     1534     | real-literal-constant 
     1535     | logical-literal-constant 
     1536     | complex-literal-constant 
     1537     {in_complex_literal=0;} 
     1538     | char-literal-constant 
     1539     ; 
     1540      
     1541/* R306 : named-constant */ 
     1542named-constant: ident 
     1543     ; 
     1544 
     1545scalar-int-constant:int-constant 
     1546     ; 
     1547 
     1548/* R307 : int-constant */ 
     1549int-constant: int-literal-constant 
     1550     | named-constant 
     1551     ; 
     1552      
     1553/* 
     1554constant: TOK_CSTINT 
     1555     | TOK_CSTREAL 
     1556     | ident 
     1557     ; 
     1558*/ 
     1559 
     1560opt-label: 
     1561     {strcpy($$,"");} 
     1562     | label 
     1563     ; 
     1564 
     1565/* R312 : label */ 
     1566label: TOK_LABEL 
     1567     | TOK_CSTINT 
     1568     ; 
     1569 
     1570opt-label-djview: 
     1571     {strcpy($$,"");} 
     1572     | label-djview 
     1573     {strcpy($$,$1);} 
     1574     ; 
     1575      
     1576label-djview: TOK_LABEL_DJVIEW 
     1577     ; 
     1578 
     1579/* R401 : type-param-value */ 
     1580type-param-value: scalar-int-expr 
     1581     | '*' 
     1582     | ':' 
     1583     ; 
     1584 
     1585/* R402: type-spec */ 
     1586type-spec: intrinsic-type-spec 
     1587     {strcpy($$,$1);} 
     1588     | derived-type-spec 
     1589     {strcpy($$,$1);} 
     1590     ; 
     1591 
     1592/* R403 : declaration-type-spec */ 
     1593declaration-type-spec: {pos_cur_decl=my_position_before;} intrinsic-type-spec 
     1594     {strcpy($$,$2);} 
     1595     | TOK_TYPEPAR intrinsic-type-spec ')' 
     1596     | TOK_TYPEPAR derived-type-spec ')' 
     1597     {strcpy(DeclType,"type"); GlobalDeclarationType = 1;  } 
     1598     ; 
     1599 
     1600/* R404 : intrinsic-type-spec */ 
     1601intrinsic-type-spec: TOK_INTEGER {in_kind_selector = 1;} opt-kind-selector 
     1602     {sprintf($$,"%s%s",$1,$[opt-kind-selector]);strcpy(DeclType,$1); in_kind_selector =0;} 
     1603     | TOK_REAL {in_kind_selector = 1;} opt-kind-selector 
     1604     {sprintf($$,"%s%s",$1,$[opt-kind-selector]);strcpy(DeclType,$1);in_kind_selector =0;} 
     1605     | TOK_DOUBLEPRECISION {in_kind_selector = 1;} opt-kind-selector 
     1606     {sprintf($$,"%s%s",$1,$[opt-kind-selector]);strcpy(DeclType,"real"); strcpy(NamePrecision,"8");in_kind_selector =0;} 
     1607     | TOK_COMPLEX {in_kind_selector = 1;} opt-kind-selector 
     1608     {sprintf($$,"%s%s",$1,$[opt-kind-selector]);strcpy(DeclType,$1);in_kind_selector =0;} 
     1609     | TOK_CHARACTER {in_char_selector = 1;} opt-char-selector 
     1610     {sprintf($$,"%s%s",$1,$[opt-char-selector]);strcpy(DeclType,$1);in_char_selector = 0;} 
     1611     | TOK_LOGICAL {in_kind_selector = 1;} opt-kind-selector 
     1612     {sprintf($$,"%s%s",$1,$[opt-kind-selector]);strcpy(DeclType,$1);in_kind_selector =0;} 
     1613     ; 
     1614 
     1615opt-kind-selector: 
     1616     {strcpy($$,"");strcpy(NamePrecision,"");} 
     1617     |kind-selector 
     1618     {strcpy($$,$1);} 
     1619     ; 
     1620      
     1621/* R405 : kind-selector */ 
     1622/* Nonstandard extension : * INT */ 
     1623kind-selector: '(' scalar-int-constant-expr ')' 
     1624     {sprintf($$,"(%s)",$2); strcpy(NamePrecision,$2);} 
     1625     | '(' TOK_KIND '=' scalar-int-constant-expr ')' 
     1626     {sprintf($$,"(KIND=%s)",$4); strcpy(NamePrecision,$4);} 
     1627     | '*' TOK_CSTINT 
     1628     {sprintf($$,"*%s",$2);strcpy(NamePrecision,$2);} 
     1629     ; 
     1630 
     1631/* R406 : signed-int-literal-constant */ 
     1632/* sign replaced by add-op */ 
     1633 
     1634signed-int-literal-constant:int-literal-constant 
     1635     | add-op int-literal-constant 
     1636     {sprintf($$,"%s%s",$1,$2);} 
     1637     ; 
     1638      
     1639/* R407 : int-literal-constant */ 
     1640int-literal-constant: TOK_CSTINT 
     1641     | TOK_CSTINT '_' kind-param 
     1642     {sprintf($$,"%s_%s",$1,$3);} 
     1643     ; 
     1644 
     1645/*R408 : kind-param */ 
     1646kind-param: TOK_CSTINT 
     1647     | TOK_NAME 
     1648     ; 
     1649 
     1650opt-sign: 
     1651     | sign 
     1652     ; 
     1653 
     1654/* R411 : sign */ 
     1655sign:'+' 
     1656     {strcpy($$,"+");} 
     1657     | '-' 
     1658     {strcpy($$,"-");} 
     1659     ; 
     1660 
     1661/* R412 : signed-real-literal-constant */ 
     1662/* sign replaced by add-op */ 
     1663signed-real-literal-constant:real-literal-constant 
     1664     | add-op real-literal-constant 
     1665     {sprintf($$,"%s%s",$1,$2);} 
     1666     ; 
     1667 
     1668/* R413 : real-literal-constant */ 
     1669real-literal-constant: TOK_CSTREAL 
     1670     | TOK_CSTREAL '_' kind-param 
     1671     {sprintf($$,"%s_%s",$1,$3);}; 
     1672     ; 
     1673 
     1674/* R417 : complex-literal-constant */ 
     1675/* in-complex-literal is just here to change default precedence rules ... */ 
     1676 
     1677complex-literal-constant: '(' real-part TOK_COMMACOMPLEX imag-part ')' 
     1678     {sprintf($$,"(%s,%s)",$2,$4);} 
     1679     ; 
     1680 
     1681 
     1682/* R418 : real-part */ 
     1683real-part: signed-int-literal-constant 
     1684     | signed-real-literal-constant 
     1685     | ident 
     1686     ; 
     1687 
     1688/* R419 : imag-part */ 
     1689imag-part: signed-int-literal-constant 
     1690     | signed-real-literal-constant 
     1691     | named-constant 
     1692     ; 
     1693 
     1694opt-char_length-star: 
     1695     | '*' char-length 
     1696     {char_length_toreset = 1;} 
     1697     ; 
     1698 
     1699opt-char-selector: 
     1700     {strcpy($$,"");} 
     1701    | char-selector 
     1702    {strcpy($$,"");} 
     1703    ; 
     1704 
     1705/* R420 : char-selector */ 
     1706char-selector:length-selector 
     1707    | '(' TOK_LEN '=' type-param-value ',' TOK_KIND '=' scalar-int-constant-expr ')' 
     1708    | '(' type-param-value ',' scalar-int-constant-expr ')' 
     1709    | '(' TOK_KIND '=' scalar-int-constant-expr ')' 
     1710    | '(' TOK_KIND '=' scalar-int-constant-expr ',' TOK_LEN '=' type-param-value ')' 
     1711    ; 
     1712 
     1713/* R421 : length-selector */ 
     1714length-selector: '(' type-param-value ')' 
     1715     {strcpy(CharacterSize,$2);} 
     1716     | '(' TOK_LEN '=' type-param-value ')' 
     1717     {strcpy(CharacterSize,$4);} 
     1718     | '*' char-length 
     1719     | '*' char-length ',' 
     1720     ; 
     1721 
     1722/* R422 : char-length */ 
     1723char-length: '(' type-param-value ')' 
     1724     {c_star=1; strcpy(CharacterSize,$2);} 
     1725     | int-literal-constant 
     1726     {c_selectorgiven = 1; strcpy(c_selectorname,$1);} 
     1727     ; 
     1728 
     1729/* R423 : char-literal-constant */ 
     1730char-literal-constant: TOK_CHAR_CONSTANT 
     1731     | TOK_CHAR_MESSAGE 
     1732     | TOK_CHAR_CUT 
     1733     ; 
     1734 
     1735/* R424 : logical-literal-constant */ 
     1736logical-literal-constant: TOK_TRUE 
     1737     | TOK_FALSE 
     1738     ; 
     1739 
     1740/* R425 : derived-type-def */ 
     1741derived-type-def: derived-type-stmt { inside_type_declare = 1;} opt-component-part end-type-stmt 
     1742     { inside_type_declare = 0;} 
     1743     ; 
     1744      
     1745/* R426 : derived-type-stmt */ 
     1746derived-type-stmt: TOK_TYPE opt-type-attr-spec-list-comma-fourdots TOK_NAME line-break 
     1747     | TOK_TYPE opt-type-attr-spec-list-comma TOK_NAME '(' type-param-name-list ')' line-break 
     1748     ; 
     1749 
     1750opt-type-attr-spec-list-comma-fourdots: 
     1751    | opt-type-attr-spec-list-comma TOK_FOURDOTS 
     1752    ; 
     1753  
     1754 opt-type-attr-spec-list-comma: 
     1755     | ',' type-attr-spec-list 
     1756     ; 
     1757 
     1758type-attr-spec-list: type-attr-spec 
     1759     | type-attr-spec-list ',' type-attr-spec 
     1760     ; 
     1761 
     1762/* R427 : type-attr-spec */ 
     1763type-attr-spec: access-spec 
     1764     ; 
     1765 
     1766type-param-name-list: type-param-name 
     1767     | type-param-name-list ',' type-param-name 
     1768     ; 
     1769      
     1770type-param-name: TOK_NAME 
     1771     ; 
     1772 
     1773/* R429 : end-type-stmt */ 
     1774end-type-stmt: TOK_ENDTYPE line-break 
     1775     | TOK_ENDTYPE TOK_NAME line-break 
     1776     ; 
     1777 
     1778opt-component-part: 
     1779     | component-part 
     1780     ; 
     1781 
     1782/* R434 : component-part */ 
     1783component-part: component-def-stmt 
     1784    | component-part component-def-stmt 
     1785    ; 
     1786 
     1787/* R435 : component-def-stmt */ 
     1788component-def-stmt: data-component-def-stmt 
     1789    ; 
     1790     
     1791/* R436 : data-component-def-stmt */ 
     1792data-component-def-stmt: declaration-type-spec opt-component-attr-spec-list-comma-2points component-decl-list line-break 
     1793     ; 
     1794 
     1795opt-component-attr-spec-list-comma-2points: 
     1796     | TOK_FOURDOTS 
     1797     | ',' component-attr-spec-list TOK_FOURDOTS 
     1798     ; 
     1799 
     1800component-attr-spec-list: component-attr-spec 
     1801     | component-attr-spec-list ',' component-attr-spec 
     1802     ; 
     1803      
     1804/* R437 : component-attr-spec */ 
     1805component-attr-spec: access-spec 
     1806     | TOK_ALLOCATABLE 
     1807     | TOK_DIMENSION '(' {in_complex_literal=0;} component-array-spec ')' 
     1808     | TOK_POINTER 
     1809     ; 
     1810 
     1811component-decl-list: component-decl 
     1812     | component-decl-list ',' component-decl 
     1813     ; 
     1814 
     1815/* R438 : component-decl */ 
     1816component-decl : ident opt-component-array-spec opt-char_length-star opt-component-initialization 
     1817       { 
     1818            PublicDeclare = 0; 
     1819            PrivateDeclare = 0; 
     1820            ExternalDeclare = 0; 
     1821            strcpy(NamePrecision,""); 
     1822            c_star = 0; 
     1823            InitialValueGiven = 0 ; 
     1824            strcpy(IntentSpec,""); 
     1825            VariableIsParameter =  0 ; 
     1826            Allocatabledeclare = 0 ; 
     1827            Targetdeclare = 0 ; 
     1828            SaveDeclare = 0; 
     1829            pointerdeclare = 0; 
     1830            optionaldeclare = 0 ; 
     1831            dimsgiven=0; 
     1832            c_selectorgiven=0; 
     1833            strcpy(nameinttypename,""); 
     1834            strcpy(c_selectorname,""); 
     1835            GlobalDeclarationType = 0; 
     1836         } 
     1837     ; 
     1838 
     1839opt-component-array-spec: 
     1840     | '(' component-array-spec ')' 
     1841     ; 
     1842 
     1843/* R439 : component-array-spec */ 
     1844component-array-spec: explicit-shape-spec-list 
     1845     | deferred-shape-spec-list 
     1846     ; 
     1847 
     1848opt-component-initialization: 
     1849     | component-initialization 
     1850     ; 
     1851      
     1852/* R442 : component-initialization */ 
     1853component-initialization: '=' constant-expr 
     1854      | TOK_POINT_TO null-init 
     1855      | TOK_POINT_TO initial-data-target 
     1856      ; 
     1857 
     1858/* R443 initial-data-target */ 
     1859initial-data-target: designator 
     1860     {strcpy(my_dim.last,"");} 
     1861     ; 
     1862 
     1863/* R453 : derived-type-spec */ 
     1864derived-type-spec: ident  
     1865     {strcpy(NamePrecision,$1);} 
     1866     | ident '(' type-param-spec-list ')' 
     1867     ; 
     1868      
     1869type-param-spec-list: type-param-spec 
     1870     | type-param-spec-list ',' type-param-spec 
     1871     ; 
     1872 
     1873/* R454 : type-param-spec */ 
     1874type-param-spec: type-param-value 
     1875    | keyword '=' type-param-value 
     1876    ; 
     1877 
     1878/* R455 : structure-constructor */ 
     1879structure-constructor: derived-type-spec '(' ')' 
     1880     | derived-type-spec '(' component-spec-list ')' 
     1881     ; 
     1882      
     1883component-spec-list: component-spec 
     1884     | component-spec-list ',' component-spec 
     1885     ; 
     1886      
     1887/* R456 : component-spec */ 
     1888component-spec: component-data-source 
     1889     | keyword '=' component-data-source 
     1890     ; 
     1891 
     1892/* R457 : component-data-source */ 
     1893component-data-source: expr 
     1894     | data-target 
     1895     | proc-target 
     1896     ; 
     1897 
     1898/* R468 : array-constructor */ 
     1899array-constructor: TOK_LEFTAB ac-spec TOK_RIGHTAB 
     1900     { sprintf($$,"(/%s/)",$2);} 
     1901     | lbracket ac-spec rbracket 
     1902     { sprintf($$,"[%s]",$2); } 
     1903     ; 
     1904      
     1905/* R469 : ac-spec */ 
     1906/* type-spec TOK_FOURDOTS is removed due to conflicts with part-ref */ 
     1907 
     1908/*ac-spec: type-spec TOK_FOURDOTS 
     1909     {sprintf($$,"%s::",$1);} 
     1910     | ac-value-list 
     1911     | type-spec TOK_FOURDOTS ac-value-list 
     1912     {sprintf($$,"%s::%s",$1,$3);} 
     1913     ; 
     1914*/ 
     1915 
     1916ac-spec: ac-value-list 
     1917     ; 
     1918      
     1919/* R470 : lbracket */ 
     1920lbracket: '[' 
     1921     ; 
     1922 
     1923/* R471 : rbracket */ 
     1924rbracket: ']' 
     1925     ; 
     1926 
     1927ac-value-list: 
     1928        ac-value 
     1929      | ac-value-list ',' ac-value 
     1930      {sprintf($$,"%s,%s",$1,$3);} 
     1931      ; 
     1932 
     1933/* R472 : ac-value */ 
     1934ac-value: expr 
     1935      | ac-implied-do 
     1936      ; 
     1937 
     1938/* R473 : ac-implied-do */ 
     1939ac-implied-do: '(' ac-value-list ',' ac-implied-do-control ')' 
     1940     {sprintf($$,"(%s,%s)",$2,$4);} 
     1941     ; 
     1942 
     1943/* R474 : ac-implied-do-control */ 
     1944ac-implied-do-control: ac-do-variable '=' scalar-int-expr ',' scalar-int-expr 
     1945     {sprintf($$,"%s=%s,%s",$1,$3,$5);} 
     1946     | ac-do-variable '=' scalar-int-expr ',' scalar-int-expr ',' scalar-int-expr 
     1947     {sprintf($$,"%s=%s,%s,%s",$1,$3,$5,$7);} 
     1948     ; 
     1949 
     1950/* R475 : ac-do-variable */ 
     1951ac-do-variable: do-variable 
     1952     ; 
     1953 
     1954/* R501 : type-declaration-stmt */ 
     1955type-declaration-stmt: {indeclaration=1;} declaration-type-spec opt-attr-spec-construct entity-decl-list 
     1956        { 
     1957            /* if the variable is a parameter we can suppose that is*/ 
     1958            /*    value is the same on each grid. It is not useless */ 
     1959            /*    to create a copy of it on each grid               */ 
     1960            if ( ! inside_type_declare ) 
     1961            { 
     1962                pos_end = setposcur(); 
     1963                //printf("POS = %d %d\n",pos_cur_decl,pos_end); 
     1964                RemoveWordSET_0(fortran_out,pos_cur_decl,pos_end-pos_cur_decl); 
     1965                ReWriteDeclarationAndAddTosubroutine_01($[entity-decl-list]); 
     1966                pos_cur_decl = setposcur(); 
     1967                if ( firstpass == 0 && GlobalDeclaration == 0 
     1968                                    && insubroutinedeclare == 0 ) 
     1969                { 
     1970                    fprintf(fortran_out,"\n#include \"Module_Declar_%s.h\"\n", curmodulename); 
     1971                    sprintf(ligne, "Module_Declar_%s.h", curmodulename); 
     1972                    module_declar = open_for_write(ligne); 
     1973                    GlobalDeclaration = 1 ; 
     1974                    pos_cur_decl = setposcur(); 
     1975                } 
     1976 
     1977                if ( firstpass ) 
     1978                { 
     1979                    Add_Globliste_1($[entity-decl-list]); 
     1980                    if ( insubroutinedeclare ) 
     1981                    { 
     1982                        if ( pointerdeclare ) Add_Pointer_Var_From_List_1($[entity-decl-list]); 
     1983                        Add_Parameter_Var_1($[entity-decl-list]); 
     1984                    } 
     1985                    else 
     1986                        Add_GlobalParameter_Var_1($[entity-decl-list]); 
     1987 
     1988                    /* If there's a SAVE declaration in module's subroutines we should    */ 
     1989                    /*    remove it from the subroutines declaration and add it in the    */ 
     1990                    /*    global declarations                                             */ 
     1991                                         
     1992                    if ( aftercontainsdeclare && SaveDeclare ) 
     1993                    { 
     1994                        if ( inmodulemeet ) Add_SubroutineDeclarationSave_Var_1($[entity-decl-list]); 
     1995                        else                Add_Save_Var_dcl_1($[entity-decl-list]); 
     1996                    } 
     1997                } 
     1998            } 
     1999            indeclaration = 0; 
     2000            PublicDeclare = 0; 
     2001            PrivateDeclare = 0; 
     2002            ExternalDeclare = 0; 
     2003            strcpy(NamePrecision,""); 
     2004            c_star = 0; 
     2005            InitialValueGiven = 0 ; 
     2006            strcpy(IntentSpec,""); 
     2007            VariableIsParameter =  0 ; 
     2008            Allocatabledeclare = 0 ; 
     2009            Targetdeclare = 0 ; 
     2010            SaveDeclare = 0; 
     2011            pointerdeclare = 0; 
     2012            optionaldeclare = 0 ; 
     2013            dimsgiven=0; 
     2014            c_selectorgiven=0; 
     2015            strcpy(nameinttypename,""); 
     2016            strcpy(c_selectorname,""); 
     2017            strcpy(DeclType,""); 
     2018            GlobalDeclarationType = 0; 
     2019        } 
     2020     line-break 
     2021     ; 
     2022 
     2023opt-attr-spec-construct: 
     2024     | opt-attr-spec-comma-list TOK_FOURDOTS 
     2025     ; 
     2026 
     2027opt-attr-spec-comma-list: 
     2028     | attr-spec-comma-list 
     2029     ; 
     2030      
     2031attr-spec-comma-list: 
     2032        ',' attr-spec 
     2033      | attr-spec-comma-list ',' attr-spec 
     2034      ; 
     2035 
     2036/* R502 : attr-spec */ 
     2037attr-spec:access-spec 
     2038     | TOK_ALLOCATABLE 
     2039     { Allocatabledeclare = 1; } 
     2040     | TOK_DIMENSION '(' {in_complex_literal=0;} array-spec ')' 
     2041     { dimsgiven = 1; curdim = $4; } 
     2042     | TOK_EXTERNAL 
     2043     { ExternalDeclare = 1; } 
     2044     | TOK_INTENT '(' {in_complex_literal=0;} intent-spec ')' 
     2045     { strcpy(IntentSpec,$4); } 
     2046     | TOK_INTRINSIC 
     2047     | TOK_OPTIONAL 
     2048     { optionaldeclare = 1 ; } 
     2049     | TOK_PARAMETER 
     2050     {VariableIsParameter = 1; } 
     2051     | TOK_POINTER 
     2052     { pointerdeclare = 1 ; } 
     2053     | TOK_SAVE 
     2054     { SaveDeclare = 1 ; } 
     2055     | TOK_TARGET 
     2056     { Targetdeclare = 1; } 
     2057     ; 
     2058 
     2059 
     2060entity-decl-list: entity-decl 
     2061     {$$=insertvar(NULL,$1);} 
     2062     | entity-decl-list ',' entity-decl 
     2063     {$$=insertvar($1,$3);} 
     2064     ; 
     2065 
     2066/* R503 : entity-decl */ 
     2067entity-decl: object-name-noident opt-array-spec-par opt-char_length-star opt-initialization 
     2068        { 
     2069            if ( ! inside_type_declare ) 
     2070            { 
     2071                if (dimsgiven == 1) curvar = createvar($1,curdim); 
     2072                else                curvar = createvar($1,$2); 
     2073                CreateAndFillin_Curvar(DeclType, curvar); 
     2074                strcpy(curvar->v_typevar,DeclType); 
     2075                curvar->v_catvar = get_cat_var(curvar); 
     2076                 
     2077                if (!strcasecmp(DeclType,"character")) 
     2078                { 
     2079                    if (c_selectorgiven == 1) 
     2080                    { 
     2081                        Save_Length(c_selectorname,1); 
     2082                        strcpy(curvar->v_dimchar,c_selectorname); 
     2083                    } 
     2084                } 
     2085            } 
     2086            strcpy(vallengspec,""); 
     2087            if (char_length_toreset == 1) 
     2088            { 
     2089            c_selectorgiven = 0; 
     2090            c_star = 0; 
     2091            strcpy(c_selectorname,""); 
     2092            strcpy(CharacterSize,""); 
     2093            char_length_toreset = 0; 
     2094            } 
     2095            $$=curvar; 
     2096        } 
     2097     ; 
     2098 
     2099 
     2100/* R504 : object-name */ 
     2101object-name: ident 
     2102     ; 
     2103 
     2104object-name-noident: TOK_NAME 
     2105     ; 
     2106 
     2107opt-initialization: {InitialValueGiven = 0; } 
     2108     | initialization 
     2109     ; 
     2110 
     2111/* R505 : initialization */ 
     2112initialization: '=' constant-expr 
     2113        { 
     2114            if ( inside_type_declare ) break; 
     2115            strcpy(InitValue,$2); 
     2116            InitialValueGiven = 1; 
     2117        } 
     2118     | TOK_POINT_TO null-init 
     2119        { 
     2120            if ( inside_type_declare ) break; 
     2121            strcpy(InitValue,$2); 
     2122            InitialValueGiven = 2; 
     2123        } 
     2124     | TOK_POINT_TO initial-data-target 
     2125        { 
     2126            if ( inside_type_declare ) break; 
     2127            strcpy(InitValue,$2); 
     2128            InitialValueGiven = 2; 
     2129        } 
     2130     ; 
     2131 
     2132/* R506 : null-init */ 
     2133null-init: function-reference 
     2134     ; 
     2135 
     2136/* R507 : access-spec */ 
     2137access-spec: TOK_PUBLIC 
     2138     {PublicDeclare = 1;  } 
     2139     | TOK_PRIVATE 
     2140     {PrivateDeclare = 1;  } 
     2141     ; 
     2142 
     2143opt-array-spec-par: 
     2144     {$$=NULL;} 
     2145     | '(' {in_complex_literal=0;} array-spec ')' 
     2146     {$$=$3;} 
     2147     ; 
     2148 
     2149/* R514 : array-spec */ 
     2150array-spec: explicit-shape-spec-list 
     2151     {$$=$1;} 
     2152     | assumed-shape-spec-list 
     2153     {$$=$1;} 
     2154     | deferred-shape-spec-list 
     2155     {$$=$1;} 
     2156     | assumed-size-spec 
     2157     {$$=$1;} 
     2158     | implied-shape-spec-list 
     2159     {$$=$1;} 
     2160     ; 
     2161 
     2162explicit-shape-spec-list: explicit-shape-spec 
     2163        { 
     2164            $$ = (listdim*) NULL; 
     2165            if ( inside_type_declare ) break; 
     2166            if ( created_dimensionlist == 1 || agrif_parentcall == 1 )  $$=insertdim(NULL,$1); 
     2167        } 
     2168      | explicit-shape-spec-list ',' explicit-shape-spec 
     2169        { 
     2170            $$ = (listdim*) NULL; 
     2171            if ( inside_type_declare ) break; 
     2172            if ( (!inside_type_declare) && created_dimensionlist == 1 ) $$=insertdim($1,$3); 
     2173        } 
     2174      ; 
     2175       
     2176/* R516 : explicit-shape-spec */ 
     2177explicit-shape-spec: lower-bound ':' upper-bound 
     2178     {strcpy($$.first,$1);  Save_Length($1,2); strcpy($$.last,$3); Save_Length($3,1); } 
     2179     |upper-bound  
     2180     {strcpy($$.first,"1"); strcpy($$.last,$1); Save_Length($1,1);} 
     2181     ; 
     2182      
     2183/* R517 : lower-bound */ 
     2184lower-bound: specification-expr 
     2185     {strcpy($$,$1);} 
     2186     ; 
     2187      
     2188/* R518 : upper-bound */ 
     2189upper-bound: specification-expr 
     2190     ; 
     2191 
     2192assumed-shape-spec-list: 
     2193        assumed-shape-spec 
     2194        { 
     2195            $$ = (listdim*) NULL; 
     2196            if ( inside_type_declare ) break; 
     2197            if ( created_dimensionlist == 1 || agrif_parentcall == 1 )  $$=insertdim(NULL,$1); 
     2198        } 
     2199      | assumed-shape-spec-list ',' assumed-shape-spec 
     2200        { 
     2201            $$ = (listdim*) NULL; 
     2202            if ( inside_type_declare ) break; 
     2203            if ( (!inside_type_declare) && created_dimensionlist == 1 ) $$=insertdim($1,$3); 
     2204        } 
     2205      ; 
     2206 
     2207/* R519 : assumed-shape-spec */ 
     2208assumed-shape-spec : ':' 
     2209      { strcpy($$.first,"");  strcpy($$.last,"");  } 
     2210      | lower-bound ':' 
     2211      { strcpy($$.first,$1);  Save_Length($1,2); strcpy($$.last,""); } 
     2212      ; 
     2213 
     2214deferred-shape-spec-list: 
     2215        deferred-shape-spec 
     2216        { 
     2217            $$ = (listdim*) NULL; 
     2218            if ( inside_type_declare ) break; 
     2219            if ( created_dimensionlist == 1 || agrif_parentcall == 1 )  $$=insertdim(NULL,$1); 
     2220        } 
     2221      | deferred-shape-spec-list ',' deferred-shape-spec 
     2222        { 
     2223            $$ = (listdim*) NULL; 
     2224            if ( inside_type_declare ) break; 
     2225            if ( (!inside_type_declare) && created_dimensionlist == 1 ) $$=insertdim($1,$3); 
     2226        } 
     2227      ; 
     2228 
     2229/* R520 : deferred-shape-spec */ 
     2230deferred-shape-spec: ':' 
     2231     { strcpy($$.first,"");  strcpy($$.last,"");  } 
     2232     ; 
     2233 
     2234/* R521 : assume-size-spec */ 
     2235assumed-size-spec:opt-explicit-shape-spec-list-comma opt-lower-bound-2points '*' 
     2236        { 
     2237            $$ = (listdim*) NULL; 
     2238            if ( inside_type_declare ) break; 
     2239            if ( created_dimensionlist == 1 || agrif_parentcall == 1 )  
     2240            { 
     2241            if (!strcasecmp($2,"")) 
     2242            { 
     2243            strcpy(my_dim.first,"1"); 
    13392244            } 
    13402245            else 
    13412246            { 
    1342                 if ( insubroutinedeclare ) 
    1343                     copyuse_0($2); 
    1344  
    1345                 if ( inmoduledeclare == 0 ) 
     2247            strcpy(my_dim.first,$2); 
     2248            } 
     2249            strcpy(my_dim.last,"*"); 
     2250            $$=insertdim($1,my_dim); 
     2251            strcpy(my_dim.first,""); 
     2252            strcpy(my_dim.last,""); 
     2253            } 
     2254        } 
     2255     ; 
     2256      
     2257opt-explicit-shape-spec-list-comma: 
     2258     {$$ = (listdim *) NULL;} 
     2259     | explicit-shape-spec-list ',' 
     2260     {$$ = $1;} 
     2261     ; 
     2262 
     2263explicit-shape-spec-list-comma: explicit-shape-spec ',' 
     2264        { 
     2265            $$ = (listdim*) NULL; 
     2266            if ( inside_type_declare ) break; 
     2267            if ( created_dimensionlist == 1 || agrif_parentcall == 1 )  $$=insertdim(NULL,$1); 
     2268        } 
     2269     | explicit-shape-spec-list-comma explicit-shape-spec ',' 
     2270        { 
     2271            $$ = (listdim*) NULL; 
     2272            if ( inside_type_declare ) break; 
     2273            if ( (!inside_type_declare) && created_dimensionlist == 1 ) $$=insertdim($1,$2); 
     2274        } 
     2275     ; 
     2276 
     2277opt-lower-bound-2points: 
     2278     {strcpy($$,"");} 
     2279     | lower-bound ':' 
     2280     {strcpy($$,$1);} 
     2281     ; 
     2282 
     2283implied-shape-spec-list: implied-shape-spec 
     2284     | implied-shape-spec-list ',' implied-shape-spec 
     2285     ; 
     2286 
     2287/* R522 : implied-shape-spec */ 
     2288implied-shape-spec: opt-lower-bound-2points '*' 
     2289     ; 
     2290 
     2291/* R523 : intent-spec */ 
     2292intent-spec: TOK_IN 
     2293     { strcpy($$,$1); } 
     2294     | TOK_OUT 
     2295     { strcpy($$,$1); } 
     2296     | TOK_INOUT 
     2297     { strcpy($$,$1); } 
     2298     ; 
     2299 
     2300/* R524 : access-stmt */ 
     2301access-stmt: access-spec opt-access-id-list 
     2302     { 
     2303            if ((firstpass == 0) && (PublicDeclare == 1)) 
     2304            { 
     2305                if ($2) 
     2306                { 
     2307                    removeglobfromlist(&($2)); 
     2308                    pos_end = setposcur(); 
     2309                    RemoveWordSET_0(fortran_out,pos_cur,pos_end-pos_cur); 
     2310                    writelistpublic($2); 
     2311                } 
     2312            } 
     2313     PublicDeclare = 0; 
     2314     PrivateDeclare = 0; 
     2315     } 
     2316     line-break 
     2317     ; 
     2318 
     2319opt-access-id-list: 
     2320     {$$=(listname *)NULL;} 
     2321     | opt-TOK_FOURDOTS access-id-list 
     2322     {$$=$2;} 
     2323     ; 
     2324 
     2325access-id-list: access-id 
     2326     {$$=Insertname(NULL,$1,0);} 
     2327     | access-id-list ',' access-id 
     2328     {$$=Insertname($1,$3,0);} 
     2329     ; 
     2330      
     2331/* R525 : access-id */ 
     2332access-id: TOK_NAME 
     2333     | generic-spec 
     2334     ; 
     2335      
     2336/* R534 : data-stmt */ 
     2337data-stmt: TOK_DATA data-stmt-set opt-data-stmt-set-nlist 
     2338        { 
     2339            /* we should remove the data declaration                */ 
     2340            pos_end = setposcur(); 
     2341            RemoveWordSET_0(fortran_out,pos_curdata,pos_end-pos_curdata); 
     2342            if ( aftercontainsdeclare == 1  && firstpass == 0 ) 
     2343            { 
     2344                ReWriteDataStatement_0(fortran_out); 
     2345                pos_end = setposcur(); 
     2346            } 
     2347            Init_List_Data_Var(); 
     2348        } 
     2349        line-break 
     2350     ; 
     2351 
     2352opt-data-stmt-set-nlist: 
     2353     | data-stmt-set-nlist 
     2354     ; 
     2355 
     2356data-stmt-set-nlist: opt-comma data-stmt-set 
     2357     | data-stmt-set-nlist opt-comma data-stmt-set 
     2358     ; 
     2359 
     2360/* R535 : data-stmt-set */ 
     2361data-stmt-set: data-stmt-object-list TOK_SLASH data-stmt-value-list TOK_SLASH 
     2362        { 
     2363            if (firstpass == 1)   
     2364            { 
     2365            Add_Data_Var_Names_01(&List_Data_Var,$1,$3); 
     2366            } 
     2367            else                 Add_Data_Var_Names_01(&List_Data_Var_Cur,$1,$3); 
     2368        } 
     2369     ; 
     2370 
     2371data-stmt-object-list: data-stmt-object 
     2372     { $$=insertvar(NULL,$1); } 
     2373     | data-stmt-object-list ',' data-stmt-object 
     2374     { 
     2375     $$ = insertvar($1,$3); 
     2376     } 
     2377     ; 
     2378 
     2379data-stmt-value-list: data-stmt-value 
     2380     {$$=Insertname(NULL,$1,0);} 
     2381     | data-stmt-value-list ',' data-stmt-value 
     2382     {$$ = Insertname($1,$3,1);   } 
     2383     ; 
     2384      
     2385/* R536 : data-stmt-object */ 
     2386data-stmt-object: variable 
     2387     | data-implied-do 
     2388     ; 
     2389  
     2390/* R537 : data-implied-do */             
     2391data-implied-do: '(' data-i-do-object-list ',' data-i-do-variable '=' scalar-int-constant-expr ',' scalar-int-constant-expr ')' 
     2392     {printf("DOVARIABLE = %s %s %s\n",$4,$6,$8); 
     2393     printf("AUTRE = %s %s\n",$2->var->v_nomvar,$2->var->v_initialvalue_array); 
     2394     Insertdoloop($2->var,$4,$6,$8,""); 
     2395     $$=$2->var; 
     2396     } 
     2397     | '(' data-i-do-object-list ',' data-i-do-variable '=' scalar-int-constant-expr ',' scalar-int-constant-expr ',' scalar-int-constant-expr ')' 
     2398     { 
     2399     Insertdoloop($2->var,$4,$6,$8,$10); 
     2400     $$=$2->var; 
     2401     } 
     2402     ; 
     2403 
     2404data-i-do-object-list: data-i-do-object 
     2405     {$$=insertvar(NULL,$1);} 
     2406     | data-i-do-object-list ',' data-i-do-object 
     2407     {$$ = insertvar($1,$3);} 
     2408     ; 
     2409 
     2410/* R538 : data-i-do-object */ 
     2411data-i-do-object: array-element 
     2412     | scalar-structure-component 
     2413     {$$->v_initialvalue_array=Insertname($$->v_initialvalue_array,my_dim.last,0); 
     2414     strcpy(my_dim.last,""); 
     2415     } 
     2416     | data-implied-do 
     2417     ; 
     2418 
     2419/* R539 : data-i-do-variable */ 
     2420data-i-do-variable: do-variable 
     2421     ; 
     2422 
     2423/* R540 : data-stmt-value */ 
     2424/* data-stmt-repeat and first data-stmt-constant inlined */ 
     2425data-stmt-value: scalar-constant-subobject opt-data-stmt-star 
     2426     {sprintf($$,"%s%s",$1,$2);} 
     2427     | int-literal-constant opt-data-stmt-star 
     2428     {sprintf($$,"%s%s",$1,$2);} 
     2429     | char-literal-constant opt-data-stmt-star 
     2430     {sprintf($$,"%s%s",$1,$2);} 
     2431     | signed-int-literal-constant 
     2432     | signed-real-literal-constant 
     2433     | null-init 
     2434     | initial-data-target 
     2435     | structure-constructor 
     2436     ; 
     2437 
     2438opt-data-stmt-star: 
     2439     {strcpy($$,"");} 
     2440     | '*' data-stmt-constant 
     2441     {sprintf($$,"*%s",$2);} 
     2442     ; 
     2443 
     2444opt-data-stmt-repeat-star: 
     2445     | data-stmt-repeat '*' 
     2446     ; 
     2447 
     2448/* R541 : data-stmt-repeat */ 
     2449/* scalar-int-constant inlined */ 
     2450 
     2451data-stmt-repeat: scalar-int-constant 
     2452     | scalar-int-constant-subobject 
     2453     ; 
     2454 
     2455/* R542 : data-stmt-constant */ 
     2456data-stmt-constant: scalar-constant 
     2457     | scalar-constant-subobject 
     2458     | signed-int-literal-constant 
     2459     | signed-real-literal-constant 
     2460     | null-init 
     2461     | initial-data-target 
     2462     | structure-constructor 
     2463     ; 
     2464 
     2465scalar-int-constant-subobject: int-constant-subobject 
     2466     ; 
     2467 
     2468scalar-constant-subobject: constant-subobject 
     2469     ; 
     2470 
     2471/* R543 : int-constant-subobject */ 
     2472int-constant-subobject: constant-subobject 
     2473     ; 
     2474      
     2475/* R544 : constant-subobject */ 
     2476constant-subobject: designator 
     2477     {strcpy(my_dim.last,"");} 
     2478     ; 
     2479      
     2480/* R545 : dimension-stmt */ 
     2481dimension-stmt: {positioninblock = 0; pos_curdimension = my_position_before;} 
     2482     TOK_DIMENSION opt-TOK_FOURDOTS array-name-spec-list 
     2483        { 
     2484            /* if the variable is a parameter we can suppose that is   */ 
     2485            /*    value is the same on each grid. It is not useless to */ 
     2486            /*    create a copy of it on each grid                     */ 
     2487            if ( ! inside_type_declare ) 
     2488            { 
     2489                if ( firstpass ) 
     2490                { 
     2491                    Add_Globliste_1($4); 
     2492                    /* if variableparamlists has been declared in a subroutine   */ 
     2493                    if ( insubroutinedeclare )     Add_Dimension_Var_1($4); 
     2494                     
     2495                    /* Add it to the List_SubroutineDeclaration_Var list if not present */ 
     2496                    /* NB: if not done, a variable declared with DIMENSION but with no type given */ 
     2497                    /* will not be declared by the conv */ 
     2498                    ReWriteDeclarationAndAddTosubroutine_01($4); 
     2499                } 
     2500                else 
    13462501                { 
    13472502                    pos_end = setposcur(); 
    1348                     RemoveWordSET_0(fortran_out,pos_curuse,pos_end-pos_curuse); 
     2503                    RemoveWordSET_0(fortran_out,pos_curdimension,pos_end-pos_curdimension); 
     2504                    ReWriteDeclarationAndAddTosubroutine_01($4); 
    13492505                } 
    13502506            } 
    1351         } 
    1352       | word_use TOK_NAME ',' rename_list 
    1353         { 
     2507            PublicDeclare = 0; 
     2508            PrivateDeclare = 0; 
     2509            ExternalDeclare = 0; 
     2510            strcpy(NamePrecision,""); 
     2511            c_star = 0; 
     2512            InitialValueGiven = 0 ; 
     2513            strcpy(IntentSpec,""); 
     2514            VariableIsParameter =  0 ; 
     2515            Allocatabledeclare = 0 ; 
     2516            Targetdeclare = 0 ; 
     2517            SaveDeclare = 0; 
     2518            pointerdeclare = 0; 
     2519            optionaldeclare = 0 ; 
     2520            dimsgiven=0; 
     2521            c_selectorgiven=0; 
     2522            strcpy(nameinttypename,""); 
     2523            strcpy(c_selectorname,""); 
     2524        } 
     2525     line-break 
     2526     ; 
     2527      
     2528array-name-spec-list: TOK_NAME '(' {in_complex_literal = 0;} array-spec ')' 
     2529     { 
     2530        if ( inside_type_declare ) break; 
     2531        curvar = createvar($1,$4); 
     2532        CreateAndFillin_Curvar("", curvar); 
     2533        curlistvar=insertvar(NULL, curvar); 
     2534        $$ = settype("",curlistvar); 
     2535        strcpy(vallengspec,""); 
     2536     } 
     2537     | array-name-spec-list ',' TOK_NAME '(' {in_complex_literal = 0;} array-spec ')' 
     2538        { 
     2539        if ( inside_type_declare ) break; 
     2540        curvar = createvar($3,$6); 
     2541        CreateAndFillin_Curvar("", curvar); 
     2542        curlistvar = insertvar($1, curvar); 
     2543        $$ = curlistvar; 
     2544        strcpy(vallengspec,""); 
     2545        } 
     2546     ; 
     2547 
     2548 
     2549/* R548 : parameter-stmt */ 
     2550parameter-stmt: TOK_PARAMETER { VariableIsParameter = 1; pos_curparameter = setposcur()-9; } '(' named-constant-def-list ')' 
     2551        { 
     2552            if ( ! inside_type_declare ) 
     2553            { 
     2554                if ( firstpass ) 
     2555                { 
     2556                    if ( insubroutinedeclare )  Add_Parameter_Var_1($4); 
     2557                    else                        Add_GlobalParameter_Var_1($4); 
     2558                } 
     2559                else 
     2560                { 
     2561                    pos_end = setposcur(); 
     2562                    RemoveWordSET_0(fortran_out, pos_curparameter, pos_end-pos_curparameter); 
     2563                } 
     2564            } 
     2565            VariableIsParameter =  0 ; 
     2566        } 
     2567        line-break 
     2568     ; 
     2569 
     2570named-constant-def-list: named-constant-def 
     2571     {$$=insertvar(NULL,$1);} 
     2572     | named-constant-def-list ',' named-constant-def 
     2573     {$$=insertvar($1,$3);} 
     2574     ; 
     2575 
     2576/* R549 : named-constant-def */ 
     2577named-constant-def: TOK_NAME '=' constant-expr 
     2578        { 
     2579            if ( inside_type_declare ) break; 
     2580            curvar=(variable *) calloc(1,sizeof(variable)); 
     2581            Init_Variable(curvar); 
     2582            curvar->v_VariableIsParameter = 1; 
     2583            strcpy(curvar->v_nomvar,$1); 
     2584            strcpy(curvar->v_subroutinename,subroutinename); 
     2585            strcpy(curvar->v_modulename,curmodulename); 
     2586            curvar->v_initialvalue=Insertname(curvar->v_initialvalue,$3,0); 
     2587            strcpy(curvar->v_commoninfile,cur_filename); 
     2588            Save_Length($3,14); 
     2589            $$ = curvar; 
     2590        } 
     2591     ; 
     2592 
     2593/* R553 : save-stmt */ 
     2594save-stmt: {pos_cursave = my_position_before;} TOK_SAVE opt-TOK_FOURDOTS opt-saved-entity-list 
     2595     { 
     2596     pos_end = setposcur(); 
     2597     RemoveWordSET_0(fortran_out,pos_cursave,pos_end-pos_cursave); 
     2598     } 
     2599     line-break 
     2600     ; 
     2601 
     2602opt-TOK_FOURDOTS: 
     2603     | TOK_FOURDOTS 
     2604     ; 
     2605 
     2606opt-saved-entity-list: 
     2607     | saved-entity-list 
     2608     ; 
     2609 
     2610saved-entity-list: saved-entity 
     2611     | saved-entity-list ',' saved-entity 
     2612     ; 
     2613 
     2614/* R554 : saved-entity */ 
     2615saved-entity: object-name 
     2616     {if ( ! inside_type_declare ) Add_Save_Var_1($1,(listdim*) NULL); } 
     2617     | proc-pointer-name 
     2618     | common-block-name 
     2619     ; 
     2620 
     2621/* R555 : proc-pointer-name */ 
     2622proc-pointer-name: ident 
     2623     ; 
     2624 
     2625get_my_position: 
     2626     {my_position = my_position_before;} 
     2627     ; 
     2628 
     2629/* R560 : implicit-stmt */ 
     2630implicit-stmt: get_my_position TOK_IMPLICIT implicit-spec-list line-break 
     2631    | get_my_position TOK_IMPLICIT TOK_NONE 
     2632        { 
     2633            if ( insubroutinedeclare == 1 ) 
     2634            { 
     2635                Add_ImplicitNoneSubroutine_1(); 
     2636                pos_end = setposcur(); 
     2637                RemoveWordSET_0(fortran_out,my_position,pos_end-my_position); 
     2638            } 
     2639        } 
     2640    line-break 
     2641    ; 
     2642 
     2643implicit-spec-list: implicit-spec 
     2644     | implicit-spec-list ',' implicit-spec 
     2645     ; 
     2646 
     2647/*R561 implicit-spec */ 
     2648implicit-spec: declaration-type-spec '(' letter-spec-list ')' 
     2649    ; 
     2650 
     2651letter-spec-list:letter-spec 
     2652     | letter-spec-list ',' letter-spec 
     2653     ; 
     2654      
     2655/* R562 : letter-spec */ 
     2656letter-spec: TOK_NAME 
     2657     | TOK_NAME '-' TOK_NAME 
     2658     ; 
     2659 
     2660/* R563 : namelist-stmt */ 
     2661namelist-stmt: TOK_NAMELIST TOK_SLASH TOK_NAME TOK_SLASH namelist-group-object-list opt-namelist-other line-break 
     2662     ; 
     2663 
     2664opt-namelist-other: 
     2665     | opt-namelist-other opt-comma TOK_SLASH TOK_NAME TOK_SLASH namelist-group-object-list 
     2666 
     2667namelist-group-object-list:namelist-group-object 
     2668     | namelist-group-object-list ',' namelist-group-object 
     2669     ; 
     2670 
     2671/* R564 : namelist-group-object */ 
     2672namelist-group-object: variable-name 
     2673    ; 
     2674 
     2675/* R565 : equivalence-stmt */ 
     2676equivalence-stmt:  TOK_EQUIVALENCE equivalence-set-list line-break 
     2677     ; 
     2678 
     2679equivalence-set-list:equivalence-set 
     2680     | equivalence-set-list ',' equivalence-set 
     2681     ; 
     2682 
     2683/* R566 : equivalence-set */ 
     2684equivalence-set: '(' {in_complex_literal=0;} equivalence-object ',' equivalence-object-list ')' 
     2685     ; 
     2686 
     2687equivalence-object-list:equivalence-object 
     2688     | equivalence-object-list ',' equivalence-object 
     2689     ; 
     2690 
     2691/* R567 : equivalence-object */      
     2692equivalence-object: variable-name 
     2693     | array-element 
     2694     | substring 
     2695     ; 
     2696 
     2697 
     2698/* R568 : common-stmt */ 
     2699common-stmt: TOK_COMMON { positioninblock = 0; pos_curcommon = my_position_before; indeclaration=1;} opt-common-block-name common-block-object-list opt-common-block-list 
     2700     { 
     2701            indeclaration = 0; 
     2702            if ( inside_type_declare ) break; 
     2703            pos_end = setposcur(); 
     2704            RemoveWordSET_0(fortran_out,pos_curcommon,pos_end-pos_curcommon); 
     2705     } 
     2706     line-break 
     2707     ; 
     2708 
     2709opt-common-block-name: 
     2710     | common-block-name 
     2711     { 
     2712     if ( inside_type_declare ) break; 
     2713     sprintf(charusemodule,"%s",$1); 
     2714     Add_NameOfCommon_1($1,subroutinename); 
     2715     } 
     2716     ; 
     2717      
     2718common-block-name:TOK_DSLASH 
     2719        { 
     2720            strcpy($$,""); 
     2721            positioninblock=0; 
     2722            strcpy(commonblockname,""); 
     2723        } 
     2724     | TOK_SLASH TOK_NAME TOK_SLASH 
     2725        { 
     2726            strcpy($$,$2); 
     2727            positioninblock=0; 
     2728            strcpy(commonblockname,$2); 
     2729        } 
     2730      ; 
     2731 
     2732opt-comma: 
     2733     | ',' 
     2734     ; 
     2735 
     2736opt-common-block-list: 
     2737     | opt-common-block-list opt-comma common-block-name 
     2738     { 
     2739     if ( inside_type_declare ) break; 
     2740     sprintf(charusemodule,"%s",$3); 
     2741     Add_NameOfCommon_1($3,subroutinename); 
     2742     } 
     2743     common-block-object-list 
     2744     ; 
     2745 
     2746 
     2747common-block-object-list: common-block-object 
     2748     {if ( ! inside_type_declare ) Add_Common_var_1(); } 
     2749     | common-block-object-list ',' common-block-object 
     2750     {if ( ! inside_type_declare ) Add_Common_var_1(); } 
     2751     ; 
     2752   
     2753/* R569 : common-block-object */ 
     2754/* variable-name replaced by TOK_NAME */ 
     2755/* because the corresponding variable do not have to be added to the listofsubroutine_used */ 
     2756 
     2757common-block-object: TOK_NAME 
     2758        { 
     2759            positioninblock = positioninblock + 1 ; 
     2760            strcpy(commonvar,$1); 
     2761            commondim = (listdim*) NULL; 
     2762        } 
     2763     | TOK_NAME '(' {in_complex_literal=0;} array-spec ')' 
     2764        { 
     2765            positioninblock = positioninblock + 1 ; 
     2766            strcpy(commonvar,$1); 
     2767            commondim = $4; 
     2768        } 
     2769     ; 
     2770 
     2771/* R601 : designator */ 
     2772designator: array-element 
     2773     | array-section 
     2774     | structure-component 
     2775     | substring 
     2776     {$$=createvar($1,NULL);} 
     2777     ; 
     2778/* R602 : variable */ 
     2779/*variable: designator 
     2780       | expr 
     2781       ; 
     2782*/ 
     2783 
     2784scalar-variable: variable 
     2785     ; 
     2786      
     2787variable: designator 
     2788       {if (strcmp(my_dim.last,"")) 
     2789       { 
     2790       $$->v_initialvalue_array=Insertname(NULL,my_dim.last,0); 
     2791       } 
     2792       strcpy(my_dim.last,""); 
     2793       } 
     2794       ; 
     2795        
     2796scalar-variable-name: variable-name 
     2797     ; 
     2798 
     2799/* R603 : variable-name */ 
     2800variable-name: ident 
     2801      ; 
     2802 
     2803scalar-logical-variable: logical-variable 
     2804      ; 
     2805 
     2806/* R604 : logical-variable */ 
     2807logical-variable: variable 
     2808      ; 
     2809 
     2810/* R605 : char-variable */ 
     2811char-variable: variable 
     2812       ; 
     2813 
     2814scalar-default-char-variable: default-char-variable 
     2815     ; 
     2816      
     2817/* R606 : default-char-variable */ 
     2818default-char-variable: variable 
     2819     ; 
     2820 
     2821scalar-int-variable: int-variable 
     2822      ; 
     2823       
     2824int-variable: variable 
     2825     ; 
     2826 
     2827/* R608 : substring */ 
     2828substring: data-ref 
     2829     | data-ref '(' substring-range ')' 
     2830     {sprintf($$,"%s(%s)",$1,$3);} 
     2831     | char-literal-constant '(' substring-range ')' 
     2832     {sprintf($$,"%s(%s)",$1,$3);} 
     2833     ; 
     2834 
     2835/* R609 : parent-string */ 
     2836/* IS INLINED IN SUBSTRING (R608) */ 
     2837/* 
     2838parent-string: scalar-variable-name 
     2839     | array-element 
     2840     | scalar-structure-component 
     2841     | scalar-constant 
     2842     ; 
     2843*/ 
     2844 
     2845/* R610 : substring-range */ 
     2846substring-range: opt-scalar-int-expr ':' opt-scalar-int-expr 
     2847     {sprintf($$,"%s:%s",$1,$3);} 
     2848     ; 
     2849 
     2850/* R611: data-ref */ 
     2851data-ref: part-ref opt-part-ref 
     2852     {sprintf($$,"%s%s",$1->v_nomvar,$2);} 
     2853     ; 
     2854      
     2855opt-part-ref: 
     2856     {strcpy($$,"");} 
     2857     | opt-part-ref '%' part-ref 
     2858     {sprintf($$,"%s%%%s",$1,$3->v_nomvar);} 
     2859     ; 
     2860 
     2861/* R612 : part-ref */ 
     2862part-ref:ident 
     2863     {$$=createvar($1,NULL);} 
     2864     | ident '(' {in_complex_literal=0;} section-subscript-list ')' 
     2865     {sprintf(ligne,"%s(%s)",$1,$4);$$=createvar($1,NULL);strcpy(my_dim.last,$4);} 
     2866     ; 
     2867      
     2868/* $$=createvar($1,insertdim(NULL,my_dim)); 
     2869{strcpy(my_dim.first,"1");strcpy(my_dim.last,$4);$$=createvar($1,insertdim(NULL,my_dim));} 
     2870} */ 
     2871 
     2872/*part-name: ident 
     2873     ; 
     2874*/ 
     2875 
     2876scalar-structure-component: structure-component 
     2877     ; 
     2878 
     2879/* R613 : structure-component */ 
     2880structure-component: data-ref 
     2881     {strcpy(my_dim.last,"");} 
     2882     ; 
     2883 
     2884/* R617 : array-element */ 
     2885array-element: data-ref 
     2886      {strcpy(my_dim.last,"");} 
     2887      ; 
     2888 
     2889/* R618 : array-section */ 
     2890array-section: data-ref 
     2891     {strcpy(my_dim.last,"");} 
     2892     | data-ref '(' substring-range ')' 
     2893     {strcpy(my_dim.last,"");} 
     2894      ; 
     2895 
     2896/* section-subscript-list can be empty ... */ 
     2897/* in contradiction with the grammar ... */ 
     2898section-subscript-list: 
     2899      {strcpy($$,"");} 
     2900      |  section-subscript 
     2901      {strcpy($$,$1);} 
     2902      | section-subscript-list ',' section-subscript 
     2903      {sprintf($$,"%s,%s",$1,$3);} 
     2904      ; 
     2905 
     2906opt-subscript: 
     2907     {strcpy($$,"");} 
     2908     | subscript 
     2909     ; 
     2910 
     2911/* R619 : subscript */ 
     2912subscript: scalar-int-expr 
     2913     ; 
     2914 
     2915/* R620 : section-subscript */ 
     2916/*section-subscript: subscript 
     2917     | subscript-triplet 
     2918     | vector-subscript 
     2919     ; 
     2920*/ 
     2921 
     2922/* USE OpenFortranParser rules */ 
     2923 
     2924section-subscript: expr section_subscript_ambiguous 
     2925     {sprintf($$,"%s%s",$1,$2);} 
     2926     | ':' 
     2927     {strcpy($$,":");} 
     2928     | ':' expr  
     2929     {sprintf($$,":%s",$2);} 
     2930     | ':' ':' expr 
     2931     {sprintf($$,": :%s",$3);} 
     2932     | ':' expr ':' expr 
     2933     {sprintf($$,":%s :%s",$2,$4);} 
     2934     | TOK_FOURDOTS expr 
     2935     {sprintf($$,"::%s",$2);} 
     2936     | vector-subscript 
     2937     | ident '=' expr 
     2938     {sprintf($$,"%s=%s",$1,$3);} 
     2939     | ident '=' '*' label 
     2940     {sprintf($$,"%s=*%s",$1,$4);} 
     2941     | '*' label 
     2942     {sprintf($$,"*%s",$2);} 
     2943     ; 
     2944 
     2945section_subscript_ambiguous: ':' 
     2946     {strcpy($$,":");} 
     2947     | ':' expr 
     2948     {sprintf($$,":%s",$2);} 
     2949     | ':' ':' expr 
     2950     {sprintf($$,": :%s",$3);} 
     2951     | ':' expr ':' expr 
     2952     {sprintf($$,":%s :%s",$2,$4);} 
     2953     | TOK_FOURDOTS expr 
     2954     {sprintf($$,"::%s",$2);} 
     2955     | 
     2956     {strcpy($$,"");} 
     2957     ; 
     2958/* R621 : subscript-triplet */ 
     2959subscript-triplet: opt-subscript ':' opt-subscript  
     2960     {sprintf($$,"%s:%s",$1,$3);} 
     2961     | opt-subscript ':' opt-subscript ':' stride 
     2962     {sprintf($$,"%s:%s:%s",$1,$3,$5);} 
     2963     ; 
     2964 
     2965/* R622 : stride */ 
     2966stride: scalar-int-expr 
     2967     ; 
     2968      
     2969/* R623 : vector-subscript */ 
     2970vector-subscript: int-expr 
     2971     ; 
     2972 
     2973/* R626 : allocate-stmt */ 
     2974allocate-stmt: TOK_ALLOCATE '(' {in_complex_literal=0;} allocation-list opt-alloc-opt-list-comma ')' 
     2975     {inallocate = 0;} 
     2976     line-break 
     2977     ; 
     2978 
     2979opt-type-spec-fourdots: 
     2980     | type-spec TOK_FOURDOTS 
     2981     ; 
     2982 
     2983opt-alloc-opt-list-comma: 
     2984     | ',' alloc-opt-list 
     2985     ; 
     2986 
     2987alloc-opt-list: 
     2988        alloc-opt 
     2989      | alloc-opt-list ',' alloc-opt 
     2990      ; 
     2991       
     2992/* R627 : alloc-opt */ 
     2993alloc-opt: TOK_ERRMSG errmsg-variable 
     2994     | TOK_STAT '=' stat-variable 
     2995     ; 
     2996      
     2997/* R628 : stat-variable */ 
     2998stat-variable: scalar-int-variable 
     2999     ; 
     3000      
     3001/* R629 : errmsg-variable */ 
     3002errmsg-variable: scalar-default-char-variable 
     3003    ; 
     3004 
     3005allocation-list: 
     3006        allocation 
     3007      | allocation-list ',' allocation 
     3008      ; 
     3009  
     3010/* R631 allocation */ 
     3011allocation: allocate-object opt-allocate-shape-spec-list-par 
     3012     ; 
     3013 
     3014/* R632 allocate-object */      
     3015allocate-object: variable-name 
     3016     | structure-component 
     3017     ; 
     3018 
     3019opt-allocate-shape-spec-list-par: 
     3020     | '(' allocate-shape-spec-list ')' 
     3021     ; 
     3022 
     3023allocate-shape-spec-list: 
     3024        allocate-shape-spec 
     3025      | allocate-shape-spec-list ',' allocate-shape-spec 
     3026      ; 
     3027 
     3028/* R633 : allocate-shape-spec */ 
     3029allocate-shape-spec: opt-lower-bound-expr upper-bound-expr 
     3030     ; 
     3031 
     3032opt-lower-bound-expr: 
     3033     | lower-bound-expr ':' 
     3034     ; 
     3035 
     3036/* R634 : lower-bound-expr */ 
     3037lower-bound-expr: scalar-int-expr 
     3038     ; 
     3039 
     3040/* R634 : upper-bound-expr */ 
     3041upper-bound-expr: scalar-int-expr 
     3042     ; 
     3043      
     3044/* R640 : deallocate-stmt */ 
     3045deallocate-stmt: TOK_DEALLOCATE '(' {in_complex_literal=0;} allocate-object-list opt-dealloc-opt-list-comma ')' 
     3046     {inallocate = 0;} 
     3047     line-break 
     3048     ; 
     3049 
     3050allocate-object-list: 
     3051        allocate-object 
     3052      | allocate-object-list ',' allocate-object 
     3053      ; 
     3054       
     3055opt-dealloc-opt-list-comma: 
     3056     | ',' dealloc-opt-list 
     3057     ; 
     3058 
     3059dealloc-opt-list: 
     3060        dealloc-opt 
     3061      | dealloc-opt-list ',' dealloc-opt 
     3062      ; 
     3063       
     3064/* R641 : dealloc-opt */ 
     3065dealloc-opt: TOK_ERRMSG errmsg-variable 
     3066     | TOK_STAT '=' stat-variable 
     3067     ; 
     3068 
     3069/* R701 : primary */ 
     3070/* remove type-param-name */ 
     3071/* constant replaced by literal-constant to avoid conflict with designato */ 
     3072/* real-part is added because potential conflicts with complex-literal-constant */ 
     3073 
     3074primary:  
     3075      designator 
     3076      { 
     3077      strcpy($$,$1->v_nomvar); 
     3078      if (strcasecmp(my_dim.last,"")) 
     3079      { 
     3080      strcat($$,"("); 
     3081      strcat($$,my_dim.last); 
     3082      strcat($$,")"); 
     3083      } 
     3084      } 
     3085      | literal-constant 
     3086      | array-constructor 
     3087      | function-reference 
     3088      | '(' expr ')' 
     3089     { sprintf($$,"(%s)",$2);} 
     3090     ; 
     3091 
     3092/* R702 : level-1-expr */ 
     3093level-1-expr: primary 
     3094      {strcpy(my_dim.last,"");} 
     3095     ; 
     3096 
     3097/* R704 : mult-operand */ 
     3098mult-operand: level-1-expr 
     3099     | level-1-expr power-op mult-operand 
     3100     {sprintf($$,"%s**%s",$1,$3);} 
     3101     ; 
     3102/* R705 : add-operand */ 
     3103add-operand: mult-operand 
     3104     | add-operand mult-op mult-operand 
     3105     { sprintf($$,"%s%s%s",$1,$2,$3); } 
     3106     ; 
     3107      
     3108/* R706 : level-2-expr */ 
     3109/* add signed-int-literal-constant because potential reduce conflict with add-op add-operand */ 
     3110 
     3111level-2-expr: add-operand 
     3112     | add-op add-operand 
     3113     { sprintf($$,"%s%s",$1,$2); } 
     3114     | level-2-expr add-op add-operand 
     3115     { sprintf($$,"%s%s%s",$1,$2,$3); } 
     3116     | signed-int-literal-constant 
     3117     | level-2-expr signed-int-literal-constant 
     3118     { sprintf($$,"%s%s",$1,$2); } 
     3119     ; 
     3120      
     3121/* R707 : power-op */ 
     3122power-op : TOK_DASTER 
     3123     ; 
     3124      
     3125/* R708 : mult-op */ 
     3126mult-op : '*' 
     3127     {strcpy($$,"*");} 
     3128     | TOK_SLASH 
     3129     ; 
     3130      
     3131/* R709 : add-op */ 
     3132add-op : '+' 
     3133     {strcpy($$,"+");} 
     3134     | '-' 
     3135     {strcpy($$,"-");}      
     3136     ;      
     3137 
     3138/* R710 : level-3-expr */ 
     3139level-3-expr: level-2-expr 
     3140     | level-3-expr concat-op level-2-expr 
     3141     { sprintf($$,"%s%s%s",$1,$2,$3); } 
     3142     ; 
     3143 
     3144/* R711 : concat-op */ 
     3145concat-op : TOK_DSLASH 
     3146     ; 
     3147/* R712 : level-4-expr */ 
     3148level-4-expr: level-3-expr 
     3149     | level-3-expr rel-op level-3-expr 
     3150     { sprintf($$,"%s%s%s",$1,$2,$3); } 
     3151     ; 
     3152 
     3153/* R713 : rel-op */ 
     3154rel-op : TOK_EQ 
     3155     | TOK_NE 
     3156     | TOK_LT 
     3157     | TOK_LE 
     3158     | TOK_GT 
     3159     | TOK_GE 
     3160     | TOK_EQUALEQUAL 
     3161     | TOK_SLASHEQUAL 
     3162     | '<' 
     3163     {strcpy($$,"<");} 
     3164     | TOK_INFEQUAL 
     3165     | '>' 
     3166     {strcpy($$,">");} 
     3167     | TOK_SUPEQUAL 
     3168     ; 
     3169 
     3170/* R714 : and-operand */ 
     3171/* level-4-expr inlined as level-3-expr */ 
     3172and-operand: level-4-expr 
     3173     | not-op level-4-expr 
     3174     { sprintf($$,"%s%s",$1,$2); } 
     3175     ; 
     3176 
     3177 
     3178/* R715 : or-operand */ 
     3179or-operand: and-operand 
     3180     | or-operand and-op and-operand 
     3181     { sprintf($$,"%s%s%s",$1,$2,$3); } 
     3182     ; 
     3183 
     3184 
     3185/* R716 : equiv-operand */ 
     3186equiv-operand : or-operand 
     3187     | equiv-operand or-op or-operand 
     3188     { sprintf($$,"%s%s%s",$1,$2,$3); } 
     3189     ; 
     3190 
     3191/* R717 : level-5-expr */ 
     3192level-5-expr: equiv-operand 
     3193     | level-5-expr equiv-op equiv-operand 
     3194     { sprintf($$,"%s%s%s",$1,$2,$3); } 
     3195     ; 
     3196 
     3197/* R718 : not-op */ 
     3198not-op: TOK_NOT 
     3199     ; 
     3200      
     3201/* R719 : and-op */ 
     3202and-op: TOK_AND 
     3203     ; 
     3204      
     3205/* R720 : or-op */ 
     3206or-op: TOK_OR 
     3207     ; 
     3208 
     3209/* R721 : equiv-op */ 
     3210equiv-op: TOK_EQV 
     3211     | TOK_NEQV 
     3212     ; 
     3213      
     3214/* R722 : expr */ 
     3215expr: level-5-expr 
     3216     ; 
     3217 
     3218scalar-default-char-expr: default-char-expr 
     3219     ; 
     3220 
     3221/* R725 : default-char-expr */ 
     3222default-char-expr : expr 
     3223       ; 
     3224 
     3225/* R726 : int-expr */ 
     3226int-expr: expr 
     3227       ; 
     3228 
     3229opt-scalar-int-expr: 
     3230     {strcpy($$,"");} 
     3231     | scalar-int-expr 
     3232     ; 
     3233 
     3234scalar-int-expr: int-expr 
     3235       ; 
     3236 
     3237/* R728 : specification-expr */ 
     3238specification-expr: scalar-int-expr 
     3239     { 
     3240     strcpy($$,$1); 
     3241     } 
     3242     ; 
     3243 
     3244/* R729 : constant-expr */ 
     3245constant-expr: expr 
     3246     {strcpy($$,$1);} 
     3247     ; 
     3248 
     3249scalar-default-char-constant-expr: default-char-constant-expr 
     3250     ; 
     3251      
     3252/* R730: default-char-constant-expr */ 
     3253default-char-constant-expr: default-char-expr 
     3254     ; 
     3255 
     3256scalar-int-constant-expr: int-constant-expr 
     3257     ; 
     3258 
     3259/* R731 : int-constant-expr */ 
     3260int-constant-expr: int-expr 
     3261     ; 
     3262 
     3263/* R732 : assignment-stmt */ 
     3264/* cannot use opt-label due to conflicts ... */ 
     3265 
     3266assignment-stmt: variable '=' expr line-break 
     3267      | label variable '=' expr line-break 
     3268      ; 
     3269 
     3270/* R733 : pointer-assignment-stmt */ 
     3271 
     3272/* data-pointer-object and proc-pointer-object replaced by designator */ 
     3273/*pointer-assignment-stmt: data-pointer-object opt-bounds-spec-list-par TOK_POINT_TO data-target line-break 
     3274     | data-pointer-object '(' bounds-remapping-list ')' TOK_POINT_TO data-target line-break 
     3275     | proc-pointer-object TOK_POINT_TO proc-target line-break 
     3276     ; 
     3277*/ 
     3278 
     3279pointer-assignment-stmt: designator opt-bounds-spec-list-par TOK_POINT_TO data-target line-break 
     3280     | designator '(' bounds-remapping-list ')' TOK_POINT_TO data-target line-break 
     3281     | designator TOK_POINT_TO proc-target line-break 
     3282     ; 
     3283      
     3284/* R734 : data-pointer-object */ 
     3285data-pointer-object: variable-name 
     3286     | scalar-variable '%' TOK_NAME 
     3287     ; 
     3288 
     3289opt-bounds-spec-list-par: 
     3290     | '(' bounds-spec-list ')' 
     3291     ; 
     3292 
     3293bounds-spec-list: 
     3294        bounds-spec 
     3295      | bounds-spec-list ',' bounds-spec 
     3296      ; 
     3297 
     3298bounds-remapping-list: 
     3299        bounds-remapping 
     3300      | bounds-remapping-list ',' bounds-remapping 
     3301      ; 
     3302       
     3303/* R735 : bounds-spec */ 
     3304bounds-spec: lower-bound-expr ':' 
     3305     ; 
     3306 
     3307/* R736 : bounds-remapping */ 
     3308bounds-remapping: lower-bound-expr ':' upper-bound-expr 
     3309     ; 
     3310      
     3311/* R737 : data-target */ 
     3312data-target: variable 
     3313     ; 
     3314 
     3315procedure-component-name: TOK_NAME 
     3316     ; 
     3317 
     3318/* R738 : proc-pointer-object */ 
     3319proc-pointer-object: proc-pointer-name 
     3320     | proc-component-ref 
     3321     ; 
     3322 
     3323/* R739 : proc-component-ref */ 
     3324proc-component-ref : scalar-variable '%' procedure-component-name 
     3325     ; 
     3326      
     3327/* R740 : proc-target */ 
     3328proc-target: expr 
     3329     | procedure-component-name 
     3330     | proc-component-ref 
     3331     ; 
     3332 
     3333/* R741 : where-stmt */ 
     3334where-stmt: TOK_WHERE '(' mask-expr ')' where-assignment-stmt 
     3335      ; 
     3336 
     3337/* R742 : where-construct */ 
     3338where-construct: where-construct-stmt opt-where-body-construct opt-masked-elsewhere-construct opt-elsewhere-construct end-where-stmt 
     3339      ; 
     3340 
     3341opt-where-body-construct: 
     3342      | opt-where-body-construct where-body-construct 
     3343      ; 
     3344 
     3345opt-masked-elsewhere-construct : 
     3346      | opt-masked-elsewhere-construct masked-elsewhere-stmt opt-where-body-construct 
     3347      ; 
     3348 
     3349opt-elsewhere-construct: 
     3350      | opt-elsewhere-construct elsewhere-stmt opt-where-body-construct 
     3351      ; 
     3352 
     3353/* R743 : where-construct-stmt */ 
     3354where-construct-stmt: TOK_WHERE '(' mask-expr ')' line-break 
     3355      ; 
     3356 
     3357/* R744 : where-body-construct */ 
     3358where-body-construct: where-assignment-stmt 
     3359      | where-stmt 
     3360      | where-construct 
     3361      ; 
     3362 
     3363/* R745 : where-assignment-stmt */ 
     3364where-assignment-stmt: assignment-stmt 
     3365      ; 
     3366 
     3367/* R746 : mask-expr */ 
     3368mask-expr: expr 
     3369      ; 
     3370 
     3371/* R747 : masked-elsewhere-stmt */ 
     3372masked-elsewhere-stmt: TOK_ELSEWHEREPAR mask-expr ')' line-break 
     3373      | TOK_ELSEWHEREPAR mask-expr ')' TOK_NAME line-break 
     3374      ; 
     3375 
     3376/* R748: elsewhere-stmt */ 
     3377elsewhere-stmt: TOK_ELSEWHERE line-break 
     3378      | TOK_ELSEWHERE TOK_NAME line-break 
     3379      ; 
     3380 
     3381/* R749: end-where-stmt */ 
     3382end-where-stmt: 
     3383        TOK_ENDWHERE line-break 
     3384      | TOK_ENDWHERE TOK_NAME line-break 
     3385      ; 
     3386 
     3387/* R752 : forall-header */ 
     3388forall-header : 
     3389     ; 
     3390 
     3391/* R801 : block */ 
     3392block: opt-execution-part-construct 
     3393      ; 
     3394 
     3395opt-execution-part-construct: 
     3396      | opt-execution-part-construct execution-part-construct 
     3397      ; 
     3398 
     3399/* R813 : do-construct */ 
     3400do-construct: 
     3401        block-do-construct 
     3402      | nonblock-do-construct 
     3403      ; 
     3404 
     3405do-construct: 
     3406        block-do-construct 
     3407      ; 
     3408       
     3409/* R814 : block-do-construct */ 
     3410 
     3411block-do-construct: label-do-stmt do-block end-do 
     3412      | nonlabel-do-stmt do-block end-do 
     3413      ; 
     3414 
     3415/* R815 : do-stmt */ 
     3416/*do-stmt: 
     3417        label-do-stmt 
     3418      | nonlabel-do-stmt 
     3419      ; 
     3420*/ 
     3421 
     3422/* R816 : label-do-stmt */ 
     3423label-do-stmt: TOK_NAME ':' TOK_PLAINDO_LABEL line-break 
     3424      |              TOK_PLAINDO_LABEL line-break 
     3425      | TOK_NAME ':' TOK_PLAINDO_LABEL loop-control line-break 
     3426      |              TOK_PLAINDO_LABEL loop-control line-break 
     3427      ; 
     3428       
     3429label-do-stmt-djview: TOK_NAME ':' TOK_PLAINDO_LABEL_DJVIEW line-break 
     3430      |              TOK_PLAINDO_LABEL_DJVIEW line-break 
     3431      | TOK_NAME ':' TOK_PLAINDO_LABEL_DJVIEW loop-control line-break 
     3432      |              TOK_PLAINDO_LABEL_DJVIEW loop-control line-break 
     3433      ; 
     3434       
     3435/* R817 : nonlabel-do-stmt */ 
     3436nonlabel-do-stmt: TOK_NAME ':' TOK_PLAINDO line-break 
     3437      |              TOK_PLAINDO line-break 
     3438      | TOK_NAME ':' TOK_PLAINDO loop-control line-break 
     3439      |              TOK_PLAINDO loop-control line-break 
     3440      ; 
     3441 
     3442/* R818 : loop-control */ 
     3443loop-control: 
     3444        opt_comma do-variable '=' expr ',' expr 
     3445      | opt_comma do-variable '=' expr ',' expr ',' expr 
     3446      | opt_comma TOK_WHILE '(' expr ')' 
     3447      | opt_comma TOK_CONCURRENT forall-header 
     3448      ; 
     3449 
     3450/* R819 : do-variable */ 
     3451do-variable: ident 
     3452     ; 
     3453 
     3454/* R820 : do-block */ 
     3455do-block: block 
     3456     ; 
     3457 
     3458/* R821 : end-do */ 
     3459/*end-do: end-do-stmt 
     3460     | do-term-action-stmt 
     3461     ; 
     3462*/ 
     3463 
     3464end-do: end-do-stmt 
     3465     | label-djview continue-stmt 
     3466     ; 
     3467 
     3468/* R822 : end-do-stmt */ 
     3469end-do-stmt: opt-label-djview TOK_ENDDO line-break 
     3470      | opt-label-djview TOK_ENDDO TOK_NAME line-break 
     3471      ; 
     3472 
     3473/* R823 : nonblock-do-construct */ 
     3474/* only outer-shared-do-construct is used */ 
     3475 
     3476/* 
     3477nonblock-do-construct: outer-shared-do-construct 
     3478      ; 
     3479*/ 
     3480 
     3481nonblock-do-construct: action-term-do-construct 
     3482      | outer-shared-do-construct 
     3483      ; 
     3484 
     3485 
     3486/* R824 : action-term-do-construct */ 
     3487 
     3488action-term-do-construct: label-do-stmt do-block do-term-action-stmt 
     3489      ; 
     3490       
     3491/* R825 : do-body */ 
     3492 
     3493do-body : 
     3494      | execution-part-construct do-body 
     3495      ; 
     3496 
     3497/* R826 : do-term-action-stmt */ 
     3498do-term-action-stmt:  label-djview do-term-action-stmt-special 
     3499      ; 
     3500 
     3501/* do-term-action-stmt-special */ 
     3502do-term-action-stmt-special: 
     3503      allocate-stmt 
     3504      | assignment-stmt 
     3505      | call-stmt 
     3506      | close-stmt 
     3507      | deallocate-stmt 
     3508      | flush-stmt 
     3509      | goto-stmt 
     3510      | TOK_REWIND after_rewind 
     3511      | TOK_NULLIFY '(' pointer_name_list ')' 
     3512      | if-stmt 
     3513      | inquire-stmt 
     3514      | open-stmt 
     3515      | print-stmt 
     3516      | read-stmt 
     3517      | rewind-stmt 
     3518      | where-stmt 
     3519      | write-stmt 
     3520      ; 
     3521 
     3522 
     3523/* R827 : outer-shared-do-construct */ 
     3524/* do-body is same as do-block  
     3525we extend the definition of outer-shared-do-construct 
     3526a label-do-stmt statement must be followed by a label-do-stmt-djview statement 
     3527*/ 
     3528 
     3529outer-shared-do-construct : label-do-stmt do-block label-do-stmt-djview-do-block-list inner-shared-do-construct 
     3530       | label-do-stmt do-block inner-shared-do-construct 
     3531       ; 
     3532 
     3533label-do-stmt-djview-do-block-list: label-do-stmt-djview do-block 
     3534       | label-do-stmt-djview-do-block-list label-do-stmt-djview do-block 
     3535       ; 
     3536 
     3537/* R828 : shared-term-do-construct */ 
     3538 
     3539shared-term-do-construct: outer-shared-do-construct 
     3540      | inner-shared-do-construct 
     3541      ; 
     3542     
     3543/* R829 : inner-shared-do-construct */ 
     3544/* do-body is same as do-block */ 
     3545inner-shared-do-construct: label-do-stmt-djview do-block do-term-shared-stmt 
     3546      ; 
     3547       
     3548/* R830 : do-term-shared-stmt */ 
     3549 
     3550do-term-shared-stmt: label-djview action-stmt 
     3551      ; 
     3552 
     3553opt-do-construct-name: 
     3554     | TOK_NAME 
     3555     ; 
     3556 
     3557/* R831 : cycle-stmt */ 
     3558cycle-stmt: TOK_CYCLE opt-do-construct-name line-break 
     3559     ; 
     3560 
     3561/* R832 : if-construct */ 
     3562if-construct: if-then-stmt block opt-else-if-stmt-block opt-else-stmt-block end-if-stmt 
     3563      ; 
     3564   
     3565opt-else-if-stmt-block:  
     3566      | else-if-stmt-block 
     3567      | opt-else-if-stmt-block else-if-stmt-block 
     3568      ; 
     3569 
     3570else-if-stmt-block: else-if-stmt block 
     3571      ; 
     3572 
     3573opt-else-stmt-block:  
     3574      | else-stmt-block 
     3575      | opt-else-stmt-block else-if-stmt-block 
     3576      ; 
     3577 
     3578else-stmt-block: else-stmt block 
     3579        ; 
     3580 
     3581/* R833 : if-then-stmt */ 
     3582if-then-stmt: TOK_NAME ':' TOK_LOGICALIF_PAR expr ')' TOK_THEN line-break 
     3583      | label TOK_NAME ':' TOK_LOGICALIF_PAR expr ')' TOK_THEN line-break 
     3584      | opt-label TOK_LOGICALIF_PAR expr ')' TOK_THEN line-break 
     3585      ; 
     3586 
     3587/* R834 : else-if-stmt */ 
     3588else-if-stmt:TOK_ELSEIF '(' expr ')' TOK_THEN line-break 
     3589      | TOK_ELSEIF '(' expr ')' TOK_THEN TOK_NAME line-break 
     3590      ; 
     3591 
     3592/* R835 : else-stmt */ 
     3593else-stmt:TOK_ELSE line-break 
     3594      | TOK_ELSE TOK_NAME line-break 
     3595      ; 
     3596 
     3597/* R836 : end-if-stmt */ 
     3598end-if-stmt:TOK_ENDIF line-break 
     3599      | TOK_ENDIF TOK_NAME line-break 
     3600      ; 
     3601 
     3602/* R837 : if-stmt */ 
     3603if-stmt: opt-label TOK_LOGICALIF_PAR expr ')' action-stmt 
     3604        ; 
     3605 
     3606/* R838 : case-construct */ 
     3607case-construct: select-case-stmt opt_case-stmt-block end-select-stmt 
     3608        ; 
     3609 
     3610opt_case-stmt-block: 
     3611        | case-stmt-block 
     3612        | opt_case-stmt-block case-stmt-block 
     3613        ; 
     3614 
     3615case-stmt-block: case-stmt block 
     3616        ; 
     3617 
     3618/* R839 : select-case-stmt */ 
     3619select-case-stmt :TOK_NAME ':' TOK_SELECTCASE '(' expr ')' {in_select_case_stmt++;} line-break 
     3620        |              TOK_SELECTCASE '(' expr ')' {in_select_case_stmt++;} line-break 
     3621        ; 
     3622 
     3623/* R840 : case-stmt */ 
     3624case-stmt:TOK_CASE case-selector line-break 
     3625        | TOK_CASE case-selector TOK_NAME line-break 
     3626        ; 
     3627 
     3628/* R840 : end-select-stmt */ 
     3629end-select-stmt: TOK_ENDSELECT {in_select_case_stmt--;} line-break 
     3630        | TOK_ENDSELECT TOK_NAME {in_select_case_stmt--;} line-break 
     3631        ; 
     3632 
     3633/* R843 : case-selector */ 
     3634case-selector: 
     3635          '(' {in_complex_literal=0;} case-value-range-list ')' 
     3636        | TOK_DEFAULT 
     3637        ; 
     3638 
     3639case-value-range-list: 
     3640        case-value-range 
     3641      | case-value-range-list ',' case-value-range 
     3642      ; 
     3643 
     3644/* R844: case-value-range */ 
     3645case-value-range : 
     3646        case-value 
     3647      | case-value ':' 
     3648      | ':' case-value 
     3649      | case-value ':' case-value 
     3650      ; 
     3651 
     3652/* R845 : case-value */ 
     3653case-value: expr 
     3654        ; 
     3655 
     3656/* R850 : exit-stmt */ 
     3657exit-stmt: TOK_EXIT line-break 
     3658       | TOK_EXIT TOK_NAME line-break 
     3659       ; 
     3660 
     3661/* R851 : goto-stmt */ 
     3662goto-stmt: TOK_PLAINGOTO label line-break 
     3663     ; 
     3664 
     3665/* R853 arithmetic-if-stmt */ 
     3666arithmetic-if-stmt: opt-label TOK_LOGICALIF_PAR expr ')' label ',' label ',' label line-break 
     3667     ; 
     3668 
     3669/* R854 : continue-stmt */ 
     3670continue-stmt: opt-label TOK_CONTINUE line-break 
     3671        ; 
     3672 
     3673/* R855 : stop-stmt */ 
     3674stop-stmt: TOK_STOP line-break 
     3675     | TOK_STOP stop-code line-break 
     3676     ; 
     3677 
     3678/* R857 : stop-code */ 
     3679stop-code: scalar-default-char-constant-expr 
     3680    | scalar-int-constant-expr 
     3681    ; 
     3682 
     3683/* R901 : io-unit */ 
     3684io-unit : file-unit-number 
     3685        | '*' 
     3686        | internal-file-variable 
     3687        ; 
     3688 
     3689/* R902 : file-unit-number */ 
     3690file-unit-number : scalar-int-expr 
     3691        ; 
     3692 
     3693/* R902 : internal-file-variable */ 
     3694internal-file-variable : char-variable 
     3695        ; 
     3696 
     3697/* R904 : open-stmt */ 
     3698open-stmt: TOK_OPEN '(' {close_or_connect = 1;} connect-spec-list ')' {close_or_connect = 0;} line-break 
     3699        ; 
     3700 
     3701connect-spec-list: connect-spec 
     3702         | connect-spec-list ',' connect-spec 
     3703         ; 
     3704 
     3705/* R905 : connect-spec */ 
     3706connect-spec: file-unit-number 
     3707      | TOK_UNIT file-unit-number 
     3708      | TOK_ACCESS scalar-default-char-expr 
     3709      | TOK_ACTION scalar-default-char-expr 
     3710      | TOK_ERR label 
     3711      | TOK_FILE file-name-expr 
     3712      | TOK_FORM scalar-default-char-expr 
     3713      | TOK_IOSTAT scalar-int-variable 
     3714      | TOK_POSITION scalar-default-char-expr 
     3715      | TOK_RECL scalar-int-expr 
     3716      | TOK_STATUS '=' scalar-default-char-expr 
     3717      ; 
     3718 
     3719/* R906 : file-name-expr */ 
     3720file-name-expr: scalar-default-char-expr 
     3721     ; 
     3722 
     3723/* R907 : iomsg-variable */ 
     3724iomsg-variable: scalar-default-char-variable 
     3725     ; 
     3726 
     3727/* R908 : close-stmt */ 
     3728close-stmt: opt-label TOK_CLOSE '(' {close_or_connect = 1;} close-spec-list ')' line-break 
     3729        {close_or_connect = 0;} 
     3730        ; 
     3731 
     3732close-spec-list: close-spec 
     3733         | close-spec-list ',' close-spec 
     3734         ; 
     3735 
     3736/* R909 : close-spec */ 
     3737close-spec: file-unit-number 
     3738       | TOK_UNIT file-unit-number 
     3739       | TOK_IOSTAT scalar-int-variable 
     3740       | TOK_ERR label 
     3741       | TOK_STATUS '=' scalar-default-char-expr 
     3742       ; 
     3743 
     3744/* R910 : read-stmt */ 
     3745read-stmt: opt-label TOK_READ_PAR io-control-spec-list ')' 
     3746         { 
     3747         in_io_control_spec = 0; 
     3748         } 
     3749         line-break 
     3750        | opt-label TOK_READ_PAR io-control-spec-list ')' input-item-list 
     3751         { 
     3752         in_io_control_spec = 0; 
     3753         } 
     3754         line-break 
     3755        | opt-label TOK_READ format line-break 
     3756        | opt-label TOK_READ format ',' input-item-list line-break 
     3757        ; 
     3758         
     3759/* R911 : write-stmt */ 
     3760write-stmt: opt-label TOK_WRITE_PAR io-control-spec-list ')' 
     3761         { 
     3762         in_io_control_spec = 0; 
     3763         } 
     3764         line-break 
     3765        | opt-label TOK_WRITE_PAR io-control-spec-list ')'  output-item-list 
     3766         { 
     3767         in_io_control_spec = 0; 
     3768         } 
     3769         line-break 
     3770        ; 
     3771 
     3772/* R912 : print-stmt */ 
     3773print-stmt: opt-label TOK_PRINT format line-break 
     3774        | opt-label TOK_PRINT format ',' output-item-list line-break 
     3775        ; 
     3776io-control-spec-list: io-control-spec 
     3777         | io-control-spec-list ',' io-control-spec 
     3778         ; 
     3779 
     3780namelist-group-name: TOK_NAME 
     3781         ; 
     3782 
     3783/* R913 : io-control-spec */ 
     3784io-control-spec: io-unit 
     3785         | TOK_UNIT io-unit 
     3786         | format 
     3787         | namelist-group-name 
     3788         | TOK_NML namelist-group-name 
     3789         | TOK_FMT format 
     3790         | TOK_END label 
     3791         | TOK_EOR label 
     3792         | TOK_ERR label 
     3793         | TOK_IOSTAT scalar-int-variable 
     3794         | TOK_REC '=' scalar-int-expr 
     3795        ; 
     3796 
     3797/* R915 : format */ 
     3798format: default-char-expr 
     3799        | label 
     3800        | '*' 
     3801        ; 
     3802input-item-list: 
     3803         input-item 
     3804         | input-item-list ',' input-item 
     3805         ; 
     3806/* R916 : input-item */ 
     3807input-item: variable 
     3808        | io-implied-do 
     3809        ; 
     3810 
     3811output-item-list: 
     3812         output-item 
     3813         | output-item-list ',' output-item 
     3814         ; 
     3815 
     3816/* R917 : output-item */ 
     3817output-item: expr 
     3818        | io-implied-do 
     3819        ; 
     3820 
     3821/* R918 : io-implied-do */ 
     3822io-implied-do : '(' io-implied-do-object-list ',' io-implied-do-control ')' 
     3823        ; 
     3824 
     3825io-implied-do-object-list: io-implied-do-object 
     3826         | io-implied-do-object-list ',' io-implied-do-object 
     3827         ; 
     3828 
     3829/* R919 : io-implied-do-object */ 
     3830/* input-item removed since possible conflicts (output-item can be variable) */ 
     3831/* io-implied-do-object : input-item 
     3832        | output-item 
     3833        ; 
     3834*/ 
     3835 
     3836io-implied-do-object : output-item 
     3837        ;         
     3838 
     3839/* R920 : io-implied-do-control */ 
     3840io-implied-do-control: do-variable '=' scalar-int-expr ',' scalar-int-expr 
     3841        | do-variable '=' scalar-int-expr ',' scalar-int-expr ',' scalar-int-expr 
     3842        ; 
     3843 
     3844/* R926 : rewind-stmt */ 
     3845rewind-stmt: TOK_REWIND file-unit-number line-break 
     3846     | TOK_REWIND '(' position-spec-list ')' line-break 
     3847     ; 
     3848 
     3849position-spec-list: 
     3850        position-spec 
     3851      | position-spec-list ',' position-spec 
     3852      ; 
     3853       
     3854/* R927 : position-spec */ 
     3855position-spec: file-unit-number 
     3856     | TOK_UNIT file-unit-number 
     3857     | TOK_IOMSG iomsg-variable 
     3858     | TOK_IOSTAT scalar-int-variable 
     3859     | TOK_ERR label 
     3860     ; 
     3861 
     3862/* R928 : flush-stmt */ 
     3863flush-stmt: TOK_FLUSH file-unit-number line-break 
     3864     | TOK_FLUSH '(' flush-spec-list ')' line-break 
     3865     ; 
     3866 
     3867flush-spec-list: 
     3868        flush-spec 
     3869      | flush-spec-list ',' flush-spec 
     3870      ; 
     3871       
     3872/* R929 : flush-spec */ 
     3873flush-spec: file-unit-number 
     3874     | TOK_UNIT file-unit-number 
     3875     | TOK_IOSTAT scalar-int-variable 
     3876     | TOK_IOMSG iomsg-variable 
     3877     | TOK_ERR label 
     3878     ; 
     3879 
     3880 
     3881/* R930 : inquire-stmt */ 
     3882inquire-stmt: TOK_INQUIRE set_in_inquire '(' inquire-spec-list ')' 
     3883     {in_inquire=0;} 
     3884     line-break 
     3885     | TOK_INQUIRE set_in_inquire '(' TOK_IOLENGTH scalar-int-variable ')' output-item-list 
     3886     {in_inquire=0;} 
     3887     line-break 
     3888     ; 
     3889 
     3890set_in_inquire: {in_inquire=1;}   
     3891     ; 
     3892 
     3893inquire-spec-list: 
     3894        inquire-spec 
     3895      | inquire-spec-list ',' inquire-spec 
     3896      ; 
     3897       
     3898/* R931 : inquire-spec */ 
     3899inquire-spec: file-unit-number 
     3900     | TOK_UNIT file-unit-number 
     3901     | TOK_FILE file-name-expr 
     3902     | TOK_ACCESS scalar-default-char-variable 
     3903     | TOK_ACTION scalar-default-char-variable 
     3904     | TOK_ERR label 
     3905     | TOK_EXIST scalar-logical-variable 
     3906     | TOK_IOSTAT scalar-int-variable 
     3907     | TOK_NAME_EQ '=' scalar-default-char-variable 
     3908     | TOK_OPENED scalar-logical-variable 
     3909     | TOK_RECL scalar-int-variable 
     3910     ; 
     3911 
     3912/* R1001 : format-stmt */ 
     3913format-stmt: TOK_LABEL_FORMAT line-break 
     3914        ; 
     3915 
     3916/* R1104 : module */ 
     3917module:module-stmt opt-specification-part opt-module-subprogram-part {pos_endsubroutine=setposcur();} end-module-stmt 
     3918     ; 
     3919 
     3920opt-module-subprogram-part: 
     3921     | module-subprogram-part 
     3922     ; 
     3923 
     3924/* R1105 : module-stmt */ 
     3925module-stmt : TOK_MODULE TOK_NAME 
     3926        { 
     3927            GlobalDeclaration = 0; 
     3928            strcpy(curmodulename,$2); 
     3929            strcpy(subroutinename,""); 
     3930            Add_NameOfModule_1($2); 
     3931            if ( inmoduledeclare == 0 ) 
     3932            { 
     3933                /* To know if there are in the module declaration    */ 
     3934                inmoduledeclare = 1; 
     3935                /* to know if a module has been met                  */ 
     3936                inmodulemeet = 1; 
     3937                /* to know if we are after the keyword contains      */ 
     3938                aftercontainsdeclare = 0 ; 
     3939            } 
     3940        } 
     3941        line-break 
     3942     ; 
     3943 
     3944/* R1106 : end-module-stmt */ 
     3945end-module-stmt: get_my_position TOK_ENDUNIT opt-tok-module opt-ident 
     3946        { 
     3947            /* if we never meet the contains keyword               */ 
     3948            if ( firstpass == 0 ) 
     3949            { 
     3950                RemoveWordCUR_0(fortran_out, setposcur()-my_position);    // Remove word "end module" 
     3951                if ( inmoduledeclare && ! aftercontainsdeclare ) 
     3952                { 
     3953                    Write_Closing_Module(1); 
     3954                } 
     3955                fprintf(fortran_out,"\n      end module %s\n", curmodulename); 
     3956                if ( module_declar && insubroutinedeclare == 0 ) 
     3957                { 
     3958                    fclose(module_declar); 
     3959                } 
     3960            } 
     3961            inmoduledeclare = 0 ; 
     3962            inmodulemeet = 0 ; 
     3963            aftercontainsdeclare = 1; 
     3964            strcpy(curmodulename, ""); 
     3965            GlobalDeclaration = 0 ; 
     3966        } 
     3967        line-break 
     3968     ; 
     3969 
     3970opt-tok-module: 
     3971     | TOK_MODULE 
     3972     ; 
     3973 
     3974opt-ident: 
     3975     | TOK_NAME 
     3976     ; 
     3977/* R1107 : module-subprogram-part */ 
     3978module-subprogram-part:contains-stmt opt-module-subprogram-list 
     3979     ; 
     3980      
     3981opt-module-subprogram-list: 
     3982     | module-subprogram-list 
     3983     ; 
     3984      
     3985module-subprogram-list: module-subprogram 
     3986     | module-subprogram-list module-subprogram 
     3987     ; 
     3988 
     3989module-subprogram: function-subprogram 
     3990     | subroutine-subprogram 
     3991     ; 
     3992 
     3993use-stmt-list:use-stmt 
     3994     | use-stmt-list use-stmt 
     3995     ; 
     3996 
     3997save_olduse: 
     3998     {if (firstpass == 0 && oldfortran_out) pos_curuseold = setposcurname(oldfortran_out);} 
     3999     ; 
     4000      
     4001/* R1109 use-stmt */ 
     4002use-stmt: get_my_position TOK_USE save_olduse opt-module-nature-2points TOK_NAME opt-rename-list 
     4003    { 
    13544004            if ( firstpass ) 
    13554005            { 
    13564006                if ( insubroutinedeclare ) 
    13574007                { 
    1358                     Add_CouplePointed_Var_1($2,$4); 
    1359                     coupletmp = $4; 
    1360                     strcpy(ligne,""); 
    1361                     while ( coupletmp ) 
    1362                     { 
     4008                    if ($6) { 
     4009                      Add_CouplePointed_Var_1($5,$6); 
     4010                      coupletmp = $6; 
     4011                      strcpy(ligne,""); 
     4012                      while ( coupletmp ) 
     4013                      { 
    13634014                        strcat(ligne, coupletmp->c_namevar); 
    13644015                        strcat(ligne, " => "); 
     
    13664017                        coupletmp = coupletmp->suiv; 
    13674018                        if ( coupletmp ) strcat(ligne,","); 
     4019                      } 
     4020                      } 
     4021                  sprintf(charusemodule,"%s",$5); 
     4022                } 
     4023                Add_NameOfModuleUsed_1($5); 
     4024            } 
     4025            else 
     4026            { 
     4027                if ( insubroutinedeclare ) 
     4028                { 
     4029                  copyuse_0($5); 
    13684030                    } 
    1369                     sprintf(charusemodule,"%s",$2); 
    1370                 } 
    1371                 Add_NameOfModuleUsed_1($2); 
    1372             } 
    1373             if ( inmoduledeclare == 0 ) 
    1374             { 
    1375                 pos_end = setposcur(); 
    1376                 RemoveWordSET_0(fortran_out,pos_curuse,pos_end-pos_curuse); 
    1377             } 
    1378         } 
    1379       | word_use TOK_NAME ',' TOK_ONLY ':' '\n' 
    1380         { 
    1381             /* if variables has been declared in a subroutine       */ 
    1382             sprintf(charusemodule,"%s",$2); 
    1383             if ( firstpass ) 
    1384             { 
    1385                 Add_NameOfModuleUsed_1($2); 
    1386             } 
    1387             else 
    1388             { 
    1389                 if ( insubroutinedeclare ) 
    1390                     copyuseonly_0($2); 
    13914031 
    13924032                if ( inmoduledeclare == 0 ) 
    13934033                { 
    13944034                    pos_end = setposcur(); 
    1395                     RemoveWordSET_0(fortran_out,pos_curuse,pos_end-pos_curuse); 
     4035                    RemoveWordSET_0(fortran_out,my_position,pos_end-my_position); 
    13964036                } 
    13974037            } 
    1398         } 
    1399       | word_use  TOK_NAME ',' TOK_ONLY ':' only_list 
    1400         { 
    1401             /* if variables has been declared in a subroutine      */ 
     4038    } 
     4039    line-break 
     4040    | get_my_position TOK_USE save_olduse opt-module-nature-2points TOK_NAME ',' TOK_ONLY ':' opt-only-list 
     4041    { 
    14024042            if ( firstpass ) 
    14034043            { 
    14044044                if ( insubroutinedeclare ) 
    14054045                { 
    1406                     Add_CouplePointed_Var_1($2,$6); 
    1407                     coupletmp = $6; 
     4046                  if ($9) 
     4047                  { 
     4048                    Add_CouplePointed_Var_1($5,$9); 
     4049                    coupletmp = $9; 
    14084050                    strcpy(ligne,""); 
    14094051                    while ( coupletmp ) 
     
    14154057                        if ( coupletmp ) strcat(ligne,","); 
    14164058                    } 
    1417                     sprintf(charusemodule,"%s",$2); 
     4059                  } 
     4060                  sprintf(charusemodule,"%s",$5); 
    14184061                } 
    1419                 Add_NameOfModuleUsed_1($2); 
    1420             } 
    1421             else /* if ( firstpass == 0 ) */ 
    1422             { 
     4062                Add_NameOfModuleUsed_1($5); 
     4063            } 
     4064            else 
     4065            { 
     4066                if ( insubroutinedeclare ) 
     4067                    copyuseonly_0($5); 
     4068 
    14234069                if ( inmoduledeclare == 0 ) 
    14244070                { 
    14254071                    pos_end = setposcur(); 
    1426                     RemoveWordSET_0(fortran_out,pos_curuse,pos_end-pos_curuse); 
    1427                     if (oldfortran_out)  variableisglobalinmodule($6,$2,oldfortran_out,pos_curuseold); 
     4072                    RemoveWordSET_0(fortran_out,my_position,pos_end-my_position); 
     4073                    if ($9) 
     4074                    { 
     4075                    if (oldfortran_out)  variableisglobalinmodule($9,$5,oldfortran_out,pos_curuseold); 
     4076                    } 
    14284077                } 
    14294078                else 
    14304079                { 
     4080                  if ($9) 
     4081                  { 
    14314082                    /* if we are in the module declare and if the    */ 
    14324083                    /* onlylist is a list of global variable         */ 
    1433                     variableisglobalinmodule($6, $2, fortran_out,pos_curuse); 
     4084                    variableisglobalinmodule($9, $5, fortran_out,my_position); 
     4085                  } 
    14344086                } 
    14354087            } 
    1436         } 
    1437       ; 
    1438 word_use : 
    1439         TOK_USE 
    1440         { 
    1441             pos_curuse = setposcur()-strlen($1); 
    1442             if (firstpass == 0 && oldfortran_out) pos_curuseold = setposcurname(oldfortran_out); 
    1443         } 
    1444       ; 
    1445 rename_list : 
    1446         rename_name 
    1447         { 
    1448             $$ = $1; 
    1449         } 
    1450       | rename_list ',' rename_name 
    1451         { 
    1452             /* insert the variable in the list $1                 */ 
    1453             $3->suiv = $1; 
    1454             $$ = $3; 
    1455         } 
    1456       ; 
    1457 rename_name : TOK_NAME TOK_POINT_TO TOK_NAME 
     4088    } 
     4089    line-break 
     4090    ; 
     4091 
     4092opt-module-nature-2points: 
     4093    | TOK_FOURDOTS 
     4094    | ',' module-nature TOK_FOURDOTS 
     4095    ; 
     4096 
     4097opt-only-list: 
     4098    {$$=NULL;} 
     4099    | only-list 
     4100    {$$=$1;} 
     4101    ; 
     4102 
     4103/* R1101 : main-program */ 
     4104main-program: program-stmt opt-specification-part opt-execution-part opt-internal-subprogram-part end-program-stmt 
     4105     ; 
     4106 
     4107opt-specification-part: 
     4108     | specification-part 
     4109     ; 
     4110 
     4111opt-execution-part: 
     4112     | execution-part 
     4113     ; 
     4114 
     4115/* R1102 : program-stmt */ 
     4116program-stmt: TOK_PROGRAM TOK_NAME  
     4117        { 
     4118            strcpy(subroutinename,$2); 
     4119            insubroutinedeclare = 1; 
     4120            inprogramdeclare = 1; 
     4121            /* in the second step we should write the head of       */ 
     4122            /*    the subroutine sub_loop_<subroutinename>          */ 
     4123            if ( ! firstpass ) 
     4124                WriteBeginof_SubLoop(); 
     4125        } 
     4126        line-break 
     4127     ; 
     4128 
     4129/* R1103 : end-program-stmt */ 
     4130end-program-stmt: {pos_endsubroutine=my_position_before;} TOK_ENDUNIT opt-tok-program opt-tok-name 
     4131     { 
     4132            insubroutinedeclare = 0; 
     4133            inprogramdeclare = 0; 
     4134            pos_cur = setposcur(); 
     4135            closeandcallsubloopandincludeit_0(3); 
     4136            functiondeclarationisdone = 0; 
     4137            strcpy(subroutinename,"");      
     4138     }      
     4139     line-break 
     4140     ; 
     4141 
     4142opt-tok-program: 
     4143     | TOK_PROGRAM 
     4144     ; 
     4145opt-tok-name: 
     4146     | TOK_NAME 
     4147     ; 
     4148/* R1110 : module-nature */ 
     4149module-nature: TOK_INTRINSIC 
     4150    ; 
     4151 
     4152opt-rename-list: 
     4153    { 
     4154    $$=NULL; 
     4155    } 
     4156    | ',' rename-list 
     4157    { 
     4158    $$=$2; 
     4159    } 
     4160    ; 
     4161     
     4162rename-list: rename 
     4163     { 
     4164     $$=$1; 
     4165     } 
     4166     | rename-list ',' rename 
     4167     { 
     4168     /* insert the variable in the list $1                 */ 
     4169     $3->suiv = $1; 
     4170     $$=$3; 
     4171     } 
     4172     ; 
     4173 
     4174/* R1111: rename */ 
     4175rename: TOK_NAME TOK_POINT_TO TOK_NAME 
    14584176        { 
    14594177            coupletmp = (listcouple *) calloc(1,sizeof(listcouple)); 
     
    14634181            $$ = coupletmp; 
    14644182        } 
    1465       ; 
    1466 only_list : 
    1467         only_name   {  $$ = $1; } 
    1468       | only_list ',' only_name 
     4183     ; 
     4184 
     4185only-list:only 
     4186     {$$=$1;} 
     4187     | only-list ',' only 
    14694188        { 
    14704189            /* insert the variable in the list $1                 */ 
     
    14724191            $$ = $3; 
    14734192        } 
    1474       ; 
    1475 only_name : 
    1476         TOK_NAME TOK_POINT_TO TOK_NAME 
    1477         { 
    1478             coupletmp = (listcouple *)calloc(1,sizeof(listcouple)); 
    1479             strcpy(coupletmp->c_namevar,$1); 
    1480             strcpy(coupletmp->c_namepointedvar,$3); 
    1481             coupletmp->suiv = NULL; 
    1482             $$ = coupletmp; 
    1483             pointedvar = 1; 
    1484             Add_UsedInSubroutine_Var_1($1); 
    1485         } 
    1486       | TOK_NAME 
     4193     ; 
     4194 
     4195/* R1112: only */ 
     4196only:generic-spec 
    14874197        { 
    14884198            coupletmp = (listcouple *)calloc(1,sizeof(listcouple)); 
     
    14924202            $$ = coupletmp; 
    14934203        } 
    1494       ; 
    1495  
    1496 /* R209 : execution-part-construct */ 
    1497 execution-part-construct: 
    1498         executable-construct 
    1499       | format-stmt 
    1500       ; 
    1501  
    1502 /* R213 : executable-construct */ 
    1503 executable-construct: 
    1504         action-stmt 
    1505       | do-construct 
    1506       | case-construct 
    1507       | if-construct 
    1508       | where-construct 
    1509       ; 
    1510  
    1511 /* R214 : action-stmt */ 
    1512 action-stmt : 
    1513         TOK_CONTINUE 
    1514       | ident_dims after_ident_dims 
    1515       | goto 
    1516       | call 
    1517       | iofctl ioctl 
    1518       | read option_read 
    1519       | TOK_WRITE ioctl 
    1520       | TOK_WRITE ioctl outlist 
    1521       | TOK_REWIND after_rewind 
    1522       | TOK_ALLOCATE '(' allocation_list opt_stat_spec ')'          { inallocate = 0; } 
    1523       | TOK_DEALLOCATE '(' allocate_object_list opt_stat_spec ')'   { inallocate = 0; } 
    1524       | TOK_EXIT optexpr 
    1525       | TOK_RETURN opt_expr 
    1526       | TOK_CYCLE opt_expr 
    1527       | stop opt_expr 
    1528       | int_list 
    1529       | TOK_NULLIFY '(' pointer_name_list ')' 
    1530       | word_endunit 
    1531         { 
     4204     | only-use-name 
     4205        { 
     4206            coupletmp = (listcouple *)calloc(1,sizeof(listcouple)); 
     4207            strcpy(coupletmp->c_namevar,$1); 
     4208            strcpy(coupletmp->c_namepointedvar,""); 
     4209            coupletmp->suiv = NULL; 
     4210            $$ = coupletmp; 
     4211        } 
     4212     | rename 
     4213     { 
     4214     $$=$1; 
     4215     pointedvar = 1; 
     4216      Add_UsedInSubroutine_Var_1($1->c_namevar); 
     4217     } 
     4218     ; 
     4219/* R1113 : only-use-name */ 
     4220only-use-name: TOK_NAME 
     4221     ; 
     4222 
     4223/* R1207: generic-spec */ 
     4224generic-spec: TOK_NAME 
     4225     ; 
     4226 
     4227/* R1210 : external-stmt */ 
     4228external-stmt: TOK_EXTERNAL external-name-list line-break 
     4229     | TOK_EXTERNAL TOK_FOURDOTS external-name-list line-break 
     4230     ; 
     4231      
     4232external-name-list: external-name 
     4233     | external-name-list ',' external-name 
     4234     ; 
     4235      
     4236external-name: TOK_NAME 
     4237     ; 
     4238 
     4239/* R1218 : intrinsic-stmt */ 
     4240intrinsic-stmt: TOK_INTRINSIC opt-TOK_FOURDOTS intrinsic-procedure-name-list line-break 
     4241     ; 
     4242 
     4243intrinsic-procedure-name-list: 
     4244        intrinsic-procedure-name 
     4245      | intrinsic-procedure-name-list ',' intrinsic-procedure-name 
     4246      ; 
     4247       
     4248intrinsic-procedure-name: TOK_NAME 
     4249     ; 
     4250 
     4251/* R1219 : function-reference */ 
     4252function-reference: procedure-designator '(' ')' 
     4253     | procedure-designator '(' {in_complex_literal=0;} actual-arg-spec-list ')' 
     4254     {sprintf($$,"%s(%s)",$[procedure-designator],$[actual-arg-spec-list]);} 
     4255     ; 
     4256 
     4257/* R1220 :  
     4258*/ 
     4259call-stmt: before-call-stmt 
     4260             { 
     4261            inagrifcallargument = 0 ; 
     4262            incalldeclare=0; 
     4263            if ( oldfortran_out && (callagrifinitgrids == 1) && (firstpass == 0) ) 
     4264            { 
     4265                pos_end = setposcur(); 
     4266                RemoveWordSET_0(fortran_out,pos_curcall,pos_end-pos_curcall); 
     4267                strcpy(subofagrifinitgrids,subroutinename); 
     4268            } 
     4269            Instanciation_0(sameagrifname); 
     4270        } 
     4271        line-break 
     4272     | before-call-stmt '(' ')' 
     4273             { 
     4274            inagrifcallargument = 0 ; 
     4275            incalldeclare=0; 
     4276            if ( oldfortran_out && (callagrifinitgrids == 1) && (firstpass == 0) ) 
     4277            { 
     4278                pos_end = setposcur(); 
     4279                RemoveWordSET_0(fortran_out,pos_curcall,pos_end-pos_curcall); 
     4280                strcpy(subofagrifinitgrids,subroutinename); 
     4281            } 
     4282            Instanciation_0(sameagrifname); 
     4283        } 
     4284        line-break 
     4285     | before-call-stmt '(' {in_complex_literal=0;} actual-arg-spec-list ')' 
     4286        { 
     4287            inagrifcallargument = 0 ; 
     4288            incalldeclare=0; 
     4289            if ( oldfortran_out && (callagrifinitgrids == 1) && (firstpass == 0) ) 
     4290            { 
     4291                pos_end = setposcur(); 
     4292                RemoveWordSET_0(fortran_out,pos_curcall,pos_end-pos_curcall); 
     4293                strcpy(subofagrifinitgrids,subroutinename); 
     4294            } 
     4295            Instanciation_0(sameagrifname); 
     4296        } 
     4297        line-break 
     4298     ; 
     4299 
     4300before-call-stmt: opt-label TOK_CALL {pos_curcall=my_position_before-strlen($[opt-label])-4;} procedure-designator 
     4301             { 
     4302            if (!strcasecmp($[procedure-designator],"MPI_Init") )    callmpiinit = 1; 
     4303            else                                callmpiinit = 0; 
     4304 
     4305            if (!strcasecmp($[procedure-designator],"Agrif_Init_Grids") ) 
     4306            { 
     4307                callagrifinitgrids = 1; 
     4308                strcpy(meetagrifinitgrids,subroutinename); 
     4309            } 
     4310            else 
     4311            { 
     4312                callagrifinitgrids = 0; 
     4313            } 
     4314            if ( Vartonumber($[procedure-designator]) == 1 ) 
     4315            { 
     4316                incalldeclare = 0; 
     4317                inagrifcallargument = 0 ; 
     4318                Add_SubroutineWhereAgrifUsed_1(subroutinename, curmodulename); 
     4319            } 
     4320        } 
     4321        ; 
     4322 
     4323/* R1221 : procedure-designator */ 
     4324procedure-designator: ident 
     4325     | TOK_FLUSH 
     4326     | TOK_REAL 
     4327     ; 
     4328 
     4329actual-arg-spec-list: 
     4330        actual-arg-spec 
     4331      | actual-arg-spec-list ',' actual-arg-spec 
     4332      {sprintf($$,"%s,%s",$1,$[actual-arg-spec]);} 
     4333      ; 
     4334 
     4335/* R1222 : actual-arg-spec */ 
     4336actual-arg-spec: actual-arg 
     4337        { 
     4338            if ( callmpiinit == 1 ) 
     4339            { 
     4340                strcpy(mpiinitvar,$1); 
     4341                if ( firstpass == 1 )  Add_UsedInSubroutine_Var_1 (mpiinitvar); 
     4342            } 
     4343        }      
     4344     | keyword '=' actual-arg 
     4345     {sprintf($$,"%s = %s",$1,$3); 
     4346                 if ( callmpiinit == 1 ) 
     4347            { 
     4348                strcpy(mpiinitvar,$3); 
     4349                if ( firstpass == 1 )  Add_UsedInSubroutine_Var_1 (mpiinitvar); 
     4350            } 
     4351            } 
     4352     ; 
     4353 
     4354/* R1223 : actual-arg */ 
     4355actual-arg: expr 
     4356     | variable 
     4357     { 
     4358     strcpy($$,$1->v_nomvar); 
     4359     if ($1->v_initialvalue_array) 
     4360     { 
     4361     strcat($$,"("); 
     4362     strcat($$,$1->v_initialvalue_array->n_name); 
     4363     strcat($$,")"); 
     4364     } 
     4365     } 
     4366     | ident 
     4367     ; 
     4368 
     4369opt-prefix:     {isrecursive = 0;} 
     4370     | prefix 
     4371     ; 
     4372      
     4373/* R1225 : prefix */ 
     4374prefix: prefix-spec 
     4375     | prefix prefix-spec 
     4376     ; 
     4377 
     4378/* R1226 prefix-spec */ 
     4379prefix-spec: declaration-type-spec 
     4380     {isrecursive = 0; functiondeclarationisdone = 1;} 
     4381     | TOK_MODULE 
     4382     {isrecursive = 0;} 
     4383     | TOK_RECURSIVE 
     4384     {isrecursive = 1;} 
     4385     ; 
     4386 
     4387/*R1227 : function-subprogram */ 
     4388function-subprogram: function-stmt opt-specification-part opt-execution-part opt-internal-subprogram-part end-function-stmt 
     4389     ; 
     4390 
     4391/* R1228 : function-stmt */ 
     4392function-stmt: opt-prefix TOK_FUNCTION 
     4393     function-name '(' {in_complex_literal=0;} opt-dummy-arg-list ')' opt-suffix 
     4394     { 
     4395            insubroutinedeclare = 1; 
     4396            suborfun = 0; 
     4397            /* we should to list of the subroutine argument the  */ 
     4398            /*    name of the function which has to be defined   */ 
     4399            if ( firstpass ) 
     4400            { 
     4401                Add_SubroutineArgument_Var_1($[opt-dummy-arg-list]); 
     4402                if ( ! is_result_present ) 
     4403                    Add_FunctionType_Var_1($[function-name]); 
     4404            } 
     4405            else 
     4406            /* in the second step we should write the head of    */ 
     4407            /*    the subroutine sub_loop_<subroutinename>       */ 
     4408               { 
     4409                if (todebug == 1) fprintf(fortran_out,"      !DEBUG: Avant Writebeginof subloop\n"); 
     4410                WriteBeginof_SubLoop(); 
     4411                if (todebug == 1) fprintf(fortran_out,"      !DEBUG: Apres Writebeginof subloop\n"); 
     4412                } 
     4413                strcpy(NamePrecision,""); 
     4414     } 
     4415     line-break 
     4416     ; 
     4417 
     4418function-name: TOK_NAME 
     4419     { 
     4420     if (strcmp(subroutinename,"")) 
     4421     { 
     4422     strcpy(old_subroutinename,subroutinename); // can occur in internal-subprogram 
     4423     old_oldfortran_out=oldfortran_out; 
     4424     } 
     4425     else 
     4426     { 
     4427     old_oldfortran_out=(FILE *)NULL; 
     4428     } 
     4429     strcpy($$,$1);strcpy(subroutinename,$1); 
     4430     } 
     4431     ; 
     4432 
     4433opt-dummy-arg-name-list: 
     4434     | dummy-arg-name-list 
     4435     ; 
     4436 
     4437dummy-arg-name-list: 
     4438        dummy-arg-name 
     4439      | dummy-arg-name-list ',' dummy-arg-name 
     4440      ; 
     4441 
     4442/* R1230 : dummy-arg-name */ 
     4443dummy-arg-name: TOK_NAME 
     4444     {strcpy($$,$1);} 
     4445     ; 
     4446 
     4447opt-suffix: 
     4448     {is_result_present = 0; } 
     4449     | suffix 
     4450     ; 
     4451      
     4452/* R1231 : suffix */ 
     4453suffix: TOK_RESULT '(' TOK_NAME ')' 
     4454     {is_result_present = 1; 
     4455                 if ( firstpass == 1 ) 
     4456            { 
     4457                strcpy(nameinttypenameback,nameinttypename); 
     4458                strcpy(nameinttypename,""); 
     4459                curvar = createvar($3,NULL); 
     4460                strcpy(nameinttypename,nameinttypenameback); 
     4461                strcpy(curvar->v_typevar,""); 
     4462                curlistvar = insertvar(NULL,curvar); 
     4463                Add_SubroutineArgument_Var_1(curlistvar); 
     4464            } 
     4465     } 
     4466     ; 
     4467 
     4468/* R1232 : end-function-stmt */ 
     4469end-function-stmt: get_my_position TOK_ENDUNIT opt-tok-function opt-ident close_subroutine 
     4470     {strcpy(DeclType, "");} 
     4471     line-break 
     4472     ; 
     4473 
     4474opt-tok-function: 
     4475     | TOK_FUNCTION 
     4476     ; 
     4477 
     4478/*R1233 : subroutine-subprogram */ 
     4479subroutine-subprogram: subroutine-stmt opt-specification-part opt-execution-part opt-internal-subprogram-part end-subroutine-stmt 
     4480     ; 
     4481      
     4482/* R1234 : subroutine-stmt */ 
     4483subroutine-stmt: opt-prefix TOK_SUBROUTINE subroutine-name opt-dummy-arg-list-par 
     4484        { 
     4485            insubroutinedeclare = 1; 
     4486            suborfun = 1; 
     4487            if ( firstpass ) 
     4488                Add_SubroutineArgument_Var_1($4); 
     4489            else 
     4490              { 
     4491                WriteBeginof_SubLoop(); 
     4492              } 
     4493        } 
     4494        line-break 
     4495     ; 
     4496 
     4497 
     4498subroutine-name: TOK_NAME 
     4499     { 
     4500     if (strcmp(subroutinename,"")) 
     4501     { 
     4502     strcpy(old_subroutinename,subroutinename); // can occur in internal-subprogram 
     4503     old_oldfortran_out=oldfortran_out; 
     4504     } 
     4505     else 
     4506     { 
     4507     old_oldfortran_out=(FILE *)NULL; 
     4508     } 
     4509     strcpy($$,$1);strcpy(subroutinename,$1); 
     4510     } 
     4511     ; 
     4512 
     4513/* R1236 : end-subroutine-stmt */ 
     4514 
     4515end-subroutine-stmt: get_my_position TOK_ENDUNIT opt-tok-subroutine opt-ident close_subroutine 
     4516     line-break 
     4517     ; 
     4518 
     4519close_subroutine: 
     4520          {pos_endsubroutine = my_position; 
    15324521            GlobalDeclaration = 0 ; 
    15334522            if ( firstpass == 0 && strcasecmp(subroutinename,"") ) 
     
    15454534                        insubroutinedeclare = 0 ; 
    15464535                        pos_cur = setposcur(); 
    1547                         closeandcallsubloopandincludeit_0(1); 
     4536                        closeandcallsubloopandincludeit_0(suborfun); 
    15484537                        functiondeclarationisdone = 0; 
    15494538                    } 
     
    15644553            } 
    15654554            strcpy(subroutinename,""); 
    1566         } 
    1567       | word_endprogram opt_name 
    1568         { 
    1569             insubroutinedeclare = 0; 
    1570             inprogramdeclare = 0; 
    1571             pos_cur = setposcur(); 
    1572             closeandcallsubloopandincludeit_0(3); 
    1573             functiondeclarationisdone = 0; 
    1574             strcpy(subroutinename,""); 
    1575         } 
    1576       | word_endsubroutine opt_name 
    1577         { 
    1578             if ( strcasecmp(subroutinename,"") ) 
    1579             { 
    1580                 insubroutinedeclare = 0; 
    1581                 pos_cur = setposcur(); 
    1582                 closeandcallsubloopandincludeit_0(1); 
    1583                 functiondeclarationisdone = 0; 
    1584                 strcpy(subroutinename,""); 
    1585             } 
    1586         } 
    1587       | word_endfunction opt_name 
    1588         { 
    1589             insubroutinedeclare = 0; 
    1590             pos_cur = setposcur(); 
    1591             closeandcallsubloopandincludeit_0(0); 
    1592             functiondeclarationisdone = 0; 
    1593             strcpy(subroutinename,""); 
    1594         } 
    1595       | TOK_ENDMODULE opt_name 
    1596         { 
    1597             /* if we never meet the contains keyword               */ 
    1598             if ( firstpass == 0 ) 
    1599             { 
    1600                 RemoveWordCUR_0(fortran_out, strlen($2)+11);    // Remove word "end module" 
    1601                 if ( inmoduledeclare && ! aftercontainsdeclare ) 
    1602                 { 
    1603                     Write_Closing_Module(1); 
    1604                 } 
    1605                 fprintf(fortran_out,"\n      end module %s\n", curmodulename); 
    1606                 if ( module_declar && insubroutinedeclare == 0 ) 
    1607                 { 
    1608                     fclose(module_declar); 
    1609                 } 
    1610             } 
    1611             inmoduledeclare = 0 ; 
    1612             inmodulemeet = 0 ; 
    1613             aftercontainsdeclare = 1; 
    1614             strcpy(curmodulename, ""); 
    1615             GlobalDeclaration = 0 ; 
    1616         } 
    1617       | if-stmt 
    1618       | where-stmt 
    1619       | TOK_CONTAINS 
     4555            if (strcmp(old_subroutinename,"")) 
     4556            { 
     4557            strcpy(subroutinename,old_subroutinename); 
     4558            strcpy(old_subroutinename,""); 
     4559            oldfortran_out=old_oldfortran_out; 
     4560            insubroutinedeclare=1; 
     4561            } 
     4562        } 
     4563        ; 
     4564opt-tok-subroutine: 
     4565     | TOK_SUBROUTINE 
     4566     ; 
     4567 
     4568opt-dummy-arg-list-par: 
     4569     {if (firstpass) $$=NULL;} 
     4570     | '(' {in_complex_literal=0;} opt-dummy-arg-list ')' 
     4571     {if (firstpass) $$=$3;} 
     4572     ; 
     4573 
     4574opt-dummy-arg-list: 
     4575     {if (firstpass) $$=NULL;} 
     4576     | dummy-arg-list 
     4577     {if (firstpass) $$=$1;} 
     4578     ; 
     4579      
     4580dummy-arg-list: 
     4581        dummy-arg 
     4582        { 
     4583            if ( firstpass == 1 ) 
     4584            { 
     4585                strcpy(nameinttypenameback,nameinttypename); 
     4586                strcpy(nameinttypename,""); 
     4587                curvar = createvar($1,NULL); 
     4588                strcpy(nameinttypename,nameinttypenameback); 
     4589                curlistvar = insertvar(NULL,curvar); 
     4590                $$ = settype("",curlistvar); 
     4591            } 
     4592        } 
     4593      | dummy-arg-list ',' dummy-arg 
     4594        { 
     4595            if ( firstpass == 1 ) 
     4596            { 
     4597                strcpy(nameinttypenameback,nameinttypename); 
     4598                strcpy(nameinttypename,""); 
     4599                curvar = createvar($3,NULL); 
     4600                strcpy(nameinttypename,nameinttypenameback); 
     4601                $$ = insertvar($1,curvar); 
     4602            } 
     4603        } 
     4604      ; 
     4605       
     4606/* R1235: dummy-arg */ 
     4607dummy-arg: dummy-arg-name 
     4608      {strcpy($$,$1);} 
     4609      | '*' 
     4610      {strcpy($$,"*");} 
     4611      ; 
     4612       
     4613/* R1241 : return-stmt */ 
     4614return-stmt : opt-label TOK_RETURN line-break 
     4615     | opt-label TOK_RETURN scalar-int-expr line-break 
     4616     ; 
     4617 
     4618/* R1242 : contains-stmt */ 
     4619contains-stmt: opt-label TOK_CONTAINS 
    16204620        { 
    16214621            if ( inside_type_declare ) break; 
     
    16464646            else printf("l.%4d -- TOK_CONTAINS -- MHCHECK\n",line_num_input); 
    16474647        } 
    1648       ; 
    1649  
    1650 /* R601 : variable */ 
    1651 //variable : expr 
    1652 //       ; 
    1653  
    1654 /* R734 : assignment-stmt */ 
    1655 // assignment-stmt: variable '=' expr 
    1656 //       ; 
    1657 assignment-stmt: expr 
    1658       ; 
    1659  
    1660 /* R741 : where-stmt */ 
    1661 where-stmt: TOK_WHERE '(' mask-expr ')' where-assignment-stmt 
    1662       ; 
    1663  
    1664 /* R742 : where-construct */ 
    1665 where-construct: where-construct-stmt line-break opt-where-body-construct opt-masked-elsewhere-construct opt-elsewhere-construct end-where-stmt 
    1666       ; 
    1667  
    1668 opt-where-body-construct: 
    1669       | opt-where-body-construct where-body-construct line-break 
    1670       ; 
    1671  
    1672 opt-masked-elsewhere-construct : 
    1673       | opt-masked-elsewhere-construct masked-elsewhere-stmt line-break opt-where-body-construct 
    1674       ; 
    1675  
    1676 opt-elsewhere-construct: 
    1677       | opt-elsewhere-construct elsewhere-stmt line-break opt-where-body-construct 
    1678       ; 
    1679  
    1680 /* R743 : where-construct-stmt */ 
    1681 where-construct-stmt: 
    1682         TOK_WHERE '(' mask-expr ')' 
    1683       ; 
    1684  
    1685 /* R744 : where-body-construct */ 
    1686 where-body-construct: where-assignment-stmt 
    1687       | where-stmt 
    1688       | where-construct 
    1689       ; 
    1690  
    1691 /* R745 : where-assignment-stmt */ 
    1692 where-assignment-stmt: assignment-stmt 
    1693       ; 
    1694  
    1695 /* R746 : mask-expr */ 
    1696 mask-expr: expr 
    1697       ; 
    1698  
    1699 /* R747 : masked-elsewhere-stmt */ 
    1700 masked-elsewhere-stmt: 
    1701         TOK_ELSEWHEREPAR mask-expr ')' 
    1702       | TOK_ELSEWHEREPAR mask-expr ')' TOK_NAME 
    1703       ; 
    1704  
    1705 /* R748: elsewhere-stmt */ 
    1706 elsewhere-stmt: 
    1707         TOK_ELSEWHERE 
    1708       | TOK_ELSEWHERE TOK_NAME 
    1709       ; 
    1710  
    1711 /* R749: end-where-stmt */ 
    1712 end-where-stmt: 
    1713         TOK_ENDWHERE 
    1714       | TOK_ENDWHERE TOK_NAME 
    1715       ; 
    1716  
    1717 /* R752 : forall-header */ 
    1718 forall-header : 
    1719      ; 
    1720  
    1721 /* R801 : block */ 
    1722 block: 
    1723       |block execution-part-construct 
    1724       |block execution-part-construct line-break 
    1725       ; 
    1726  
    1727 /* R813 : do-construct */ 
    1728 do-construct: 
    1729         block-do-construct 
    1730       ; 
    1731  
    1732 /* R814 : block-do-construct */ 
    1733 block-do-construct: 
    1734         do-stmt line-break do-block end-do 
    1735       ; 
    1736  
    1737 /* R815 : do-stmt */ 
    1738 do-stmt: 
    1739         label-do-stmt 
    1740       | nonlabel-do-stmt 
    1741       ; 
    1742  
    1743 /* R816 : label-do-stmt */ 
    1744 label-do-stmt: 
    1745         TOK_NAME ':' TOK_PLAINDO label 
    1746       |              TOK_PLAINDO label 
    1747       | TOK_NAME ':' TOK_PLAINDO label loop-control 
    1748       |              TOK_PLAINDO label loop-control 
    1749       ; 
    1750  
    1751 /* R817 : nonlabel-do-stmt */ 
    1752 nonlabel-do-stmt: 
    1753         TOK_NAME ':' TOK_PLAINDO 
    1754       |              TOK_PLAINDO 
    1755       | TOK_NAME ':' TOK_PLAINDO loop-control 
    1756       |              TOK_PLAINDO loop-control 
    1757       ; 
    1758  
    1759 /* R818 : loop-control */ 
    1760 loop-control: 
    1761         opt_comma do-variable '=' expr ',' expr 
    1762       | opt_comma do-variable '=' expr ',' expr ',' expr 
    1763       | opt_comma TOK_WHILE '(' expr ')' 
    1764       | opt_comma TOK_CONCURRENT forall-header 
    1765       ; 
    1766  
    1767 /* R819 : do-variable */ 
    1768 do-variable : ident 
    1769      ; 
    1770  
    1771 /* R820 : do-block */ 
    1772 do-block: block 
    1773      ; 
    1774  
    1775 /* R821 : end-do */ 
    1776 end-do: end-do-stmt 
    1777      | continue-stmt 
    1778      ; 
    1779  
    1780 /* R822 : end-do-stmt */ 
    1781 end-do-stmt: 
    1782         TOK_ENDDO 
    1783       | TOK_ENDDO TOK_NAME 
    1784       ; 
    1785  
    1786 /* R832 : if-construct */ 
    1787 if-construct: if-then-stmt line-break block opt-else-if-stmt-block opt-else-stmt-block end-if-stmt 
    1788       ; 
    1789  
    1790 opt-else-if-stmt-block: 
    1791       | else-if-stmt-block 
    1792       | opt-else-if-stmt-block else-if-stmt-block 
    1793       ; 
    1794  
    1795 else-if-stmt-block: 
    1796         else-if-stmt line-break block 
    1797       ; 
    1798  
    1799 opt-else-stmt-block: 
    1800       | else-stmt-block 
    1801       | opt-else-stmt-block else-if-stmt-block 
    1802       ; 
    1803  
    1804 else-stmt-block: else-stmt line-break block 
    1805         ; 
    1806  
    1807 /* R833 : if-then-stmt */ 
    1808 if-then-stmt: 
    1809          TOK_NAME ':' TOK_LOGICALIF '(' expr ')' TOK_THEN 
    1810       |               TOK_LOGICALIF '(' expr ')' TOK_THEN 
    1811       ; 
    1812  
    1813 /* R834 : else-if-stmt */ 
    1814 else-if-stmt: 
    1815         TOK_ELSEIF '(' expr ')' TOK_THEN 
    1816       | TOK_ELSEIF '(' expr ')' TOK_THEN TOK_NAME 
    1817       ; 
    1818  
    1819 /* R835 : else-stmt */ 
    1820 else-stmt: 
    1821         TOK_ELSE 
    1822       | TOK_ELSE TOK_NAME 
    1823       ; 
    1824  
    1825 /* R836 : end-if-stmt */ 
    1826 end-if-stmt: 
    1827         TOK_ENDIF 
    1828       | TOK_ENDIF TOK_NAME 
    1829       ; 
    1830  
    1831 /* R837 : if-stmt */ 
    1832 if-stmt: TOK_LOGICALIF '(' expr ')' action-stmt 
    1833         ; 
    1834  
    1835 /* R838 : case-construct */ 
    1836 case-construct: select-case-stmt line-break opt_case-stmt-block end-select-stmt 
    1837         ; 
    1838  
    1839 opt_case-stmt-block: 
    1840         | case-stmt-block 
    1841         | opt_case-stmt-block case-stmt-block 
    1842         ; 
    1843  
    1844 case-stmt-block: case-stmt line-break block 
    1845         ; 
    1846  
    1847 /* R839 : select-case-stmt */ 
    1848 select-case-stmt : 
    1849           TOK_NAME ':' TOK_SELECTCASE '(' expr ')' 
    1850         |              TOK_SELECTCASE '(' expr ')' 
    1851         ; 
    1852  
    1853 /* R840 : case-stmt */ 
    1854 case-stmt: 
    1855           TOK_CASE case-selector 
    1856         | TOK_CASE case-selector TOK_NAME 
    1857         ; 
    1858  
    1859 /* R840 : end-select-stmt */ 
    1860 end-select-stmt: 
    1861           TOK_ENDSELECT 
    1862         | TOK_ENDSELECT TOK_NAME 
    1863         ; 
    1864  
    1865 /* R843 : case-selector */ 
    1866 case-selector: 
    1867           '(' case-value-range-list ')' 
    1868         | TOK_DEFAULT 
    1869         ; 
    1870  
    1871 case-value-range-list: 
    1872         case-value-range 
    1873       | case-value-range-list ',' case-value-range 
    1874       ; 
    1875  
    1876 /* R844: case-value-range */ 
    1877 case-value-range : 
    1878         case-value 
    1879       | case-value ':' 
    1880       | ':' case-value 
    1881       | case-value ':' case-value 
    1882       ; 
    1883  
    1884 /* R845 : case-value */ 
    1885 case-value: expr 
    1886         ; 
    1887  
    1888 /* R854 : continue-stmt */ 
    1889 continue-stmt: TOK_CONTINUE 
    1890         ; 
    1891  
    1892 /* R1001 : format-stmt */ 
    1893 format-stmt: TOK_FORMAT 
    1894         ; 
    1895  
    1896 word_endsubroutine : 
    1897         TOK_ENDSUBROUTINE 
    1898         { 
    1899             strcpy($$,$1); 
    1900             pos_endsubroutine = setposcur()-strlen($1); 
    1901             functiondeclarationisdone = 0; 
    1902         } 
    1903       ; 
    1904 word_endunit : 
    1905         TOK_ENDUNIT 
    1906         { 
    1907             strcpy($$,$1); 
    1908             pos_endsubroutine = setposcur()-strlen($1); 
    1909         } 
    1910       ; 
    1911 word_endprogram : 
    1912         TOK_ENDPROGRAM 
    1913         { 
    1914             strcpy($$,$1); 
    1915             pos_endsubroutine = setposcur()-strlen($1); 
    1916         } 
    1917       ; 
    1918 word_endfunction : 
    1919         TOK_ENDFUNCTION 
    1920         { 
    1921             strcpy($$,$1); 
    1922             pos_endsubroutine = setposcur()-strlen($1); 
    1923         } 
    1924       ; 
     4648        line-break 
     4649     ; 
     4650 
     4651/* R1243 : stmt-function-stmt */ 
     4652stmt-function-stmt: TOK_NAME '(' opt-dummy-arg-name-list ')' '=' expr line-break 
     4653     ; 
    19254654 
    19264655opt_name : '\n'  {strcpy($$,"");} 
     
    19744703      | callarglist 
    19754704      ; 
    1976 keywordcall : 
     4705keywordcall: 
    19774706        before_call TOK_FLUSH 
    19784707      | before_call TOK_NAME 
     
    19994728      ; 
    20004729before_call : TOK_CALL  { pos_curcall=setposcur()-4; } 
     4730      | label TOK_CALL  { pos_curcall=setposcur()-4; } 
    20014731      ; 
    20024732callarglist : 
     
    20204750      ; 
    20214751 
    2022 option_inlist : 
    2023       | inlist 
    2024       ; 
    2025 option_read : 
    2026         ioctl option_inlist 
    2027       | infmt opt_inlist 
    2028       ; 
    2029 opt_inlist : 
    2030       | ',' inlist 
    2031       ; 
     4752option_io_1 : 
     4753        infmt ',' inlist 
     4754      | infmt 
     4755 
     4756option_io_2 : 
     4757        ioctl outlist 
     4758      | ioctl 
     4759 
    20324760ioctl : '(' ctllist ')' 
    20334761      ; 
     
    20574785      ; 
    20584786iofctl : 
    2059         TOK_OPEN 
    2060       | TOK_CLOSE 
    2061       | TOK_FLUSH 
     4787      TOK_FLUSH 
    20624788      ; 
    20634789infmt :  unpar_fexpr 
     
    20654791      ; 
    20664792 
    2067 read :  TOK_READ 
    2068       | TOK_INQUIRE 
    2069       | TOK_PRINT 
     4793write_or_inq : 
     4794        TOK_WRITE 
    20704795      ; 
    20714796 
Note: See TracChangeset for help on using the changeset viewer.