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
.
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
// Parse MoonBit source code from bytes
let source = b"fn hello() -> Unit { println(\"Hello, World!\") }"
let (impls, diagnostics) = @moonbitlang/parser.parse_bytes(source)
This project uses the MoonBit build system:
moon update
moon check
moon test