@@ -1,15 +1,19 @@
import os
import os, ast
_all__ = ["parse"]
def parse(codelet):
WRITE_F = "../../tmp/parser.proc"
def parse(codelet, pid):
"""
Sends codelet code to the Java parsing process via a named pipe. Reads the
resulting symbols from the pipe and updates the codelet.
:param codelet: The codelet object to parsed.
:param pid: The id of the current python process.
:type code: Codelet
:param pid: str.
.. todo::
Create a named pipe for python process to communicate with Java
@@ -19,5 +23,21 @@ def parse(codelet):
Read the result from the named pipe and turn it into a dict.
"""
pass
with open(WRITE_F, 'a') as wf:
wf.write('pid:' + str(pid) + '\n')
wf.write('body:\n' + codelet.code)
read_f = '../../tmp/%s_py.data' % str(pid)
data = ''
while data == '':
with open(read_f) as rf:
data = rf.read()
os.remove(read_f)
results = data.split('\n')
codelet.language = results[0].split(',')[1]
codelet.symbols = ast.literal_eval(results[1].split(',')[1])