#parser #parser-combinator #regex #macro

yanked informal

Macro-based parser combinator library

4.1.1 Feb 7, 2021
4.0.0 Feb 7, 2021
3.1.0 Jan 31, 2021
2.1.0 Jan 24, 2021
1.0.2 Jan 17, 2021

#147 in #parser-combinator

23 downloads per month

0BSD license

28KB
511 lines

Informal

A macro-based parser combinator library.


lib.rs:

Informal is a library to help build your own parser using a few simple declarative macros.

Each macro translates to a function with the type fn (String, usize) -> ParseResult.

Usage

Macros from informal are largely just syntactic sugar for writing parsing functions, so they end up looking like simplified function declarations.

informal macros will take an identifier, then a block containing that parser's one or more children depending on the specific macro.

Example

For example, parsing a terminal symbol can be done by calling the just! macro like so:

just!( pub plus { "+"; } ); 

Notice you can specify pub visibility like a regular function.

The above macro call declares a function that can be called with the same identifier you provided with a String and a usize as arguments.

assert!( plus ( String::from("+"), 0 ).is_ok() );

Dependencies

~2.2–3MB
~54K SLoC