Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/maksasj/uroboros

πŸ‰ rust package for making parsers with parser combinators and state machines
https://github.com/maksasj/uroboros

package parser rust uroboros

Last synced: about 6 hours ago
JSON representation

πŸ‰ rust package for making parsers with parser combinators and state machines

Awesome Lists containing this project

README

        

# uroboros πŸ‰

> Uroboros is an ancient symbol depicting a serpent or dragon eating its own tail, this time uroboros is a rust package for making parsers

## Overview

Uroboros is a **Rust** package for making complex parsers with parser combinators and classical state machine LL parsers with **cfg** (context-free grammars). For now this is my personal project, for learning parsing and **Rust**, so do not expect readable and reliable code 🀑

*Name is highly inspired by [github.com/mame/quine-relay](https://github.com/mame/quine-relay)*

> uroboros is a not a new python fork ?

Cool looking widgets
license
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Maksasj/uroboros/rust.yml)
![GitHub Repo stars](https://img.shields.io/github/stars/Maksasj/uroboros?style=flat)

### Links
1. Source code avaiable at [github.com/Maksasj/uroboros](https://github.com/Maksasj/uroboros)
2. **Backus-Naur form** wiki [wikipedia.org/wiki/Backus–Naur_form](https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form)

### Features
- Macros for writing **Backus-Naur form** style grammars
- **LL grammar parser** Left-to-right, leftmost derivation
- Parser combinators such as **Token**, **Or**, **Many**

## Example
As example we have this simple grammar written in **Backus-Naur form**:

```bash
:= '='
:= '+' |
:= 'x' | 'y' | ...
```

With **uroboros** you can write previous grammar in **Rust** like this(Note `Token` is a enum, that represents all terminals)

```rust
let _: Grammar = gram![
("expr" => ("term", Token::Equal, "term")),
("term" => ("term", Token::Plus, "num") | ("num")),
("num" => (Token::VariableLiteral))
];
```

Now you can use this structure in parsing, or modify gramma it self for example removing left recursion with **remove_left_recursion()** method.

## License
uroboros is free, open source library. All code in this repository is licensed under
- MIT License ([LICENSE.md](https://github.com/Maksasj/uroboros/blob/master/LICENSE.md) or https://opensource.org/license/mit/)