commit
f8fbad627d
@ -31,11 +31,9 @@ pub(crate) fn string_literal_impl(s: Span) -> IResult<Span, Locate> {
|
||||
|
||||
let a = if let Some(b) = ret {
|
||||
let a = concat(a, b).unwrap();
|
||||
let a = concat(a, c).unwrap();
|
||||
a
|
||||
concat(a, c).unwrap()
|
||||
} else {
|
||||
let a = concat(a, c).unwrap();
|
||||
a
|
||||
concat(a, c).unwrap()
|
||||
};
|
||||
|
||||
Ok((s, into_locate(a)))
|
||||
|
@ -51,7 +51,7 @@ pub(crate) fn symbol<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult<Span<'a>, S
|
||||
#[cfg(not(feature = "trace"))]
|
||||
pub(crate) fn symbol_exact<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult<Span<'a>, Symbol> {
|
||||
move |s: Span<'a>| {
|
||||
let (s, x) = map(no_ws(map(tag(t.clone()), |x: Span| into_locate(x))), |x| {
|
||||
let (s, x) = map(no_ws(map(tag(t.clone()), into_locate)), |x| {
|
||||
Symbol { nodes: x }
|
||||
})(s)?;
|
||||
Ok((s, x))
|
||||
@ -63,7 +63,7 @@ pub(crate) fn symbol_exact<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult<Span<
|
||||
move |s: Span<'a>| {
|
||||
let (depth, s) = nom_tracable::forward_trace(s, &format!("symbol(\"{}\")", t));
|
||||
let body = || {
|
||||
let (s, x) = map(no_ws(map(tag(t.clone()), |x: Span| into_locate(x))), |x| {
|
||||
let (s, x) = map(no_ws(map(tag(t.clone()), into_locate)), |x| {
|
||||
Symbol { nodes: x }
|
||||
})(s)?;
|
||||
Ok((s, x))
|
||||
@ -78,9 +78,9 @@ pub(crate) fn keyword<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult<Span<'a>,
|
||||
move |s: Span<'a>| {
|
||||
let (s, x) = map(
|
||||
ws(alt((
|
||||
all_consuming(map(tag(t.clone()), |x: Span| into_locate(x))),
|
||||
all_consuming(map(tag(t.clone()), into_locate)),
|
||||
terminated(
|
||||
map(tag(t.clone()), |x: Span| into_locate(x)),
|
||||
map(tag(t.clone()), into_locate),
|
||||
peek(none_of(AZ09_)),
|
||||
),
|
||||
))),
|
||||
@ -97,9 +97,9 @@ pub(crate) fn keyword<'a>(t: &'a str) -> impl Fn(Span<'a>) -> IResult<Span<'a>,
|
||||
let body = || {
|
||||
let (s, x) = map(
|
||||
ws(alt((
|
||||
all_consuming(map(tag(t.clone()), |x: Span| into_locate(x))),
|
||||
all_consuming(map(tag(t.clone()), into_locate)),
|
||||
terminated(
|
||||
map(tag(t.clone()), |x: Span| into_locate(x)),
|
||||
map(tag(t.clone()), into_locate),
|
||||
peek(none_of(AZ09_)),
|
||||
),
|
||||
))),
|
||||
@ -281,16 +281,12 @@ where
|
||||
{
|
||||
move |s: Span<'a>| {
|
||||
let (s, a) = g(s)?;
|
||||
let mut s = s.clone();
|
||||
let mut s = s;
|
||||
let mut ret = Vec::new();
|
||||
loop {
|
||||
if let Ok((t, b)) = f(s) {
|
||||
if let Ok((u, c)) = g(t) {
|
||||
s = u;
|
||||
ret.push((b, c));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
while let Ok((t, b)) = f(s) {
|
||||
if let Ok((u, c)) = g(t) {
|
||||
s = u;
|
||||
ret.push((b, c));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@ -353,10 +349,7 @@ thread_local!(
|
||||
);
|
||||
|
||||
pub(crate) fn in_directive() -> bool {
|
||||
IN_DIRECTIVE.with(|x| match x.borrow().last() {
|
||||
Some(_) => true,
|
||||
None => false,
|
||||
})
|
||||
IN_DIRECTIVE.with(|x| x.borrow().last().is_some())
|
||||
}
|
||||
|
||||
pub(crate) fn begin_directive() {
|
||||
|
@ -393,19 +393,19 @@ fn resolve_text_macro_usage<T: AsRef<Path>, U: AsRef<Path>>(
|
||||
|
||||
let (replaced, new_defines) =
|
||||
preprocess_str(&replaced, path.as_ref(), &defines, include_paths)?;
|
||||
return Ok((
|
||||
Ok((
|
||||
String::from(replaced.text()),
|
||||
define.path.clone(),
|
||||
*range,
|
||||
new_defines,
|
||||
));
|
||||
))
|
||||
} else {
|
||||
return Err(ErrorKind::DefineTextNotFound(String::from(id)).into());
|
||||
Err(ErrorKind::DefineTextNotFound(String::from(id)).into())
|
||||
}
|
||||
} else if let Some(_) = define {
|
||||
return Err(ErrorKind::DefineTextNotFound(String::from(id)).into());
|
||||
Err(ErrorKind::DefineTextNotFound(String::from(id)).into())
|
||||
} else {
|
||||
return Err(ErrorKind::DefineNotFound(String::from(id)).into());
|
||||
Err(ErrorKind::DefineNotFound(String::from(id)).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user