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