Add lexer code from Andrew.
Fix compilation.