title: How does flex support bison-location exactly?
body: <p>I'm trying to use flex and bison to create a filter, because I want get certain grammar elements from a complex language. My plan is to use flex + bison to recognise the grammar, and dump out the location of elements of interest. (Then use a script to grab text according the locations dumped.) </p>
  
  <p>I found flex can support a bison feature called bison-locations, but how it works in exactly. I tried the example in flex document, it seems the yylloc is not set automatically by flex, I always get <code>(1,0)-(1,0)</code>. Could flex calculate each token's location automatically?  If not, what interface function is defined for me to implement? Is there any example?</p>
  
  <p>Any better solution regarding to tools?</p>
  
  <p>Best Regards,
  Kevin</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Now the interface for yylex turn to:</p>
  
  <pre><code>int yylex(YYSTYPE * yylval_param,YYLTYPE * yylloc_param );
  </code></pre>
  
  <p>bison manual does not specify how lexer should implement to correctly set yylloc_param. For me it is hard to manually trace column number of each token.</p>