chandeliers-syn

Crates.iochandeliers-syn
lib.rschandeliers-syn
version1.0.0
sourcesrc
created_at2023-10-24 13:23:02.593625
updated_at2024-01-05 20:24:20.17311
descriptionSyntax of the Lustre language, to be parsed by procedural macros
homepage
repositoryhttps://github.com/Vanille-N/chandeliers
max_upload_size
id1012368
size117,763
Neven Villani (Vanille-N)

documentation

README

Chandeliers-Syn

Syntax of Lustre.


In this crate we describe the parsing AST of Lustre programs. This AST is not meant to be used directly, instead it should be translated into one that is more convenient for static analysis.

How to obtain a parsing AST and what to do with it

All types of the module ast implement syn::parse::Parse, so they can be parsed from any stream of tokens that conforms to the structure expected by syn.

The typical usage inside a proc macro would be like:

use chandeliers_syn::ast::Prog;
use proc_macro::TokenStream;

#[proc_macro]
pub fn get_and_handle_ast(input: TokenStream) -> TokenStream {
    let prog: Prog = syn::parse_macro_input!(input as Prog);
    // now you have a `Prog`, you can e.g.
    // `Prog::translate` it to get something that can be used by
    // Chandeliers' sanitizer.
}
Commit count: 220

cargo fmt