Commit a3f78cab authored by di68kap's avatar di68kap

- bugfix: configured error messages and resume directives are now case-sensitive!

parent b0022ee9
......@@ -721,7 +721,7 @@ class EBNFCompiler(Compiler):
def on_directive(self, node: Node) -> str:
key = node.children[0].content.lower()
key = node.children[0].content
assert key not in self.directives['tokens']
if key not in self.REPEATABLE_DIRECTIVES:
......
......@@ -57,7 +57,7 @@ class LaTeXGrammar(Grammar):
paragraph = Forward()
tabular_config = Forward()
text_element = Forward()
source_hash__ = "79e85f223d89452f2ba796f9c40daac9"
source_hash__ = "e09808ecd485c07b3455c3a2bf4eada3"
parser_initialization__ = "upon instantiation"
resume_rules__ = {}
COMMENT__ = r'%.*'
......
......@@ -491,6 +491,24 @@ class TestCuratedErrors:
assert st.collect_errors()[0].code == Error.MANDATORY_CONTINUATION
assert st.collect_errors()[0].message == "a user defined error message"
def test_curated_error_message_case_sensitive(self):
lang = """
document = Series | /.*/
@Series_error = "a user defined error message"
Series = "X" | head §"C" "D"
head = "A" "B"
"""
# from DHParser.dsl import compileDSL
# from DHParser.preprocess import nil_preprocessor
# from DHParser.ebnf import get_ebnf_grammar, get_ebnf_transformer, get_ebnf_compiler
# grammar_src = compileDSL(lang, nil_preprocessor, get_ebnf_grammar(),
# get_ebnf_transformer(), get_ebnf_compiler("test", lang))
# print(grammar_src)
parser = grammar_provider(lang)()
st = parser("ABC_"); assert st.error_flag
assert st.collect_errors()[0].code == Error.MANDATORY_CONTINUATION
assert st.collect_errors()[0].message == "a user defined error message"
class TestCustomizedResumeParsing:
def setup(self):
......
Markdown is supported
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