소스 검색

Merge branch 'fix-888' of https://github.com/MegaIng/lark into MegaIng-fix-888

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.12.0
Erez Sh 3 년 전
부모
커밋
0ad4e8a177
2개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. +3
    -0
      lark/load_grammar.py
  2. +4
    -0
      tests/test_grammar.py

+ 3
- 0
lark/load_grammar.py 파일 보기

@@ -448,6 +448,9 @@ def _literal_to_pattern(literal):

s = eval_escaping(x)

if s == "":
raise GrammarError("Can't have empty terminals (offending literal: %s)" % literal.value)

if literal.type == 'STRING':
s = s.replace('\\\\', '\\')
return PatternStr(s, flags, raw=literal.value)


+ 4
- 0
tests/test_grammar.py 파일 보기

@@ -22,6 +22,10 @@ class TestGrammar(TestCase):
else:
assert False, "example did not raise an error"

def test_empty_literal(self):
# Issues #888
self.assertRaises(GrammarError, Lark, "start: \"\"")

def test_override_rule(self):
# Overrides the 'sep' template in existing grammar to add an optional terminating delimiter
# Thus extending it beyond its original capacity


불러오는 중...
취소
저장