title: Beginner: L1 Parsing Table Syntax Error
body: <p>I'm a CS Student working on a code to implement but having hard time running it.</p>
  
  <p>Can you please help me out in running this L1 Parsing Table.</p>
  
  <p>May be i'm doing some stupid syntax mistake.</p>
  
  <p>I'll be very thankful to your replies.</p>
  
  <p>Cheers!</p>
  
  <pre><code>    #include &lt;iostream.h&gt;
      #include &lt;conio.h&gt;
      #include &lt;string.h&gt;
      #include &lt;stdio.h&gt;
      #include &lt;stdlib.h&gt;
      void main()
      {
          clrscr();
          int i=0,j=0,k=0,m=0,n=0,o=0,o1=0,var=0,l=0,f=0,c=0,f1=0;
          char     str[30],str1[40]="E",temp[20],temp1[20],temp2[20],tt[20],t3[20];
          strcpy(temp1,'\0');
          strcpy(temp2,'\0');
          char t[10];
          char array[6][5][10] = {
                       "NT", "&lt;id&gt;","+","*",";",
                       "E", "Te","Error","Error","Error",
                       "e", "Error","+Te","Error","\0",
                       "T", "Vt","Error","Error","Error",
                       "t", "Error","\0","*Vt","\0",
                       "V", "&lt;id&gt;","Error","Error","Error"
                        };
          cout &lt;&lt; "\n\tLL(1)  PARSER  TABLE \n";
          for(i=0;i&lt;6;i++)
          {
              for(j=0;j&lt;5;j++)
              {
                  cout.setf(ios::right);
                  cout.width(10);
                  cout&lt;&lt;array[i][j];
              }
              cout&lt;&lt;endl;
          }
          cout &lt;&lt; endl;
          cout &lt;&lt; "\n\tENTER THE STRING :";
          gets(str);
          if(str[strlen(str)-1] != ';')
          {
                cout &lt;&lt; "END OF STRING MARKER SHOULD BE ';'";
                getch();
                exit(1);
          }
          cout &lt;&lt; "\n\tCHECKING VALIDATION OF THE STRING ";
          cout &lt;&lt;"\n\t" &lt;&lt; str1;
          i=0;
  
      while(i&lt;strlen(str))
          {
           again:
                if(str[i] == ' ' &amp;&amp; i&lt;strlen(str))
                {
                     cout &lt;&lt; "\n\tSPACES IS NOT ALLOWED IN SOURSE STRING ";
                     getch();
                     exit(1);
                }
                temp[k]=str[i];
                temp[k+1]='\0';
                f1=0;
           again1:
                if(i&gt;=strlen(str))
                {
                     getch();
                     exit(1);
                }
                for(int l=1;l&lt;=4;l++)
                {
                  if(strcmp(temp,array[0][l])==0)
                  {
                      f1=1;
                      m=0,o=0,var=0,o1=0;
                      strcpy(temp1,'\0');
                      strcpy(temp2,'\0');
                      int len=strlen(str1);
                      while(m&lt;strlen(str1) &amp;&amp; m&lt;strlen(str))
                      {
                            if(str1[m]==str[m])
                            {
                                 var=m+1;
                                 temp2[o1]=str1[m];
                                 m++;
                                 o1++;
                            }
                            else
                            {
                                 if((m+1)&lt;strlen(str1))
                                 {
                                     m++;
                                     temp1[o]=str1[m];
                                     o++;
                                 }
                                 else
                                     m++;
                            }
  
                      }
                      temp2[o1] = '\0';
                      temp1[o] = '\0';
                      t[0] = str1[var];
                      t[1] = '\0';
                      for(n=1;n&lt;=5;n++)
                      {
                          if(strcmp(array[n][0],t)==0)
                              break;
                      }
                      strcpy(str1,temp2);
                      strcat(str1,array[n][l]);
                      strcat(str1,temp1);
                      cout &lt;&lt; "\n\t" &lt;&lt;str1;
                      getch();
  
                      if(strcmp(array[n][l],'\0')==0)
                      {
                          if(i==(strlen(str)-1))
                          {
                                int len=strlen(str1);
                                str1[len-1]='\0';
                                cout &lt;&lt; "\n\t"&lt;&lt;str1;
                                cout &lt;&lt; "\n\n\tENTERED STRING IS                             VALID";
                                getch();
                                exit(1);
                            }
                            strcpy(temp1,'\0');
                            strcpy(temp2,'\0');
                            strcpy(t,'\0');
                            goto again1;
                      }
                      if(strcmp(array[n][l],"Error")==0)
                      {
                            cout &lt;&lt; "\n\tERROR IN YOUR SOURCE STRING";
                            getch();
                            exit(1);
                      }
                      strcpy(tt,'\0');
                      strcpy(tt,array[n][l]);
                      strcpy(t3,'\0');
                      f=0;
                      for(c=0;c&lt;strlen(tt);c++)
                      {
                           t3[c]=tt[c];
                           t3[c+1]='\0';
                           if(strcmp(t3,temp)==0)
                           {
                                 f=0;
                                 break;
                           }
                           else
                                 f=1;
                       }
  
                       if(f==0)
                       {
                          strcpy(temp,'\0');
                          strcpy(temp1,'\0');
                          strcpy(temp2,'\0');
                          strcpy(t,'\0');
                          i++;
                          k=0;
                          goto again;
                       }
                       else
                       {
                          strcpy(temp1,'\0');
                          strcpy(temp2,'\0');
                          strcpy(t,'\0');
                          goto again1;
                      }
                  }
                }
                i++;
                k++;
          }
          if(f1==0)
                 cout &lt;&lt; "\nENTERED STRING IS INVALID";
          else
                cout &lt;&lt; "\n\n\tENTERED STRING IS VALID";
          getch();
      }
  </code></pre>
  
  <p>OUTPUT </p>
  
  <hr>
  
  <pre><code>        LL(1)  PARSER  TABLE
  
          NT      &lt;id&gt;         +         *         ;
          E        Te     Error     Error     Error
          e     Error       +Te     Error
          T        Vt     Error     Error     Error
          t     Error                 *Vt
          V      &lt;id&gt;     Error     Error     Error
  
          ENTER THE STRING :&lt;id&gt;+&lt;id&gt;*&lt;id&gt;;
  
      CHECKING VALIDATION OF THE STRING
                  E
                  Te
                  Vte
                  &lt;id&gt;te
                  &lt;id&gt;e
                  &lt;id&gt;+Te
                  &lt;id&gt;+Vte
                  &lt;id&gt;+&lt;id&gt;te
                  &lt;id&gt;+&lt;id&gt;*Vte
                  &lt;id&gt;+&lt;id&gt;*&lt;id&gt;te
                  &lt;id&gt;+&lt;id&gt;*&lt;id&gt;e
                  &lt;id&gt;+&lt;id&gt;*&lt;id&gt;
                  ENTERED STRING IS VALID
      [/Code]
  </code></pre>