Download rust/crates/hyperkitty-constraints/src/compiler.rs from Snapkitty/hyperkitty-constraint-dsl: direct link, hf CLI and curl.
- Browser
- Download file 907 Bytes
-
https://huggingface.co/Snapkitty/hyperkitty-constraint-dsl/resolve/main/rust/crates/hyperkitty-constraints/src/compiler.rs
- Command line
-
hf download hf://Snapkitty/hyperkitty-constraint-dsl/rust/crates/hyperkitty-constraints/src/compiler.rs
-
curl -L -o compiler.rs https://huggingface.co/Snapkitty/hyperkitty-constraint-dsl/resolve/main/rust/crates/hyperkitty-constraints/src/compiler.rs
907 Bytes
| //! DSL to constraint compilation | |
| use super::language::ValidityProgram; | |
| use crate::Result; | |
| use hyperkitty_core::Error; | |
| pub fn compile(source: &str) -> Result<ValidityProgram> { | |
| // Stub: simplified compilation (parser integration deferred) | |
| let mut prog = ValidityProgram::new(); | |
| if source.contains("balance") { | |
| prog.add_constraint(super::language::Constraint::Balance("main".to_string())); | |
| } | |
| if source.contains("reject") { | |
| prog.set_reject_on_fail(true); | |
| } | |
| Ok(prog) | |
| } | |
| mod tests { | |
| use super::*; | |
| fn compile_simple() { | |
| let prog = compile("require balance").unwrap(); | |
| assert!(!prog.constraints.is_empty()); | |
| } | |
| fn compile_with_reject() { | |
| let prog = compile("require balance otherwise reject").unwrap(); | |
| assert!(prog.otherwise_reject); | |
| } | |
| } | |