Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/maksasj/uroboros
- Owner: Maksasj
- License: mit
- Created: 2024-06-14T17:58:26.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2024-06-18T19:12:05.000Z (5 months ago)
- Last Synced: 2024-06-19T19:53:56.757Z (5 months ago)
- Topics: package, parser, rust, uroboros
- Language: Rust
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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
![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/)