Ticket #14 (closed feature request: duplicate)

Opened 5 years ago

Last modified 5 years ago

Parametrize parsing on extensions that should be recognized

Reported by: nibro Owned by: nibro
Priority: blocker Milestone: Full code support
Component: parser Version:
Keywords: Cc:

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.

Change History

Changed 5 years ago by nibro

  • description modified (diff)

Changed 5 years ago by nibro

  • status changed from new to assigned

I've started working on this, and I've come a really long way. But of course it's the easy cases I've done so far, and the tricky ones still remain.

Those extensions that are fixed are those that fall into one of the following categories: * They require new lexemes, which means it can be handled in the lexer. * They rely on completely new parser productions, meaning they can be checked directly in the parser. * PatternGuards? and ScopedTypeVariables?, which were both easy checks on what was returned from sub-productions.

This actually covers the vast majority of extensions. But as noted, the trickiest ones remain.

Changed 5 years ago by nibro

  • status changed from assigned to closed
  • resolution set to duplicate

This is now enabled in general. There are however three cases left to handle: The allowed classes and contexts (#28), the use of forall types (#29) and the use of type operators (#30). These now have tickets of their own.

Note: See TracTickets for help on using tickets.