Sign in

    This version of the module is deprecated: Moved to moonbit-community/diago. Use moonbit-community/diago@0.4.0 or later and update import paths.

    Milky2018/diago/lexer does not have a README file

    LexError

    pub struct LexError {
    message : String
    range : Range
    }

    Lexer error
    impl Eq for LexError
    impl Show for LexError

    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
    }

    Position in source code (0-based)

    offset is a 0-based codepoint offset within the source string.
    impl Eq for Position
    impl Show for Position

    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
    }

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

    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
    }

    String literal types
    impl Eq for StringType
    impl Show for StringType

    Token

    pub struct Token {
    kind : TokenKind
    range : Range
    raw : String
    }

    A token with its kind, range, and raw text
    impl Eq for Token
    impl Show for Token

    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
    }

    Token types for the diago language
    impl Eq for TokenKind
    impl Show for TokenKind

    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