Ticket #14 (closed feature request: duplicate)
Parametrize parsing on extensions that should be recognized
|Reported by:||nibro||Owned by:||nibro|
|Priority:||blocker||Milestone:||Full code support|
Description (last modified by nibro) (diff)
The main sticking point for haskell-src-exts at the moment is that it cannot parse some perfectly valid Haskell98 code. This is because it assumes all extensions are active, including those that "steal" syntax.
The typical example is Template Haskell's special treatment of $ident and $( ). In Haskell 98 there would be no difference between $ident and $ ident, i.e. the application operator followed by an identifier ident. With Template Haskell active, $ident is a splicing of the TH expression ident.
We obviously want to be able to handle both interpretations, and thus we must parametrize the parser on what extensions it should recognize during parsing. For instance, $ident would only be a TH splice if the TemplateHaskell extension was active.
Some extensions can be handled at the level of the lexer, such as the TH splices. These are the simple ones. Other extensions must be deferred to the parser, such as MPTCs. These are far trickier since the Parser is written using happy. In these cases we need to first parse a rule, and then verify/massage the result of the parse into whatever form is appropriate.