Reserve ! character
This commit is contained in:
parent
f21f906eaf
commit
cb35ef0ebb
1 changed files with 29 additions and 2 deletions
|
@ -71,7 +71,7 @@ pub fn make_parser() -> impl Parser<char, Expr, Error = Simple<char>> {
|
||||||
.ignore_then(none_of('"').repeated().collect::<String>())
|
.ignore_then(none_of('"').repeated().collect::<String>())
|
||||||
.then_ignore(just('"'));
|
.then_ignore(just('"'));
|
||||||
|
|
||||||
let symbols = r#"()<>"|&="#.chars().collect::<HashSet<_>>();
|
let symbols = r#"()<>"|&=!"#.chars().collect::<HashSet<_>>();
|
||||||
|
|
||||||
let raw_str = filter(move |c: &char| !c.is_whitespace() && !symbols.contains(c))
|
let raw_str = filter(move |c: &char| !c.is_whitespace() && !symbols.contains(c))
|
||||||
.repeated()
|
.repeated()
|
||||||
|
@ -295,7 +295,7 @@ fn can_parse_number_operators() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_use_boolean_operators() {
|
fn can_use_and_operator() {
|
||||||
let parser = make_parser();
|
let parser = make_parser();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -314,6 +314,11 @@ fn can_use_boolean_operators() {
|
||||||
))
|
))
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn can_use_or_operator() {
|
||||||
|
let parser = make_parser();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parser.parse(r#"album % lands || title % "sword""#).unwrap(),
|
parser.parse(r#"album % lands || title % "sword""#).unwrap(),
|
||||||
|
@ -333,6 +338,28 @@ fn can_use_boolean_operators() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn can_use_not_operator() {
|
||||||
|
let parser = make_parser();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
parser.parse(r#"album % lands !! title % "sword""#).unwrap(),
|
||||||
|
Expr::Combined(
|
||||||
|
Box::new(Expr::TextCmp(
|
||||||
|
TextField::Album,
|
||||||
|
TextOp::Like,
|
||||||
|
"lands".to_owned()
|
||||||
|
)),
|
||||||
|
BoolOp::Not,
|
||||||
|
Box::new(Expr::TextCmp(
|
||||||
|
TextField::Title,
|
||||||
|
TextOp::Like,
|
||||||
|
"sword".to_owned()
|
||||||
|
))
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn boolean_operators_share_precedence() {
|
fn boolean_operators_share_precedence() {
|
||||||
let parser = make_parser();
|
let parser = make_parser();
|
||||||
|
|
Loading…
Add table
Reference in a new issue