I've written a very basic expression parser and I would like it to be extendable so it can parse user defined expression types.
For exemple, if when parsing I meet the character <
, I want to create an instance of the class used to parse expressions starting by this character.
I have two questions:
How can I associate a character to a static method pointer?
I want to use a static method that will return a new instance of the class since I can't get a pointer to the class constructror. The following syntax is probably wrong, but that's the idea:
typedef static IValue * (*returnPtrIValue)(); map<char, returnPtrIValue> ...
Assuming I have class A, and class B extends class A, can I initialize a pointer to a function returning a pointer/ref to a A with a pointer to a function returning a pointer/ref to a B since a B is an A?
For example, can I do:
typedef A * (*returnPtrA)(); B * func() { ... } returnPtrA foo = func;