Fixing more errors.
This commit is contained in:
@@ -12,9 +12,9 @@ use nom::multi::many_till;
|
||||
use nom::sequence::tuple;
|
||||
|
||||
use super::org_source::OrgSource;
|
||||
use crate::context::ContextMatcher;
|
||||
use crate::context::parser_with_context;
|
||||
use crate::context::ContextElement;
|
||||
use crate::context::ContextMatcher;
|
||||
use crate::context::ExitClass;
|
||||
use crate::context::ExitMatcherNode;
|
||||
use crate::context::RefContext;
|
||||
@@ -50,10 +50,9 @@ pub fn verse_block<'r, 's>(
|
||||
exit_matcher: &lesser_block_end_specialized,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
@@ -106,10 +105,9 @@ pub fn comment_block<'r, 's>(
|
||||
exit_matcher: &lesser_block_end_specialized,
|
||||
}),
|
||||
];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
@@ -139,14 +137,17 @@ pub fn example_block<'r, 's>(
|
||||
let (remaining, parameters) = opt(tuple((space1, data)))(remaining)?;
|
||||
let (remaining, _nl) = line_ending(remaining)?;
|
||||
let lesser_block_end_specialized = lesser_block_end("example");
|
||||
let contexts = [ContextElement::ConsumeTrailingWhitespace(true), ContextElement::Context("lesser block"), ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
let contexts = [
|
||||
ContextElement::ConsumeTrailingWhitespace(true),
|
||||
ContextElement::Context("lesser block"),
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Beta,
|
||||
exit_matcher: &lesser_block_end_specialized,
|
||||
})];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
}),
|
||||
];
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
@@ -177,14 +178,17 @@ pub fn export_block<'r, 's>(
|
||||
let (remaining, parameters) = opt(tuple((space1, data)))(remaining)?;
|
||||
let (remaining, _nl) = line_ending(remaining)?;
|
||||
let lesser_block_end_specialized = lesser_block_end("export");
|
||||
let contexts = [ContextElement::ConsumeTrailingWhitespace(true), ContextElement::Context("lesser block"), ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
let contexts = [
|
||||
ContextElement::ConsumeTrailingWhitespace(true),
|
||||
ContextElement::Context("lesser block"),
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Beta,
|
||||
exit_matcher: &lesser_block_end_specialized,
|
||||
})];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
}),
|
||||
];
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
@@ -215,14 +219,17 @@ pub fn src_block<'r, 's>(
|
||||
let (remaining, parameters) = opt(tuple((space1, data)))(remaining)?;
|
||||
let (remaining, _nl) = line_ending(remaining)?;
|
||||
let lesser_block_end_specialized = lesser_block_end("src");
|
||||
let contexts = [ContextElement::ConsumeTrailingWhitespace(true), ContextElement::Context("lesser block"), ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
let contexts = [
|
||||
ContextElement::ConsumeTrailingWhitespace(true),
|
||||
ContextElement::Context("lesser block"),
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Alpha,
|
||||
exit_matcher: &lesser_block_end_specialized,
|
||||
})];
|
||||
let parser_context = context
|
||||
.with_additional_node(&contexts[0])
|
||||
.with_additional_node(&contexts[1])
|
||||
.with_additional_node(&contexts[2]);
|
||||
}),
|
||||
];
|
||||
let parser_context = context.with_additional_node(&contexts[0]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
||||
let parser_context = parser_context.with_additional_node(&contexts[2]);
|
||||
let parameters = match parameters {
|
||||
Some((_ws, parameters)) => Some(parameters),
|
||||
None => None,
|
||||
@@ -253,9 +260,7 @@ fn data<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
is_not("\r\n")(input)
|
||||
}
|
||||
|
||||
fn lesser_block_end(
|
||||
current_name: &str,
|
||||
) -> impl ContextMatcher {
|
||||
fn lesser_block_end(current_name: &str) -> impl ContextMatcher {
|
||||
let current_name_lower = current_name.to_lowercase();
|
||||
move |context, input: OrgSource<'_>| {
|
||||
_lesser_block_end(context, input, current_name_lower.as_str())
|
||||
@@ -282,9 +287,7 @@ fn _lesser_block_end<'r, 's, 'x>(
|
||||
/// Parser for the beginning of a lesser block
|
||||
///
|
||||
/// current_name MUST be lowercase. We do not do the conversion ourselves because it is not allowed in a const fn.
|
||||
const fn lesser_block_begin<'c>(
|
||||
current_name: &'c str,
|
||||
) -> impl ContextMatcher + 'c {
|
||||
const fn lesser_block_begin<'c>(current_name: &'c str) -> impl ContextMatcher + 'c {
|
||||
// TODO: Since this is a const fn, is there ANY way to "generate" functions at compile time?
|
||||
move |context, input: OrgSource<'_>| _lesser_block_begin(context, input, current_name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user