I thought this was a neat example, so I had a go at porting it from C to use my Python plugin for GCC
The result is about 35 lines of Python code (including comments), which you can see here
I hope the code is easy to read. One other thing this demonstrates is how by extending the compiler in Python you have access to the whole of the Python packaging ecosystem - I was able to use the "enchant" spellchecking library (originally from the AbiWord project) with about 4 lines of code.