From ffef323d3c927f84e94cae21afeb541be7320f1c Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 9 Sep 2022 11:07:46 +0200 Subject: Add some missing docs --- src/construct/partial_mdx_jsx.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/construct/partial_mdx_jsx.rs b/src/construct/partial_mdx_jsx.rs index b85fb50..583241a 100644 --- a/src/construct/partial_mdx_jsx.rs +++ b/src/construct/partial_mdx_jsx.rs @@ -1057,6 +1057,7 @@ pub fn es_whitespace_eol_after(tokenizer: &mut Tokenizer) -> State { } } +/// Check if a character can start a JSX identifier. fn id_start(code: Option) -> bool { if let Some(char) = code { UnicodeID::is_id_start(char) || matches!(char, '$' | '_') @@ -1065,6 +1066,7 @@ fn id_start(code: Option) -> bool { } } +/// Check if a character can continue a JSX identifier. fn id_cont(code: Option) -> bool { if let Some(char) = code { UnicodeID::is_id_continue(char) || matches!(char, '-' | '\u{200c}' | '\u{200d}') @@ -1073,25 +1075,18 @@ fn id_cont(code: Option) -> bool { } } -fn crash_lazy(tokenizer: &Tokenizer) -> State { - State::Error(format!( - "{}:{}: Unexpected lazy line in container, expected line to be prefixed with `>` when in a block quote, whitespace when in a list, etc", - tokenizer.point.line, tokenizer.point.column - )) -} - +/// Crash because something happened `at`, with info on what was `expect`ed +/// instead. fn crash(tokenizer: &Tokenizer, at: &str, expect: &str) -> State { - let char = if tokenizer.current == None { - None - } else { - char_after_index(tokenizer.parse_state.bytes, tokenizer.point.index) - }; - State::Error(format!( "{}:{}: Unexpected {} {}, expected {}", tokenizer.point.line, tokenizer.point.column, - format_char_opt(char), + format_char_opt(if tokenizer.current == None { + None + } else { + char_after_index(tokenizer.parse_state.bytes, tokenizer.point.index) + }), at, expect )) -- cgit