Git Product home page Git Product logo

kudzu's Introduction

Kudzu

A monadic (I think...) recursive-descent parser combinator written in Kotlin

GitHub release (latest by date) Maven Central Kotlin Version

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

Installation

repositories {
    mavenCentral()
}

// for plain JVM or Android projects
dependencies {
    implementation("io.github.copper-leaf:kudzu-core:{{site.version}}")
}

// for multiplatform projects
kotlin {
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("io.github.copper-leaf:kudzu-core:{{site.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

kudzu's People

Contributors

cjbrooks12 avatar ephemient avatar kilink avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.