瀏覽代碼

Make `UnexpectedCharacters` print the repr

This is an additional response to #738.

I also often came across this when unexpectedly having a newline, which would previously result in the message being split up across two lines. This PR makes it easier to identify exactly which special character is causing problems.
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.0
MegaIng 3 年之前
committed by GitHub
父節點
當前提交
633a6dfee8
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. +1
    -1
      lark/exceptions.py

+ 1
- 1
lark/exceptions.py 查看文件

@@ -130,7 +130,7 @@ class UnexpectedCharacters(LexError, UnexpectedInput):
else:
_s = seq[lex_pos]

message = "No terminal defined for '%s' at line %d col %d" % (_s, line, column)
message = "No terminal defined for %r at line %d col %d" % (_s, line, column)
message += '\n\n' + self.get_context(seq)
if allowed:
message += '\nExpecting: %s\n' % allowed


Loading…
取消
儲存