pub struct ElementParser {
pub element: Option<Elements>,
pub error: Option<ErrorCodes>,
pub line_number: usize,
/* private fields */
}Expand description
This struct is responsible for evaluating the Delimiters in each line, parsing the KeyVals, building the Elements variant or providing the ErrorCodes if an element could not be built.
Fields§
§element: Option<Elements>§error: Option<ErrorCodes>§line_number: usizeImplementations§
Source§impl ElementParser
impl ElementParser
Sourcepub fn is_ok(&self) -> bool
pub fn is_ok(&self) -> bool
Short-hand to query Self::error is None.
Sourcepub fn read(
line_number: usize,
line: &str,
literals: &Option<Vec<Literal>>,
) -> ElementParser
pub fn read( line_number: usize, line: &str, literals: &Option<Vec<Literal>>, ) -> ElementParser
This is the entry-point for the entire element parsing algorithm broken down into the following steps: - Parsing the element type and name. - Parsing the remaining tokens via Self::parse_tokens. - Which must first call Self::collect_tokens. - And then evaluating the tokens Self::evaluate_keyvals.
The process must ensure custom Literals are respected and that the order of delimiter characters are evaluated correctly to best parse the remaining KeyVals. The judgement for the delimiter uses a heuristic which looks for Glyphs::Equal outside of string literal spans.