MCPcopy Create free account
hub / github.com/daisy/MathCAT / catch_errors_building_intent

Function catch_errors_building_intent

src/infer_intent.rs:45–59  ·  view source on GitHub ↗
(rules_with_context: &'r mut SpeechRulesWithContext<'c,'s,'m>, mathml: Element<'c>)

Source from the content-addressed store, hash-verified

43 }
44
45 fn catch_errors_building_intent<'r, 'c, 's:'c, 'm:'c>(rules_with_context: &'r mut SpeechRulesWithContext<'c,'s,'m>, mathml: Element<'c>) -> Result<Element<'m>> {
46 if let Some(intent_str) = mathml.attribute_value("intent") {
47 // debug!("Before intent: {}", crate::pretty_print::mml_to_string(&mathml));
48 let mut lex_state = LexState::init(intent_str.trim())?;
49 let result = build_intent(rules_with_context, &mut lex_state, mathml)
50 .chain_err(|| format!("occurs before '{}' in intent attribute value '{}'", lex_state.remaining_str, intent_str))?;
51 if lex_state.token != Token::None {
52 bail!("Error in intent value: extra unparsed intent '{}' in intent attribute value '{}'", lex_state.remaining_str, intent_str);
53 }
54 assert!(lex_state.remaining_str.is_empty());
55 debug!("Resulting intent: {}", crate::pretty_print::mml_to_string(&result));
56 return Ok(result);
57 }
58 bail!("Internal error: infer_intent() called on MathML with no intent arg:\n{}", mml_to_string(&mathml));
59 }
60}
61
62// intent := S ( term property* | property+ | application ) S

Callers 1

infer_intentFunction · 0.85

Calls 1

build_intentFunction · 0.85

Tested by

no test coverage detected