I'm working on an assembly language support plugin and about to bang my head against the wall after several days of fruitless attempts to Get Things Right(TM).
The language has some things I have a hard time to get working in a BNF / Lexer way.
Legal examples of defining a label:
The label itself is optional on the line. After the optional label, an assembly instruction may be posted e.g.
GlobalLabel: move.l d0,d1
With the Parser skipping the whitespaces I explicitly defined in the BNF to distinguish lines with spaces before the first token it makes it impossible to distinguish the various forms of legal label definitions and assembly mnemonics.
To make things extra complicated, one can also define macros (via preprocessor keyword) and use these instead of assembly mnemonics, e.g.
The ambiguity between assembly language mnemonics (which I don't want to define within the BNF) and macro calls with a different syntax for the parameters makes parsing hard.
I'm stuck here, but I guess I will need to write a manual lexer to handle these cases? Or is there a less awful way?