I'm currently working on creating a tiny expression language in Apex. I'm following https://craftinginterpreters.com which develops a simple lexer / parser in Java. I'm working on the lexer now which traverses the source character by character. Apex does not have a native character type. I'm wondering if it would be better to go to the work of treating characters as Integers.
Integer c = 'Hello, world!'.charAt(currentPosition);
String c = 'Hello, world!'.substring(currentPosition, currentPosition + 1);
CPU time is a consideration as it might have to parse 1,000's of small source expressions in a regular transaction. I suspect the low friction path is to implement characters as strings of length 1.
I thought someone here is been down this path and would have some advice or a pointer or two.