moonrockz/diagrams-plantuml/cst

Types

Element

pub(all) enum Element {
  Token(Token)
  Node(Node)
} derive(Eq, @moonbitlang/core/debug.Debug)

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

Lines

pub struct Lines {
  // private fields
}

A line index of a source text for UTF-16 positions.

Source

Lines::new

fn Lines::new(source : String) -> Lines

Source

Lines::position

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

The position of a UTF-16 offset. Lines and columns start at 1; columns count UTF-16 code units. A CR before LF belongs to its line.

Source

Lines::span

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

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

Source

Node::nodes

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

The child nodes of the 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 half-open UTF-16 range of the node, or None for an empty node.

Source

Node::text

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

The source text of the 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 of the node in source order, without recursion.

Source

NodeKind

pub(all) enum NodeKind {
  Document
  Start
  End
  Title
  Caption
  Header
  Footer
  Legend
  Skinparam
  Style
  Pragma
  Scale
  Hide
  Comment
  Directive
  Highlight
  Pattern
  Rule
  Note
  Data
  Blank
  Trailing
  Error
} derive(Eq, @moonbitlang/core/debug.Debug)

The kind of a node. Each source line, or each multi-line statement, is one node under the document.

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

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 {
  Marker
  Keyword
  Name
  Text
  String
  Number
  Literal
  Escape
  Operator
  Punctuation
  Comment
  Whitespace
  Newline
  Directive
  Error
} derive(Eq, @moonbitlang/core/debug.Debug)

The kind of a token in the lossless syntax tree. All four body languages share these kinds.

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

slice

fn slice(text : String, start : Int, end : Int) -> String

The owned text of the half-open UTF-16 range start to end of text.

Source

span

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

The span of a half-open UTF-16 range of source.

Source