title: Python Lex-Yacc reports "Infinite recursion detected for symbol"
body: <p>I have a lot of error using PLY. The error happens when I try to add this to the code:</p>
  
  <pre><code>def p_assign(p):
     '''assign : NAME EQUALS expr'''
      p[0] = ('ASSIGN',p[1],p[3])
  def p_expr_plus(p):
      '''expr : expr PLUS term'''
      p[0] = ('+',p[1],p[3])
  def p_term_mul(p):
      '''term : term TIMES factor'''
      p[0] = ('*',p[1],p[3])
  def p_term_factor(p):
      '''term : factor'''
      p[0] = p[1]
  def p_factor(p):
      '''factor : NUMBER'''
      p[0] = ('NUM',p[1])
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre><code>ERROR: C:\Users\-user-\Desktop\dw_parser.py:9: Symbol 'EQUALS' used, but not defined as a token or a rule
  WARNING: Token 'COLON' defined, but not used
  WARNING: Token 'DIVIDE' defined, but not used
  WARNING: Token 'EQUAL' defined, but not used
  WARNING: Token 'EQUAL_TO' defined, but not used
  WARNING: Token 'GREATER' defined, but not used
  WARNING: Token 'GREATER_EQL' defined, but not used
  WARNING: Token 'LESS' defined, but not used
  WARNING: Token 'LESS_EQL' defined, but not used
  WARNING: Token 'LPAREN' defined, but not used
  WARNING: Token 'MINUS' defined, but not used
  WARNING: Token 'QUOTATION' defined, but not used
  WARNING: Token 'REMAINDER' defined, but not used
  WARNING: Token 'RPAREN' defined, but not used
  WARNING: Token 'SEMICOLON' defined, but not used
  WARNING: Token 'STRING' defined, but not used
  WARNING: There are 15 unused tokens
  ERROR: Infinite recursion detected for symbol 'assign'
  ERROR: Infinite recursion detected for symbol 'expr'
  Traceback (most recent call last):
    File "C:\Users\-user-\Desktop\dw_parser.py", line 35, in &lt;module&gt;
      parser = yacc.yacc()
    File "C:\Program Files\Python37\lib\site-packages\ply-3.11-py3.7.egg\ply\yacc.py", line 3432, in yacc
      raise YaccError('Unable to build parser')
  ply.yacc.YaccError: Unable to build parser
  </code></pre>
  
  <p>There is the full parser code: <a href="https://pastebin.com/bPrwDQEK" rel="nofollow noreferrer">https://pastebin.com/bPrwDQEK</a>
  I can't put the parser code directly here, because code sample doesn't works too.</p>