adze_governance_runtime_profile_core/
lib.rs1#![forbid(unsafe_op_in_unsafe_fn)]
7#![deny(missing_docs)]
8#![cfg_attr(feature = "strict_api", deny(unreachable_pub))]
9#![cfg_attr(not(feature = "strict_api"), warn(unreachable_pub))]
10#![cfg_attr(feature = "strict_docs", deny(missing_docs))]
11#![cfg_attr(not(feature = "strict_docs"), allow(missing_docs))]
12
13pub use adze_governance_matrix_contract::{ParserBackend, ParserFeatureProfile};
14
15pub const fn parser_feature_profile_for_runtime() -> ParserFeatureProfile {
17 ParserFeatureProfile::current()
18}
19
20pub const fn parser_feature_profile_for_runtime2(pure_rust_glr: bool) -> ParserFeatureProfile {
22 ParserFeatureProfile {
23 pure_rust: pure_rust_glr,
24 tree_sitter_standard: false,
25 tree_sitter_c2rust: false,
26 glr: pure_rust_glr,
27 }
28}
29
30pub const fn resolve_backend_for_profile(
32 profile: ParserFeatureProfile,
33 has_conflicts: bool,
34) -> ParserBackend {
35 profile.resolve_backend(has_conflicts)
36}
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41
42 #[test]
43 fn runtime_profile_matches_current_cfg() {
44 assert_eq!(
45 parser_feature_profile_for_runtime().pure_rust,
46 cfg!(feature = "pure-rust")
47 );
48 }
49
50 #[test]
51 fn runtime2_profile_reflects_glr_toggle() {
52 let enabled = parser_feature_profile_for_runtime2(true);
53 assert!(enabled.pure_rust);
54 assert!(enabled.glr);
55 assert!(!enabled.tree_sitter_standard);
56 assert!(!enabled.tree_sitter_c2rust);
57
58 let disabled = parser_feature_profile_for_runtime2(false);
59 assert!(!disabled.pure_rust);
60 assert!(!disabled.glr);
61 }
62
63 #[test]
64 fn resolve_backend_for_profile_delegates_correctly() {
65 let profile = parser_feature_profile_for_runtime2(true);
66 let backend = resolve_backend_for_profile(profile, false);
67 assert_eq!(backend, profile.resolve_backend(false));
68
69 let conflict_backend = resolve_backend_for_profile(profile, true);
70 assert_eq!(conflict_backend, profile.resolve_backend(true));
71 }
72}