Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 02 02:19
    CAD97 labeled #429
  • Dec 02 02:19
    CAD97 unlabeled #429
  • Dec 02 02:19
    CAD97 commented #429
  • Dec 02 02:11
    onelson commented #429
  • Dec 02 02:04
    CAD97 labeled #429
  • Dec 02 02:04
    CAD97 labeled #429
  • Dec 02 02:03
    CAD97 commented #429
  • Dec 02 01:00
    onelson commented #429
  • Dec 02 00:58
    onelson opened #429
  • Dec 01 03:59
    jedmao closed #428
  • Dec 01 03:59
    jedmao commented #428
  • Dec 01 01:05
    CAD97 commented #428
  • Dec 01 00:21
    jedmao edited #428
  • Dec 01 00:20
    jedmao opened #428
  • Nov 11 13:44
    CAD97 commented #416
  • Nov 11 09:32
    Timmmm commented #416
  • Nov 10 12:50
    Proximyst commented #427
  • Nov 10 11:02
    Nadrieril commented #416
  • Nov 10 10:30
    Timmmm commented #416
  • Nov 10 10:10
    birkenfeld commented #416
Tesla Ice Zhang‮
@ice1000
Install pest plugins and you at least have editing assistance for pest grammar files
Completion for Rule::<caret> is not yet available -- as intellij-rust devs claims that the completion API will not be very stable
Tesla Ice Zhang‮
@ice1000
Pest
Can we have a newer version of pest
Laurent Wandrebeck
@lwandrebeck
@ice1000 : please be patient, @dragostis will do that as soon as he can.
@ice1000 : meanwhile you can easily use git master branch in your Cargo.toml
Tesla Ice Zhang‮
@ice1000
Ok
Goldstein
@GoldsteinE

Hi. I can't realize how to skip character.
E.g. I have this:

regex_char = _{
    !("\\" | "/") ~ ANY
}
pattern = @{ regex_char* }
regex = { "/" ~ pattern ~ "/" }

I want to parse string /a\/b/ to regex -> pattern("a/b"), so backslash character is skipped and /a\\b/ to regex -> pattern("a\\b"), so first backslash character is skipped. How can I achieve this?

JSON example in the book leaves backslash inside of string on it's place
Goldstein
@GoldsteinE

Another example: I want to allow non-quoted strings for simple cases (like in TOML paths).

quoted_string_char = _{
    !("\"" | "\\") ~ ANY
    | "\\" ~ ANY
}

quoted_string = _{
    "\"" ~ quoted_string_char* ~ "\""
}

string = ${
    ASCII_ALPHANUMERIC+
       | quoted_string
}

This code leaves quotes in string for quoted strings

Goldstein
@GoldsteinE
I understand why I can't skip chars in any place, but it should be possible without copying on start or end of token
Tesla Ice Zhang‮
@ice1000
You can define COMMENT
Laurent Wandrebeck
@lwandrebeck
pest 2.1.2 has been released, thanks @dragostis :)
Dragoș Tiselice
@dragostis
I finally had some time to sort a few things out. Lemme know if I broke anything. Will try to invest a bit more time this month maybe; I'd really love to have a working demo of pest3.
Laurent Wandrebeck
@lwandrebeck
@dragostis : that would be really sweet :)
@dragostis : do you have anything waiting to be commited for pest3 ?
Dragoș Tiselice
@dragostis
Just a second. I think I did break people, indeed.
Laurent Wandrebeck
@lwandrebeck
I’ve (at laaaaaaaast) made some progress on RuSh, particularly on parsing front, the parsing loop still has to be rewritten, but the shell will be able to manage echo command and variables with next commit, hopefully.
Dragoș Tiselice
@dragostis
@lwandrebeck, super exciting! I really have to figure my life out to be able to get more open source development in.
It seems like the last update to quote 1.0 broke the bootstrap. I've tried updating quote to 1.0 in bootstrap as well, but it doesn't seem to work since it uses different version of proc_macro2.
I wish all of this procedural macro was a little bit harder to misuse...
Tesla Ice Zhang‮
@ice1000
Hi, can any admin of pest-parser update the description of this repo to "Pest Grammar file support for all JetBrains IDEs"?
/cc @dragostis
Dragoș Tiselice
@dragostis
Will do next week!
Tesla Ice Zhang‮
@ice1000
Ok
Andreas Rammhold
@andir
Is there some (efficient) way to find ta specific inner Rule match on a pair? I am constructing DateTime<Utc> objects from some input and iterating through all the submatches to find one specific one sounds wrong. Also having a bunch of (defaulted) mutable vars that I fill while iterating feels wrong.
Dragoș Tiselice
@dragostis
@andir, how else would you want to figure out without iterating?
Andreas Rammhold
@andir
@dragostis I do not want to avoid it I was just thinking I might have missed the existence of a helper method
I am mostly concerned about the readbility of the code not so much the runtime costs.
Dragoș Tiselice
@dragostis
I understand that. It's being on the wishlist for pest3, but I haven't had much time to invest lately.
Tesla Ice Zhang‮
@ice1000
pest3
The IntelliJ plugin has been updated with pest 2.1.2
RS
@sayrer
@johnstonskj (primitive_value ~ ("," ~ primitive_value)* ~ ","?)?
Simon Johnston
@johnstonskj
@sayrer , thanks
Tesla Ice Zhang‮
@ice1000

