dimanche 3 mars 2019

how to make string written function to AST

I have a xml written function

<functions>
   <function>
       <name>add</name>
       <params>
            <param>a<param>
            <param>b<param>
      </params>
      <body>var c:= a + b<body>
      <return>c</return>
  </function>
</functions>

if one want to convert this into actual function, it will something like that of

auto add(T a, T b)
{
   auto c = a + b;
   return c;
}

what i want to achieve is type of grammar, no hard coding of functions. just update that xml and you are good to go. every user can update is function and after a while, i will a whole of function. and of course, user is also able to use it.

query: add(add(5, 6), add(6,7))
and able to get the result also.

if i were to that. i will all that function hard coding. and probably wont able to achieve it also.

i was able to find to string to mathparser library exprtk but still not much. how can i do all this using c++

Aucun commentaire:

Enregistrer un commentaire