#token-stream #generation #macro #compiler #interface #struct #convert

to_tokenstream

An interface for creating a compiler within a Rust macro

4 releases

0.1.3 Dec 23, 2023
0.1.2 Dec 23, 2023
0.1.1 Dec 5, 2023
0.1.0 Oct 27, 2023

#2124 in Rust patterns

Download history 10/week @ 2024-09-30 7/week @ 2024-12-02 9/week @ 2024-12-09

250 downloads per month
Used in 3 crates (via python-ast)

Apache-2.0

6KB

to_tokenstream

An interface for writing code generation tools like compilers. It allows the conversion of any implementing struct into a stream of tokens, which can then be used within Rust macros.


lib.rs:

A simple interface for building compilers within the Rust pre-processor. Generally implemented on the node types of an abstract syntax tree (AST), this crate defines a uniform interface that a compiler can call to generate rust code. Output will be a TokenStream, which can be converted to a string (with .to_string()) or used in a macro to generate rust code.

Dependencies

~55KB