stalwartlabs / sieve

Sieve filter interpreter for Rust
https://docs.rs/sieve-rs/
GNU Affero General Public License v3.0
20 stars 5 forks source link

Expose parsing for consumers #3

Open mainrs opened 1 year ago

mainrs commented 1 year ago

Hello!

I am looking into writing a sieve filter linter and formatter. I have started work on my own parser and found your crate afterwards.

Is it possible to leverage your already existing parsing capabilities and work on some kind of ast?

That way I would not have to write my own parser. If that is out of scope for this project, let me know and I'll happily link my crate for others to find!

mdecimus commented 1 year ago

Hi,

That would be a nice addition but unfortunately, since I am currently busy working on the mail server, I don't think I'll have time to implement this anytime soon.

Currently when a script is compiled with this crate, an abstract representation is returned but not as an AST but rather an array with instructions where any nested code in the script is unrolled. Since grammar validation is done directly within the compiler I do not think it can be easily exposed. That being said, it might save you some work to use the tokenizer directly, this way you'll only have to implement the grammar validation in your crate.

xtuc commented 4 months ago

What do you think about https://github.com/stalwartlabs/sieve/pull/7? This makes it possible for projects to consume the Sieve parser.