remove some more nom

This commit is contained in:
Robin Appelman 2021-12-21 15:42:39 +01:00
commit 311345cf4e
15 changed files with 103 additions and 91 deletions

View file

@ -1,5 +1,6 @@
use crate::event::{param_parse, param_parse_with, position, u_int, ParamIter};
use crate::raw_event::{subject_parser, RawSubject};
use crate::raw_event::{against_subject_parser, RawSubject};
use nom::bytes::complete::{tag, take_while};
use nom::combinator::opt;
use nom::number::complete::float;
@ -103,7 +104,7 @@ pub fn point_captures_event_parser(input: &str) -> IResult<&str, PointCapturedEv
(Some((subject_key, subject)), Some((position_key, position_str)))
if subject_key.starts_with("player") && position_key.starts_with("position") =>
{
let (_, subject) = subject_parser(subject)?;
let (_, subject) = against_subject_parser(subject)?;
let (_, position) = position(position_str)?;
players.push((subject, position));
}

View file

@ -1,5 +1,5 @@
use crate::event::{param_parse, param_parse_with, quoted, u_int, ParamIter};
use crate::raw_event::{subject_parser, RawSubject};
use crate::raw_event::{against_subject_parser, RawSubject};
use nom::combinator::opt;
use nom::number::complete::float;
use nom::IResult;
@ -11,7 +11,7 @@ pub struct HealedEvent<'a> {
}
pub fn healed_event_parser(input: &str) -> IResult<&str, HealedEvent> {
let (input, subject) = param_parse_with("against", subject_parser)(input)?;
let (input, subject) = param_parse_with("against", against_subject_parser)(input)?;
let (input, amount) = param_parse_with("healing", quoted(u_int))(input)?;
Ok((
input,

View file

@ -1,6 +1,6 @@
use crate::common::{Class, Team};
use crate::event::{param_parse, param_parse_with, parse_from_str, position, u_int, ParamIter};
use crate::raw_event::{subject_parser, RawSubject};
use crate::raw_event::{against_subject_parser, RawSubject};
use nom::combinator::opt;
use nom::IResult;
use std::net::SocketAddr;
@ -35,7 +35,7 @@ pub struct DamageEvent<'a> {
}
pub fn damage_event_parser(input: &str) -> IResult<&str, DamageEvent> {
let (input, target) = param_parse_with("against", subject_parser)(input)?;
let (input, target) = param_parse_with("against", against_subject_parser)(input)?;
let mut event = DamageEvent {
target,
damage: None,
@ -62,7 +62,7 @@ pub struct KillEvent<'a> {
}
pub fn kill_event_parser(input: &str) -> IResult<&str, KillEvent> {
let (input, target) = subject_parser(input)?;
let (input, target) = against_subject_parser(input)?;
let (input, weapon) = param_parse("with")(input)?;
let mut event = KillEvent {
target,
@ -88,7 +88,7 @@ pub struct KillAssistEvent<'a> {
}
pub fn kill_assist_event_parser(input: &str) -> IResult<&str, KillAssistEvent> {
let (input, target) = param_parse_with("against", subject_parser)(input)?;
let (input, target) = param_parse_with("against", against_subject_parser)(input)?;
let mut event = KillAssistEvent {
target,
attacker_position: None,
@ -188,7 +188,7 @@ pub struct DominationEvent<'a> {
}
pub fn domination_event_parser(input: &str) -> IResult<&str, DominationEvent> {
let (input, against) = param_parse_with("against", subject_parser)(input)?;
let (input, against) = param_parse_with("against", against_subject_parser)(input)?;
Ok((input, DominationEvent { against }))
}
@ -198,7 +198,7 @@ pub struct RevengeEvent<'a> {
}
pub fn revenge_event_parser(input: &str) -> IResult<&str, RevengeEvent> {
let (input, against) = param_parse_with("against", subject_parser)(input)?;
let (input, against) = param_parse_with("against", against_subject_parser)(input)?;
Ok((input, RevengeEvent { against }))
}
@ -235,7 +235,8 @@ pub struct KilledObjectEvent<'a> {
pub fn killed_object_event_parser(input: &str) -> IResult<&str, KilledObjectEvent> {
let (input, object) = opt(param_parse("object"))(input)?;
let (input, weapon) = opt(param_parse("weapon"))(input)?;
let (input, object_owner) = opt(param_parse_with("objectowner", subject_parser))(input)?;
let (input, object_owner) =
opt(param_parse_with("objectowner", against_subject_parser))(input)?;
let (input, attacker_position) = opt(param_parse_with("attacker_position", position))(input)?;
Ok((
input,
@ -257,7 +258,7 @@ pub struct ExtinguishedEvent<'a> {
}
pub fn extinguished_event_parser(input: &str) -> IResult<&str, ExtinguishedEvent> {
let (input, against) = param_parse_with("against", subject_parser)(input)?;
let (input, against) = param_parse_with("against", against_subject_parser)(input)?;
let (input, with) = param_parse("with")(input)?;
let (input, attacker_position) = opt(param_parse_with("attacker_position", position))(input)?;
let (input, victim_position) = opt(param_parse_with("victim_position", position))(input)?;