Added basic implementation for Python code evaluation
This commit is contained in:
@@ -226,3 +226,57 @@ need the second call :code:`add("Concepts", "bar")` to produce
|
||||
|
||||
So we are no longer in the usual way of implementing a CRUD.
|
||||
|
||||
|
||||
|
||||
2019-11-06
|
||||
**********
|
||||
|
||||
Input processing
|
||||
"""""""""""""""""
|
||||
The basic processing flow should be
|
||||
|
||||
::
|
||||
|
||||
1. parsers
|
||||
2. evaluators
|
||||
3. printers
|
||||
|
||||
So, for each new input, all known parsers will try to recognize the input. Each parser will
|
||||
return a triplet of :code:`(status, concept found (or node found), text message)`
|
||||
|
||||
This list of triplet is given to the evaluators. In the same way, there should be multiple
|
||||
types of evaluators. There will be the rules that will be introduced later.
|
||||
|
||||
All evaluators will provide a list (a guess it will be triplets as well) to the printers.
|
||||
|
||||
Python processing
|
||||
"""""""""""""""""
|
||||
Sheerka natively understand Python. So it will be able to execute Python code.
|
||||
I will manage later on the issues caused by the different version of Python, or the fact
|
||||
that some external modules must remain isolated (maybe using virtualenv)
|
||||
|
||||
My first problem is to correctly implement the :code:`eval / exec` function.
|
||||
|
||||
I don't know why, by Python has two similar function to do the same thing. One must use
|
||||
eval to evaluate expression, or use exec to execute code. There must be an explanation but,
|
||||
as for know, it seems to be a complication for nothing.
|
||||
|
||||
The next issue that I will have to tackle is that Sheerka is not a REPL. After the execution
|
||||
of the input, the system stops. Nothing is kept in memory (eg RAM).
|
||||
The whole idea is to make Sheerka 'remember', even something that happened a long time ago.
|
||||
So I should find a way to 'freeze the time'
|
||||
|
||||
To better explain what I have in mind. let's say that I want to pretty print an object
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import pprint
|
||||
pp = pprint.PrettyPrinter(indent=4)
|
||||
pp.pprint(stuff)
|
||||
|
||||
I need three line in oder to be able to pretty print. I will first try by dumping the
|
||||
globals(), using pickle and load it back whenever needed.
|
||||
|
||||
If it does not work as expected, I can find a way to save the commands a exec everything
|
||||
when needed. (first time, I exec import... second time I exec import + pp == and the last
|
||||
time I exec the three statements).
|
||||
|
||||
Reference in New Issue
Block a user