Index: trunk/AGRIF/LIB/fortran.lex
===================================================================
--- trunk/AGRIF/LIB/fortran.lex	(revision 530)
+++ trunk/AGRIF/LIB/fortran.lex	(revision 663)
@@ -3,6 +3,6 @@
 /*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
 /*                                                                            */
-/* Copyright or © or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
-/*                        Cyril Mazauric (Cyril.Mazauric@imag.fr)             */
+/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
+/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
 /* This software is governed by the CeCILL-C license under French law and     */
 /* abiding by the rules of distribution of free software.  You can  use,      */
@@ -31,5 +31,5 @@
 /* knowledge of the CeCILL-C license and that you accept its terms.           */
 /******************************************************************************/
-/* version 1.0                                                                */
+/* version 1.6                                                                */
 /******************************************************************************/
 %x parameter
@@ -58,17 +58,17 @@
 /******************************************************************************/
 #define YY_USER_ACTION \
-	{\
-	   if (firstpass == 0) \
+        {\
+           if (firstpass == 0) \
            {\
               strcat(curbuf,yytext); \
-	      strcpy(motparse,yytext);\
+              strcpy(motparse,yytext);\
               colnum = colnum + strlen(motparse);\
-	      /*printf("motparse = %s %d\n",motparse,strlen(motparse));*/\
+              /*printf("motparse = %s %d\n",motparse,strlen(motparse)); */\
               ECHO; \
            }\
            strcpy(motparse1,yytext);\
-	/*if ( firstpass == 1 ) 
+        /*if ( firstpass == 1 ) 
                       printf("yytext = %s %d\n",yytext,strlen(yytext));*/\
-	}
+        }
 %}
 AGRIFDEB "Agrif_debut"
@@ -98,18 +98,7 @@
 COMMENTAIRESFORTRAN90_2 (!{NIMPORTEQUOI}*)
 NEXTLINEF90 "&"{NIMPORTEQUOI}*[\n]*
-NEXTLINEF77 \n[ \t]*("&"|"+"|"$"|"*")
+NEXTLINEF77 \n[ \t]{5}("&"|"+"|"$"|"*"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"."|"#")
 %%
-{NAME}\= {
-		if (firstpass == 0)
-		{
-		fseek(fortranout,-1,1);
-		strcpy(&curbuf[strlen(curbuf)-1],"\0");
-		}
-		yyless(yyleng-1);
-		strcpy(yylval.na,yytext);
-		return TOK_NAME;
-		}
-^C${NOTTREAT}           {return TOK_DONOTTREAT;}
-^C${ENDNOTTREAT}        {return TOK_ENDDONOTTREAT;}
+
 ^C${AGRIFDEB}            return TOK_DEBUT;
 ^C${AGRIFFIN}            return TOK_FIN;
@@ -133,8 +122,8 @@
                             tmpc = input();
                             unput(tmpc);
