Lexer Package
This crate provides some methods for parsing text.
I mostly developed it for a custom language I want to build.
Features
This crate exposes two main structs:
- TextParser: The base parser that loads the text from a
Readtrait. - Peeker: Allows you to read ahead without consuming the previous characters until you consume all read characters.
Usage
To use this package, add the the crate to your Cargo.toml file or run cargo add wood-parse
Then, import into your Rust code:
use ;
Example
This code will remove all whitespace from a file:
let input = "a b c";
let expected = "abc";
// create the parser and get the peeker
let mut parser = new;
let mut peeker = parser.peeker;
let mut parsed_string = Stringnew;
// Loop until the end is hit or an error occurs
loop
//compare results
assert!;