Crates.io | camxes-rs |
lib.rs | camxes-rs |
version | |
source | src |
created_at | 2025-02-02 09:58:41.973172 |
updated_at | 2025-02-02 09:58:41.973172 |
description | A Parsing Expression Grammar (PEG) parser generator with zero-copy parsing and rich debugging capabilities |
homepage | |
repository | https://github.com/lojban/camxes.rs |
max_upload_size | |
id | 1539427 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A lightning-fast Parsing Expression Grammar (PEG) parser generator implemented in Rust. This tool helps you create parsers from grammar definitions with minimal hassle.
Add this to your Cargo.toml
:
[dependencies]
camxes-rs = "0.1"
Full API documentation is available on docs.rs
Add this to your Cargo.toml
:
[dependencies]
camxes-rs = "0.0.1"
You must have latest Rust installed.
Go to the project directory and run cargo run --example cmaxes-test
.
It will run the PEG grammar specified in src/examples/cmaxes-test.rs
file against a sample input.
The grammar supports these PEG operators:
Operator | Description | Example |
---|---|---|
<- |
Definition | rule <- expression |
/ |
Ordered choice | a / b |
* |
Zero or more | [0-9]* |
+ |
One or more | [a-z]+ |
? |
Optional | [A-Z]? |
& |
And-predicate | &[a-z] |
! |
Not-predicate | ![0-9] |
() |
Grouping | (a / b) |
[] |
Character range / class | [abd] and [a-zA-Z] |
. |
Any character | . |
Enable debug logging to see detailed parsing information:
// Initialize logging (using env_logger)
env_logger::builder()
.filter_level(log::LevelFilter::Debug)
.init();
Or set the environment variable:
RUST_LOG=debug cargo run
let calc_grammar = (
"calc",
r#"
calc <- additive
additive <- multiplicative (('+' / '-') multiplicative)*
multiplicative <- primary (('*' / '/') primary)*
primary <- number / '(' additive ')'
number <- [0-9]+
"#
);
let json_grammar = (
"json",
r#"
json <- spacing value spacing
value <- object / array / string / number / true / false / null
object <- '{' spacing (pair (',' pair)*)? '}'
pair <- string spacing ':' spacing value
array <- '[' spacing (value (',' value)*)? ']'
string <- '"' (!'"' .)* '"'
number <- '-'? ([0-9] / [1-9][0-9]*) ('.' [0-9]+)? ([eE][-+]?[0-9]+)?
true <- 'true'
false <- 'false'
null <- 'null'
spacing <- [ \t\n\r]*
"#
);
Contributions are welcome! Here's how you can help:
git checkout -b feature/amazing-feature
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ for the Rust community