You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a charting application which should allow the user to add new time series by entering an expression that refers to existing ones, e.g. make an average of two other series. Each series have a name, so you could e.g. write (s1+s2)/2 to define the average of series s1 and s2. However, the series are grouped and only unique within a group, so it's natural to have a hierarchical naming scheme. The groups aren't named, but can be given a name based on the order. Hence, I end up with names like a_amount and b_amount. What I would like is to allow using $n.name for referring to series name within group n. To do this I need to make a custom Tokenizer that allows $ as the first char of a variable. This is currently not easy or possible, for several reasons:
the set of legal characters of operators is hard-coded in the Operator class
the method that creates the Tokenizer, ShuntingYard.convertToRPN is static and thus cannot be replaced
I suggest the following changes:
move the logic for allowed operator chars to the Tokenizer, to make it easier to customise
add the Tokenizer as argument to ShuntingYard.convertToRPN and use a factory method in ExpressionBuilder to create ut, so you can replace it in a subclass
There may be other changes necessary, and I will explore them in a branch. But it may be best to discuss it in this issue first?
The text was updated successfully, but these errors were encountered:
So what you're saying is that you want be able inject custom Tokenizers into exp4j using e.g. ExpressionBuilder.tokenizer(Tokenizer t) ?
Have you already implemented this and if yes, can I take a look at it?
I'm working on a charting application which should allow the user to add new time series by entering an expression that refers to existing ones, e.g. make an average of two other series. Each series have a name, so you could e.g. write (s1+s2)/2 to define the average of series s1 and s2. However, the series are grouped and only unique within a group, so it's natural to have a hierarchical naming scheme. The groups aren't named, but can be given a name based on the order. Hence, I end up with names like a_amount and b_amount. What I would like is to allow using $n.name for referring to series name within group n. To do this I need to make a custom Tokenizer that allows $ as the first char of a variable. This is currently not easy or possible, for several reasons:
I suggest the following changes:
There may be other changes necessary, and I will explore them in a branch. But it may be best to discuss it in this issue first?
The text was updated successfully, but these errors were encountered: