Commit c770ba56 authored by di68kap's avatar di68kap

- tst_MLW_grammar.py: XML-switch repaired

parent 2144a10f
......@@ -59,12 +59,6 @@ from DHParser import is_filename, Grammar, Compiler, Lookahead, Alternative, Tok
from DHParser.log import logging
CONFIG_PRESET = access_presets()
CONFIG_PRESET['test_parallelization'] = True
CONFIG_PRESET['ast_serialization'] = "S-expression"
finalize_presets()
#######################################################################
#
# PREPROCESSOR SECTION - Can be edited. Changes will be preserved.
......@@ -477,7 +471,7 @@ MLW_AST_transformation_table = {
"gesichert": [reduce_single_child],
"LemmaWort": [flatten, strip, normalize_wsp_nodes, collapse],
"LemmaVariante": [flatten, strip, normalize_wsp_nodes,
collapse_if(not_one_of("Zusatz"), PlainText)],
collapse_if(not_one_of("Zusatz", "FesterZusatz"), PlainText)],
"LemmaVarianten": [flatten, drop_whitespace],
"GrammatikPosition": [flatten],
"GrammatikVariante": [flatten, flatten(is_one_of('Belege')), drop_whitespace],
......@@ -2242,6 +2236,11 @@ def verarbeite_mlw_artikel(file_name, log_dir, output) -> int:
if __name__ == "__main__":
CONFIG_PRESET = access_presets()
CONFIG_PRESET['test_parallelization'] = True
CONFIG_PRESET['ast_serialization'] = "S-expression"
finalize_presets()
BEISPIEL = os.path.join('facitergula', 'fascitergula.mlw')
# BEISPIEL = "99_test_SPIELWIESE.ini"
......
......@@ -13,10 +13,12 @@ M1: """(fasc-, -iet-, -ist, -rcu-)"""
M2: "(fasc-)"
M3: """(fasc-, -iet- {sim.})"""
[fail:LemmaVarianten]
F1: * fascitergula
[ast:LemmaVarianten]
M3: """(LemmaVarianten (LemmaVariante (TEXT "fasc-")) (LemmaVariante (TEXT "-iet- ") (FesterZusatz "sim.")))"""
[match:LemmaPosition]
M1: """LEMMA facitergula
......
......@@ -19,9 +19,7 @@ See the License for the specific language governing permissions and
limitations under the License.
"""
import io
import os
import platform
import sys
sys.path.extend(['DHParser-submodule'])
......@@ -37,7 +35,9 @@ TEMPLATES = ['*_test_*.ini']
DIRECTORY = 'grammar_tests'
if __name__ == "__main__":
configuration.CONFIG_PRESET['test_parallelization'] = True
CONFIG_PRESET = configuration.access_presets()
CONFIG_PRESET['test_parallelization'] = True
configuration.finalize_presets()
if not dsl.recompile_grammar('MLW.ebnf', force=False,
notify=lambda: print('recompiling MLW.ebnf')): # recompiles grammar only if it has changed
......@@ -51,9 +51,11 @@ if __name__ == "__main__":
try:
i = sys.argv.index('--xml')
del sys.argv[i]
configuration.CONFIG_PRESET['ast_serialization'] = "XML"
CONFIG_PRESET['ast_serialization'] = "XML"
except ValueError:
configuration.CONFIG_PRESET['ast_serialization'] = "S-expression"
CONFIG_PRESET['ast_serialization'] = "S-expression"
if len(sys.argv) > 1:
if os.path.isdir(sys.argv[1]):
DIRECTORY = sys.argv[1]
if len(sys.argv) > 2:
......@@ -77,6 +79,7 @@ if __name__ == "__main__":
if valid_names:
TEMPLATES = valid_names
LOGGING = (len(TEMPLATES) == 1)
configuration.finalize_presets()
print("\nRunning all tests matching %s in directory '%s' %s logging."
% (TEMPLATES, os.path.basename(DIRECTORY), 'with' if LOGGING else 'without'))
......
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