Git Product home page Git Product logo

Comments (6)

wdebeaum avatar wdebeaum commented on August 19, 2024

Thanks for your interest in PEG.jl, and sorry for my delay in replying (I was on vacation, and then working through the backlog from that vacation).

I had thought about doing something like this, but I was kind of on the fence because I wanted to keep it simple. But I think seeing that someone else wants this feature too has pushed me off the fence.

I think it might be good to have one extra modifier that changes the behavior of p and w, rather than two modifiers that copy p and w with the change. Modifier letters are a scarce resource, and in addition to overriding Julia's imsx, I'd like to avoid redefining those that are in active use in other languages like Perl. That leaves bfhjkqtvyz. How about h for horizontal?

I think most whitespace characters are horizontal, so I should just list the ones that aren't, in a negative lookahead before the \s. That would turn the implementation of p from \s* to (?:(?![\r\n\v\f\u85])\s)*. That is to say, the vertical whitespace characters are: carriage return, line feed, vertical tab, form feed, and next line. Did I miss any?

from peg.jl.

ntezak avatar ntezak commented on August 19, 2024

Thanks for your reply! There is actually a special horizontal whitespace \h regex form, so we can probably use that directly, right?

from peg.jl.

ntezak avatar ntezak commented on August 19, 2024

So would this then be?

  1. r","p to match comma, followed by any whitespace
  2. r","ph to match comma, followed by any horizontal whitespace
  3. r"BEGIN"w to match "BEGIN", followed by any whitespace
  4. r"BEGIN"wh to match "BEGIN", followed by any horizontal whitespace

from peg.jl.

wdebeaum avatar wdebeaum commented on August 19, 2024

Oh, \h is good to know! Apparently it was added in Perl 5.10, after I learned Perl 5.6 :)

And yes, your four examples are correct.

OK, I just committed this change; eventually this will be version 0.2.0, once the CI tests finish and I submit the version tag/metadata.

from peg.jl.

wdebeaum avatar wdebeaum commented on August 19, 2024

Hm, mac tests are taking forever to even start running. Submitted it anyway; hopefully it'll get there eventually.

from peg.jl.

ntezak avatar ntezak commented on August 19, 2024

They seem to have passed eventually. Thanks @wdebeaum, this is super helpful!

from peg.jl.

Related Issues (4)

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.