I'm currently working on a 3-part blog series on writing a one-pass compiler in Python that emits C. It is quite a bit longer though because we make the lexer and parser from scratch. I started it because my students were having trouble with other tutorials because of all the jargon, theory, and libraries required. http://web.eecs.utk.edu/~azh/blog/teenytinycompiler1.html
def getToken(self):
self.skipWhitespace()
self.skipComment()
How does that handle multiple consecutive comments? Whitespace following a comment?(returning ‘comment’ and ‘whitespace’ tokens would fix this, and would make it possible to reuse the lexer for pretty-printing/syntax coloring)