use super::*;
#[derive(Debug, Clone)]
pub struct Static {
pub file_id: FileID,
pub name: S<StrID>,
pub expr: S<Expr>,
}
pub(crate) fn static_p<'src, I, M>(
make_input: M,
) -> impl Parser<'src, I, Static, AstExtras<'src>> + Clone
where
I: BorrowInput<'src, Token = TokenTree, Span = SimpleSpan> + ValueInput<'src>,
M: Fn(&'src [(TokenTree, SimpleSpan)], SimpleSpan) -> I + Copy + 'src,
{
let keyword = kw_static_p().labelled("static_keyword").as_context();
let name = ident_p()
.map_with(|i, ex| S::from_extras(i, ex))
.labelled("static_name")
.as_context();
let expr = expr_p(make_input).labelled("static_expr").as_context();
keyword.ignore_then(name).then_ignore(equal_p()).then(expr).map_with(
|(name, expr), ex| {
let state: &mut SimpleState<&'static FileData> = ex.state();
let file_id: FileID = state.id();
Static { file_id, name, expr }
},
)
}