Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/traxys/stelar
stelar is an SLR parser
https://github.com/traxys/stelar
parser-library rust slr-parser
Last synced: 27 days ago
JSON representation
stelar is an SLR parser
- Host: GitHub
- URL: https://github.com/traxys/stelar
- Owner: traxys
- License: gpl-3.0
- Created: 2019-07-19T13:02:57.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-10T15:57:39.000Z (about 5 years ago)
- Last Synced: 2024-09-17T18:07:08.540Z (about 2 months ago)
- Topics: parser-library, rust, slr-parser
- Language: Rust
- Size: 895 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stelar
stelar is an SLR parserWhy stelar ? Because SteLaR.
The generation of the SLR parse table is absolutely not optimized, as such you should generate it once, save it somewhere by serializing it with serde and get it back that way
## Usage
You will need to define two types, `T` and `NT`, both need to be `Hash + Clone + PartialEq + Eq`.
Morever if you want more meaningfull errors you should have `Debug`.
`T` is the token, or terminal type, representing the input values.
`NT` are the grammar construct.You then have to define rules of the form `(NT, Vec>)` and call `create_rules`.
To make the rule definition easier there is a macro `rule_rhs![]`, it works by creating a `Vec` of symbols such that `[..., Foo, ...]` is mapped to `Symbol::Terminal(Foo)` and `[...., (Bar), ....]` is mapped to `Symbol::NonTerminal(Bar)`.
And a grammar `g` is a `Vec` of such rules, such that `g[i].index == i`.
With this grammar you can generate a `ParseTable`.
You will then need an iterator of `ValuedToken`, being a token `T` maybe associated with a Value `V` (`Option`).
With this you can create and parse data.
## Example
An example of how evrything is done is provided in `calc_grammar`