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

sync-commit: work on MLW...

parent 82e16eb0
......@@ -1150,26 +1150,18 @@ def flatten(node):
node.result = tuple(new_result)
def remove_tokens(node, tokens):
def remove_tokens(node, tokens={}):
"""Reomoves any among a particular set of tokens from the immediate
descendants of a node.
"""
if node.children:
node.result = tuple(child for child in node.result
if child.parser.name != TOKEN_KEYWORD or
child.result not in tokens)
def remove_all_tokens(node):
"""Removes all tokens from the immediate descendants of a node.
:param node: the node from which children that represent tokens
shall be removed
:return: the node with all children that are tokens removed
"""
if node.children:
node.result = tuple(child for child in node.result
if child.parser.name != TOKEN_KEYWORD)
if tokens:
node.result = tuple(child for child in node.result
if child.parser.name != TOKEN_KEYWORD or
child.result not in tokens)
else:
node.result = tuple(child for child in node.result
if child.parser.name != TOKEN_KEYWORD)
def remove_enclosing_delimiters(node):
......
......@@ -100,7 +100,7 @@ class MLWGrammar(ParserHeadquarter):
DATEI_ENDE = !/./
NIEMALS = /(?!.)/
"""
source_hash__ = "d7afa7bb0037ee25c0cabfa6e5a956c6"
source_hash__ = "2c3456ee74172407cbe1f15e3649b41f"
parser_initialization__ = "upon instatiation"
wsp__ = mixin_comment(whitespace=r'\s*', comment=r'#.*(?:\n|$)')
wspL__ = wsp__
......@@ -151,17 +151,26 @@ class MLWGrammar(ParserHeadquarter):
### DON'T EDIT OR REMOVE THIS LINE ###
def test(node):
if node.parser.name == "WORT_KLEIN":
assert False, node.as_sexpr()
node = remove_expendables(node)
node = reduce_single_child(node)
assert False, node.parser.name
return node
def test(node):
print(node.as_sexpr())
return node
def join_strings(node, delimiter='\n'):
new_result = []
n = 0
while n < len(node.result):
nd = node.result[n]
if not nd.children:
a = n
n += 1
while n < len(node.result) and not node.result[n].children:
n += 1
nd.result = delimiter.join((r.result for r in node.result[a:n]))
new_result.append(nd)
node.result = tuple(new_result)
print(node.as_sexpr())
MLWTransTable = {
# AST Transformations for the MLW-grammar
......@@ -174,7 +183,7 @@ MLWTransTable = {
"LemmaVarianten":
[partial(remove_tokens, tokens={'VARIANTEN'}), flatten,
partial(remove_tokens, tokens={',', ';'})],
"LVariante, LVZusatz, Schreibweise":
"LVariante, LVZusatz, Schreibweise, Name":
[remove_expendables, reduce_single_child],
"SWVariante":
[remove_expendables, partial(remove_tokens, tokens={':'})],
......@@ -197,10 +206,12 @@ MLWTransTable = {
"Bedeutung": no_transformation,
"Bedeutungskategorie": no_transformation,
"Interpretamente": no_transformation,
"LateinischeBedeutung": no_transformation,
"DeutscheBedeutung": no_transformation,
"Belege": no_transformation,
"EinBeleg": no_transformation,
"LateinischeBedeutung, DeutscheBedeutung":
[remove_expendables, remove_tokens, reduce_single_child],
"Belege":
[flatten, remove_tokens],
"EinBeleg":
[flatten], # remove_expendables], # join_strings],
"Beleg": no_transformation,
"VerweisZiel": no_transformation,
"WORT, WORT_KLEIN, WORT_GROSS, GROSSSCHRIFT":
......
......@@ -21,7 +21,7 @@ limitations under the License.
import os
import sys
sys.path.append(os.path.abspath('../'))
sys.path.append(os.path.abspath('../../'))
from ParserCombinators import run_compiler
errors = run_compiler("MLW.ebnf")
if errors:
......
......@@ -21,7 +21,7 @@ limitations under the License.
import os
import sys
sys.path.append(os.path.abspath('../'))
sys.path.append(os.path.abspath('../../../'))
import ParserCombinators
from ParserCombinators import run_compiler, has_source_changed
......
......@@ -110,103 +110,63 @@
<Bedeutung>
<Interpretamente>
<LateinischeBedeutung>
<token__>
LAT
</token__>
<RegExp>
pannus, faciale, sudarium
</RegExp>
pannus, faciale, sudarium
</LateinischeBedeutung>
<DeutscheBedeutung>
<token__>
DEU
</token__>
<RegExp>
Gesichts-, Schweißtuch [usu liturg.; de re v. p. 32, 63]
</RegExp>
Gesichts-, Schweißtuch [usu liturg.; de re v. p. 32, 63]
</DeutscheBedeutung>
<Belege>
<token__>
BELEGE
</token__>
<ZeroOrMore>
<Sequence>
<EinBeleg>
<RegExp>
Catal. thes. Germ. 28,11 (post 851) -um III.
</RegExp>
</EinBeleg>
<EinBeleg>
<OneOrMore>
<RegExp>
Form. Sangall. 39 p. 421,16 "munuscula ... direximus, hoc est palliolum ... ,
</RegExp>
<RegExp>
-as duas."
</RegExp>
</OneOrMore>
</EinBeleg>
<EinBeleg>
<RegExp>
Catal. thes. Germ. 18,7 "-eterculi viginti quatuor".
</RegExp>
</EinBeleg>
<EinBeleg>
<OneOrMore>
<RegExp>
Libri confrat. I app. A 6 p. 137,30 "pulpitum ... -a cocco imaginata
</RegExp>
<RegExp>
circumdari iussit pontifex."
</RegExp>
</OneOrMore>
</EinBeleg>
<EinBeleg>
<OneOrMore>
<RegExp>
Catal. thes. Germ. 76,15 -rulae II. 40,5 VI vizregule. 129a,5 -sterculas
</RegExp>
<RegExp>
II. 24,8 -itella X. 114,8 VIII fezdregle. 6,24 fasciutercule
</RegExp>
<RegExp>
VII. 92,6 fascercule tres. 21,20 IIII festregele.
</RegExp>
</OneOrMore>
<Zusatz>
<token__>
*
ZUSATZ
</token__>
<EinBeleg>
<RegExp>
Catal. thes. Germ. 28,11 (post 851) -um III.
</RegExp>
</EinBeleg>
</Sequence>
<Sequence>
<token__>
*
</token__>
<EinBeleg>
<OneOrMore>
<RegExp>
Form. Sangall. 39 p. 421,16 "munuscula ... direximus, hoc est palliolum ... ,
</RegExp>
<RegExp>
-as duas."
</RegExp>
</OneOrMore>
</EinBeleg>
</Sequence>
<Sequence>
<token__>
*
</token__>
<EinBeleg>
<RegExp>
Catal. thes. Germ. 18,7 "-eterculi viginti quatuor".
</RegExp>
</EinBeleg>
</Sequence>
<Sequence>
<token__>
*
</token__>
<EinBeleg>
<OneOrMore>
<RegExp>
Libri confrat. I app. A 6 p. 137,30 "pulpitum ... -a cocco imaginata
</RegExp>
<RegExp>
circumdari iussit pontifex."
</RegExp>
</OneOrMore>
</EinBeleg>
</Sequence>
<Sequence>
<token__>
*
</token__>
<EinBeleg>
<OneOrMore>
<RegExp>
Catal. thes. Germ. 76,15 -rulae II. 40,5 VI vizregule. 129a,5 -sterculas
</RegExp>
<RegExp>
II. 24,8 -itella X. 114,8 VIII fezdregle. 6,24 fasciutercule
</RegExp>
<RegExp>
VII. 92,6 fascercule tres. 21,20 IIII festregele.
</RegExp>
</OneOrMore>
<Zusatz>
<token__>
ZUSATZ
</token__>
<RegExp>
saepe.
</RegExp>
</Zusatz>
</EinBeleg>
</Sequence>
</ZeroOrMore>
<RegExp>
saepe.
</RegExp>
</Zusatz>
</EinBeleg>
</Belege>
</Interpretamente>
</Bedeutung>
......@@ -218,52 +178,27 @@
<Bedeutung>
<Interpretamente>
<LateinischeBedeutung>
<token__>
LAT
</token__>
<RegExp>
capital, rica
</RegExp>
capital, rica
</LateinischeBedeutung>
<DeutscheBedeutung>
<token__>
DEU
</token__>
<RegExp>
Kopftuch
</RegExp>
Kopftuch
</DeutscheBedeutung>
<Belege>
<token__>
BELEGE
</token__>
<ZeroOrMore>
<Sequence>
<token__>
*
</token__>
<EinBeleg>
<RegExp>
Transl. Libor. I 32 raptis feminarum -is (fa[s]citergiis var. l.).
</RegExp>
</EinBeleg>
</Sequence>
<Sequence>
<token__>
*
</token__>
<EinBeleg>
<OneOrMore>
<RegExp>
II 20 nuditatem membrorum illius (puellae) tegere festinarunt fideles
</RegExp>
<RegExp>
clerici et laici inprimis cum eorum -cula, dein vestibus solitis.
</RegExp>
</OneOrMore>
</EinBeleg>
</Sequence>
</ZeroOrMore>
<EinBeleg>
<RegExp>
Transl. Libor. I 32 raptis feminarum -is (fa[s]citergiis var. l.).
</RegExp>
</EinBeleg>
<EinBeleg>
<OneOrMore>
<RegExp>
II 20 nuditatem membrorum illius (puellae) tegere festinarunt fideles
</RegExp>
<RegExp>
clerici et laici inprimis cum eorum -cula, dein vestibus solitis.
</RegExp>
</OneOrMore>
</EinBeleg>
</Belege>
</Interpretamente>
</Bedeutung>
......@@ -274,9 +209,7 @@
AUTORIN
</token__>
<Name>
<WORT>
Weber
</WORT>
Weber
</Name>
</Autorinfo>
</Artikel>
\ No newline at end of file
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