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.

Source

Element::equal

fn Element::equal(Element, Element) -> Bool

Source

Element::not_equal

fn Element::not_equal(x : Element, y : Element) -> Bool

Source

Element::to_repr

fn Element::to_repr(Element) -> @moonbitlang/core/debug.Repr

Source

Node

pub struct Node {
  kind : NodeKind
  children : ReadOnlyArray[Element]
} derive(Eq, @moonbitlang/core/debug.Debug)

A node of the lossless syntax tree.

Source

Node::equal

fn Node::equal(Node, Node) -> Bool

Source

Node::new

fn Node::new(kind : NodeKind, children : ArrayView[Element]) -> Node

A node. The node keeps a copy of children.

Source

Node::nodes

fn Node::nodes(self : Node) -> Array[Node]

The direct child nodes of this node.

Source

Node::not_equal

fn Node::not_equal(x : Node, y : Node) -> Bool

Source

Node::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.

Source

Node::text

fn Node::text(self : Node) -> String

The source text of this node.

Source

Node::to_repr

fn Node::to_repr(Node) -> @moonbitlang/core/debug.Repr

Source

Node::tokens

fn Node::tokens(self : Node) -> Array[Token]

All tokens below this node, in source order.

Source

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.

Source

NodeKind::equal

fn NodeKind::equal(NodeKind, NodeKind) -> Bool

Source

NodeKind::not_equal

fn NodeKind::not_equal(x : NodeKind, y : NodeKind) -> Bool

Source

NodeKind::to_repr

fn NodeKind::to_repr(NodeKind) -> @moonbitlang/core/debug.Repr

Source

Token

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.

Source

Token::equal

fn Token::equal(Token, Token) -> Bool

Source

Token::new

fn Token::new(kind : TokenKind, text : String, offset : Int) -> Token

A token.

Source

Token::not_equal

fn Token::not_equal(x : Token, y : Token) -> Bool

Source

Token::to_repr

fn Token::to_repr(Token) -> @moonbitlang/core/debug.Repr

Source

TokenKind

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.

Source

TokenKind::equal

fn TokenKind::equal(TokenKind, TokenKind) -> Bool

Source

TokenKind::not_equal

fn TokenKind::not_equal(x : TokenKind, y : TokenKind) -> Bool

Source

TokenKind::to_repr

fn TokenKind::to_repr(TokenKind) -> @moonbitlang/core/debug.Repr

Source

Values

position

fn position(source : String, offset : Int) -> @moonrockz/diagrams.Position

The 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.

Source

span

fn span(source : String, start : Int, end : Int) -> @moonrockz/diagrams.Span

The span from the UTF-16 offset start to end in source.

Source