spidior 0.2.2

A tool for handling sed-like substitution tasks where pesky source code semantics are getting in the way.
use crate::regexparser::ast::*;

grammar;

pub Location: Box<Location> = {
    <r:RLocation> => r,
    "^" <r:RLocation> => Box::new(Location::Not(r)),
    <l:Location> "|" <r:RLocation>  => Box::new(Location::Or(l, r)),
    <l:Location> "&" <r:RLocation>  => Box::new(Location::And(l ,r)),
};

RLocation: Box<Location> = {
    "(" <c:Location> ")" => c,
    "%" => Box::new(Location::All),
    <s:r"<[^%:<>(){}]*>"> => Box::new(Location::Path(s[1..s.len()-1].to_string())),
    <s:r"\{[^%:<>(){}]*\}"> => Box::new(Location::Function(s[1..s.len()-1].to_string())),
    "l" <s:r"[0-9]*"> "-" <e:r"[0-9]*"> => Box::new(Location::LineRange(s.parse::<usize>().unwrap(), e.parse::<usize>().unwrap())),
    "c" <s:r"[0-9]*"> "-" <e:r"[0-9]*"> => Box::new(Location::CharRange(s.parse::<usize>().unwrap(), e.parse::<usize>().unwrap())),
};