Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
badw-it
DHParser
Commits
a3f78cab
Commit
a3f78cab
authored
Jan 07, 2019
by
di68kap
Browse files
- bugfix: configured error messages and resume directives are now case-sensitive!
parent
b0022ee9
Changes
3
Hide whitespace changes
Inline
Side-by-side
DHParser/ebnf.py
View file @
a3f78cab
...
...
@@ -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
:
...
...
examples/LaTeX/LaTeXCompiler.py
View file @
a3f78cab
...
...
@@ -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
'%.*'
...
...
test/test_ebnf.py
View file @
a3f78cab
...
...
@@ -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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment