Skip to content
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

Stop leaking identifiers in parser generator and use more DSLv2 types #977

Merged
merged 8 commits into from
May 24, 2024
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ pub struct KeywordItem {
#[derive_spanned_type(Clone, Debug, ParseInputTokens, WriteOutputTokens)]
pub struct KeywordDefinition {
pub enabled: Option<VersionSpecifier>,
/// When the keyword is reserved, i.e. can't be used in other position (e.g. as a name)
pub reserved: Option<VersionSpecifier>,

// Underlying keyword scanner (i.e. identifier scanner)
pub value: KeywordValue,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt;
use std::ops::Deref;

use proc_macro2::{Literal, TokenStream};
Expand Down Expand Up @@ -81,3 +82,9 @@ impl WriteOutputTokens for Identifier {
}
}
}

impl quote::IdentFragment for Identifier {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.value.fmt(f)
}
}
1 change: 1 addition & 0 deletions crates/codegen/runtime/generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ indexmap = { workspace = true }
Inflector = { workspace = true }
infra_utils = { workspace = true }
itertools = { workspace = true }
once_cell = { workspace = true }
proc-macro2 = { workspace = true }
quote = { workspace = true }
semver = { workspace = true }
Expand Down
Loading