There already is a com.singularsys.jep.misc.CaseInsensitiveVariableTable that probably fits the bill.
Just set up Jep with
Jep jep = new Jep(new CaseInsensitiveVariableTable());
There is no need to modify the configurable parser.
Here's a simple test
package com.singularsys.jeptests.unit;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import com.singularsys.jep.Jep;
import com.singularsys.jep.JepException;
import com.singularsys.jep.ParseException;
import com.singularsys.jep.misc.CaseInsensitiveVariableTable;
class CaseInsensitiveVariableTableTest {
Jep jep;
private CaseInsensitiveVariableTable civt;
@BeforeEach
void setUp() throws Exception {
civt = new CaseInsensitiveVariableTable();
jep = new Jep(civt);
}
@Test
void testAdd_Get_Variable() throws JepException {
civt.addVariable("FOO",5.0);
double val = (double) civt.getVariable("Foo").getValue();
assertEquals(5.0,val,0.0);
}
@Test
void test_JepJava_Users_25_10_2022() throws JepException {
jep.addVariable("x",1);
jep.parse("x+X");
Object result = jep.evaluate(); // = 2
assertEquals(2.0,result);
}
@Test
void test_parsing_with_CIVT() throws ParseException, JepException {
jep.parse("X = 5");
double r1 = jep.evaluateD();
assertEquals(5.0,r1,0.0);
jep.parse("Foo = x * X");
double r2 = jep.evaluateD();
assertEquals(25.0,r2,0.0);
double r3 = (double) jep.getVariableValue("fOO");
assertEquals(25.0,r3,0.0);
}
}