Commit 64c305e5 authored by di68kap's avatar di68kap
Browse files

test_toolkit.py: better issybtype test

parent 3c8cd9e9
......@@ -1272,8 +1272,8 @@ class Grammar:
stitches.append(Node(ZOMBIE_TAG, rest))
result = Node(ZOMBIE_TAG, tuple(stitches)).with_pos(0)
if any(self.variables__.values()):
error_msg = "Capture-retrieve-stack not empty after end of parsing: " \
+ str(self.variables__)
error_msg = "Capture-stack not empty after end of parsing: " \
+ ', '.join(k for k, i in self.variables__.items() if len(i) >= 1)
error_code = Error.CAPTURE_STACK_NOT_EMPTY
if result:
if result.children:
......
......@@ -431,7 +431,6 @@ def has_fenced_code(text_or_file: str, info_strings=('ebnf', 'test')) -> bool:
See http://spec.commonmark.org/0.28/#fenced-code-blocks for more
information on fenced code blocks in common mark documents.
"""
if is_filename(text_or_file):
with open(text_or_file, 'r', encoding='utf-8') as f:
markdown = f.read()
......
......@@ -34,7 +34,8 @@ from DHParser.parse import ParserError, Parser, Grammar, Forward, TKN, ZeroOrMor
RegExp, Lookbehind, NegativeLookahead, OneOrMore, Series, Alternative, AllOf, SomeOf, \
Interleave, UnknownParserError, MetaParser, Token, EMPTY_NODE
from DHParser import compile_source
from DHParser.ebnf import get_ebnf_grammar, get_ebnf_transformer, get_ebnf_compiler, DHPARSER_IMPORTS
from DHParser.ebnf import get_ebnf_grammar, get_ebnf_transformer, get_ebnf_compiler, \
compile_ebnf, DHPARSER_IMPORTS
from DHParser.dsl import grammar_provider
from DHParser.syntaxtree import Node, parse_sxpr
from DHParser.stringview import StringView
......@@ -775,16 +776,20 @@ class TestPopRetrieve:
log_ST(syntax_tree, "test_PopRetrieve_multi_line.cst")
def test_autoretrieve(self):
lang = """
document = { definition }
lang = r"""
document = { definition } § EOF
definition = symbol :defsign value
symbol = /\w+/~
defsign = "=" | ":="
value = /\d+/~
EOF = !/./ :?defsign # eat up captured defsign
"""
code, _, _ = compile_ebnf(lang)
print(code)
parser = grammar_provider(lang)()
st = parser("X := 1")
print(st.as_sxpr())
print('>>> ', parser["defsign"].parser)
# st = parser("X := 1")
# print(st.as_sxpr())
class TestWhitespaceHandling:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment