title: Yacc/Lex: Rejecting symbols not defined
body: <p>I was just wondering whether its possible to make YACC report a syntax error on all symbols not defined in a LEX file.</p>
  
  <p>Eg.</p>
  
  <p>Lex file</p>
  
  <pre><code>/*dummy.l*/
  %{
  #include "dummy.tab.h"
  
  %%
  
  int    return INT;
  [a-z]+ return ID;
  [0-9]+ return NUM;
  
  %%
  </code></pre>
  
  <p>Yacc file</p>
  
  <pre><code>/*dummy.y*/
  %token INT ID NUM
  
  %% 
  var : INT ID "=" NUM ";" 
  %%
  
  int main(void) {
      yyparse();
  }
  </code></pre>
  
  <p>Say I have these 2 files, how do I make it so that my program will report a syntax error when a </p>
  
  <p><strong>$</strong>(dollar symbol) appears in the input.</p>
  
  <p>Eg. It will still accept on input</p>
  
  <blockquote>
    <p>int a = 234; $</p>
  </blockquote>
  
  <p>NOTE: I want to reject all symbols that <strong>ARE NOT</strong> defined</p>