Skip to content

Lexer behaviour #45

@tmbb

Description

@tmbb

Pinging @josevalim because of the discussion on the NimbleParsec repo.

Currently, the lexer behaviour defines these two callbacks: https://github.com/elixir-makeup/makeup/blob/master/lib/makeup/lexer.ex#L8-L17

However, when I defined this behaviour, I was thinking of reusing combinators from one lexer inside another lexer. The goal would be to be able (for example) to create an EEx lexer that would call the Elixir lexer for the Elixir part. This means that the root_element and the root combinators should be accessible from outside of the Lexer as combinators (not only as functions).

My question is:

  1. Should we keep the behaviour as it is and add combinators corresponding to these entrypoints? (that is, a root_element__0/6 function and a root__0/6 function?
  2. Should we change the behaviour so that only the combinators (i.e. fun__0/6) are exported?

I think that for backward compatibility reasons we should go with option 1. Also, the way we are implementing the lex/2 function in most lexers is based on a the fact that a root/1 function exists.

What do you think @josevalim? This would be a good case for the export_combinator: true option you've talked about?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions