Skip to content

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

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)
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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