From 74dc6574650a157ab57779dc633e140d020b792a Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 May 2020 15:25:33 +0200 Subject: add -class player filter --- src/fexpr/grammar.lalrpop | 13 +++++++++++++ src/fexpr/mod.rs | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src/fexpr') diff --git a/src/fexpr/grammar.lalrpop b/src/fexpr/grammar.lalrpop index 654722b..f91da19 100644 --- a/src/fexpr/grammar.lalrpop +++ b/src/fexpr/grammar.lalrpop @@ -3,6 +3,7 @@ use super::{ FErrorKind, FightOutcome, filters, + PlayerClass, SearchField, }; use evtclib::Boss; @@ -77,6 +78,8 @@ PlayerPredicate: Box = { filters::player::account(<>.clone()) | filters::player::character(<>), + "-class" > => filters::player::class(<>), + "(" ")", } @@ -135,6 +138,16 @@ Boss: Boss = { }), } +PlayerClass: PlayerClass = { + =>? w.parse().map_err(|_| ParseError::User { + error: FError { + location: l, + data: w.into(), + kind: FErrorKind::InvalidClass, + } + }), +} + Date: DateTime = { =>? Local.datetime_from_str(d, "%Y-%m-%d %H:%M:%S") .map_err(|error| ParseError::User { diff --git a/src/fexpr/mod.rs b/src/fexpr/mod.rs index 2bdbfe7..452d66c 100644 --- a/src/fexpr/mod.rs +++ b/src/fexpr/mod.rs @@ -3,7 +3,7 @@ //! This module contains methods to parse a given string into an abstract filter tree, check its //! type and convert it to a [`Filter`][super::filters::Filter]. // Make it available in the grammar mod. -use super::{filters, FightOutcome, SearchField}; +use super::{filters, playerclass::PlayerClass, FightOutcome, SearchField}; use std::{error, fmt}; @@ -44,6 +44,8 @@ pub enum FErrorKind { InvalidTimestamp(#[from] chrono::format::ParseError), #[error("invalid boss name")] InvalidBoss, + #[error("invalid class name")] + InvalidClass, } /// Shortcut to create a new parser and parse the given input. -- cgit v1.2.3