I am trying to use lex (then parse) a C-like language. C has preprocessor directives where line breaks are significant, and then actual code, where they are just spaces.
One way to do this would be to execute a two-processor process, such as the early C compilers, to have a separate preprocessor for the # directives, and then lex output it.
However, I wondered if this could be done in one lexer. I am very pleased with the scala combinator parser code, but I'm not sure how it StdLexicalhandles spaces.
Can someone write some simple code example that could use lex a #includeline (using a new line) and some trivial code (ignoring a new line)? Or is it impossible, and is it better to go with a two-pass application?
source
share