1
我正在使用PLY解析文件。當我在一條線上發生錯誤時,我必須向用戶打印一條消息。PLY lex yacc:處理錯誤
類似Error at the line 4
的消息。
def p_error(p):
flag_for_error = 1
print ("Erreur de syntaxe sur la ligne %d" % (p.lineno))
yacc.errok()
但它不工作。我有錯誤
print ("Erreur de syntaxe sur la ligne %d" % (p.lineno))
AttributeError: 'NoneType' object has no attribute 'lineno'
有沒有另一種更合適的方法來做到這一點?
我那麼幾天前,但它不工作。解析器無限期地執行else語句。 – dimele
我解決了這個問題。 – dimele