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 663 for trunk/AGRIF/LIB/fortran.lex – NEMO

Ignore:
Timestamp:
2007-05-25T18:00:33+02:00 (17 years ago)
Author:
opalod
Message:

RB: update CONV

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/AGRIF/LIB/fortran.lex

    r530 r663  
    33/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */ 
    44/*                                                                            */ 
    5 /* Copyright or © or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */ 
    6 /*                        Cyril Mazauric (Cyril.Mazauric@imag.fr)             */ 
     5/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */ 
     6/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */ 
    77/* This software is governed by the CeCILL-C license under French law and     */ 
    88/* abiding by the rules of distribution of free software.  You can  use,      */ 
     
    3131/* knowledge of the CeCILL-C license and that you accept its terms.           */ 
    3232/******************************************************************************/ 
    33 /* version 1.0                                                                */ 
     33/* version 1.6                                                                */ 
    3434/******************************************************************************/ 
    3535%x parameter 
     
    5858/******************************************************************************/ 
    5959#define YY_USER_ACTION \ 
    60    {\ 
    61       if (firstpass == 0) \ 
     60        {\ 
     61           if (firstpass == 0) \ 
    6262           {\ 
    6363              strcat(curbuf,yytext); \ 
    64          strcpy(motparse,yytext);\ 
     64              strcpy(motparse,yytext);\ 
    6565              colnum = colnum + strlen(motparse);\ 
    66          /*printf("motparse = %s %d\n",motparse,strlen(motparse));*/\ 
     66              /*printf("motparse = %s %d\n",motparse,strlen(motparse)); */\ 
    6767              ECHO; \ 
    6868           }\ 
    6969           strcpy(motparse1,yytext);\ 
    70    /*if ( firstpass == 1 )  
     70        /*if ( firstpass == 1 )  
    7171                      printf("yytext = %s %d\n",yytext,strlen(yytext));*/\ 
    72    } 
     72        } 
    7373%} 
    7474AGRIFDEB "Agrif_debut" 
     
    9898COMMENTAIRESFORTRAN90_2 (!{NIMPORTEQUOI}*) 
    9999NEXTLINEF90 "&"{NIMPORTEQUOI}*[\n]* 
    100 NEXTLINEF77 \n[ \t]*("&"|"+"|"$"|"*") 
     100NEXTLINEF77 \n[ \t]{5}("&"|"+"|"$"|"*"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"."|"#") 
    101101%% 
    102 {NAME}\= { 
    103       if (firstpass == 0) 
    104       { 
    105       fseek(fortranout,-1,1); 
    106       strcpy(&curbuf[strlen(curbuf)-1],"\0"); 
    107       } 
    108       yyless(yyleng-1); 
    109       strcpy(yylval.na,yytext); 
    110       return TOK_NAME; 
    111       } 
    112 ^C${NOTTREAT}           {return TOK_DONOTTREAT;} 
    113 ^C${ENDNOTTREAT}        {return TOK_ENDDONOTTREAT;} 
     102 
    114103^C${AGRIFDEB}            return TOK_DEBUT; 
    115104^C${AGRIFFIN}            return TOK_FIN; 
     
    133122                            tmpc = input(); 
    134123                            unput(tmpc); 
    135                             if ( (  
    136                                tmpc >= 'a' && tmpc <= 'z'  
     124                            if ( ( 
     125                               tmpc >= 'a' && tmpc <= 'z' 
    137126                                  ) || ( 
    138                                tmpc >= 'A' && tmpc <= 'Z'  
     127                               tmpc >= 'A' && tmpc <= 'Z' 
    139128                               )  ) 
    140129                               { 
     
    165154\.[ \t]*and\.           {strcpy(yylval.na,yytext);return TOK_AND;} 
    166155module                  {return TOK_MODULE;} 
    167 do[ \t]*while           {return TOK_DOWHILE;} 
     156do[ 0-9\t]*while           {return TOK_DOWHILE;} 
    168157end[ \t]*module          return TOK_ENDMODULE; 
    169158end[ \t]*do              return TOK_ENDDO; 
     
    187176only                    {return TOK_ONLY;} 
    188177parameter               {return TOK_PARAMETER;} 
     178recursive               {return TOK_RECURSIVE;} 
    189179common                  {return TOK_COMMON;} 
    190 global                  {return TOK_GLOBAL;} 
     180^[ \t]*global[ \t]+     {return TOK_GLOBAL;} 
    191181external                {return TOK_EXTERNAL;} 
    192182intent                  {return TOK_INTENT;} 
    193 kind                    {return TOK_KIND;} 
    194183pointer                 {return TOK_POINTER;} 
    195184optional                {return TOK_OPTIONAL;} 
    196185save                    {return TOK_SAVE;} 
    197 ^[ \t]*type              {return TOK_TYPE;} 
     186^[ \t]*type[ \t\,]+       {return TOK_TYPE;} 
     187^[ \t]*type[ \t]*\(     {return TOK_TYPEPAR;} 
     188stat                    {return TOK_STAT;} 
    198189end[ \t]*type           {return TOK_ENDTYPE;} 
    199190open                     return TOK_OPEN; 
     
    209200private                 {return TOK_PRIVATE;} 
    210201\([ \t]*in[ \t]*\)      {return TOK_IN;} 
    211 data                    {return TOK_DATA;}  
     202^[ \t]*data[ \t]+       {strcpy(yylval.na,yytext);return TOK_DATA;} 
    212203continue                 return TOK_CONTINUE; 
    213204go[ \t]*to              {return TOK_PLAINGOTO;} 
     
    227218sqrt\(                  {return TOK_SQRT;} 
    228219select[ \t]*case        {return TOK_SELECTCASE;} 
    229 case                    {return TOK_CASE;} 
    230 case[ \t]*default       {return TOK_CASEDEFAULT;} 
     220^[ \t]*case[ \t]*\(     {return TOK_CASE;} 
     221^[ \t]*case[ \t]*default       {return TOK_CASEDEFAULT;} 
    231222end[ \t]*select         {return TOK_ENDSELECT;} 
    232223file[ \t]*\=            {return TOK_FILE;} 
     224end[ \t]*\=             {return TOK_END;} 
     225err[ \t]*\=             {return TOK_ERR;} 
    233226exist[ \t]*\=           {return TOK_EXIST;} 
    234227min[ \t]*\(             {return TOK_MIN;} 
     
    247240atan                    {return TOK_ATAN;} 
    248241cycle                   {return TOK_CYCLE;} 
    249 abs\(                     {return TOK_ABS;} 
     242abs\(                   {return TOK_ABS;} 
    250243mod                     {return TOK_MOD;} 
    251244sign                    {return TOK_SIGN;} 
     
    258251\({SLASH}               {return TOK_LEFTAB;} 
    259252{SLASH}\)               {return TOK_RIGHTAB;} 
    260 format                  {return TOK_FORMAT;} 
     253format[ \t]*\(({NIMPORTEQUOI}|{NEXTLINEF90}|{NEXTLINEF77})*\)  {return TOK_FORMAT;} 
    261254{DOUBLEPRECISION}       {strcpy(yylval.na,yytext);return TOK_DOUBLEPRECISION;} 
    262255{DOUBLECOMPLEX}         {strcpy(yylval.na,yytext);return TOK_DOUBLECOMPLEX;} 
     
    272265{REALQP}                {strcpy(yylval.na,yytext);return TOK_CSTREALQP;} 
    273266({DIGIT}\.)/[^{NAME}|"and."|"false."|"true."|"eq."|"or."|"gt."|"ge."|"lt."|"le."|"not."|"ne."] {strcpy(yylval.na,yytext);return TOK_CSTREAL;} 
    274 \.                      {return TOK_POINT;} 
    275267{INT}                   {strcpy(yylval.na,yytext);return TOK_CSTINT;} 
    276268\$ {} 
    277269\'|\"                   {return TOK_QUOTE;} 
    278 ;|\(|\)|:|\[|\]|\+|\-|\*|\% {strcpy(yylval.na,yytext);return (int) *yytext;}  
     270\.                      {} 
     271;|\(|\)|:|\[|\]|\+|\-|\*|\% {strcpy(yylval.na,yytext);return (int) *yytext;} 
    279272\,                      {return (int) *yytext;} 
    280273\;                      {return (int) *yytext;} 
     
    291284{NEXTLINEF77}           {line_num_fortran++;line_num_fortran_common++;colnum=0;} 
    292285{COMMENTAIRESFORTRAN77} { 
    293 /* fonction non standard     if (  strcasestr(motparse1,"contains") )         */ 
    294                            if (  strstr(motparse1,"contains")  || 
    295                                  strstr(motparse1,"Contains")  || 
    296                                  strstr(motparse1,"CONTAINS")  ) 
     286                           convert2lower(motparse1); 
     287                           if ( strncasecmp(motparse1,"contains",8) == 0 ) 
    297288                           { 
    298289                              return TOK_CONTAINS; 
     
    300291                           else 
    301292                           { 
    302                               colnum=0;line_num_fortran++;line_num_fortran_common++;                            
     293                              colnum=0;line_num_fortran++;line_num_fortran_common++; 
     294                             if ( !strcasecmp(motparse1,"C$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT; 
     295                             if ( !strcasecmp(motparse1,"C$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT; 
    303296                           } 
    304297                         } 
    305298{COMMENTAIRESFORTRAN90}   { 
    306299                             colnum = 0; 
    307                              if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;  
    308                              if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;  
     300                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT; 
     301                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT; 
    309302                          } 
    310303{COMMENTAIRESFORTRAN90_2} { 
    311304                             colnum = 0; 
    312                              if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;  
    313                              if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;  
     305                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT; 
     306                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT; 
    314307                          } 
    315308%% 
Note: See TracChangeset for help on using the changeset viewer.