Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def p_error(p):
if p:
print("Line %d: Syntax error at '%s'" % (p.lineno, p.value))
# Scan ahead looking for a name token
while True:
tok = yacc.token()
if not tok or tok.type == 'RPAREN':
break
if tok:
yacc.restart()
return None
def p_error(t):
if tag_stack[0] != []:
print "HTML Syntax Error: <" + tag_stack[0][0] + "> on line " + str(tag_stack[0][1]) + " never closed"
else:
tok = yacc.token()
print "HTML Syntax Error: Near Token " + str(tok)
exit(1)
if p is None:
print "Syntax error: unexpected EOF"
else: #remember to subtract 1 from line number since we had a newline at the start of the file
print "Syntax error at line {}: unexpected token {!r}".format(p.lineno-1, p.value)
#Ugly hack since Ply doesn't provide any useful error information
import inspect
frame = inspect.currentframe()
cvars = frame.f_back.f_locals
print 'Expected:', ', '.join(cvars['actions'][cvars['state']].keys())
print 'Found:', cvars['ltype']
print 'Current stack:', cvars['symstack']
#Discard the rest of the input so that Ply doesn't attempt error recovery
from ply import yacc
tok = yacc.token()
while tok is not None:
tok = yacc.token()
def p_error(p):
msg = []
w = msg.append
w('%r\n' % p)
w('followed by:\n')
for i in range(5):
n = yacc.token()
if not n:
break
w(' %r\n' % n)
raise sherrors.ShellSyntaxError(''.join(msg))
def p_error(p):
msg = []
w = msg.append
w('%r\n' % p)
w('followed by:\n')
for i in range(5):
n = yacc.token()
if not n:
break
w(' %r\n' % n)
raise sherrors.ShellSyntaxError(''.join(msg))
def p_error(p):
msg = []
w = msg.append
w('%r\n' % p)
w('followed by:\n')
for i in range(5):
n = yacc.token()
if not n:
break
w(' %r\n' % n)
raise sherrors.ShellSyntaxError(''.join(msg))
def p_error(p):
msg = []
w = msg.append
w('%r\n' % p)
w('followed by:\n')
for i in range(5):
n = yacc.token()
if not n:
break
w(' %r\n' % n)
raise sherrors.ShellSyntaxError(''.join(msg))
def p_error(p):
msg = []
w = msg.append
w('%r\n' % p)
w('followed by:\n')
for i in range(5):
n = yacc.token()
if not n:
break
w(' %r\n' % n)
raise sherrors.ShellSyntaxError(''.join(msg))
def p_error(p):
"""."""
next_token = yacc.token()
if next_token is None:
use_token = 'EOF'
else:
use_token = repr(next_token.value)
if p:
raise ParseError(' ERROR on "%s" (type %s, line %d, Next %s)'
% (p.value, p.type, p.lineno, use_token))
else:
raise ParseError(' ERROR you likely have unablanaced "{"\'s')