@initialize:python@ s_id << virtual.server_id; s_port << virtual.server_port; @@ import json, socket, struct, sys if s_id == False: s_id = "localhost" target = s_id, int(s_port) if s_port else 1234 sys.stderr.write("Using Python version:\n%s\n" % (sys.version)) sys.stderr.write('Connections will be tried with server ā€œ%sā€ on port ā€œ%dā€.\n' % target) def store_statements(fun, source, s1, s2): """Send data for the service.""" records = [] for place in source: records.append('{"name":%s,"file":%s,"line":%s,"column":%s,"s1":%s,"s2":%s}' % (json.dumps(fun), json.dumps(place.file), json.dumps(place.line), json.dumps(int(place.column) + 1), json.dumps(s1), json.dumps(s2))) with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as so: so.connect(target) result = "[\n" result += ",\n".join(records) result += "\n]" b = bytes(result, "utf8") p = struct.pack(">I", len(b)) p += b so.sendall(p) @searching exists@ identifier work; statement s1, s2; position pos; type T; @@ T work(...) { ... when any if (...) { ... when any s1@pos s2 } ... when any } @script:python collection@ fun << searching.work; s1 << searching.s1; s2 << searching.s2; place << searching.pos; @@ store_statements(fun, place, s1, s2)