-
-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export generator and docs api in the pest_generator trait #961
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,13 +26,14 @@ use std::fs::File; | |
use std::io::{self, Read}; | ||
use std::path::Path; | ||
|
||
use generator::generate; | ||
use proc_macro2::TokenStream; | ||
use syn::{Attribute, DeriveInput, Expr, ExprLit, Generics, Ident, Lit, Meta}; | ||
|
||
#[macro_use] | ||
mod macros; | ||
mod docs; | ||
mod generator; | ||
pub mod docs; | ||
pub mod generator; | ||
|
||
use pest_meta::parser::{self, rename_meta_rule, Rule}; | ||
use pest_meta::{optimizer, unwrap_or_report, validator}; | ||
|
@@ -96,7 +97,7 @@ pub fn derive_parser(input: TokenStream, include_grammar: bool) -> TokenStream { | |
let ast = unwrap_or_report(parser::consume_rules(pairs)); | ||
let optimized = optimizer::optimize(ast); | ||
|
||
generator::generate( | ||
generate( | ||
parsed_derive, | ||
paths, | ||
optimized, | ||
|
@@ -119,10 +120,14 @@ enum GrammarSource { | |
Inline(String), | ||
} | ||
|
||
struct ParsedDerive { | ||
pub(crate) name: Ident, | ||
pub(crate) generics: Generics, | ||
pub(crate) non_exhaustive: bool, | ||
/// Parsed information of the derive and the attributes. | ||
pub struct ParsedDerive { | ||
/// The identifier of the deriving struct, union, or enum. | ||
pub name: Ident, | ||
/// The generics of the deriving struct, union, or enum. | ||
pub generics: Generics, | ||
/// Indicates whether the 'non_exhaustive' attribute is added to the 'Rule' enum. | ||
pub non_exhaustive: bool, | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this can be feature guarded -- perhaps it can be moved to some child module and here, the feature-guard would be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my point of view, a child module is a good approach. I will add a commit with the feature guard and module. |
||
|
||
fn parse_derive(ast: DeriveInput) -> (ParsedDerive, Vec<GrammarSource>) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be feature-guarded