Commit 59addaa1 authored by di68kap's avatar di68kap
Browse files

- Hervorhebung (sprich: Invertierung der Kursivierung) jetzt auch im Artikelkopf

parent 5f022b77
......@@ -449,7 +449,7 @@ class EBNFDirectives:
setattr(self, key, value)
def keys(self):
return self.__dict__.keys()
return self.__slots__
class EBNFCompilerError(CompilerError):
......
......@@ -192,6 +192,11 @@ class Parser:
contained parser is repeated zero times.
Attributes and Properties:
pname: The parser name or the empty string in case the parser
remains anonymous.
tag_name: The tag_name for the nodes that are created by
the parser. If the parser is named, this is the same as
`pname`, otherwise it is the name of the parser's type.
visited: Mapping of places this parser has already been to
during the current parsing process onto the results the
parser returned at the respective place. This dictionary
......@@ -1696,7 +1701,13 @@ def mandatory_violation(grammar: Grammar,
location, Error.MALFORMED_ERROR_STRING)
grammar.tree__.add_error(err_node, error)
else:
msg = '%s expected, »%s« found!' % (expected, found)
if grammar.history_tracking__:
for pname, _ in reversed(grammar.call_stack__):
if not pname.startswith(':'):
break
msg = '%s expected by parser %s, »%s« found!' % (expected, pname, found)
else:
msg = '%s expected, »%s« found!' % (expected, found)
error = Error(msg, location, Error.MANDATORY_CONTINUATION_AT_EOF
if (failed_on_lookahead and not text_) else Error.MANDATORY_CONTINUATION)
grammar.tree__.add_error(err_node, error)
......
......@@ -27,14 +27,13 @@ from multiprocessing import Pool
scriptpath = os.path.dirname(__file__) or '.'
sys.path.append(os.path.abspath(os.path.join(scriptpath, '..')))
from DHParser.configuration import get_config_value, set_config_value
from DHParser.toolkit import compile_python_object, re
from DHParser.preprocess import nil_preprocessor
from DHParser import compile_source
from DHParser.error import has_errors, Error
from DHParser.syntaxtree import WHITESPACE_PTYPE
from DHParser.ebnf import get_ebnf_grammar, get_ebnf_transformer, EBNFTransform, \
get_ebnf_compiler, compile_ebnf, DHPARSER_IMPORTS
EBNFDirectives, get_ebnf_compiler, compile_ebnf, DHPARSER_IMPORTS
from DHParser.dsl import CompilationError, compileDSL, grammar_provider
from DHParser.testing import grammar_unit, clean_report
......@@ -48,6 +47,17 @@ class TestDirectives:
digit = /0/ | /1/ | /2/ | /3/ | /4/ | /5/ | /6/ | /7/ | /8/ | /9/
"""
def test_EBNFDirectives_object(self):
directives = EBNFDirectives()
assert directives.keys()
directives.tokens.add('Test')
assert 'Test' in directives.tokens
try:
directives.nonsense = 'nonsense'
assert False, 'Attribute error expected for illegal directive "nonsense"'
except AttributeError:
pass
def test_whitespace_linefeed(self):
lang = "@ whitespace = linefeed\n" + self.mini_language
MinilangParser = grammar_provider(lang)
......
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