async-graphql@4.0.7 async-graphql-actix-web@4.0.7 async-graphql-axum@4.0.7 async-graphql-derive@4.0.7 async-graphql-parser@4.0.7 async-graphql-poem@4.0.7 async-graphql-rocket@4.0.7 async-graphql-tide@4.0.7 async-graphql-value@4.0.7 async-graphql-warp@4.0.7 Generated by cargo-workspaces
30 lines
771 B
Rust
30 lines
771 B
Rust
use std::{error::Error, fs};
|
|
|
|
const PREAMBLE: &str = "\
|
|
//! This is @generated code, do not edit by hand.
|
|
//! See `graphql.pest` and `tests/codegen.rs`.
|
|
#![allow(unused_attributes)]
|
|
use super::GraphQLParser;
|
|
";
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
generated_code()?;
|
|
println!("cargo:rerun-if-changed=src/graphql.pest");
|
|
Ok(())
|
|
}
|
|
|
|
fn generated_code() -> Result<(), Box<dyn Error>> {
|
|
let input = r###"
|
|
#[derive(Parser)]
|
|
#[grammar = r#"graphql.pest"#]
|
|
struct GraphQLParser;
|
|
"###
|
|
.parse::<proc_macro2::TokenStream>()
|
|
.unwrap();
|
|
let tokens = pest_generator::derive_parser(input, false);
|
|
let new = tokens.to_string();
|
|
let code = format!("{}\n{}", PREAMBLE, &new);
|
|
fs::write("./src/parse/generated.rs", code).unwrap();
|
|
Ok(())
|
|
}
|