Crate minparser

Source
Expand description

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.

Modules§

predicates
A collection of predicates for characters.

Structs§

DefLine
A positioned iterator
NLIterator
An iterator wrapper that removes \r characters.
NoFile
A placeholder that you can use when you don’t want to use the file field in a Position.
NumAppender
An integer appender.
Pos
A positioned object, functionally equivalent to a struct containing an object of type T (the wrapped object) and its position as a Position<FILE> object.
Position
A position.

Traits§

Appender
A sequential container that can accept new objects.
AppenderExt
A sequential container with additional functionalities.
Posable
This trait allows you to easily create a Pos<T, F> object from a T object implementing the Posable traits thanks to its methods Posable::at and Posable::at_pos.