title: yacc: how to "save" code for execution in future?
body: <p>I'm stuck in misunderstanding of how to "save" grammar rule parsed by yacc into abstract syntax tree. Here's a piece of my yacc file:</p>
  
  <pre><code>expression:
                expr2                     { $$ = $1; }
              | expr2 EQ expr2            { $$ = ($1 == $3); }
              | expr2 NE expr2            { $$ = ($1 != $3); }
              | expr2 LT expr2            { $$ = ($1 &lt; $3); }
              | expr2 LE expr2            { $$ = ($1 &lt;= $3); }
              | expr2 GT expr2            { $$ = ($1 &gt; $3); }
              | expr2 GE expr2            { $$ = ($1 &gt;= $3); }
              ;
  
  expr2:
                expr3                     { $$ == $1; }
              | expr2 PLUS expr3          { $$ = $1 + $3; }
              | expr2 MINUS expr3         { $$ = $1 - $3; }
              ;
  
  expr3:
                expr4                     { $$ = $1; }
              | expr3 MULT expr4          { $$ = $1 * $3; }
              | expr3 DIVIDE expr4        { $$ = $1 / $3; }
              ;
  </code></pre>
  
  <p>as you can see all the actions are performed on the fly. I'd like to make something like:</p>
  
  <pre><code>expr2 PLUS expr3          { $$ = save_code_for_addition($1, $3); }
  </code></pre>
  
  <p>to store this action as a node of abstract syntax tree.</p>
  
  <p>Could someone please kindly explain me what would be the inner representation for such a presaved instruction and how on earth can I later execute it via execute(Statement s), what is Statement data type? how to construct it? I would really appriciate any help, thanks.</p>