Crates.io | cflp |
lib.rs | cflp |
version | 1.0.2 |
source | src |
created_at | 2023-01-25 22:24:30.174818 |
updated_at | 2023-08-29 22:00:08.417354 |
description | A context-free-language parser generated by procedural macros |
homepage | |
repository | https://github.com/fck-language/context-free-lang |
max_upload_size | |
id | 768013 |
size | 2,429,410 |
This crate provides functionality for parsing context-free languages and was written for use with fck. The documentation will also link you to some benchmarks. These were performed on a MacBook Pro with an M1 Pro CPU. The times are mainly intended for comparisons and not to be used as absolute values.
This crate provides a derive macro for the Parser
trait. It also provides another trait and two structs used along-side the Parser
trait.
For how to use the derive macro, you will need to read the documentation
The examples directory contains some example files with generated expansions. These are generated using cargo-expand
and have been neatened up to make them more readable.
The structure of the examples is the same for all of them:
TokenType
and Token
along with required trait implsmod nodes
which contains the nodes with #[derive(Parser)]
mod equivalent
which is the expanded code for the Parser
impl(Token::T1)?, Token::T2
, the first token could be either Token::T1
or Token::T2
. If neither of these are found then the returned error will say it expected Token::T2
. A future version wil have better errors where the expected
is a Vec<E>
that will be calculated for each possible error position for more useful errorsNodeWrapper
). This is intended for v1.1.0 with an additional method in the NodeData
trait to return additional data wrapped in an Option
. This will then be wrapped in a new struct to contain additional data