title: How to return from the yylex()?
body: <p>I am writing lex code to convert tabs into spacebars (one tab equals 4 spacebars) and count those spacebars. The code is as following:</p>
  
  <pre><code>%{
   #include&lt;stdio.h&gt;
   int spacebarCount=0;
  %}
  
  %%
  [\t]    {
          spacebarCount+=4;
          }
  [ ]     {
          spacebarCount++;
          }
  %%
  
  int main()
      {
      yylex();
      printf("The spacebar is: %d",spacebarCount);
      spacebarCount=0;
      }
  </code></pre>
  
  <p>The output should print a statement: printf("The spacebar is: %d",spacebarCount); However it didn't. So what should I do to make it print the output I wanted? Also, I have tried to substitute the statements below in the main function but it didn't work.</p>
  
  <pre><code> int main()
      {
      do
         {
         if(yylex()==0);
            {
            printf("The spacebar is: %d",spacebarCount);
            spacebarCount=0; 
            }
         }while(1);
      }
  </code></pre>