I'm trying to lex (then parse) a C like language. In C there are preprocessor directives where line breaks are significant, then the actual code where they are just whitespace.
One way of doing this would be do a two pass process like early C compilers - have a separate preprocessor for the # directives, then lex the output of that.
However, I wondered if it was possible to do it in a single lexer. I'm pretty happy with writing the scala parser-combinator code, but I'm not so sure of how StdLexical
handles whitespace.
Could someone write some simple sample code which say could lex a #include
line (using the newline) and some trivial code (ignoring the newline)? Or is this not possible, and it is better to go with the 2-pass appproach?