Exemple #1
0
int startSyntaxAnalysis(int argc , char * argv[])
{
    if(initAnalysisTable() == -1)
    {
        return -1 ;
    }
    if(argc == 1)
    {
        printf("start run test file \n") ;
        return syntaxAnalysis("test.out");
    }
    else
    {
        if(strcmp(argv[1],"genfile") == 0)
        {
            genfile() ;
            printf("generate file finished") ;
        }
        else
        {
            printf("start run %s file \n",argv[1]) ;
            return syntaxAnalysis(argv[1]);
        }
    }
}
Exemple #2
0
int
main(int argc, char *argv[])
{

/* Starting binary file: file2.bin1 */
genfile("file2.bin1", 0, 32, 0);

/* Binary file after translation: file2.bin2 */
genfile("file2.bin2", 128, 159, -1);

/* Binary file after translation of special characters */
(void) printf("Creating file file2.bin3\n");
if ( (bf = fopen("file2.bin3", "wb")) == NULL )   {
	perror("Opening file file2.bin3");
	}
else   {
	for (ch=0; ch<=32; ch++)
                switch (ch)   {
	        	case '\a':
				(void) putc('A', bf);
                                break;
	        	case '\b':
				(void) putc('B', bf);
                                break;
	        	case '\t':
				(void) putc('T', bf);
                                break;
	        	case '\n':
				(void) putc('N', bf);
                                break;
	        	case '\v':
				(void) putc('V', bf);
                                break;
	        	case '\f':
				(void) putc('F', bf);
                                break;
	        	case '\r':
				(void) putc('R', bf);
                                break;
	        	default:
				(void) putc(ch, bf);
                        }
        (void) fclose(bf);
        }

/* Full ASCII set: file3.full */
genfile("file3.full", 0, 127, 0);

/* Generate subsets that meet class criteria */
genfile("file3.alnum", 0, 127, 1);
genfile("file3.alpha", 0, 127, 2);
genfile("file3.cntrl", 0, 127, 3);
genfile("file3.digit", 0, 127, 4);
genfile("file3.graph", 0, 127, 5);
genfile("file3.lower", 0, 127, 6);
genfile("file3.print", 0, 127, 7);
genfile("file3.punct", 0, 127, 8);
genfile("file3.space", 0, 127, 9);
genfile("file3.upper", 0, 127, 10);
genfile("file3.xdigit", 0, 127, 11);
genfile("file3.blank", 0, 127, 12);

return 0;
}