Kudzu
A monadic (I think...) recursive-descent parser written in Kotlin
Install / Use
/learn @copper-leaf/KudzuREADME
Kudzu
A monadic (I think...) recursive-descent parser combinator written in Kotlin
Kudzu is a recursive-descent parser written in Kotlin, inspired by Parsec, with the goal of immutability, simplicity, testability, and multiplatform usability. It's designed to be a simple starting place for writing smaller parsers to evaluate relatively simple grammars for other Copper-Leaf libraries, but flexible enough to be used for larger languages.
Notable features:
- Multiplatform targets: JVM, Android, JS Legacy, JS IR, iOS
- No separate lexer/parser. You really just don't need it, so Kudzu omits it
- Parser combinator structure means every piece of your grammar is a complete parser, and thus smaller parsing units can be tested in isolation, but the combination of them creates the full language
- Everything in Kudzu is immutable, and thus fully thread-safe
- Built on top of DeepRecursiveFunction to provide readable stacktraces and prevent StackOverflowErrors
- No complicated DSL or arcane combinator operators required, just normal, readable Kotlin classes. You don't need a Ph.D. in computational linguistics or functional programming to understand a Kudzu parser
- Many useful combinators provided out of the box
- Boolean, Int, Double literals
- String and Character literals, with standard escaped characters (i.e. \n) and Unicode sequences (i.e. \u00A2)
- Identifiers
- Choice, repetition, optional higher-kinded parsers
- Parses input to an Abstract Syntax Tree (AST) and provides facilities for simplifying and/or introspecting the AST
- Line- and column-number source tracking
- Generic expression parser with all the fixin's
- Customizable operator precedence
- Operators with prefix, postfix, and infix with both left- and right-recursive associativity
- Parentheses
- Simplify deeply-nested expressions AST to simpler representation
Supported Platforms/Features
| Platform | |----------| | Android | | JVM | | iOS | | JS | | WasmJS |
Installation
repositories {
mavenCentral()
}
// for plain JVM or Android projects
dependencies {
implementation("io.github.copper-leaf:kudzu-core:{{gradle.version}}")
}
// for multiplatform projects
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.copper-leaf:kudzu-core:{{gradle.version}}")
}
}
}
}
Documentation
See the website for detailed documentation and usage instructions.
License
Kudzu is licensed under the BSD 3-Clause License, see LICENSE.md.
References
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
