Crates.io | quoth |
lib.rs | quoth |
version | 0.1.7 |
source | src |
created_at | 2023-08-21 18:44:01.84735 |
updated_at | 2024-06-21 06:29:13.632578 |
description | Quoth is a scannerless (no-lexing), developer-friendly parsing library for implementing DSLs and syntax parsers in Rust |
homepage | https://github.com/sam0x17/quoth |
repository | https://github.com/sam0x17/quoth |
max_upload_size | |
id | 950354 |
size | 600,120 |
Quoth is a scannerless parsing library (meaning there is no lexing/tokenization step)
specifically designed for implementing languages and DSLs (domain specific languages) in Rust.
It is based on the admittedly dtolnayian idea from
syn that everything should implement the same Parse
trait,
however quoth takes this idea further to the point where lexing is no longer necessary, and
what you are left with is something akin to "Object Oriented Parsing" where it is quite easy to
compose, combine, parse, and even "unparse" Parsable
s in a myriad of ways.
In quoth, everything implements Parsable
, which brings with it a large set of requirements
(and thus features) that are at best conventions in other parsing ecosystems. Some core
features of quoth include:
Span
source text for any Parsable
is always available and is cheap/free to access at any time during parsingSpan
itself is very lightweight and is just a reference-counted string slice into a
Source
ParseStream
is also incredibly lightweight and provides normally expensive
operations like forking virtually for freeParsable
type, but you can also peek by value, and even by
regexQuoth also takes special care to make anything that is Parsable
also automatically
Peekable
, making it even easier to implement Parsable
. Furthermore, Peekable
itself
allows peeking on both a type-basis, and on a specific value basis. For example, you could
peek "is an Ident
next?" or "is an Ident
with this specific value next?".
More information and docs will be coming in the next release