8000 Unexpected parsing behavior when composing parsers programmatically · Issue #298 · com-lihaoyi/fastparse · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Unexpected parsing behavior when composing parsers programmatically #298
Open
@Amaumaury

Description

@Amaumaury

I'm trying to build a simple parser using fastparse which succeeds when the given input is one of the words defined in a given list. Concretely this is what my code looks like:

val words = List("a", "b", "c", "d")

def reader[$: P] = words.map(f => P( f )).reduce((l, r) => l | r )

fastparse.parse(input, reader(_))

The parser fails when input is "a", "b", or "c" and succeeds when given "d". Precisely, the parser seems to succeed when "d" appears in the input and all other characters are from the list of words.

From my understanding this parser should succeed on "a", "b", "c" and "d". Am I missing something ?

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

      0