Stanford compilers: flex lexer for Cool
Posted on June 06, 2016
I just finished the first programming assignment for the Stanford Compilers course, which was to implement a lexer for the Cool (classroom object oriented language) using Flex. Flex is a C-language based lexical analyzer generator. It generates a valid c source file for the lexical rules you put together. The .flex file format is basically a c file with some special syntax. The bulk of this assignment was hunting for implementation details. I do not enjoy courses as much when they don't go through an assignment...