mirror of https://github.com/lark-parser/lark.git
Fixed examples for error reporting
This commit is contained in:
parent
d11c67fea0
commit
e7212261b2
|
@ -60,14 +60,14 @@ def parse(json_text):
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
try:
|
try:
|
||||||
parse('{"key": "value"')
|
parse('{"example1": "value"')
|
||||||
except JsonMissingClosing:
|
except JsonMissingClosing as e:
|
||||||
pass
|
print(e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
parse('{"key": ] ')
|
parse('{"example2": ] ')
|
||||||
except JsonMissingOpening:
|
except JsonMissingOpening as e:
|
||||||
pass
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -13,7 +13,7 @@ class LexError(LarkError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class UnexpectedInput(LarkError):
|
class UnexpectedInput(LarkError):
|
||||||
def get_context(self, text, span=10):
|
def get_context(self, text, span=40):
|
||||||
pos = self.pos_in_stream
|
pos = self.pos_in_stream
|
||||||
start = max(pos - span, 0)
|
start = max(pos - span, 0)
|
||||||
end = pos + span
|
end = pos + span
|
||||||
|
|
Loading…
Reference in New Issue