Sign in

    parser

    AST and parsers for the MoonBit programming language

    parser
    lexer
    AST
    MoonBit
    Download zip
    Version
    0.1.5
    License
    Apache-2.0
    Last updated
    last year
    Downloads
    227K

    #moonbitlang/parser

    Note: This module is highly experimental and unstable. Use with caution.

    A parser implementation for the MoonBit programming language, written in MoonBit, providing lexical analysis and syntax parsing capabilities.

    This module defines the Abstract Syntax Tree (AST) and provides parsers for MoonBit source code. It includes both a hand-written LL(k) parser with error recovery and an LR(1) parser generated by moonyacc.

    #Project Structure

    src/ ├── tokens/ # token definitions and utilities ├── lexer/ # Lexical analysis components ├── mbti_ast/ # AST for .mbti files ├── mbti_parser/ # LR parser for .mbti files ├── syntax/ # AST and utils for MoonBit source code ├── handrolled_parser/ # Hand-written parser implementation ├── yacc_parser/ # LR parser generated by moonyacc ├── test/ # Test suite └── top.mbt # parsing entries

    #Usage

    // Parse MoonBit source code from bytes
    let source = b"fn hello() -> Unit { println(\"Hello, World!\") }"
    let (impls, diagnostics) = @moonbitlang/parser.parse_bytes(source)

    #Build & Test

    This project uses the MoonBit build system:

    moon update moon check moon test

    Parser

    pub(all) enum Parser {
    MoonYacc
    Handrolled
    }

    parse_string

    Source Files