I have expressions that can be provided by the user, such as:
a*sin(w*t)
a+b/c
x^2+y^2/2
And I would like to just get the list of variables there. I don't need to do any substitutions. So, for the first formula it's gonna be {a,w,t}
. For the second one {a,b,c}
, and for the last one {x,y}
.
The expression is primarily written to be parsed with Sympy, but I need to be able to get the list of variables in C++ for some checks. I would like to:
- Avoid having to link the whole Python interpreter to my program
- Avoid reinventing the wheel, as I saw there are many parsing libraries available, such as
muparser
, but I don't know if any of these provide this functionality
What's the easiest way to do this? How would you tackle this problem?