Commit df506660 authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

some small amendmends

parent c75f9148
...@@ -471,19 +471,18 @@ class ParserHeadquarter: ...@@ -471,19 +471,18 @@ class ParserHeadquarter:
return return
cdict = cls.__dict__ cdict = cls.__dict__
for entry in cdict: for entry in cdict:
if sane_parser_name(entry): if sane_parser_name(entry): # implies isinstance(parser, Parser) qua convention
parser = cdict[entry] parser = cdict[entry]
if isinstance(parser, Parser): assert isinstance(parser, Parser)
# print(type(parser), parser.name, entry) if isinstance(parser, Forward):
if isinstance(parser, Forward): assert not parser.name or parser.name == entry
assert not parser.name or parser.name == entry if parser.name and parser.name != entry:
if parser.name and parser.name != entry: raise ValueError(("Parser named %s should not be "
raise ValueError(("Parser named %s should not be " " assigned to field with different name: %s"
" assigned to field with different name: %s" % (parser.name, entry)))
% (parser.name, entry))) parser.parser.name = entry
parser.parser.name = entry else:
else: parser.name = entry
parser.name = entry
cls.parser_initialization__ = "done" cls.parser_initialization__ = "done"
def __init__(self): def __init__(self):
...@@ -500,7 +499,9 @@ class ParserHeadquarter: ...@@ -500,7 +499,9 @@ class ParserHeadquarter:
"""Adds the copy of the parser object to this instance of ParserHeadquarter. """Adds the copy of the parser object to this instance of ParserHeadquarter.
""" """
# print(parser.name) # print(parser.name)
if sane_parser_name(parser.name): # overwrite class variable with instance variable if sane_parser_name(parser.name): # implies isinstance(parser, Parser) qua convention
assert isinstance(parser, Parser)
# overwrite class variable with instance variable!!!
setattr(self, parser.name, parser) setattr(self, parser.name, parser)
parser.headquarter = self parser.headquarter = self
...@@ -661,7 +662,7 @@ class RegExp(Parser): ...@@ -661,7 +662,7 @@ class RegExp(Parser):
class RE(Parser): class RE(Parser):
def __init__(self, regexp, wL='', wR='', name=None): def __init__(self, regexp, wL=None, wR=None, name=None):
super(RE, self).__init__(name) super(RE, self).__init__(name)
self.wL = RegExp(wL, WHITESPACE_KEYWORD) if wL else '' self.wL = RegExp(wL, WHITESPACE_KEYWORD) if wL else ''
self.wR = RegExp(wR, WHITESPACE_KEYWORD) if wR else '' self.wR = RegExp(wR, WHITESPACE_KEYWORD) if wR else ''
......
...@@ -100,7 +100,7 @@ class MLWGrammar(ParserHeadquarter): ...@@ -100,7 +100,7 @@ class MLWGrammar(ParserHeadquarter):
DATEI_ENDE = !/./ DATEI_ENDE = !/./
NIEMALS = /(?!.)/ NIEMALS = /(?!.)/
""" """
source_hash__ = "7a55cb4440d934ce0300c8610a3b4c33" source_hash__ = "460019891fffc4dbf8d8e8573f5f699c"
parser_initialization__ = "upon instatiation" parser_initialization__ = "upon instatiation"
wsp__ = mixin_comment(whitespace=r'\s*', comment=r'#.*(?:\n|$)') wsp__ = mixin_comment(whitespace=r'\s*', comment=r'#.*(?:\n|$)')
NIEMALS = RE('(?!.)') NIEMALS = RE('(?!.)')
...@@ -112,37 +112,37 @@ class MLWGrammar(ParserHeadquarter): ...@@ -112,37 +112,37 @@ class MLWGrammar(ParserHeadquarter):
WORT_GROSS = RE('[A-ZÄÖÜ][a-zäöüß]+', wR=wsp__) WORT_GROSS = RE('[A-ZÄÖÜ][a-zäöüß]+', wR=wsp__)
WORT = RE('[A-ZÄÖÜ]?[a-zäöüß]+', wR=wsp__) WORT = RE('[A-ZÄÖÜ]?[a-zäöüß]+', wR=wsp__)
Name = Sequence(WORT, ZeroOrMore(Alternative(WORT, RE('[A-ZÄÖÜÁÀ]\\.')))) Name = Sequence(WORT, ZeroOrMore(Alternative(WORT, RE('[A-ZÄÖÜÁÀ]\\.'))))
Autorinfo = Sequence(Alternative(Token("AUTORIN", wR=wsp__, wL=wsp__), Token("AUTOR", wR=wsp__, wL=wsp__)), Name) Autorinfo = Sequence(Alternative(Token("AUTORIN", wL=wsp__, wR=wsp__), Token("AUTOR", wL=wsp__, wR=wsp__)), Name)
Zusatz = Sequence(Token("ZUSATZ", wR=wsp__, wL=wsp__), RE('\\s?.*')) Zusatz = Sequence(Token("ZUSATZ", wL=wsp__, wR=wsp__), RE('\\s?.*'))
EinBeleg = Sequence(OneOrMore(Sequence(NegativeLookahead(Sequence(RE('\\s*'), Alternative(Token("*", wR=wsp__, wL=wsp__), Token("BEDEUTUNG", wR=wsp__, wL=wsp__), Token("AUTOR", wR=wsp__, wL=wsp__), Token("NAME", wR=wsp__, wL=wsp__), Token("ZUSATZ", wR=wsp__, wL=wsp__)))), RE('\\s?.*'))), Optional(Zusatz)) EinBeleg = Sequence(OneOrMore(Sequence(NegativeLookahead(Sequence(RE('\\s*'), Alternative(Token("*", wL=wsp__, wR=wsp__), Token("BEDEUTUNG", wL=wsp__, wR=wsp__), Token("AUTOR", wL=wsp__, wR=wsp__), Token("NAME", wL=wsp__, wR=wsp__), Token("ZUSATZ", wL=wsp__, wR=wsp__)))), RE('\\s?.*'))), Optional(Zusatz))
Belege = Sequence(Token("BELEGE", wR=wsp__, wL=wsp__), ZeroOrMore(Sequence(Token("*", wR=wsp__, wL=wsp__), EinBeleg))) Belege = Sequence(Token("BELEGE", wL=wsp__, wR=wsp__), ZeroOrMore(Sequence(Token("*", wL=wsp__, wR=wsp__), EinBeleg)))
DeutscheBedeutung = Sequence(Token("DEU", wR=wsp__, wL=wsp__), RE('(?:(?![A-ZÄÖÜ][A-ZÄÖÜ]).)+', wR=wsp__)) DeutscheBedeutung = Sequence(Token("DEU", wL=wsp__, wR=wsp__), RE('(?:(?![A-ZÄÖÜ][A-ZÄÖÜ]).)+', wR=wsp__))
LateinischeBedeutung = Sequence(Token("LAT", wR=wsp__, wL=wsp__), RE('(?:(?![A-ZÄÖÜ][A-ZÄÖÜ]).)+', wR=wsp__)) LateinischeBedeutung = Sequence(Token("LAT", wL=wsp__, wR=wsp__), RE('(?:(?![A-ZÄÖÜ][A-ZÄÖÜ]).)+', wR=wsp__))
Interpretamente = Sequence(LateinischeBedeutung, DeutscheBedeutung, Optional(Belege)) Interpretamente = Sequence(LateinischeBedeutung, DeutscheBedeutung, Optional(Belege))
Bedeutungskategorie = RE('(?:(?![A-ZÄÖÜ][A-ZÄÖÜ]).)+', wR=wsp__) Bedeutungskategorie = RE('(?:(?![A-ZÄÖÜ][A-ZÄÖÜ]).)+', wR=wsp__)
Bedeutung = Alternative(Interpretamente, Bedeutungskategorie) Bedeutung = Alternative(Interpretamente, Bedeutungskategorie)
BedeutungsPosition = OneOrMore(Sequence(Token("BEDEUTUNG", wR=wsp__, wL=wsp__), Bedeutung)) BedeutungsPosition = OneOrMore(Sequence(Token("BEDEUTUNG", wL=wsp__, wR=wsp__), Bedeutung))
VerweisZiel = RE('<\\w+>', wR=wsp__, wL=wsp__) VerweisZiel = RE('<\\w+>', wR=wsp__, wL=wsp__)
Verweis = RE('>>\\w+', wR=wsp__, wL=wsp__) Verweis = RE('>>\\w+', wR=wsp__, wL=wsp__)
Beleg = Verweis Beleg = Verweis
Schreibweise = Alternative(Token("vizreg-", wR=wsp__, wL=wsp__), Token("festregel(a)", wR=wsp__, wL=wsp__), Token("fezdregl(a)", wR=wsp__, wL=wsp__), Token("fat-", wR=wsp__, wL=wsp__)) Schreibweise = Alternative(Token("vizreg-", wL=wsp__, wR=wsp__), Token("festregel(a)", wL=wsp__, wR=wsp__), Token("fezdregl(a)", wL=wsp__, wR=wsp__), Token("fat-", wL=wsp__, wR=wsp__))
SWVariante = Sequence(Schreibweise, Token(":", wR=wsp__, wL=wsp__), Beleg) SWVariante = Sequence(Schreibweise, Token(":", wL=wsp__, wR=wsp__), Beleg)
SWTyp = Alternative(Token("script.", wR=wsp__, wL=wsp__), Token("script. fat-", wR=wsp__, wL=wsp__)) SWTyp = Alternative(Token("script.", wL=wsp__, wR=wsp__), Token("script. fat-", wL=wsp__, wR=wsp__))
SchreibweisenPosition = Sequence(Token("SCHREIBWEISE", wR=wsp__, wL=wsp__), Required(SWTyp), Token(":", wR=wsp__, wL=wsp__), Required(SWVariante), ZeroOrMore(Sequence(Token(",", wR=wsp__, wL=wsp__), Required(SWVariante)))) SchreibweisenPosition = Sequence(Token("SCHREIBWEISE", wL=wsp__, wR=wsp__), Required(SWTyp), Token(":", wL=wsp__, wR=wsp__), Required(SWVariante), ZeroOrMore(Sequence(Token(",", wL=wsp__, wR=wsp__), Required(SWVariante))))
ArtikelKopf = SchreibweisenPosition ArtikelKopf = SchreibweisenPosition
_genus = Alternative(Token("maskulinum", wR=wsp__, wL=wsp__), Token("m.", wR=wsp__, wL=wsp__), Token("femininum", wR=wsp__, wL=wsp__), Token("f.", wR=wsp__, wL=wsp__), Token("neutrum", wR=wsp__, wL=wsp__), Token("n.", wR=wsp__, wL=wsp__)) _genus = Alternative(Token("maskulinum", wL=wsp__, wR=wsp__), Token("m.", wL=wsp__, wR=wsp__), Token("femininum", wL=wsp__, wR=wsp__), Token("f.", wL=wsp__, wR=wsp__), Token("neutrum", wL=wsp__, wR=wsp__), Token("n.", wL=wsp__, wR=wsp__))
Flexion = RE('-?[a-z]+', wR=wsp__) Flexion = RE('-?[a-z]+', wR=wsp__)
Flexionen = Sequence(Flexion, ZeroOrMore(Sequence(Token(",", wR=wsp__, wL=wsp__), Required(Flexion)))) Flexionen = Sequence(Flexion, ZeroOrMore(Sequence(Token(",", wL=wsp__, wR=wsp__), Required(Flexion))))
GVariante = Sequence(Flexionen, Optional(_genus), Token(":", wR=wsp__, wL=wsp__), Beleg) GVariante = Sequence(Flexionen, Optional(_genus), Token(":", wL=wsp__, wR=wsp__), Beleg)
GrammatikVarianten = Sequence(Token(";", wR=wsp__, wL=wsp__), Required(GVariante)) GrammatikVarianten = Sequence(Token(";", wL=wsp__, wR=wsp__), Required(GVariante))
_wortart = Alternative(Token("nomen", wR=wsp__, wL=wsp__), Token("n.", wR=wsp__, wL=wsp__), Token("verb", wR=wsp__, wL=wsp__), Token("v.", wR=wsp__, wL=wsp__), Token("adverb", wR=wsp__, wL=wsp__), Token("adv.", wR=wsp__, wL=wsp__), Token("adjektiv", wR=wsp__, wL=wsp__), Token("adj.", wR=wsp__, wL=wsp__)) _wortart = Alternative(Token("nomen", wL=wsp__, wR=wsp__), Token("n.", wL=wsp__, wR=wsp__), Token("verb", wL=wsp__, wR=wsp__), Token("v.", wL=wsp__, wR=wsp__), Token("adverb", wL=wsp__, wR=wsp__), Token("adv.", wL=wsp__, wR=wsp__), Token("adjektiv", wL=wsp__, wR=wsp__), Token("adj.", wL=wsp__, wR=wsp__))
GrammatikPosition = Sequence(Token("GRAMMATIK", wR=wsp__, wL=wsp__), Required(_wortart), Required(Token(";", wR=wsp__, wL=wsp__)), Required(Flexionen), Optional(_genus), ZeroOrMore(GrammatikVarianten), Optional(Alternative(Token(";", wR=wsp__, wL=wsp__), Token(".", wR=wsp__, wL=wsp__)))) GrammatikPosition = Sequence(Token("GRAMMATIK", wL=wsp__, wR=wsp__), Required(_wortart), Required(Token(";", wL=wsp__, wR=wsp__)), Required(Flexionen), Optional(_genus), ZeroOrMore(GrammatikVarianten), Optional(Alternative(Token(";", wL=wsp__, wR=wsp__), Token(".", wL=wsp__, wR=wsp__))))
LVZusatz = Token("sim.", wR=wsp__, wL=wsp__) LVZusatz = Token("sim.", wL=wsp__, wR=wsp__)
LVariante = RE('(?:[a-z]|-)+', wR=wsp__, wL=wsp__) LVariante = RE('(?:[a-z]|-)+', wR=wsp__, wL=wsp__)
LemmaVarianten = Sequence(Token("VARIANTEN", wR=wsp__, wL=wsp__), Required(LVariante), ZeroOrMore(Sequence(Token(",", wR=wsp__, wL=wsp__), Required(LVariante))), Optional(Sequence(Token(";", wR=wsp__, wL=wsp__), Required(LVZusatz)))) LemmaVarianten = Sequence(Token("VARIANTEN", wL=wsp__, wR=wsp__), Required(LVariante), ZeroOrMore(Sequence(Token(",", wL=wsp__, wR=wsp__), Required(LVariante))), Optional(Sequence(Token(";", wL=wsp__, wR=wsp__), Required(LVZusatz))))
_tll = Token("*", wR=wsp__, wL=wsp__) _tll = Token("*", wL=wsp__, wR=wsp__)
Lemma = Sequence(Optional(_tll), WORT_KLEIN) Lemma = Sequence(Optional(_tll), WORT_KLEIN)
LemmaPosition = Sequence(Token("LEMMA", wR=wsp__, wL=wsp__), Required(Lemma), Optional(LemmaVarianten), Required(GrammatikPosition)) LemmaPosition = Sequence(Token("LEMMA", wL=wsp__, wR=wsp__), Required(Lemma), Optional(LemmaVarianten), Required(GrammatikPosition))
Artikel = Sequence(Optional(LEER), Required(LemmaPosition), Optional(ArtikelKopf), Required(BedeutungsPosition), Required(Autorinfo), Optional(LEER), DATEI_ENDE) Artikel = Sequence(Optional(LEER), Required(LemmaPosition), Optional(ArtikelKopf), Required(BedeutungsPosition), Required(Autorinfo), Optional(LEER), DATEI_ENDE)
root__ = Artikel root__ = Artikel
......
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