-                            if ( ( 
-                               tmpc >= 'a' && tmpc <= 'z' 
+                            if ( (
+                               tmpc >= 'a' && tmpc <= 'z'
                                   ) || (
-                               tmpc >= 'A' && tmpc <= 'Z' 
+                               tmpc >= 'A' && tmpc <= 'Z'
                                )  )
                                {
@@ -165,5 +154,5 @@
 \.[ \t]*and\.           {strcpy(yylval.na,yytext);return TOK_AND;}
 module                  {return TOK_MODULE;}
-do[ \t]*while           {return TOK_DOWHILE;}
+do[ 0-9\t]*while           {return TOK_DOWHILE;}
 end[ \t]*module          return TOK_ENDMODULE;
 end[ \t]*do              return TOK_ENDDO;
@@ -187,13 +176,15 @@
 only                    {return TOK_ONLY;}
 parameter               {return TOK_PARAMETER;}
+recursive               {return TOK_RECURSIVE;}
 common                  {return TOK_COMMON;}
-global                  {return TOK_GLOBAL;}
+^[ \t]*global[ \t]+     {return TOK_GLOBAL;}
 external                {return TOK_EXTERNAL;}
 intent                  {return TOK_INTENT;}
-kind                    {return TOK_KIND;}
 pointer                 {return TOK_POINTER;}
 optional                {return TOK_OPTIONAL;}
 save                    {return TOK_SAVE;}
-^[ \t]*type              {return TOK_TYPE;}
+^[ \t]*type[ \t\,]+       {return TOK_TYPE;}
+^[ \t]*type[ \t]*\(     {return TOK_TYPEPAR;}
+stat                    {return TOK_STAT;}
 end[ \t]*type           {return TOK_ENDTYPE;}
 open                     return TOK_OPEN;
@@ -209,5 +200,5 @@
 private                 {return TOK_PRIVATE;}
 \([ \t]*in[ \t]*\)      {return TOK_IN;}
-data                    {return TOK_DATA;} 
+^[ \t]*data[ \t]+       {strcpy(yylval.na,yytext);return TOK_DATA;}
 continue                 return TOK_CONTINUE;
 go[ \t]*to              {return TOK_PLAINGOTO;}
@@ -227,8 +218,10 @@
 sqrt\(                  {return TOK_SQRT;}
 select[ \t]*case        {return TOK_SELECTCASE;}
-case                    {return TOK_CASE;}
-case[ \t]*default       {return TOK_CASEDEFAULT;}
+^[ \t]*case[ \t]*\(     {return TOK_CASE;}
+^[ \t]*case[ \t]*default       {return TOK_CASEDEFAULT;}
 end[ \t]*select         {return TOK_ENDSELECT;}
 file[ \t]*\=            {return TOK_FILE;}
+end[ \t]*\=             {return TOK_END;}
+err[ \t]*\=             {return TOK_ERR;}
 exist[ \t]*\=           {return TOK_EXIST;}
 min[ \t]*\(             {return TOK_MIN;}
@@ -247,5 +240,5 @@
 atan                    {return TOK_ATAN;}
 cycle                   {return TOK_CYCLE;}
-abs\(                     {return TOK_ABS;}
+abs\(                   {return TOK_ABS;}
 mod                     {return TOK_MOD;}
 sign                    {return TOK_SIGN;}
@@ -258,5 +251,5 @@
 \({SLASH}               {return TOK_LEFTAB;}
 {SLASH}\)               {return TOK_RIGHTAB;}
-format                  {return TOK_FORMAT;}
+format[ \t]*\(({NIMPORTEQUOI}|{NEXTLINEF90}|{NEXTLINEF77})*\)  {return TOK_FORMAT;}
 {DOUBLEPRECISION}       {strcpy(yylval.na,yytext);return TOK_DOUBLEPRECISION;}
 {DOUBLECOMPLEX}         {strcpy(yylval.na,yytext);return TOK_DOUBLECOMPLEX;}
@@ -272,9 +265,9 @@
 {REALQP}                {strcpy(yylval.na,yytext);return TOK_CSTREALQP;}
 ({DIGIT}\.)/[^{NAME}|"and."|"false."|"true."|"eq."|"or."|"gt."|"ge."|"lt."|"le."|"not."|"ne."] {strcpy(yylval.na,yytext);return TOK_CSTREAL;}
-\.                      {return TOK_POINT;}
 {INT}                   {strcpy(yylval.na,yytext);return TOK_CSTINT;}
 \$ {}
 \'|\"                   {return TOK_QUOTE;}
-;|\(|\)|:|\[|\]|\+|\-|\*|\% {strcpy(yylval.na,yytext);return (int) *yytext;} 
+\.                      {}
+;|\(|\)|:|\[|\]|\+|\-|\*|\% {strcpy(yylval.na,yytext);return (int) *yytext;}
 \,                      {return (int) *yytext;}
 \;                      {return (int) *yytext;}
@@ -291,8 +284,6 @@
 {NEXTLINEF77}           {line_num_fortran++;line_num_fortran_common++;colnum=0;}
 {COMMENTAIRESFORTRAN77} {
-/* fonction non standard     if (  strcasestr(motparse1,"contains") )         */
-                           if (  strstr(motparse1,"contains")  ||
-                                 strstr(motparse1,"Contains")  ||
-                                 strstr(motparse1,"CONTAINS")  )
+                           convert2lower(motparse1);
+                           if ( strncasecmp(motparse1,"contains",8) == 0 )
                            {
                               return TOK_CONTAINS;
@@ -300,16 +291,18 @@
                            else
                            {
-                              colnum=0;line_num_fortran++;line_num_fortran_common++;                           
+                              colnum=0;line_num_fortran++;line_num_fortran_common++;
+                             if ( !strcasecmp(motparse1,"C$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"C$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
                            }
                          }
 {COMMENTAIRESFORTRAN90}   {
                              colnum = 0;
-                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT; 
-                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT; 
+                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
                           }
 {COMMENTAIRESFORTRAN90_2} {
                              colnum = 0;
-                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT; 
-                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT; 
+                             if ( !strcasecmp(motparse1,"!$AGRIF_DO_NOT_TREAT\n")) return TOK_DONOTTREAT;
+                             if ( !strcasecmp(motparse1,"!$AGRIF_END_DO_NOT_TREAT\n")) return TOK_ENDDONOTTREAT;
                           }
 %%
