예제 #1
0
파일: Lex_1.cpp 프로젝트: wangchaohui/lib
int Lex_analyzer_construct()
{
	struct Node *root=NULL;
	init();
	memset(isinput,0,sizeof(isinput));
	for(int i=0;i<token_n;i++)
	{
		struct Node *x=bds(tokens[i].regular);
		if(x==NULL)
		{
			printf("Token #%d:%s Is Wrong\n",i,tokens[i].name);
			printf("Lex analyzer construct failed.\n");
			return -1;
		}
		x->right->token=i;
		acposition[i]=x->right->n;
		if(root==NULL)root=x;
		else root=newNode('|'+256,root,x);
	}
	memset(followpos,0,sizeof(followpos));
	nfl(root);
	ptr(root,0);
	putchar('\n');
	print_followpos();
	DFA_from_regular(root);
	print_DFA();
	Minimizing_DFA();
	print_Minimized_DFA();
	return 0;
}
예제 #2
0
int main() {
    int i;
    read();
    print();
    while (1) {
        puts("\n-----------------------------\n\t\tMENU\n\n1.NFA to DFA\n2.Show Table\n3.Exit\n");
        scanf("%d", &i);
        switch (i) {
            case 1:
                s = 0;
                DFA_states = nfa2dfa();
                print_DFA();
                break;
            case 2:
                print();
                break;
            case 3:
                return 0;
        }
    }
}
예제 #3
0
파일: Lex_1.cpp 프로젝트: wangchaohui/lib
int Test()
{
	char s[200];
	while(gets(s))
	{
		init();
		struct Node *x=bds(s);
		if(x)
		{
			memset(followpos,0,sizeof(followpos));
			nfl(x);
			ptr(x,0);
			putchar('\n');
			print_followpos();
			DFA_from_regular(x);
			print_DFA();
			Minimizing_DFA();
			print_Minimized_DFA();
		}
	}
	return 0;
}