Commit 15b9a8fd authored by eckhart's avatar eckhart
Browse files

Manual extended

parent d74aeb43
......@@ -768,7 +768,7 @@ to at most a single linefeed::
>>> testdata = '{"array": [1, 2.0, "a string"], \\n\\n\\n "number": -1.3e+25, "bool": false}'
>>> syntax_tree = json_parser(testdata)
>>> print(syntax_tree.errors[0])
1:32: Error (1010): member expected, » \\n \\n \\n "numb...« found!
1:32: Error (1010): member expected by parser 'object', » \\n \\n \\n "numb...« found!
>>> json_gr = '@whitespace = /\\\\s*/ \\n' + json_gr
>>> json_parser = create_parser(json_gr, "JSON")
>>> syntax_tree = json_parser(testdata)
......
......@@ -1365,8 +1365,8 @@ class Server:
def connection_alive() -> bool:
"""-> `False` if connection is dead or shall be shut down."""
assert self.connection
return not self.kill_switch and self.connection.alive and not reader.at_eof() # and not reader.closed
return not self.kill_switch and self.connection and self.connection.alive \
and not reader.at_eof() # and not reader.closed
buffer = bytearray() # type: bytearray
while connection_alive():
......@@ -1454,6 +1454,9 @@ class Server:
if self.log_file: # avoid decoding if logging is off
self.log('RECEIVE: ', *pp_transmission(data), '\n\n')
if self.connection is None or not self.connection.alive:
break
if id_connection:
if self.connection.alive:
if not data and self.connection.reader.at_eof():
......@@ -1558,7 +1561,7 @@ class Server:
self.log('SERVER MESSAGE: Closing service-connection.')
return
if self.kill_switch or not self.connection.alive:
if self.connection and (self.kill_switch or not self.connection.alive):
await self.connection.cleanup()
try:
writer.write_eof()
......
......@@ -252,6 +252,10 @@ class DSLLanguageServerProtocol:
log_func=self.connection.log)
return error_list
# def simply_compile(self, argstr):
# from DSLParser import compile_src
# return compile_src(argstr)
async def simply_compile(self, argstr: str):
from functools import partial
from DSLParser import compile_src
......
......@@ -90,7 +90,7 @@ class TestDHParserCommandLineTool:
'>' + data_dir + '/neu/example.xml')
with open(data_dir + '/neu/example.xml', 'r', encoding='utf-8') as f:
json = f.read()
assert json.find('document') >= 0, json
assert json.find('document') >= 0, data_dir + ' ' + str(len(json))
system(self.python + data_dir + '/neu/neuServer.py ' + data_dir + '/neu/example.dsl ' + self.nulldevice)
system(self.python + data_dir + '/neu/neuServer.py ' + data_dir + '/neu/example.dsl ' + self.nulldevice)
system(self.python + data_dir + '/neu/neuServer.py --stopserver' + self.nulldevice)
......
......@@ -1489,7 +1489,7 @@ class TestMetaParser:
self.mp.pname = "named"
self.mp.tag_name = self.mp.pname
rv = self.mp._return_values((Node('tag', 'content'), EMPTY_NODE))
print(rv.as_sxpr())
# print(rv.as_sxpr())
assert rv[-1].tag_name != EMPTY_NODE.tag_name, rv[-1].tag_name
def test_in_context(self):
......
Supports Markdown
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