Will do next week!

psst

Daniel Kolsoi
@TheDan64
Hi. Given only ident = @{ (alpha | digit)+ }, how come "Foo Bar" parses successfully to ident "Foo"? Why isn't this a failure since you didn't find only a single ident, but two of them? IE there's no rule that expects two idents, just one
Laurent Wandrebeck
@lwandrebeck
@TheDan64 : not sure I understand correctly, but + means one or more occurences, and as pest is greedy, it matches alpha 3 times, space does not match as rule is @ (atomic). So ident is "Foo"
I suppose alpha is ASCII_ALPHA. though you could use ASCII_ALPHANUMERIC builtin rule as it is ASCII_DIGIT | ASCII_ALPHA
Tesla Ice Zhang‮
@ice1000

Hi. Given only ident = @{ (alpha | digit)+ }, how come "Foo Bar" parses successfully to ident "Foo"? Why isn't this a failure since you didn't find only a single ident, but two of them? IE there's no rule that expects two idents, just one

This is why I made https://github.com/owo-lang/voile-rs/blob/572a1a8550bb228815558ba1c27c697059bf31c7/voile-util/src/pest_util.rs#L24-L43

Tesla Ice Zhang‮
@ice1000
Thanks for updating the repo description!
Daniel Kolsoi
@TheDan64
@lwandrebeck I mean, I expect it to be a failure because it doesnt strictly find an ident, but an ident and then some extra junk which isn't expected by the language
Daniel Kolsoi
@TheDan64
@ice1000 That seems to do what I expected. Thanks!
Laurent Wandrebeck
@lwandrebeck
@TheDan64 : then you’d need to add EOI so that ident fails.
Daniel Kolsoi
@TheDan64
Thanks!
Daniel Kolsoi
@TheDan64
actually, I don't think EOI works if you want to use Ident within another rule
like field = { ident ~ "." ~ ident }
Daniel Kolsoi
@TheDan64
@ice1000 you could probably make your macro into a function, I think. Something like this:
fn strict_parse<'a, P, F, R, T>(rule: R, input: &'a str, f: F)-> Result<T, Error<R>>
where
    F: FnOnce(Pair<'a, R>) -> T,
    P: Parser<R>,
    R: Copy + Debug + Hash + Ord,
{
    let rule = P::parse(rule, input)?.next().unwrap();
    let end_pos = rule.as_span().end_pos();

    if end_pos.pos() < input.len() {
        let rest = &input[end_pos.pos()..];
        let variant = ErrorVariant::CustomError {
            message: format!("Does not consume the following code: '{}'", rest)
        };
        Err(Error::new_from_pos(variant, end_pos))
    } else {
        Ok(f(rule))
    }
}
Laurent Wandrebeck
@lwandrebeck
@TheDan64 : ok, then you have to get rid of @, so rule is not atomic and goes though space without stopping
(if I remember well)
Daniel Kolsoi
@TheDan64
Doesn't that mean you can have spaces between your letters and numbers though?