10.12., 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 37fc3f35 authored by di68kap's avatar di68kap

- MLW Fehlerkorrekturen

parent 6dddb659
......@@ -1322,7 +1322,7 @@ class Series(NaryOperator):
i = max(1, text.index(match.regs[1][0])) if match else 1
node = Node(self, text_[:i]).init_pos(self.grammar.document_length__ - len(text_))
node.add_error('%s expected; "%s"... found!'
% (str(parser), text_[:10].replace('\n', '\\n ')),
% (parser.repr, text_[:10].replace('\n', '\\n ')),
code=Error.MANDATORY_CONTINUATION)
text_ = text_[i:]
results += (node,)
......
......@@ -56,7 +56,7 @@ class ParserBase:
self._ptype = ':' + self.__class__.__name__ # type: str
def __repr__(self):
return self.name + self.ptype
return self.name + self.ptype
def __str__(self):
return self.name + (' = ' if self.name else '') + repr(self)
......@@ -78,10 +78,7 @@ class ParserBase:
@property
def repr(self) -> str:
"""Returns the parser's name if it has a name and the parser's
`ptype` otherwise. Note that for named parsers this is not the
same as `repr(parsers)` which always returns the comined name
and ptype, e.g. 'term:OneOrMore'."""
"""Returns the parser's name if it has a name and repr()"""
return self.name if self.name else repr(self)
def reset(self):
......
......@@ -224,7 +224,7 @@ ZEICHENFOLGE = /[\w()-]+/~
TEXTELEMENT = DEU_WORT | SEITENZAHL | ROEMISCHE_ZAHL
EINZEILER = { TEXTELEMENT | TEIL_SATZZEICHEN }+
FREITEXT = { TEXTELEMENT | SATZZEICHEN | GROSSSCHRIFT }+
MEHRZEILER = { FREITEXT | /\s+(?=[\w,;:.\(\)\-])/ }+
MEHRZEILER = { FREITEXT | /\s+(?=[\w,;:.\(\)\-])/ | /\n\s*/ }+
TR = ABS | LZ # (beliebiger) Trenner
ABS = /\s*;;?\s*/ | ZWW # Abschluss (durch Semikolon oder Zeilenwechsel)
......
......@@ -283,7 +283,7 @@ class MLWGrammar(Grammar):
TEXTELEMENT = DEU_WORT | SEITENZAHL | ROEMISCHE_ZAHL
EINZEILER = { TEXTELEMENT | TEIL_SATZZEICHEN }+
FREITEXT = { TEXTELEMENT | SATZZEICHEN | GROSSSCHRIFT }+
MEHRZEILER = { FREITEXT | /\s+(?=[\w,;:.\(\)\-])/ }+
MEHRZEILER = { FREITEXT | /\s+(?=[\w,;:.\(\)\-])/ | /\n\s*/ }+
TR = ABS | LZ # (beliebiger) Trenner
ABS = /\s*;;?\s*/ | ZWW # Abschluss (durch Semikolon oder Zeilenwechsel)
......@@ -322,7 +322,7 @@ class MLWGrammar(Grammar):
flexion = Forward()
genus = Forward()
wortart = Forward()
source_hash__ = "d2ad87ba3c55e5da7b76adfca633e702"
source_hash__ = "c0bebb58c93f0f0986f0383b6ec022ea"
parser_initialization__ = "upon instantiation"
COMMENT__ = r'(?:\/\/.*)|(?:\/\*(?:.|\n)*?\*\/)'
WHITESPACE__ = r'[\t ]*'
......@@ -345,7 +345,7 @@ class MLWGrammar(Grammar):
LZ.set(OneOrMore(Alternative(RegExp(COMMENT__), RegExp('\\s+'))))
ABS = Alternative(RegExp('\\s*;;?\\s*'), ZWW)
TR = Alternative(ABS, LZ)
MEHRZEILER = OneOrMore(Alternative(FREITEXT, RegExp('\\s+(?=[\\w,;:.\\(\\)\\-])')))
MEHRZEILER = OneOrMore(Alternative(FREITEXT, RegExp('\\s+(?=[\\w,;:.\\(\\)\\-])'), RegExp('\\n\\s*')))
FREITEXT.set(OneOrMore(Alternative(TEXTELEMENT, SATZZEICHEN, GROSSSCHRIFT)))
EINZEILER = OneOrMore(Alternative(TEXTELEMENT, TEIL_SATZZEICHEN))
TEXTELEMENT.set(Alternative(DEU_WORT, SEITENZAHL, ROEMISCHE_ZAHL))
......@@ -885,6 +885,7 @@ if __name__ == "__main__":
rel_path = file_name[len(cwd):] if file_name.startswith(cwd) else file_name
for error in errors:
print(rel_path + ':' + str(error))
print('\nLeider hat es ein paar Fehler gegeben :-(\n')
sys.exit(1)
else:
out_name = file_name[:-4] + '.html'
......@@ -893,6 +894,6 @@ if __name__ == "__main__":
f.write(result.as_xml())
f.write(HTML_LEAD_OUT)
webbrowser.open(out_name)
print("ready.")
print("Das Einlesen war erfolgreich :-)")
else:
print("Usage: MLWCompiler.py [--debug] FILENAME")
print("Aufruf: MLWCompiler.py [--debug] FILENAME")
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