Hi all,
I have some custom expressions, and i want to add these expressions to the freecad expression engine.
I check the code about the expression, and see some parser files.
Just like:ExpressionParser.l,ExpressionParser.y,ExpressionParser.tab.h and ExpressionParser.tab.c
I think these files are about Bison parser,but i don't know anything about Bison.
So, what should i do?
Thanks!
How to add custom expression to the Expression engine?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 602
- Joined: Tue Jan 29, 2013 10:35 pm
Re: How to add custom expression to the Expression engine?
What do you want to achieve? Do you have an example of what you want to do? If you want to add a simple function, please look at https://github.com/eivindkv/FreeCAD/tree/Fix_issue_2877 for an example.G-VAR wrote:Hi all,
I have some custom expressions, and i want to add these expressions to the freecad expression engine.
I check the code about the expression, and see some parser files.
Just like:ExpressionParser.l,ExpressionParser.y,ExpressionParser.tab.h and ExpressionParser.tab.c
I think these files are about Bison parser,but i don't know anything about Bison.
So, what should i do?
Eivind
Re: How to add custom expression to the Expression engine?
Thanks for your reply, Eivind!eivindkvedalen wrote:
What do you want to achieve? Do you have an example of what you want to do? If you want to add a simple function, please look at https://github.com/eivindkv/FreeCAD/tree/Fix_issue_2877 for an example.
Eivind
I'm sorry that I didn't elaborate on my question.I meaned that if i have defined a function in C++,just like "FunctionABC(int a, int b, int c)", then i want to use this function in the SpreadSheet or other workbenches. What do i need to do?
I have looked at your commit about the issue #2877,i have got some inspiration.I'm very grateful to you.
And is there anything else to consider?
-
- Posts: 602
- Joined: Tue Jan 29, 2013 10:35 pm
Re: How to add custom expression to the Expression engine?
G-VAR wrote: Thanks for your reply, Eivind!
Within the current framework, you should look at my branch, and extend the function class with your implementation. As long as you don't need to extend the grammer, this will suffice.G-VAR wrote: I'm sorry that I didn't elaborate on my question.I meaned that if i have defined a function in C++,just like "FunctionABC(int a, int b, int c)", then i want to use this function in the SpreadSheet or other workbenches. What do i need to do?
I'm considering extending the expression system to be able to add these things at runtime (from C++), but before that happens, you have to customize the code in App.G-VAR wrote:And is there anything else to consider?
Eivind
Re: How to add custom expression to the Expression engine?
Alright, i will have a try!
Thanks, Eivind!
Thanks, Eivind!