teleparse_macros/
lib.rs

1//! # teleparse-macros
2//!
3//! These are for use with the [`teleparse`](https://docs.rs/teleparse) crate and not meant to be used standalone.
4
5mod prelude;
6use prelude::*;
7
8/// Transform an enum into a token type (a lexicon)
9///
10/// This will derive the lexicon trait as well as the super traits, and also generate
11/// an implementation for the lexer, and implementation for terminal symbols for the AST
12///
13/// Note that this is not a derive macro, since it will transform the input.
14#[proc_macro_attribute]
15pub fn derive_lexicon(_: TokenStream, input: TokenStream) -> TokenStream {
16    expand_with_mut(input, lexicon::expand)
17}
18mod lexicon;
19
20/// Transform an enum or struct into a parse tree node, as well as deriving the production rule
21/// (the AST nodes)
22///
23/// This will derive the AbstractSyntaxTree trait as well as the super traits, and also generate
24/// an implementation for the lexer, and implementation for terminal symbols for the AST
25///
26/// Note that this is not a derive macro, since it will transform the input.
27#[proc_macro_attribute]
28pub fn derive_syntax(_: TokenStream, input: TokenStream) -> TokenStream {
29    expand_with_mut(input, syntax::expand)
30}
31mod syntax;
32
33/// Derive common traits for AST helper nodes (stores a Node as its first thing)
34#[proc_macro_derive(Node)]
35pub fn derive_node(input: TokenStream) -> TokenStream {
36    expand_with(input, node::expand)
37}
38mod node;
39
40/// Derive ToSpan from a type that stores a ToSpan as its first thing
41#[proc_macro_derive(ToSpan)]
42pub fn derive_to_span(input: TokenStream) -> TokenStream {
43    expand_with(input, to_span::expand)
44}
45mod to_span;
46
47// internal helpers
48
49mod root;