Changeset 663 for trunk/AGRIF/LIB/fortran.lex
- Timestamp:
- 2007-05-25T18:00:33+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AGRIF/LIB/fortran.lex
r530 r663 3 3 /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */ 4 4 /* */ 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) */ 7 7 /* This software is governed by the CeCILL-C license under French law and */ 8 8 /* abiding by the rules of distribution of free software. You can use, */ … … 31 31 /* knowledge of the CeCILL-C license and that you accept its terms. */ 32 32 /******************************************************************************/ 33 /* version 1. 0*/33 /* version 1.6 */ 34 34 /******************************************************************************/ 35 35 %x parameter … … 58 58 /******************************************************************************/ 59 59 #define YY_USER_ACTION \ 60 61 60 {\ 61 if (firstpass == 0) \ 62 62 {\ 63 63 strcat(curbuf,yytext); \ 64 64 strcpy(motparse,yytext);\ 65 65 colnum = colnum + strlen(motparse);\ 66 /*printf("motparse = %s %d\n",motparse,strlen(motparse));*/\66 /*printf("motparse = %s %d\n",motparse,strlen(motparse)); */\ 67 67 ECHO; \ 68 68 }\ 69 69 strcpy(motparse1,yytext);\ 70 70 /*if ( firstpass == 1 ) 71 71 printf("yytext = %s %d\n",yytext,strlen(yytext));*/\ 72 72 } 73 73 %} 74 74 AGRIFDEB "Agrif_debut" … … 98 98 COMMENTAIRESFORTRAN90_2 (!{NIMPORTEQUOI}*) 99 99 NEXTLINEF90 "&"{NIMPORTEQUOI}*[\n]* 100 NEXTLINEF77 \n[ \t] *("&"|"+"|"$"|"*")100 NEXTLINEF77 \n[ \t]{5}("&"|"+"|"$"|"*"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"."|"#") 101 101 %% 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 114 103 ^C${AGRIFDEB} return TOK_DEBUT; 115 104 ^C${AGRIFFIN} return TOK_FIN; … … 133 122 tmpc = input(); 134 123 unput(tmpc); 135 if ( ( 136 tmpc >= 'a' && tmpc <= 'z' 124 if ( ( 125 tmpc >= 'a' && tmpc <= 'z' 137 126 ) || ( 138 tmpc >= 'A' && tmpc <= 'Z' 127 tmpc >= 'A' && tmpc <= 'Z' 139 128 ) ) 140 129 { … … 165 154 \.[ \t]*and\. {strcpy(yylval.na,yytext);return TOK_AND;} 166 155 module {return TOK_MODULE;} 167 do[ \t]*while {return TOK_DOWHILE;}156 do[ 0-9\t]*while {return TOK_DOWHILE;} 168 157 end[ \t]*module return TOK_ENDMODULE; 169 158 end[ \t]*do return TOK_ENDDO; … … 187 176 only {return TOK_ONLY;} 188 177 parameter {return TOK_PARAMETER;} 178 recursive {return TOK_RECURSIVE;} 189 179 common {return TOK_COMMON;} 190 global{return TOK_GLOBAL;}180 ^[ \t]*global[ \t]+ {return TOK_GLOBAL;} 191 181 external {return TOK_EXTERNAL;} 192 182 intent {return TOK_INTENT;} 193 kind {return TOK_KIND;}194 183 pointer {return TOK_POINTER;} 195 184 optional {return TOK_OPTIONAL;} 196 185 save {return TOK_SAVE;} 197 ^[ \t]*type {return TOK_TYPE;} 186 ^[ \t]*type[ \t\,]+ {return TOK_TYPE;} 187 ^[ \t]*type[ \t]*\( {return TOK_TYPEPAR;} 188 stat {return TOK_STAT;} 198 189 end[ \t]*type {return TOK_ENDTYPE;} 199 190 open return TOK_OPEN; … … 209 200 private {return TOK_PRIVATE;} 210 201 \([ \t]*in[ \t]*\) {return TOK_IN;} 211 data {return TOK_DATA;} 202 ^[ \t]*data[ \t]+ {strcpy(yylval.na,yytext);return TOK_DATA;} 212 203 continue return TOK_CONTINUE; 213 204 go[ \t]*to {return TOK_PLAINGOTO;} … … 227 218 sqrt\( {return TOK_SQRT;} 228 219 select[ \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;} 231 222 end[ \t]*select {return TOK_ENDSELECT;} 232 223 file[ \t]*\= {return TOK_FILE;} 224 end[ \t]*\= {return TOK_END;} 225 err[ \t]*\= {return TOK_ERR;} 233 226 exist[ \t]*\= {return TOK_EXIST;} 234 227 min[ \t]*\( {return TOK_MIN;} … … 247 240 atan {return TOK_ATAN;} 248 241 cycle {return TOK_CYCLE;} 249 abs\( 242 abs\( {return TOK_ABS;} 250 243 mod {return TOK_MOD;} 251 244 sign {return TOK_SIGN;} … … 258 251 \({SLASH} {return TOK_LEFTAB;} 259 252 {SLASH}\) {return TOK_RIGHTAB;} 260 format 253 format[ \t]*\(({NIMPORTEQUOI}|{NEXTLINEF90}|{NEXTLINEF77})*\) {return TOK_FORMAT;} 261 254 {DOUBLEPRECISION} {strcpy(yylval.na,yytext);return TOK_DOUBLEPRECISION;} 262 255 {DOUBLECOMPLEX} {strcpy(yylval.na,yytext);return TOK_DOUBLECOMPLEX;} … … 272 265 {REALQP} {strcpy(yylval.na,yytext);return TOK_CSTREALQP;} 273 266 ({DIGIT}\.)/[^{NAME}|"and."|"false."|"true."|"eq."|"or."|"gt."|"ge."|"lt."|"le."|"not."|"ne."] {strcpy(yylval.na,yytext);return TOK_CSTREAL;} 274 \. {return TOK_POINT;}275 267 {INT} {strcpy(yylval.na,yytext);return TOK_CSTINT;} 276 268 \$ {} 277 269 \'|\" {return TOK_QUOTE;} 278 ;|\(|\)|:|\[|\]|\+|\-|\*|\% {strcpy(yylval.na,yytext);return (int) *yytext;} 270 \. {} 271 ;|\(|\)|:|\[|\]|\+|\-|\*|\% {strcpy(yylval.na,yytext);return (int) *yytext;} 279 272 \, {return (int) *yytext;} 280 273 \; {return (int) *yytext;} … … 291 284 {NEXTLINEF77} {line_num_fortran++;line_num_fortran_common++;colnum=0;} 292 285 {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 ) 297 288 { 298 289 return TOK_CONTAINS; … … 300 291 else 301 292 { 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; 303 296 } 304 297 } 305 298 {COMMENTAIRESFORTRAN90} { 306 299 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; 309 302 } 310 303 {COMMENTAIRESFORTRAN90_2} { 311 304 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; 314 307 } 315 308 %%
Note: See TracChangeset
for help on using the changeset viewer.