title: How to get entire input string in Lex and Yacc?
body: <p>OK, so here is the deal.</p>
  
  <p>In my language I have some commands, say</p>
  
  <pre><code>XYZ 3 5
  GGB 8 9
  HDH 8783 33
  </code></pre>
  
  <p>And in my Lex file</p>
  
  <pre><code>XYZ { return XYZ; }
  GGB { return GGB; }
  HDH { return HDH; }
  [0-9]+ { yylval.ival = atoi(yytext); return NUMBER; }
  \n  { return EOL; }
  </code></pre>
  
  <p>In my yacc file</p>
  
  <pre><code>start : commands
      ;
  
  commands : command
           | command EOL commands
      ;
  
      command : xyz
              | ggb
              | hdh
      ;
  
      xyz : XYZ NUMBER NUMBER { /* Do something with the numbers */ }
         ;
  
      etc. etc. etc. etc.
  </code></pre>
  
  <p>My question is, how can I get the entire text </p>
  
  <pre><code>XYZ 3 5
  GGB 8 9
  HDH 8783 33
  </code></pre>
  
  <p>Into commands while still returning the NUMBERs?</p>
  
  <p>Also when my Lex returns a STRING [0-9a-zA-Z]+, and I want to do verification on it's length, should I do it like</p>
  
  <pre><code>rule: STRING STRING { if (strlen($1) &lt; 5 ) /* Do some shit else error */ }
  </code></pre>
  
  <p>or actually have a token in my Lex that returns different tokens depending on length?</p>