I'm working on a assembler for fun, written in C,flex,bison. I'd like to add macros, includes and repeating blocks and was thinking of doing this with a separate preprocessing stage parser.
My question is, how might I keep track of original source line numbers (and filenames)? This is for producing useful error messages, pretty printing, and generating debug information.
yylineno in the second parser after preprocessing is complete will presumably be offset after macro expansion and so on.
you can add
to the preprocessed assembler so
turns into