Skip to main content

santa_data/
parser.rs

1//! Lower-level CCL parsing utilities
2
3use serde_json::Value;
4
5/// Represents a parsed CCL value
6#[derive(Debug, Clone, PartialEq)]
7pub enum CclValue {
8    /// A simple string value
9    String(String),
10    /// An array of values
11    Array(Vec<String>),
12    /// An object with key-value pairs
13    Object(Vec<(String, CclValue)>),
14}
15
16impl From<CclValue> for Value {
17    fn from(ccl: CclValue) -> Self {
18        match ccl {
19            CclValue::String(s) => Value::String(s),
20            CclValue::Array(arr) => Value::Array(arr.into_iter().map(Value::String).collect()),
21            CclValue::Object(pairs) => {
22                let mut map = serde_json::Map::new();
23                for (k, v) in pairs {
24                    map.insert(k, v.into());
25                }
26                Value::Object(map)
27            }
28        }
29    }
30}
31
32/// Parse a CCL document into a CclValue
33///
34/// This is a lower-level API that returns the parsed structure
35/// without going through serde_ccl at all.
36pub fn parse_ccl(_content: &str) -> Result<CclValue, String> {
37    // For now, this is a placeholder
38    // A full implementation would parse CCL syntax directly
39    Err("Direct CCL parsing not yet implemented".to_string())
40}