Super cool. I wish this was open source so I could see how you did some things, but I understand you've decided to keep it closed. Just to satisfy my curiosity, would you mind sharing how you did parsing at a high level? Did you use some publicly available parser/lexer or did you just implement pattern matching yourself with something like regex or other token splitting measures?
I'm very glad you asked. I wrote my own parser combinator library in TypeScript partly based on eulalie[0], so it doesn't have a separate lexer and parser and doesn't rely heavily on regexes (though it does use them to do things like match a single alphanumeric character). I plan on open sourcing this library one day once I can tidy up the API because I think it would be useful to other people.
But to give you an idea of what that all looks like this is the code for the parser that parses the "as a % of" operator:
I wasn't familiar with Eulalie, that's a really interesting approach. I built functionality [0] similar to numpad into a larger record-keeping system, Tap [1]. Precedence rules kindof scramble my brain so I ended up implementing s-expression syntax for Tap formulas.
I ended up writing the parser myself, called sowhat, but used a library for tokenization, moo.js [2]. You can see a demo of just the sowhat editor here [3].
I've found that a super simple way to parse basic expressions is a recursive descent parser. It is very simple to implement. No need to to break into tokenizer/parser, no need to generate an AST, just evaluate the expression while parsing.