Ticket #11 (closed feature request: fixed)

Opened 8 years ago

Last modified 8 years ago

Fixities aren't handled during parsing

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

Description (last modified by nibro) (diff)

Currently, operator expressions are parsed as left-associative, and of the same fixity. It would be nice to have the parser able to return a syntax tree where the fixity is taken into account correctly.

There are several issues involved:

  • Have the parser take a set of known fixities, and take them into account when parsing.
  • Have the parser react to (possibly infix) fixity declarations in the module it is parsing.
  • Possibly handle operators with unknown fixity in a different way - though the H98 report stipulates a default behavior, so I believe it would be best to follow that.

Neil Mitchell's HLint has code to massage the AST given a set of known fixities. I will use that as my starting point.

Change History

Changed 8 years ago by nibro

  • description modified (diff)

Changed 8 years ago by nicolas.pouillard@…

Fixities should not be directly handled be the parser. The parser should first returns a list of expressions separated by operators and then the tree is re-balanced using the fixities. That's really the simpler way of doing this kind of parsing IMHO.

Changed 8 years ago by nibro

Indeed, I agree with what you say. It wouldn't be feasible to actually take fixities into account during parsing, so a post-processing step is the only reasonable way.

Changed 8 years ago by nibro

  • status changed from new to assigned

Changed 8 years ago by nibro

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

Fixities are now taken into account when parsing. The list of known fixities can be given in the parse mode, default is the fixities defined by the Prelude. Fixities in the local document will always be taken into account, including ones defined in local let-blocks (they will of course only affect that block).

Note: See TracTickets for help on using tickets.