Recently, I needed to analyze some RISC-V assembly code for a research project and then calculate some basic metrics, but I couldn’t find a suitable tool. Ok, I’ll just grab a parser from one of the smaller open-source assemblers. This wasn’t successful though since the ones I looked at use crude, regex-based parsers that don’t maintain information about the structure.
Not a problem, I’ll implement my own! Let me just look up the grammar for RISC-V assembly… oh no, there isn’t an official one?! Wait. The language itself isn’t even standardized beyond the instruction set, and each major assembler supports different notations and features???
Challenge accepted! My goal is to write a parser that supports the GNU assembler’s (GAS) syntax.