jump to content

	/* Removes comments from SQL. Compile as follows
	 * lex thisfile ; cc -o yourexe -Aa lex.yy.c ; rm lex.yy.c
	 * input - stdin/argument ; output - stdout
	 * Get GNU Flex if you want to remove annoying coding for
	 * case insensitive scanning .
	 * Vattekkat Satheesh Babu 05/01/98
	 */
    #define yywrap()    1
	char my_str[100];
	char *upper(char *);
%%
'       { /** If we are in an SQL string,print it fully
           */
        output(yytchar);while(input()!='\'')output(yytchar);output(yytchar);}
"/*"    {loop:
        while (input() != '*');
        switch (input())
            {
            case '/': break;
            case '*': unput('*');
            default: goto loop;
            }
        } else puts ( yytext );
--      {while(input()!='\n');unput('\n');}
REM|REm|Rem|rem|rEM|reM|ReM|rEm {while(input()!='\n');unput('\n');}
%%
main(argc,argv)
int argc;
char **argv;
{   
    if ( argc > 1 )
        yyin = fopen(argv[1],"r");
    else
        yyin = stdin;
    yylex() ;
}