The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated 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 57b09014 authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

- fixed pypy3 compatibility

parent bafb857e
......@@ -43,9 +43,9 @@ except ImportError:
import sys
try:
from typing import Any, List, Tuple, Collection, Union, Optional
from typing import Any, List, Tuple, Iterable, Union, Optional
except ImportError:
from .typing34 import Any, List, Tuple, Collection, Union, Optional
from .typing34 import Any, List, Tuple, Iterable, Union, Optional
__all__ = ('logging',
'is_logging',
......@@ -218,7 +218,7 @@ def sv_match(regex, sv: StringView):
return regex.match(sv.text, pos=sv.begin, endpos=sv.end)
def sv_index(absolute_index: Union[int, Collection], sv: StringView) -> Union[int, tuple]:
def sv_index(absolute_index: Union[int, Iterable], sv: StringView) -> Union[int, tuple]:
"""
Converts the an index into string watched by a StringView object
to an index relativ to the string view object, e.g.:
......
......@@ -147,30 +147,6 @@ else:
'''
def selftest() -> bool:
print("DHParser selftest...")
print("\nSTAGE I: Trying to compile EBNF-Grammar:\n")
builtin_ebnf_parser = get_ebnf_grammar()
ebnf_src = builtin_ebnf_parser.__doc__[builtin_ebnf_parser.__doc__.find('#'):]
ebnf_transformer = get_ebnf_transformer()
ebnf_compiler = get_ebnf_compiler('EBNF')
generated_ebnf_parser, errors, ast = compile_source(ebnf_src, None,
builtin_ebnf_parser, ebnf_transformer, ebnf_compiler)
if errors:
print("Selftest FAILED :-(")
print("\n\n".join(errors))
return False
print(generated_ebnf_parser)
print("\n\nSTAGE 2: Selfhosting-test: Trying to compile EBNF-Grammar with generated parser...\n")
selfhosted_ebnf_parser = compileDSL(ebnf_src, None, generated_ebnf_parser,
ebnf_transformer, ebnf_compiler)
ebnf_compiler.gen_transformer_skeleton()
print(selfhosted_ebnf_parser)
print("\n\n Selftest SUCCEEDED :-)\n\n")
return True
def create_project(path,
ebnf_tmpl=EBNF_TEMPLATE,
readme_tmpl=README_TEMPLATE,
......@@ -208,6 +184,30 @@ def create_project(path,
print('ready.')
def selftest() -> bool:
print("DHParser selftest...")
print("\nSTAGE I: Trying to compile EBNF-Grammar:\n")
builtin_ebnf_parser = get_ebnf_grammar()
ebnf_src = builtin_ebnf_parser.__doc__[builtin_ebnf_parser.__doc__.find('#'):]
ebnf_transformer = get_ebnf_transformer()
ebnf_compiler = get_ebnf_compiler('EBNF')
generated_ebnf_parser, errors, ast = compile_source(ebnf_src, None,
builtin_ebnf_parser, ebnf_transformer, ebnf_compiler)
if errors:
print("Selftest FAILED :-(")
print("\n\n".join(errors))
return False
print(generated_ebnf_parser)
print("\n\nSTAGE 2: Selfhosting-test: Trying to compile EBNF-Grammar with generated parser...\n")
selfhosted_ebnf_parser = compileDSL(ebnf_src, None, generated_ebnf_parser,
ebnf_transformer, ebnf_compiler)
ebnf_compiler.gen_transformer_skeleton()
print(selfhosted_ebnf_parser)
print("\n\n Selftest SUCCEEDED :-)\n\n")
return True
def cpu_profile(func, repetitions=1):
import cProfile, pstats
pr = cProfile.Profile()
......
......@@ -87,7 +87,7 @@ def mem_profile(func):
print(stat)
if __name__ == "__main__":
mem_profile(tst_func)
cpu_profile(tst_func)
......
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