Skip to content

Lift a parser working on a subset of the tokens #19

Description

@gallais

It would be nice to have:

reLex : (check : q -> Maybe p) ->  ∀[ Parser P v ] ->  ∀[ Parser Q v ]

where P and Q are essentially the same parameters except that P
has p as the token type while Q has q, which is larger.

My current use case: I want the user to provide a parser munching characters
but I'd like to use it in a context where a lexer has been run and some special
characters have been recognised as special. So I have:

data TOK = A | B | C Char

and I'd like reLex to run a modified view that takes check into account
so that the client's anyTok only succeeds if the TOK has the shape C c.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions