Expand description
Simple parsing tools
This crate is a collection of objects and algorithms shared among different crates that needs to implement a parser.
A Position is an object that identifies a (textual) file and a position inside it,
represented as a line index and a column index. The main role of a Position object is to
uniquely identify a single character or a token inside a file in order to allow the
user to easily find it.
A View<'a, D, F> can be seen as a suffix of a larger string with the position of
its first character and some data of type D. The match_tool method
can be used to match its prefix with any object implementing the ParseTool
trait which represents a pattern that can be satisfied or not by a string.
Many useful parsing tools can be found in tools and utils modules.
§Usage example
use minparser::prelude::*;
let view = ViewFile::new_default("My string value");
let (step, mtc) = view.match_tool_string("My string").unwrap();
assert_eq!(mtc, "My string");
assert_eq!(step.get_view(), " value");
let step = step.match_tool(minparser::utils::WhiteTool).unwrap(); // Use the WhiteTool tool to
assert_eq!(step.get_view(), "value"); //match a sequence of whitespaces
assert!(step.match_tool('a').is_err()); // A missing match is an error