Dear Sir:

Thank for your greate work for flex. I am a new man to flex, and I am learning 
to use your tool flex by reading the accompanying mannual provided by you.

I come to a problem that when I present my script to flex, it generate a 
surprise  code which turns out to the unexpected runtime result.

I try to modify the script by rearrange the line, BEGIN(FNAME), from bottom to 
elsewhere, and I get the correct run time result.

The version of Flex I am using now is 2.5, and the compile is visual studio.net 
2005 runing on window server 2003. The script is at the very end of the mail.

After successfully compiling the generated file, I run the exe file with the 
comand line "-f tmd.c -h". The result is "Use File Name: tmd.c '\n' Use File 
Name: -h" but not the wanted one "Use File Name: tmd.c '\n' Usage is: testlex 
[-help | -h | -?][-verbose | -v][(-file|-f) filename]", where "testlex" is the 
executable file  name on windows.

Can you help me?  Thanks for you help.

sincerely yours
        Ouyang Yingxiu
[EMAIL PROTECTED]
          2006-03-13


//////////////////////////////////Pcl.l/////////////////////////////////////////////////
%{
/* This demonstrate example  */
char *progName;
unsigned verbose;
%}
%x FNAME
%%
-h      |
"-?"    |
-help   {
            printf("Usage is: %s [-help | -h | -?][-verbose | -v]"
                   "[(-file|-f) filename]\n", progName);
         }
<FNAME>[^ ]+ {
                printf("Use File Name: %s\n", yytext); 
                BEGIN(INITIAL);
             }
-v      |
-verbose { printf("Verbose is off"); verbose = 1;}
.       | {printf("%s", yytext);ECHO;}
-f      |
-file   {BEGIN(FNAME);}

%%
int main(int argc, char **argv)
{
    char szCmdLine[200];
    int i=0;
    int len=0;
    progName = argv[0];
    memset(szCmdLine, 0, sizeof(szCmdLine));
    if (argc<2)
    {
        return 0;
    }
    
    for (i=0; i<argc-1; i++)
    {
        len += strlen(argv[i+1]);
        strcat(szCmdLine, argv[i+1]);
        szCmdLine[len++] = ' ';
        szCmdLine[len] = '\0';
    }
   yy_scan_string(szCmdLine);
   yylex();
}

int yywrap()
{
    return 1;
}

_______________________________________________
help-flex mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-flex

Reply via email to