Lexer? I hardly know 'er!
It's time to start writing a program that can understand the assembly code that I wrote about last time. That way, I can stop hard-coding the program into a C file, and instead just load a Carp file!
Let me backtrack. There are a few parts of the program that reads the assembly code. They are:
- Lexer
- Parser
- Interpreter/Compiler
Their respective jobs are:
- Read the raw code and separate it into tokens (keywords, values, etc)
- Read the list of tokens and separate them into groups (function calls, arguments, etc)
- Do what the program says / write the machine code of the program to a file
I've never written a lexer before. I've never written a parser before. But I have written a horrific interpreter/compiler consisting almost entirely of if/else statements. Don't do what I did... but if you want to look at the mess (still public because I have no shame), check it out here.
So far, I have written some functions that:
- Separate an array of characters (read from a file) into a linked list
- Do type-checks on characters
- Clean up all of the data
Aaaaaand now I just need to write the actual hard parts. Fantastic. Coming soon! Hopefully.