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 64ae1483 authored by eckhart's avatar eckhart
Browse files

- sync commit

parent d4d487d1
No preview for this file type
...@@ -641,7 +641,8 @@ class EBNFCompiler(Compiler): ...@@ -641,7 +641,8 @@ class EBNFCompiler(Compiler):
'', '',
' def _reset(self):', ' def _reset(self):',
' super()._reset()', ' super()._reset()',
' # initialize your variables here, not in the constructor!'] ' # initialize your variables here, not in the constructor!',
'']
for name in self.rules: for name in self.rules:
method_name = visitor_name(name) method_name = visitor_name(name)
if name == self.root_symbol: if name == self.root_symbol:
......
...@@ -32,8 +32,13 @@ file system an merely return an success or failure message. Module `server` ...@@ -32,8 +32,13 @@ file system an merely return an success or failure message. Module `server`
does not define any of these message. This is completely up to the clients does not define any of these message. This is completely up to the clients
of module `server`, i.e. the compilation-modules, to decide. of module `server`, i.e. the compilation-modules, to decide.
The communication, i.e. requests and responses, follows the json-rpc protocol The communication, i.e. requests and responses, follows the json-rpc protocol:
(https://www.jsonrpc.org/specification)
https://www.jsonrpc.org/specification
For JSON see:
https://json.org/
""" """
...@@ -42,7 +47,7 @@ import json ...@@ -42,7 +47,7 @@ import json
from multiprocessing import Process, Value, Queue from multiprocessing import Process, Value, Queue
from typing import Callable, Optional, Union, Dict, List, Sequence, cast from typing import Callable, Optional, Union, Dict, List, Sequence, cast
from DHParser.toolkit import get_config_value from DHParser.toolkit import get_config_value, re
RPC_Table = Dict[str, Callable] RPC_Table = Dict[str, Callable]
RPC_Type = Union[RPC_Table, List[Callable], Callable] RPC_Type = Union[RPC_Table, List[Callable], Callable]
...@@ -55,6 +60,9 @@ SERVER_ONLINE = 2 ...@@ -55,6 +60,9 @@ SERVER_ONLINE = 2
SERVER_TERMINATE = 3 SERVER_TERMINATE = 3
RX_MAYBE_JSON = re.compile('\s*(?:\{|\[|"|\d|true|false|null)')
class Server: class Server:
def __init__(self, rpc_functions: RPC_Type): def __init__(self, rpc_functions: RPC_Type):
if isinstance(rpc_functions, Dict): if isinstance(rpc_functions, Dict):
...@@ -70,7 +78,7 @@ class Server: ...@@ -70,7 +78,7 @@ class Server:
self.max_source_size = get_config_value('max_rpc_size') self.max_source_size = get_config_value('max_rpc_size')
self.stage = Value('b', SERVER_OFFLINE) self.stage = Value('b', SERVER_OFFLINE)
self.server = None # type: Optional[asyncio.base_events.Server] self.server = None
self.server_messages = Queue() # type: Queue self.server_messages = Queue() # type: Queue
self.server_process = None # type: Optional[Process] self.server_process = None # type: Optional[Process]
......
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
""" """
Module ``toolkit`` contains utility functions that are needed across Module ``toolkit`` contains utility functions that are needed across
several of the the other DHParser-Modules or that are just very generic several of the the other DHParser-Modules Helper funcions that are not
so that they are best defined in a toolkit-module. needed in more than one module are best placed within that module and
not in the toolkit-module. An acceptable exception from this rule are
functions that are very generic.
""" """
import hashlib import hashlib
......
...@@ -151,6 +151,7 @@ class ArithmeticRightRecursiveCompiler(Compiler): ...@@ -151,6 +151,7 @@ class ArithmeticRightRecursiveCompiler(Compiler):
def _reset(self): def _reset(self):
super()._reset() super()._reset()
# initialize your variables here, not in the constructor! # initialize your variables here, not in the constructor!
def on_expression(self, node): def on_expression(self, node):
return self.fallback_compiler(node) return self.fallback_compiler(node)
......
...@@ -42,6 +42,7 @@ class TestParserError: ...@@ -42,6 +42,7 @@ class TestParserError:
pe = ParserError(Node('TAG', 'test').with_pos(0), StringView('Beispiel'), True) pe = ParserError(Node('TAG', 'test').with_pos(0), StringView('Beispiel'), True)
assert str(pe).find('Beispiel') >= 0 and str(pe).find('TAG') >= 0 assert str(pe).find('Beispiel') >= 0 and str(pe).find('TAG') >= 0
class TestParserClass: class TestParserClass:
def test_apply(self): def test_apply(self):
minilang =""" minilang ="""
...@@ -66,7 +67,7 @@ class TestParserClass: ...@@ -66,7 +67,7 @@ class TestParserClass:
class TestInfiLoopsAndRecursion: class TestInfiLoopsAndRecursion:
def test_direct_left_recursion1(self): def test_direct_left_recursion1(self):
minilang =""" minilang = """
expr = expr ("+"|"-") term | term expr = expr ("+"|"-") term | term
term = term ("*"|"/") factor | factor term = term ("*"|"/") factor | factor
factor = /[0-9]+/~ factor = /[0-9]+/~
...@@ -176,6 +177,7 @@ class TestInfiLoopsAndRecursion: ...@@ -176,6 +177,7 @@ class TestInfiLoopsAndRecursion:
# assert not res # assert not res
# set_config_value('static_analysis', save) # set_config_value('static_analysis', save)
class TestFlowControl: class TestFlowControl:
def setup(self): def setup(self):
self.t1 = """ self.t1 = """
...@@ -237,8 +239,8 @@ class TestRegex: ...@@ -237,8 +239,8 @@ class TestRegex:
def test_multilineRegex_wo_Comments(self): def test_multilineRegex_wo_Comments(self):
mlregex = r""" mlregex = r"""
regex = /\w+ regex = /\w+
[+] [+]
\w* / \w* /
""" """
result, messages, syntax_tree = compile_source(mlregex, None, get_ebnf_grammar(), result, messages, syntax_tree = compile_source(mlregex, None, get_ebnf_grammar(),
...@@ -293,8 +295,9 @@ class TestRegex: ...@@ -293,8 +295,9 @@ class TestRegex:
test test
\end{document} \end{document}
""" """
result, messages, syntax_tree = compile_source(tokenlang, None, get_ebnf_grammar(), result, messages, syntax_tree = compile_source(
get_ebnf_transformer(), get_ebnf_compiler("TokenTest")) tokenlang, None, get_ebnf_grammar(), get_ebnf_transformer(),
get_ebnf_compiler("TokenTest"))
assert result assert result
assert not messages, str(messages) assert not messages, str(messages)
parser = compile_python_object(DHPARSER_IMPORTS + result, r'\w+Grammar$')() parser = compile_python_object(DHPARSER_IMPORTS + result, r'\w+Grammar$')()
...@@ -635,7 +638,7 @@ class TestWhitespaceHandling: ...@@ -635,7 +638,7 @@ class TestWhitespaceHandling:
class TestErrorReporting: class TestErrorReporting:
grammar = """ grammar = """
root = series alpha | anything root = series alpha | anything
series = subseries &alpha series = subseries &alpha
subseries = alpha §beta subseries = alpha §beta
alpha = /[a-z]+/ alpha = /[a-z]+/
beta = /[A-Z]+/ beta = /[A-Z]+/
...@@ -805,12 +808,12 @@ class TestEarlyTokenWhitespaceDrop: ...@@ -805,12 +808,12 @@ class TestEarlyTokenWhitespaceDrop:
@ drop = token, whitespace @ drop = token, whitespace
expression = term { ("+" | "-") term} expression = term { ("+" | "-") term}
term = factor { ("*"|"/") factor} term = factor { ("*"|"/") factor}
factor = number | variable | "(" expression ")" factor = number | variable | "(" expression ")"
| constant | fixed | constant | fixed
variable = /[a-z]/~ variable = /[a-z]/~
number = /\d+/~ number = /\d+/~
constant = "A" | "B" constant = "A" | "B"
fixed = "X" fixed = "X"
""" """
self.gr = grammar_provider(self.lang)() self.gr = grammar_provider(self.lang)()
...@@ -891,7 +894,7 @@ class TestMetaParser: ...@@ -891,7 +894,7 @@ class TestMetaParser:
term = factor { (DIV|MUL) factor} term = factor { (DIV|MUL) factor}
factor = NUMBER | VARIABLE factor = NUMBER | VARIABLE
MUL = "*" | &factor MUL = "*" | &factor
DIV = "/" DIV = "/"
NUMBER = /(?:0|(?:[1-9]\d*))(?:\.\d+)?/~ NUMBER = /(?:0|(?:[1-9]\d*))(?:\.\d+)?/~
VARIABLE = /[A-Za-z]/~ VARIABLE = /[A-Za-z]/~
""" """
...@@ -899,6 +902,7 @@ class TestMetaParser: ...@@ -899,6 +902,7 @@ class TestMetaParser:
cst = gr("2x") cst = gr("2x")
assert bool(cst.pick('MUL')), "Named empty nodes should not be dropped!!!" assert bool(cst.pick('MUL')), "Named empty nodes should not be dropped!!!"
if __name__ == "__main__": if __name__ == "__main__":
from DHParser.testing import runner from DHParser.testing import runner
with logging(False): with logging(False):
......
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