How can I get the locations of those identifiers in the source code?
... without writing a parser.
You can't. You would need to either write your own (for all programming languages your GUI will support), or hook one of the existing ones.
Clang makes it relatively easy to incorporate the C/C++ parser into a GUI, but ...
- not everything can be parsed with Clang
- this one aspect of writing a GUI is likely to be 100x more complicated than all the others, so perhaps not worth the effort.