I need validate a formula to calculate the grade of discipline:
All identifiers (A1, A2,A3,...) has been based on tests, homeworks, etc. created by teachers. Below an example of a common formula:
( (A1+A2+A3) / 3) * (B2+B3)
On this case, I'm just need validate the formula structure, like:
- Non closed parenthesis (done);
- Empty parenthesis groups '()' (done);
- Duplicated operators like '(A1++A2)';
- Duplicated distinct operators like '(A1 -* A2)';
All identifiers at formula like A1,A1, etc has been informed by final user, and doesn't validated.
Sample of valid formula:
(((A1+A2+A3)/3)*2) + (((B1+B2+B3)/3)*3)
Sample of invalid formula:
+ (((A1+A2+A3)/3)*2) + (((B1+B2+B3)/3) / 3++)