Giter VIP home page Giter VIP logo

Comments (3)

jan-hudec avatar jan-hudec commented on June 13, 2024 1

For classes only, yes. For normalisation, no, one would have to write a new parser using the unicode-normalization crate, because a token here means a single codepoint (char), but normalisation needs to see multiple-codepoint sequences.

In fact I tried—and failed (#85)—at similar thing with graphemes and unicode-segmentation yesterday.

And then it depends on how generic you'd need the parser to be. unicode-normalization works on &str, so if you have that, you can use it directly, but if you have some other kind of stream, you have to collect and try normalising.

from combine.

Marwes avatar Marwes commented on June 13, 2024

No, you will have to look into some other crate for that. You can then use satisfy(|token| predicate(token)).expected("Expected value") to create a custom parser for whatever predicate you want (digit, letter etc are all implemented like this)

from combine.

Marwes avatar Marwes commented on June 13, 2024

To get regex parsers working I added FullRangeStream which lets one get retrieve a view into the entire parsers input.
Since unicode parsers require &str then this can be used to write parsers generic over the input stream (translating the example in #85 (comment).

pub fn grapheme<'a, I>(input: I) -> ParseResult<&'a str, I>
    where I: FullRangeStream<Range = &'a str>
{
    let mut iter = input.range().graphemes();
    match iter.next() {
        Some(g) => {
            let len = input.range().len() - iter.as_str().len();
            take(len).parse_stream(input)
        }
        None => Err(ParseError::end_of_input()),
    }
}

from combine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.