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

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

#1162 in Rust patterns

42 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

~67KB