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 9a6df97d authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

further changes to LaTeX ebnf-transformation

parent 3978f82c
......@@ -317,9 +317,9 @@ class EBNFCompiler(Compiler):
self.current_symbols = [] # type: List[Node]
self.symbols = {} # type: Dict[str, Node]
self.variables = set() # type: Set[str]
self.definitions = [] # type: List[Tuple[str, str]]
# self.definitions = [] # type: List[Tuple[str, str]]
self.recursive = set() # type: Set[str]
self.deferred_tasks = [] # type: List[Callable]
self.deferred_tasks = [] # type: List[Callable]
self.root = "" # type: str
self.directives = {'whitespace': self.WHITESPACE['horizontal'],
'comment': '',
......
......@@ -98,6 +98,10 @@ def get_report(test_unit):
"""
Returns a text-report of the results of a grammar unit test.
"""
def indent(txt):
lines = txt.split('\n')
lines[0] = ' ' + lines[0]
return "\n ".join(lines)
report = []
for parser_name, tests in test_unit.items():
heading = 'Test of parser: "%s"' % parser_name
......@@ -106,7 +110,7 @@ def get_report(test_unit):
heading = 'Match-test "%s"' % test_name
report.append('\n%s\n%s\n' % (heading, '-' * len(heading)))
report.append('### Test-code:')
report.append(test_code)
report.append(indent(test_code))
error = tests.get('__err__', {}).get(test_name, "")
if error:
report.append('\n### Error:')
......@@ -115,10 +119,10 @@ def get_report(test_unit):
cst = tests.get('__cst__', {}).get(test_name, None)
if cst and (not ast or cst == ast):
report.append('\n### CST')
report.append(cst.as_sxpr())
report.append(indent(cst.as_sxpr()))
elif ast:
report.append('\n### AST')
report.append(ast.as_sxpr())
report.append(indent(ast.as_sxpr()))
return '\n'.join(report)
......@@ -199,7 +203,7 @@ def grammar_unit(test_unit, parser_factory, transformer_factory, report=True, ve
report_dir = "REPORT"
if not os.path.exists(report_dir):
os.mkdir(report_dir)
with open(os.path.join(report_dir, unit_name + '.report'), 'w') as f:
with open(os.path.join(report_dir, unit_name + '.md'), 'w') as f:
f.write(get_report(test_unit))
return errata
......
......@@ -314,7 +314,7 @@ def expand_table(compact_table):
value = compact_table[key]
for k in smart_list(key):
if k in expanded_table:
raise KeyError("Key %s used more than once in compact table!" % key)
raise KeyError('Key "%s" used more than once in compact table!' % key)
expanded_table[k] = value
return expanded_table
......
......@@ -102,7 +102,7 @@ known_command = footnote | includegraphics | caption
generic_command = !no_command CMDNAME [[ //~ config ] //~ block ]
footnote = "\footnote" block_of_paragraphs
includegraphics = "\includegraphics" config block
includegraphics = "\includegraphics" [ config ] block
caption = "\caption" block
......
......@@ -346,7 +346,7 @@ LaTeX_AST_transformation_table = {
"block_environment": replace_by_single_child,
"known_environment": replace_by_single_child,
"generic_block": [],
"begin_generic_block, end_generic_block": reduce_single_child,
"begin_generic_block, end_generic_block": replace_by_single_child,
"itemize, enumerate": [remove_brackets, flatten],
"item": [remove_first],
"figure": [],
......@@ -361,7 +361,7 @@ LaTeX_AST_transformation_table = {
"inline_environment": replace_by_single_child,
"known_inline_env": replace_by_single_child,
"generic_inline_env": [],
"begin_inline_env, end_inline_env": [reduce_single_child],
"begin_inline_env, end_inline_env": [replace_by_single_child],
"begin_environment, end_environment": [remove_brackets, reduce_single_child],
"inline_math": [remove_brackets, reduce_single_child],
"command": [],
......@@ -372,11 +372,9 @@ LaTeX_AST_transformation_table = {
"caption": [],
"config": [remove_brackets],
"block": [remove_brackets, reduce_single_child(is_anonymous)],
"text": [reduce_single_child, merge_children('word_sequence', ':Whitespace', 'TEXTCHUNK')],
"cfgtext": [flatten, reduce_single_child, replace_parser('text')],
"word_sequence": collapse, # [flatten, merge_children('TEXTCHUNK', ':Whitespace'), reduce_single_child],
"no_command": [],
"blockcmd": [],
"text": collapse,
"cfgtext, word_sequence": [],
"no_command, blockcmd": [],
"structural": [],
"CMDNAME": [remove_whitespace, reduce_single_child(is_anonymous)],
"NAME": [reduce_single_child, remove_whitespace, reduce_single_child],
......
......@@ -26,6 +26,7 @@
8 : Unknwon \xy commands within paragraphs may be simple
or \xy{complex}.
[fail:paragraph]
1 : \begin{enumerate}
2 : \item
......
[match:text]
1: Some plain text
2: Text containing [ brackets ] is distinguished from cfgtext
3: Text can also "escaped" characters like \&, \% or \_ .
4: Text can contain both brackets [] and "esacped" characters \& .
......@@ -35,7 +35,7 @@ if not DHParser.dsl.recompile_grammar('LaTeX.ebnf', force=True): # recompiles G
from DHParser import toolkit
from LaTeXCompiler import get_grammar, get_transformer
with toolkit.logging(True):
with toolkit.logging(False):
error_report = testing.grammar_suite('grammar_tests', get_grammar,
get_transformer, report=True, verbose=True)
if error_report:
......
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