forked from goffrie/lalr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
# lalry | ||
# `lalry` - a library for creating LALR(1) parsers from context-free grammars | ||
|
||
This is a fork of the great [lalr](https://github.com/goffrie/lalr) crate, a library for | ||
creating LALR(1) parsers from context-free grammars. | ||
|
||
## Additions to 'lalr' | ||
## Additions to `lalr` | ||
|
||
To make the generation of parse tables more flexible we added a way to control this process. | ||
To make the generation of parse tables more flexible `lalry` adds a way to control this process. | ||
The trait `Config` is used for this and a custom implementation can be provided to deviate from the | ||
default. | ||
To keep the default behavior as in previous versions the user can use the `DefaultConfig` structure | ||
that provides the implementation of the standard behavior. | ||
|
||
## Properties of `lalry` | ||
|
||
`lalry`, although not the main goal, is functionally fully compatible with it's ancestor `lalr`. | ||
It can be used as drop-in replacement with only minor adaptions. | ||
|
||
All you need to do is to create a `DefaultConfig` and hand it over to the call to `lalr1`: | ||
|
||
```rust | ||
let config = DefaultConfig::new(); | ||
let parse_table = grammar.lalr1(&config).unwrap(); | ||
``` | ||
|
||
By using a default configuration you get the exact same functionality as if you had called | ||
|
||
```rust | ||
let parse_table = grammar.lalr1(|_, _| true, |_, _| 0).unwrap(); | ||
``` | ||
|
||
with `lalr` style API. |