variable-core 0.1.4

Parser, lexer, AST, and validation for the Variable feature flag DSL
Documentation
use std::collections::BTreeMap;

use crate::lexer::Span;

#[derive(Debug, Clone, PartialEq)]
pub struct VarFile {
    pub structs: Vec<StructDef>,
    pub features: Vec<Feature>,
}

#[derive(Debug, Clone, PartialEq)]
pub struct StructDef {
    pub id: u32,
    pub name: String,
    pub fields: Vec<StructField>,
    pub span: Span,
}

#[derive(Debug, Clone, PartialEq)]
pub struct StructField {
    pub id: u32,
    pub name: String,
    pub field_type: VarType,
    pub default: Value,
    pub span: Span,
}

#[derive(Debug, Clone, PartialEq)]
pub struct Feature {
    pub id: u32,
    pub name: String,
    pub variables: Vec<Variable>,
    pub span: Span,
}

#[derive(Debug, Clone, PartialEq)]
pub struct Variable {
    pub id: u32,
    pub name: String,
    pub var_type: VarType,
    pub default: Value,
    pub span: Span,
}

#[derive(Debug, Clone, PartialEq)]
pub enum VarType {
    Boolean,
    Integer,
    Float,
    String,
    Struct(String),
}

#[derive(Debug, Clone, PartialEq)]
pub enum Value {
    Boolean(bool),
    Integer(i64),
    Float(f64),
    String(String),
    Struct {
        struct_name: String,
        fields: BTreeMap<String, Value>,
    },
}