Lexing newlines in scala StdLexical?
Posted
by Nick Fortescue
on Stack Overflow
See other posts from Stack Overflow
or by Nick Fortescue
Published on 2010-04-14T08:26:37Z
Indexed on
2010/04/14
12:43 UTC
Read the original article
Hit count: 268
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?
© Stack Overflow or respective owner