title: flex yacc (bison) segmentation fault while building the parsing tree
body: <p>I'm having a problem in logical operators</p>
  
  <p>In my .y file i have:</p>
  
  <pre><code>expr: expr oper1 expr { $$=insert_expression($2, $1, $3); }
       | expr oper2 expr { $$=insert_expression($2, $1, $3); }
       ;
  </code></pre>
  
  <p>In my .l file i determined that oper1 and oper2 are:</p>
  
  <pre><code>"&lt;" | "&gt;" | "=" | "&lt;&gt;" | "&lt;=" | "&gt;=" { return oper1; }
  "AND" | "OR" { return oper2; }
  </code></pre>
  
  <p>Then i have a structure to put the values in:</p>
  
  <pre><code>typedef struct _Expression
  {
      char *oper;
      struct _Expression *ex1;
      struct _Expression *ex2;
  } is_expression;
  </code></pre>
  
  <p>and put the values in:</p>
  
  <pre><code>is_expression* insert_expression(char* oper, is_expression *expr1, is_expression *expr2)
  {
      is_expression* e = (is_expression*)malloc(sizeof(is_expression));
  
      e-&gt;ex1 = expr1;
      e-&gt;ex2 = expr2;
      e-&gt;oper = oper;
  
      return e;
  }
  </code></pre>
  
  <p>and finally show them:</p>
  
  <pre><code>void show_expression(is_expression *e)
  {
      show_expression(e-&gt;ex1);
      printf("%s", e-&gt;oper);
      show_expression(e-&gt;ex2);
  }
  </code></pre>
  
  <p>but then i get a segmentation fault everytime i use a expr oper expr:</p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation Fault
  </code></pre>
  
  <p>Any ideas about what i'm doing wrong?</p>
  
  <p>Thanks</p>