README

Milky2018/diago/lexer does not have a README file

#
LexError

pub struct LexError {
message : String
range : Range
} derive(Eq,
Debug
)

Lexer error

#
Lexer

type Lexer

Lexer for the diago diagram language

#
Lexer::new

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

Create a new lexer for the given source (in-memory, no path)

#
Lexer::tokenize

fn Lexer::tokenize(self : Lexer) -> (Array[Token], Array[LexError])

Tokenize the entire source and return tokens

#
Lexer::with_path

fn Lexer::with_path(path : String, source : String) -> Lexer

#
Position

pub struct Position {
line : Int
column : Int
offset : Int
} derive(Eq,
Debug
)

Position in source code (0-based)

offset is a 0-based codepoint offset within the source string.

#
Position::new

fn Position::new(line : Int, column : Int, offset : Int) -> Position

#
Position::zero

fn Position::zero() -> Position

Create a simple position at the origin

#
Range

pub struct Range {
path : String
start : Position
end : Position
} derive(Eq,
Debug
)

A range in source code from start to end position. path may be empty for in-memory sources.

#
Range::between

fn Range::between(a : Range, b : Range) -> Range

Create a range from the start of a to the end of b.

#
Range::new

fn Range::new(start : Position, end : Position) -> Range

#
Range::with_path

fn Range::with_path(path : String, start : Position, end : Position) -> Range

#
StringType

pub enum StringType {
SingleQuoted
DoubleQuoted
} derive(Eq,
Debug
)

String literal types

#
Token

pub struct Token {
kind : TokenKind
range : Range
raw : String
} derive(Eq,
Debug
)

A token with its kind, range, and raw text

#
Token::is_arrow

fn Token::is_arrow(self : Token) -> Bool

Check if a token is an arrow

#
Token::is_edge_op

fn Token::is_edge_op(self : Token) -> Bool

Check if a token can start an edge

#
Token::is_trivia

fn Token::is_trivia(self : Token) -> Bool

Check if a token is a trivia token (whitespace, comments)

#
Token::new

fn Token::new(kind : TokenKind, range : Range, raw : String) -> Token

#
TokenKind

pub enum TokenKind {
Ident(String)
StringLit(StringType, String)
Number(String)
Colon
Semicolon
Dot
Comma
LeftBrace
RightBrace
LeftBracket
RightBracket
LeftParen
RightParen
Pipe
Ampersand
Arrow
ReverseArrow
BidirectionalArrow
DoubleDash
Comment(String)
BlockComment(String)
At
DotDotDot
Dollar
DollarBrace
Star
DoubleStar
TripleStar
Newline
Eof
} derive(Eq,
Debug
)

Token types for the diago language

#
tokenize

fn tokenize(source : String) -> (Array[Token], Array[LexError])

Convenience function to tokenize a string

#
tokenize_with_path

fn tokenize_with_path(path : String, source : String) -> (Array[Token], Array[LexError])

Source Files

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io