moonrockz/diagrams-mermaid/cst
Types
Element
pub(all) enum Element {
Token(Token)
Node(Node)
} derive(Eq, @moonbitlang/core/debug.Debug)One element of a node: a token or a child node.
Element::equal
fn Element::equal(Element, Element) -> BoolElement::not_equal
fn Element::not_equal(x : Element, y : Element) -> BoolElement::to_repr
fn Element::to_repr(Element) -> @moonbitlang/core/debug.ReprNode
pub struct Node {
kind : NodeKind
children : ReadOnlyArray[Element]
} derive(Eq, @moonbitlang/core/debug.Debug)A node of the lossless syntax tree.
Node::equal
fn Node::equal(Node, Node) -> BoolNode::new
fn Node::new(kind : NodeKind, children : ArrayView[Element]) -> NodeA node. The node keeps a copy of children.
Node::nodes
fn Node::nodes(self : Node) -> Array[Node]The direct child nodes of this node.
Node::not_equal
fn Node::not_equal(x : Node, y : Node) -> BoolNode::range
fn Node::range(self : Node) -> (Int, Int)?The UTF-16 offsets of the first code unit of this node and of the code unit
after its last token. A node with no tokens gives None.
Node::text
fn Node::text(self : Node) -> StringThe source text of this node.
Node::to_repr
fn Node::to_repr(Node) -> @moonbitlang/core/debug.ReprNode::tokens
fn Node::tokens(self : Node) -> Array[Token]All tokens below this node, in source order.
NodeKind
pub(all) enum NodeKind {
Document
Header
Participant
Destroy
Activate
Deactivate
Note
Link
Links
Properties
Details
Title
AccTitle
AccDescr
Autonumber
Message
Block
BlockStart
Section
BlockEnd
Error
} derive(Eq, @moonbitlang/core/debug.Debug)The kind of a node. A statement is one node. A frame, such as loop or
box, is a Block node with a BlockStart, its statements, a Section
node for each else, and or option, and a BlockEnd. Whitespace,
line breaks, separators, comments, directives and front matter are tokens
of the parent node.
NodeKind::equal
fn NodeKind::equal(NodeKind, NodeKind) -> BoolNodeKind::not_equal
fn NodeKind::not_equal(x : NodeKind, y : NodeKind) -> BoolNodeKind::to_repr
fn NodeKind::to_repr(NodeKind) -> @moonbitlang/core/debug.ReprToken
pub struct Token {
kind : TokenKind
text : String
offset : Int
} derive(Eq, @moonbitlang/core/debug.Debug)One token. offset is the UTF-16 offset of its first code unit in the
source. The concatenated token texts of a tree are equal to the source.
Token::equal
fn Token::equal(Token, Token) -> BoolToken::new
fn Token::new(kind : TokenKind, text : String, offset : Int) -> TokenA token.
Token::not_equal
fn Token::not_equal(x : Token, y : Token) -> BoolToken::to_repr
fn Token::to_repr(Token) -> @moonbitlang/core/debug.ReprTokenKind
pub(all) enum TokenKind {
Keyword
Identifier
Arrow
Modifier
Colon
Comma
Number
Text
ConfigOpen
Config
ConfigClose
OpenBrace
CloseBrace
Whitespace
Newline
Separator
Comment
Directive
FrontMatter
Unknown
} derive(Eq, @moonbitlang/core/debug.Debug)The kind of a token in the lossless syntax tree.
TokenKind::equal
fn TokenKind::equal(TokenKind, TokenKind) -> BoolTokenKind::not_equal
fn TokenKind::not_equal(x : TokenKind, y : TokenKind) -> BoolTokenKind::to_repr
fn TokenKind::to_repr(TokenKind) -> @moonbitlang/core/debug.ReprValues
position
fn position(source : String, offset : Int) -> @moonrockz/diagrams.PositionThe position of the UTF-16 offset offset in source. Lines and columns
start at 1. \r\n, \n and a single \r each end a line.
span
fn span(source : String, start : Int, end : Int) -> @moonrockz/diagrams.SpanThe span from the UTF-16 offset start to end in source.