Skip to content

// C++/EOL-style comments recipe does not seem to work #1866

@nyurik

Description

@nyurik

The // C++/EOL-style comments recipe seems to not match the expected content. The expected parser here should accept //...\n, whereas the example for some reason works with a single char '%'. Moreover, ideally I would like an example that requires a newline with an optional end-of-line comment before that. Am I misreading it?

/// This version uses % to start a comment, does not consume the newline character, and returns an output of ().
pub fn peol_comment<'a, E: ParseError<&'a str>>(i: &'a str) -> IResult<&'a str, (), E>
{
  value(
    (), // Output is thrown away.
    pair(char('%'), is_not("\n\r"))
  ).parse(i)
}

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