Skip to content

Maximum munch? #159

Description

@molnarp

Hi,

this is more of a question than an issue about Moo, so here goes:

I have the following lexer:

const lexer = moo.compile({
  TERM: /[a-z]+/,
  PREFIXTERM: /\*|(?:[a-z]+\*)/,
});

On input moo, this will return:

{"type":"TERM","value":"moo","text":"moo","offset":0,"lineBreaks":0,"line":1,"col":1}

On input moo* I would want it to return a single PREFIXTERM, but I'm getting this instead:

{"type":"TERM","value":"moo","text":"moo","offset":0,"lineBreaks":0,"line":1,"col":1}
{"type":"PREFIXTERM","value":"*","text":"*","offset":3,"lineBreaks":0,"line":1,"col":4}

How can I get it to go for a single PREFIXTERM?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions