Added keyword c:xxx: to express that we want the concept, not its body
This commit is contained in:
+61
-1
@@ -767,4 +767,64 @@ Let's see an example
|
||||
def concept one as 1
|
||||
def concept two as 2
|
||||
|
||||
eval one + two
|
||||
eval one + two
|
||||
|
||||
In this situation, I expect PythonEvaluator to resolve the concepts 'one' and 'two' and to return 1 + 2, hence 3
|
||||
|
||||
In this other situation
|
||||
|
||||
::
|
||||
|
||||
def concept one as 1
|
||||
def concept desc a as sheerka.desc(a)
|
||||
desc one
|
||||
|
||||
I expect Python evaluator NOT to resolve the concept one and to pass it strait to the function.
|
||||
|
||||
Unfortunately for me, in the current implementation. 'a' is resolved to the concept 'one', which is resolved to its
|
||||
body "1". So the call failed, as there is not concept 1 (moreover, 1 is an integer, it's not even the string "1").
|
||||
|
||||
There also be some cases where 'sheerka.desc()' expects the name of a concept (and the resolution of the concept
|
||||
will be done inside the function). In this case, it's not the body nor the concept itself that is required, but the name
|
||||
of the concept.
|
||||
|
||||
So here are three cases where the behaviour of PythonEvaluator is required to be different. I cannot hard code theses
|
||||
behaviours as they depend on the context.
|
||||
|
||||
The global idea, to resolve this situation is to give to Sheerka a memory. What I am currently working on is the possibility
|
||||
**to create** and **to recognize** concepts. As a recall :
|
||||
|
||||
You can create simple concepts
|
||||
|
||||
::
|
||||
|
||||
def concept one as 1
|
||||
|
||||
or concept using bnf
|
||||
|
||||
::
|
||||
|
||||
def concept twenties from bnf twenty (one | two | three...)=unit as 20 + unit
|
||||
|
||||
|
||||
Both can be recognised.
|
||||
But if I define
|
||||
|
||||
::
|
||||
|
||||
def a plus b as a + 1
|
||||
|
||||
|
||||
:code:`one + two` will be recognized but twenty two plus one is not correctly implemented yet.
|
||||
|
||||
To go back on my issue with the variables resolutions with PythonEvaluator, the idea is to implement rules that will
|
||||
recognize the concept, so you will tell Sheerka if the value, the concept or the name is expected.
|
||||
|
||||
I am far from implementing the rules. To be honest, I don't even know now how they will look like.
|
||||
|
||||
So I am going to introduce the keyword :code:`concept:name:` or :code:`c:name:`
|
||||
|
||||
It will means that the concept is required.
|
||||
|
||||
If the name is required, you can use :code:`"'name'"` or :code:`'"name"'`.
|
||||
It's already working. There is nothing to do for this one.
|
||||
Reference in New Issue
Block a user