pub struct CstNode {
pub kind: CstKind,
pub children: Vec<CstNode>,
pub value: Option<String>,
pub quote: Option<char>,
/* private fields */
}Expand description
One node or token of a concrete syntax tree.
Its Display writes the exact text it was read from.
Fields§
§kind: CstKindWhat this node or token is.
children: Vec<CstNode>The children of a node, in document order; empty for a token.
value: Option<String>What a reference token means, its delimiters and escapes resolved and a
versioned literal decoded (the ID a parsed link has); None for every
other node and token.
quote: Option<char>The delimiter a quoted reference token was written between (', " or
`); None for a bare or literal reference and every other kind.
Implementations§
Source§impl CstNode
impl CstNode
Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
The exact text this node or token was read from: a token’s own text, and the text of a node’s children one after the other.
Sourcepub fn to_s_expression(&self) -> String
pub fn to_s_expression(&self) -> String
The tree as an S-expression: (kind child ...) for a node and
kind:"text" for a token, the text escaped as a JSON string would escape
\, ", line feeds, carriage returns and tabs. Two trees are the same
exactly when their S-expressions are.
§Examples
use links_notation::parse_lino_to_cst;
assert_eq!(
parse_lino_to_cst("a '1'").unwrap().to_s_expression(),
r#"(document (line reference:"a" whitespace:" " reference:"'1'"))"#
);