variable-core 0.1.4

Parser, lexer, AST, and validation for the Variable feature flag DSL
Documentation
pub mod ast;
pub mod lexer;
pub mod parser;
pub mod validate;

use ast::VarFile;
use lexer::LexError;
use parser::ParseError;
use validate::ValidationError;

#[derive(Debug)]
pub enum Error {
    Lex(LexError),
    Parse(ParseError),
    Validation(Vec<ValidationError>),
}

pub fn parse_and_validate(source: &str) -> Result<VarFile, Error> {
    let tokens = lexer::lex(source).map_err(Error::Lex)?;
    let var_file = parser::parse(tokens).map_err(Error::Parse)?;
    validate::validate(&var_file).map_err(Error::Validation)?;
    Ok(var_file)
}