4 releases (2 breaking)
0.3.0 | Sep 10, 2024 |
---|---|
0.2.3 | Sep 9, 2024 |
0.2.0 | Aug 23, 2024 |
0.1.0 | Aug 16, 2024 |
#1955 in Parser implementations
177 downloads per month
38KB
621 lines
Minparser
Simple parsing functions
lib.rs
:
Simple parsing tools
This crate is a collection of objects and algorithms shared among different crates that needs to implement a parser.
The [predicates] module contains some useful functions in order to analize ASCII and Unicode characters. Some of these functions are just wrappers of functions defined in the standard library.
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 (textual) token inside a file in order to allow the
user to easily find it.
A Pos<T>
is just an object containing a T
object and a Position
. Usually you set
T
to be equal to char
or to a custom token type.
A DefLine
is a sort of "iterator" that returns Pos<Option<char>, FILE>
in
place of Option<char>
. Moreover, it defines a lot of useful functions for parsing tokens from
a text source.
This crate assumes a single \n
character separates lines in a text file. If you need to deal
with char
iterators that use \r\n
as a line delimiter (or both \n
and \r\n
)
you can use the NLIterator
iterator wrapper to automatically discard any \r
character so
that \r\n
becomes just \n
.