title: Lex and Yacc, how to get values from variables ? (begginner)
body: <p>this is my first post and first of all I want to say that I am a total beginner. I'm sorry if my question may seem simple but I really did not find an answer.</p>
  
  <p>I would like to be able to analyze a JSON file that I wrote. Thanks to a tutorial I was able to create my grammar, but I would like to be able to access the corresponding values ​​to use them in C functions, and I don't know how to do it.</p>
  
  <p>Here's my lex and yacc files : </p>
  
  <pre><code>%{
  #include &lt;stdio.h&gt;
  int yywrap() { return 1;}
  void yyerror(const char* s) {fprintf(stderr,"Error : %s.\n",s);}
  %}
  
  
  %token X Y DIRECTION POINT1 POINTS2
  %token INTEGER STRING
  %start linkage
  %%
  
  linkage: '{' point1 ','  points2 '}' ;
  
  point1: POINT1 ':' point ;
  point: '{'
           X ':' INTEGER ','
           Y ':' INTEGER ','
           DIRECTION ':' STRING  {printf("%s",$3);}
          '}';
  
  
  
  points2: POINTs2 ':' '[' points2_list ']';
  points2_list: points2_ | points2_list ',' points2_ ;
  points2_: '{'
           X ':' INTEGER ','
           Y ':' INTEGER ','
           DIRECTION ':' STRING
          '}';
  
  
  %%
  
  int main(int argc,char** argv)
  {
  yyparse();
  }
  </code></pre>
  
  <pre><code>%{
  #include &lt;stdio.h&gt;
  #include "sample.tab.h"
  %}
  %%
  "\"x\""    return X;
  "\"point1\""       return POINT1;
  "\"y\""  return Y;
  "\"points2\""       return POINTS2;
  [0-9]+          return INTEGER;
  \"[^\"]*\"       return STRING;
  [ \n\t\r]       ;
  .               return yytext[0];
  %%
  
  </code></pre>
  
  <p>I don't really understand how variables work, for example to print the direction.
  Again, I'm a beginner, I'm not a programmer, I just want to learn more :)</p>
  
  <p>Thanks you </p>