Hello, I am facing a similar problem. I prefer to program in Python, it’s much easier and you don’t have to solve ugly low level problems. Of course, Python has worse performance compared to C++, but in the case of BOM generation, I think it doesn’t matter if it takes a fraction of a second or several seconds. Here on the forum I found a link to a nice kiutils library that solves S-expression stuff.
Here is a link to my thread
There is nothing stopping you from rewriting Python to C++ …