Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 82e16eb0 authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

refactorings, AST-Transformations amended in MLW_compiler.py

parent f5965e58
...@@ -68,7 +68,7 @@ import types ...@@ -68,7 +68,7 @@ import types
from functools import reduce, partial from functools import reduce, partial
__version__ = '0.5.1' + '_dev' + str(os.stat(__file__).st_mtime) __version__ = '0.5.2' + '_dev' + str(os.stat(__file__).st_mtime)
DEBUG = True DEBUG = True
...@@ -1211,7 +1211,7 @@ class CompilerBase: ...@@ -1211,7 +1211,7 @@ class CompilerBase:
return compiler(node) return compiler(node)
def full_compilation(source, parser_HQ, AST_transformations, compiler): def full_compilation(source, parserHQ, AST_transformations, compiler):
"""Compiles a source in three stages: """Compiles a source in three stages:
1. Parsing 1. Parsing
2. AST-transformation 2. AST-transformation
...@@ -1221,7 +1221,7 @@ def full_compilation(source, parser_HQ, AST_transformations, compiler): ...@@ -1221,7 +1221,7 @@ def full_compilation(source, parser_HQ, AST_transformations, compiler):
Args: Args:
source (str): the input source for compilation source (str): the input source for compilation
parser_HQ (ParserHQ): the ParserHeadquarter object parserHQ (ParserHQ): the ParserHeadquarter object
AST_transformations (dict): a table that assigns AST transformation AST_transformations (dict): a table that assigns AST transformation
functions to parser names (see function ASTTransform) functions to parser names (see function ASTTransform)
compiler (object): an instance of a class derived from `CompilerBase` compiler (object): an instance of a class derived from `CompilerBase`
...@@ -1234,8 +1234,8 @@ def full_compilation(source, parser_HQ, AST_transformations, compiler): ...@@ -1234,8 +1234,8 @@ def full_compilation(source, parser_HQ, AST_transformations, compiler):
""" """
assert isinstance(compiler, CompilerBase) assert isinstance(compiler, CompilerBase)
syntax_tree = parser_HQ.parse(source) syntax_tree = parserHQ.parse(source)
DEBUG_DUMP_SYNTAX_TREE(parser_HQ, syntax_tree, compiler, ext='.cst') DEBUG_DUMP_SYNTAX_TREE(parserHQ, syntax_tree, compiler, ext='.cst')
errors = syntax_tree.collect_errors(clear=True) errors = syntax_tree.collect_errors(clear=True)
assert errors or str(syntax_tree) == source assert errors or str(syntax_tree) == source
...@@ -1243,7 +1243,7 @@ def full_compilation(source, parser_HQ, AST_transformations, compiler): ...@@ -1243,7 +1243,7 @@ def full_compilation(source, parser_HQ, AST_transformations, compiler):
# likely that error list gets littered with compile error messages # likely that error list gets littered with compile error messages
if not errors: if not errors:
ASTTransform(syntax_tree, AST_transformations) ASTTransform(syntax_tree, AST_transformations)
DEBUG_DUMP_SYNTAX_TREE(parser_HQ, syntax_tree, compiler, ext='.ast') DEBUG_DUMP_SYNTAX_TREE(parserHQ, syntax_tree, compiler, ext='.ast')
result = compiler.compile__(syntax_tree) result = compiler.compile__(syntax_tree)
errors.extend(syntax_tree.collect_errors(clear=True)) errors.extend(syntax_tree.collect_errors(clear=True))
else: else:
...@@ -1421,7 +1421,6 @@ class EBNFCompiler(CompilerBase): ...@@ -1421,7 +1421,6 @@ class EBNFCompiler(CompilerBase):
self.variables = set() self.variables = set()
self.scanner_tokens = set() self.scanner_tokens = set()
self.definition_names = [] self.definition_names = []
self.curr_name = str(None)
self.recursive = set() self.recursive = set()
self.root = "" self.root = ""
self.directives = {'whitespace': '\s*', self.directives = {'whitespace': '\s*',
...@@ -1554,7 +1553,6 @@ class EBNFCompiler(CompilerBase): ...@@ -1554,7 +1553,6 @@ class EBNFCompiler(CompilerBase):
node.add_error('A rule with name "%s" has already been defined.' % node.add_error('A rule with name "%s" has already been defined.' %
rule) rule)
try: try:
self.curr_name = '"' + rule + '"'
self.rules.add(rule) self.rules.add(rule)
defn = self.compile__(node.result[1]) defn = self.compile__(node.result[1])
if rule in self.variables: if rule in self.variables:
...@@ -1611,22 +1609,12 @@ class EBNFCompiler(CompilerBase): ...@@ -1611,22 +1609,12 @@ class EBNFCompiler(CompilerBase):
', '.join(list(EBNFCompiler.KNOWN_DIRECTIVES)))) ', '.join(list(EBNFCompiler.KNOWN_DIRECTIVES))))
return "" return ""
def _current_name(self):
# if self.curr_name in {'', str(None)}:
# name = []
# else:
# name = ["name=" + self.curr_name]
name = [] # turn explicit names declaration off
self.curr_name = str(None)
return name
def non_terminal(self, node, parser_class): def non_terminal(self, node, parser_class):
"""Compiles any non-terminal, where `parser_class` indicates the Parser class """Compiles any non-terminal, where `parser_class` indicates the Parser class
name for the particular non-terminal. name for the particular non-terminal.
""" """
name = self._current_name()
arguments = filter(lambda arg: arg, arguments = filter(lambda arg: arg,
[self.compile__(r) for r in node.result] + name) [self.compile__(r) for r in node.result])
return parser_class + '(' + ', '.join(arguments) + ')' return parser_class + '(' + ', '.join(arguments) + ')'
def expression(self, node): def expression(self, node):
...@@ -1692,10 +1680,10 @@ class EBNFCompiler(CompilerBase): ...@@ -1692,10 +1680,10 @@ class EBNFCompiler(CompilerBase):
return 'Token(' + ', '.join([node.result]) + ')' return 'Token(' + ', '.join([node.result]) + ')'
def regexp(self, node): def regexp(self, node):
name = self._current_name()
rx = node.result rx = node.result
name = []
if rx[:2] == '~/': if rx[:2] == '~/':
name = ['wL=' + WHITESPACE_KEYWORD] + name name = ['wL=' + WHITESPACE_KEYWORD]
rx = rx[1:] rx = rx[1:]
if rx[-2:] == '/~': if rx[-2:] == '/~':
name = ['wR=' + WHITESPACE_KEYWORD] + name name = ['wR=' + WHITESPACE_KEYWORD] + name
......
...@@ -100,7 +100,7 @@ class MLWGrammar(ParserHeadquarter): ...@@ -100,7 +100,7 @@ class MLWGrammar(ParserHeadquarter):
DATEI_ENDE = !/./ DATEI_ENDE = !/./
NIEMALS = /(?!.)/ NIEMALS = /(?!.)/
""" """
source_hash__ = "ae6d6896307766bb8965321636b0ed54" source_hash__ = "d7afa7bb0037ee25c0cabfa6e5a956c6"
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|$)')
wspL__ = wsp__ wspL__ = wsp__
...@@ -174,8 +174,10 @@ MLWTransTable = { ...@@ -174,8 +174,10 @@ MLWTransTable = {
"LemmaVarianten": "LemmaVarianten":
[partial(remove_tokens, tokens={'VARIANTEN'}), flatten, [partial(remove_tokens, tokens={'VARIANTEN'}), flatten,
partial(remove_tokens, tokens={',', ';'})], partial(remove_tokens, tokens={',', ';'})],
"LVariante, LVZusatz": "LVariante, LVZusatz, Schreibweise":
[remove_expendables, reduce_single_child], [remove_expendables, reduce_single_child],
"SWVariante":
[remove_expendables, partial(remove_tokens, tokens={':'})],
"GrammatikPosition": "GrammatikPosition":
[partial(remove_tokens, tokens={'GRAMMATIK', ';'}), flatten], [partial(remove_tokens, tokens={'GRAMMATIK', ';'}), flatten],
"GrammatikVarianten": "GrammatikVarianten":
...@@ -187,10 +189,10 @@ MLWTransTable = { ...@@ -187,10 +189,10 @@ MLWTransTable = {
"Flexion, Verweis": "Flexion, Verweis":
[remove_expendables, reduce_single_child], [remove_expendables, reduce_single_child],
"ArtikelKopf": no_transformation, "ArtikelKopf": no_transformation,
"SchreibweisenPosition": no_transformation, "SchreibweisenPosition":
[partial(remove_tokens, tokens={'SCHREIBWEISE', ':'}),
flatten, partial(remove_tokens, tokens={','})],
"SWTyp": no_transformation, "SWTyp": no_transformation,
"SWVariante": no_transformation,
"Schreibweise": no_transformation,
"BedeutungsPosition": no_transformation, "BedeutungsPosition": no_transformation,
"Bedeutung": no_transformation, "Bedeutung": no_transformation,
"Bedeutungskategorie": no_transformation, "Bedeutungskategorie": no_transformation,
......
...@@ -72,68 +72,35 @@ ...@@ -72,68 +72,35 @@
</GrammatikPosition> </GrammatikPosition>
</LemmaPosition> </LemmaPosition>
<SchreibweisenPosition> <SchreibweisenPosition>
<token__>
SCHREIBWEISE
</token__>
<SWTyp> <SWTyp>
<token__> <token__>
script. script.
</token__> </token__>
</SWTyp> </SWTyp>
<token__>
:
</token__>
<SWVariante> <SWVariante>
<Schreibweise> <Schreibweise>
<token__> vizreg-
vizreg-
</token__>
</Schreibweise> </Schreibweise>
<token__>
:
</token__>
<Verweis> <Verweis>
>>beleg_id_3 >>beleg_id_3
</Verweis> </Verweis>
</SWVariante> </SWVariante>
<ZeroOrMore> <SWVariante>
<Sequence> <Schreibweise>
<token__> festregel(a)
, </Schreibweise>
</token__> <Verweis>
<SWVariante> >>beleg_id_4
<Schreibweise> </Verweis>
<token__> </SWVariante>
festregel(a) <SWVariante>
</token__> <Schreibweise>
</Schreibweise> fezdregl(a)
<token__> </Schreibweise>
: <Verweis>
</token__> >>beleg_id5
<Verweis> </Verweis>
>>beleg_id_4 </SWVariante>
</Verweis>
</SWVariante>
</Sequence>
<Sequence>
<token__>
,
</token__>
<SWVariante>
<Schreibweise>
<token__>
fezdregl(a)
</token__>
</Schreibweise>
<token__>
:
</token__>
<Verweis>
>>beleg_id5
</Verweis>
</SWVariante>
</Sequence>
</ZeroOrMore>
</SchreibweisenPosition> </SchreibweisenPosition>
<BedeutungsPosition> <BedeutungsPosition>
<Sequence> <Sequence>
......
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