title: How can i peek next token in flex without removing it from buffer
body: <p>I'm trying to build lexer for some subset of AMPL language.
  I need to now what type of symbolic name lexer is dealing right now.
  Every symbolic name is var or param or set. Fortunately all of them have to be declared before they are used. So i thought i can use lookahead operator in flex simply changing code in lexer from </p>
  
  <pre><code>SYMBOLIC_NAME [a-zA-Z_][a-zA-Z0-9_]*
  %%
  param             { return PARAM; }
  var               { return VAR; }
  set               { return SET; }
  {SYMBOLIC_NAME}   { yylval.string = (char*) strdup(yytext);
                      return SYMBOLIC_NAME;  
                    }
  %%
  </code></pre>
  
  <p>to some thing like this</p>
  
  <pre><code>SYMBOLIC_NAME [a-zA-Z_][a-zA-Z0-9_]*
  %{
   #include &lt;vector&gt;
   #include &lt;algorithm&gt;
   std::vector&lt;std::string&gt; paramNames;
   std::vector&lt;std::string&gt; setNames;
   std::vector&lt;std::string&gt; varNames;
  
  %}
  %%
  param/(.|\n)+{SYMBOLIC_NAME}             { paramNames.push_back(&amp;yytext[5]);
                                             return PARAM; }
  var/(.|\n)+{SYMBOLIC_NAME}               { varNames.push_back(&amp;yytext[3]);
                                             return VAR; }
  set/(.|\n)+{SYMBOLIC_NAME}               { setNames.push_back(&amp;yytext[3]);
                                             return SET; }
  {SYMBOLIC_NAME}   { if ( std::find(setNames.begin(), setNames.end(), yytext) != setNames.end() ) {
                      yylval.string = (char*) strdup(yytext);
                      return SET_NAME;
                      }
  
                     if ( std::find(paramNames.begin(), paramNames.end(), yytext) != paramNames.end() ){
                      yylval.string = (char*) strdup(yytext);
                      return PARAM_NAME;  
                    }
                    if ( std::find(varNames.begin(), varNames.end(), yytext) != varNames.end() ){
                      yylval.string = (char*) strdup(yytext);
                      return VAR_NAME;  
                    }
                 }
  %%
  </code></pre>
  
  <p>I know it's not going to work because <em>yytext</em> does not contain second part of first three regexps.
  And question appears how can i peek what is under <strong>(.|\n)+{SYMBOLIC_NAME}</strong> .</p>
  
  <p>PS</p>
  
  <p>I know the code is not optimal but it is not an issue here :D</p>