Skip to content

negation does not capture anything #6

@ZelphirKaltstahl

Description

@ZelphirKaltstahl

I am trying to match anything but ; and thought I could do the following:

parser = peg Line do
      Line <- str(!";")
end
Xpeg.match(parser, "a")

But nothing is captured:

%{
  captures: [""],
  match_len: 0,
  rest: 'a',
  result: :ok,
  time: 0.0,
  userdata: nil
}

I also tried various other patterns to no avail:

parser = peg Line do
      Line <- str(!{";"})
end
Xpeg.match(parser, "a")

or

parser = peg Line do
      Line <- str(!{';'})
end
Xpeg.match(parser, "a")

In the tests I could only find a negation without capture: https://github.com/zevv/xpeg/blob/master/test/xpeg_test.exs#L85-L86. Maybe negation does not capture anything?

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions