Пример #1
0
void LL_construct()
{
	try
	{
		prepare_nonterminals();
		calc_first();
		print_first();
		calc_follow();
		print_follow();
		parse_table_generate();
		print_parse_table();
	}
	catch (ConstructException &e)
	{
		puts(e.message);
		puts("Syntax analyzer construct failed.");
	}
}
Пример #2
0
Файл: DFA.c Проект: zzyang/c
 void main()
 {
   //clrscr();
   //system("clear");

   char str[500];
   inpt[0]=NULL;
   printf("Enter the postfix expression\n");
   scanf("%s",str);
   node * root;
   int l;
   strcat(str,"#.\0");
   l=strlen(str);
   l--;
   int i, j=0;
   for(i=0;i<l-1;++i)    {
     j=0;
     while(inpt[j]!=NULL)
     {
       if(inpt[j]==str[i])
         break;
       j++;
     }
     if(inpt[j]!=str[i] && str[i]!='|' && str[i]!='*' && str[i]!='.')
     {
       inpt[j]=str[i];
       inpt[j+1]=NULL;
     }
   }
   int pos=1;
   root=create(str,&l);
   create_nullable(root,&pos);
   printf("NULLABLE TABLE\nElement\tFPOS\tLPOS\n");
   print_nullable(root->lc);
   print_follow(pos-2);
   dfa();
   display_dfa();
   printf("\n");
 }