#tokens #token-stream #macro #generation #compiler #interface #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

#1723 in Rust patterns

Download history 6/week @ 2024-07-15 32/week @ 2024-07-29 4/week @ 2024-09-16 11/week @ 2024-09-23 10/week @ 2024-09-30

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

~56KB