Bagel-rs Alternatives
Similar projects and alternatives to bagel-rs
-
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
-
-
-
-
salsa
A generic framework for on-demand, incrementalized computation. Inspired by adapton, glimmer, and rustc's query system.
-
-
-
-
CG-SQL-author
CG-SQL Author's Cut: CG/SQL is a compiler that converts a SQL Stored Procedure like language into C for SQLite. SQLite has no stored procedures of its own. CG/CQL can also generate other useful artifacts for testing and schema maintenance.
-
bagel-rs discussion
bagel-rs reviews and mentions
-
Why I love Rust for tokenising and parsing
Yup! You can find it here: https://github.com/brundonsmith/bagel-rs/blob/master/src/mod...
[trying to remind myself how this works because it's been a while]
So it's got macros for defining "union types", which combine a bunch of individual structs into an enum with same-name variants, and implement From and TryFrom to box/unbox the structs in their group's enum
ASTInner is a struct that holds the Any (all possible AST nodes) enum in its `details` field, alongside some other info we want all AST nodes to have
And then AST is a struct that holds (1) an RC, and (2) a PhantomData, where TKind is the (hierarchical) type of AST struct that it's known to contain
AST can then be:
1. Downcast to a TKind (basically just unboxing it)
2. Upcast to an AST
3. Recast to a different AST (changing the box's PhantomData type but not actually transforming the value). This uses trait implementations (implemented by the macros) to automatically know which parent types it can be "upwardly casted to", and which more-specific types it can try and be casted to
The above three methods also have try_ versions
What this means then is you can write functions against, eg, AST. You will have to pass an AST, but eg. an AST can be infallibly recast to an AST, but an AST can only try_recast to AST (returning an Option>)
I worked in this codebase for a while and the dev experience was actually quite nice once I got all this set up. But figuring it out in the first place was a nightmare
I'm wondering now if it would be possible/worthwhile to extract it into a crate
Stats
The primary programming language of bagel-rs is Rust.