title: flex/bison How can I make it recognize a pattern, whether the final character is a dot or not?
body: <p>I try to make an analizer/parser of the code of prolog, here is an example of a fact:
  &quot;dadof(arturo,armando).&quot;
  It ends with a dot (.) and my parser recognize it and then print (&quot;hecho&quot;)
  But I have another option and if the input it is &quot;dadof(arturo,armando)&quot;  it does not recognize it. The only diference is the lack of the dot. But it suppossed that it should recognize it too and then print &quot;(hecho&quot;) too.
  But it does not make it.</p>
  <p>Here is my code</p>
  <p>lex code:</p>
  <pre><code>%{
      #include &lt;stdio.h&gt;
      #include &lt;string.h&gt;
      #include &quot;que.tab.h&quot;
  
      void showError();
  
  %}
  
  %option noyywrap
  
  
  LETTER [a-zA-Z]
  WORD    {LETTER}+
  
  
  %%
  
  [[:blank:]] {}
  [ \t\r] {} 
  {WORD}  { sscanf(yytext, &quot;%s&quot;,yylval.cad); return CADENA; }
  &quot;%&quot;     { return PERCENT; }
  &quot;(&quot;     { return OPENB; }
  &quot;)&quot;     { return CLOSEB; }
  &quot;,&quot;     { return COMA; }
  &quot;.&quot;     { return POINT; }
  &quot;:-&quot;    { return POINTSLASH; }
  &quot;[papa]&quot;  { return NOFACT; }
  
  .   { showError(); return OTROS; }
  %%
  
  void showError(char *OTROS){
      printf(&quot;  &lt;&lt;Error lexico: \&quot;%s\&quot;&gt;&gt;  &quot;, OTROS);
  
  }
  </code></pre>
  <p>bison code:</p>
  <pre><code>%{
      #include &lt;stdio.h&gt;
  
      int yylex(void);
      void yyerror(char *s);
  %}
  
  %token CADENA PERCENT OTROS 
  %token OPENB CLOSEB COMA POINT POINTSLASH
  
  %type &lt;cad&gt; CADENA
  
  %union{
      char cad[20];
  
  }
  
  %start INPUT
  
  
  %%
  
  INPUT
      : INICIO
      | INPUT INICIO
  ;
      INICIO:
          HECHOS
          {
              printf(&quot;(Hecho)&quot;);
          }
         
      ;
  
      HECHOS
          : HECHO POINT
          | HECHO
          
          
      ; 
  
  
  
  
      HECHO
          :INSTRUCCION OPENB INSTRUCCION COMA INSTRUCCION CLOSEB 
          | INSTRUCCION OPENB INSTRUCCION COMA INSTRUCCION CLOSEB COMA HECHO
          
            
      ;
     
      INSTRUCCION:
          | CADENA
          | OTROS
      ;
  
  %%
  
  int main(){
  
      return(yyparse());
      return 0;
  }
  
  void yyerror(char *s){
      printf(&quot;%s&quot;, s);
  }
  </code></pre>
  <p>As I said before, it should print &quot;(Hecho)&quot; whether if the input ends whith a dot or not.</p>