#enum #stream #grammar #earley #earley-parser #parsing #cd-projekt #codegen #jay-earley #elizabeth-scott

nightly enum_stream_codegen

A parser generator. This package handles code generation for the enum_stream macro.”

2 unstable releases

Uses old Rust 2015

0.1.0 May 29, 2019
0.0.0 May 20, 2016

#2 in #following-libraries

Download history 14/week @ 2023-10-31 15/week @ 2023-11-07 18/week @ 2023-11-14 15/week @ 2023-11-21 21/week @ 2023-11-28 12/week @ 2023-12-05 9/week @ 2023-12-12 17/week @ 2023-12-19 18/week @ 2023-12-26 12/week @ 2024-01-02 11/week @ 2024-01-09 14/week @ 2024-01-16 10/week @ 2024-01-23 14/week @ 2024-01-30 15/week @ 2024-02-06 27/week @ 2024-02-13

69 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

23KB
562 lines

Panini • Latest version

A blazing fast, modern, extensible parser generator.

Work in progress. A general-purpose parser generator as a Rust syntax extension.

On the surface, the goal of Panini is ease of use. In the future, it will also offer advanced features without compromising on the speed.

Panini uses gearley for Earley parsing, which can handle all context-free grammars. If you write a grammar for a language, it will work as expected.

Motivation

Months of research on parsing algorithms led me to believe that the Earley/Marpa algorithm is the best parsing tool for many purposes. Earley's is simple, flexible and extensible. Alas, nobody made an advanced parser generator that would realize the full potential of the algorithm. Therefore I resolved to make one.

Syntax and semantics of grammar description

User-friendliness is harder to achieve in a statically typed language such as Rust. Consequently, Panini offers typed expressions and type inference. Expression are typed according to intuitive rules:

Expression Automatic type Description
name type of name Use of a symbol.
() () A nulling expression.
(A) type of A Ignore redundant parentheses.
(A B) (type of A, type of B) Group two or more expressions.
item* Vec<type of item> A sequence that repeats zero or more times.
item+ Vec<type of item> A sequence that repeats one or more times.
`A B` type of A and B

Automatic recursive types are forbidden.

Grammars that have mistakes in their semantics may cause warnings, but never critical errors, during compilation. These warnings may indicate that some semantic actions are ignored.

Dependency graph

The following libraries were created for Panini.

Dependency graph

In Rust

In other languages

  • Marpa — an Earley parser (not a generator) that has advanced features. Written in literate C and in Perl.
  • YAEP — an Earley parser engine that currently has the best speed and small memory use. Written in C.

In academia

Quotes

I'd be very happy to have a superfast general parser out there but some extremely bright minds have been unable to solve it for 40 years.

— Terence Parr, author of ANTLR

Thanks

Thanks to Jay Earley, Jeffrey Kegler, John Aycock, R. Nigel Horspool, and Elizabeth Scott who pioneered Earley parsing.

Special thanks to CD PROJEKT RED, HAEVN, Kaśka Sochacka, sanah, Kwiat Jabłoni, Carbon Based Lifeforms, and Solar Fields for providing amazing music, which made coding even more enjoyable.

License

Dual-licensed for compatibility with the Rust project.

Licensed under the Apache License Version 2.0: http://www.apache.org/licenses/LICENSE-2.0, or the MIT license: http://opensource.org/licenses/MIT, at your option.

Dependencies

~5.5MB
~106K SLoC