Skip to content

Commit

Permalink
build: bump winnow from 0.6.22 to 0.6.25
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbenavides committed Jan 28, 2025
1 parent b9fccfd commit 0325184
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
6 changes: 2 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions implementations/rust/ockam/ockam_abac/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ str-buf = "3.0.3"
tokio = { version = "1.41", default-features = false, optional = true, features = ["sync", "time", "rt", "rt-multi-thread", "macros"] }
tracing = { version = "0.1", default-features = false, features = ["attributes"] }
wast = { version = "220.0.0", default-features = false, optional = true }
winnow = { version = "0.6.18", default-features = false, optional = true, features = ["alloc"] }
winnow = { version = "0.6.25", default-features = false, optional = true, features = ["alloc"] }

[dev-dependencies]
ockam_vault = { path = "../ockam_vault", default-features = false, features = ["rust-crypto"] }
quickcheck = "1.0.3"
rand = "0.8.5"
serde_json = "1.0.133"
tempfile = "3.10.1"

[[bin]]
name = "repl"
Expand Down
35 changes: 18 additions & 17 deletions implementations/rust/ockam/ockam_abac/src/boolean_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,14 @@ mod parsers {
use ockam_identity::Identifier;
use winnow::ascii::multispace0;
use winnow::combinator::{alt, delimited, separated};
use winnow::error::StrContext;
use winnow::error::{ContextError, StrContext};
use winnow::stream::AsChar;
use winnow::token::{literal, take_until, take_while};
use winnow::{IResult, PResult, Parser};
use winnow::{ModalResult, Parser};

/// Top-level parser for boolean expressions as a series of 'or-ed' and-expressions
pub fn expr(i: &mut &str) -> PResult<BooleanExpr> {
fn or_separated(i: &mut &str) -> PResult<Vec<BooleanExpr>> {
pub fn expr(i: &mut &str) -> ModalResult<BooleanExpr> {
fn or_separated(i: &mut &str) -> ModalResult<Vec<BooleanExpr>> {
separated(1.., and_expr, or).parse_next(i)
}

Expand All @@ -304,8 +304,8 @@ mod parsers {
}

/// Parser for an and expression as a series of 'and-ed' not-expressions
pub fn and_expr(i: &mut &str) -> PResult<BooleanExpr> {
fn and_separated(i: &mut &str) -> PResult<Vec<BooleanExpr>> {
pub fn and_expr(i: &mut &str) -> ModalResult<BooleanExpr> {
fn and_separated(i: &mut &str) -> ModalResult<Vec<BooleanExpr>> {
separated(1.., not_expr, and).parse_next(i)
}

Expand All @@ -321,13 +321,13 @@ mod parsers {
/// - a nested not expression
/// - a parenthesized expression
/// - a single name
pub fn not_expr(i: &mut &str) -> PResult<BooleanExpr> {
fn nested_not_expr(i: &mut &str) -> PResult<BooleanExpr> {
pub fn not_expr(i: &mut &str) -> ModalResult<BooleanExpr> {
fn nested_not_expr(i: &mut &str) -> ModalResult<BooleanExpr> {
(not, not_expr)
.parse_next(i)
.map(|(_, e)| BooleanExpr::not(e))
}
fn parenthesized(i: &mut &str) -> PResult<BooleanExpr> {
fn parenthesized(i: &mut &str) -> ModalResult<BooleanExpr> {
delimited(open_paren, expr, close_paren).parse_next(i)
}
alt([nested_not_expr, parenthesized, name])
Expand All @@ -338,7 +338,7 @@ mod parsers {
// LEXED VALUES

/// Parse a name
pub fn name(input: &mut &str) -> PResult<BooleanExpr> {
pub fn name(input: &mut &str) -> ModalResult<BooleanExpr> {
let name = (
// we forbid the first character to be a number or a dot
take_while(1, |c| AsChar::is_alpha(c) || c == '_' || c == '-'),
Expand All @@ -365,7 +365,8 @@ mod parsers {

// otherwise, keep processing the input to figure out if it's a name-value pair
// peek the next char; continue only if it's an equal sign
let peeked: IResult<&str, &str> = take_while(1, |c| c == '=').parse_peek(input.as_ref());
let peeked: ModalResult<(&str, &str), ContextError> =
take_while(1, |c| c == '=').parse_peek(input.as_ref());
let next_char_is_not_equal_sign = peeked.map(|(_, s)| s.is_empty()).unwrap_or(true);
if next_char_is_not_equal_sign {
return Ok(name);
Expand All @@ -379,7 +380,7 @@ mod parsers {
.parse_next(input)?;
// skip the opening '"' if any
let is_quoted = {
let res: PResult<&str> = take_while(1, |c| c == '"').parse_next(input);
let res: ModalResult<&str> = take_while(1, |c| c == '"').parse_next(input);
res.is_ok()
};
// parse the value as the next group of chars
Expand All @@ -404,27 +405,27 @@ mod parsers {
}

/// Parse the 'and' operator
pub fn and<'a>(input: &mut &'a str) -> PResult<&'a str> {
pub fn and<'a>(input: &mut &'a str) -> ModalResult<&'a str> {
delimited(multispace0, literal("and"), multispace0).parse_next(input)
}

/// Parse the 'or' operator
pub fn or<'a>(input: &mut &'a str) -> PResult<&'a str> {
pub fn or<'a>(input: &mut &'a str) -> ModalResult<&'a str> {
delimited(multispace0, literal("or"), multispace0).parse_next(input)
}

/// Parse the 'not' operator
pub fn not<'a>(input: &mut &'a str) -> PResult<&'a str> {
pub fn not<'a>(input: &mut &'a str) -> ModalResult<&'a str> {
delimited(multispace0, literal("not"), multispace0).parse_next(input)
}

/// Parse an open parentheses '('
pub fn open_paren<'a>(input: &mut &'a str) -> PResult<&'a str> {
pub fn open_paren<'a>(input: &mut &'a str) -> ModalResult<&'a str> {
delimited(multispace0, literal("("), multispace0).parse_next(input)
}

/// Parse a close parentheses ')'
pub fn close_paren<'a>(input: &mut &'a str) -> PResult<&'a str> {
pub fn close_paren<'a>(input: &mut &'a str) -> ModalResult<&'a str> {
delimited(multispace0, literal(")"), multispace0).parse_next(input)
}
}
Expand Down

0 comments on commit 0325184

Please sign in to comment.