[Haskell-cafe] lexing nested comments in GHC/Parser/Lexer.x
Benjamin Redelings
benjamin.redelings at gmail.com
Wed Feb 10 04:57:43 UTC 2021
Hi,
I notice that in Lexer.x for GHC nested comments are parsed using a
special function, with the comment "nested comments require traversing
by hand, they can't be parsed using regular expressions."
While I see that nested comments can't be parsed using regular
expressions, the lexer has a state stack, and so it seems like nested
comments could be parsed by pushing a new "nested comment" state onto
the lexer state every time a "{-" is encountered. But perhaps this is
not done because its not clear how to make the entire comment into a
single token that way? This might be a naive question -- I don't have
that much experience with lexers.
Thanks!
-BenRI
More information about the Haskell-Cafe
mailing list