fluidattacks-blends 0.6.0

Blends imperative shell: parsing, AST-graph construction, serialization
Documentation
//! Language-aware content fixups applied after a file is loaded, mirroring the
//! python `custom_parsers_by_language` registry.

use crate::content::Content;
use crate::language::Language;

pub mod helm;

pub struct CustomParser {
    pub languages: &'static [Language],
    pub validator: fn(&Content) -> bool,
    pub transformer: fn(&Content) -> Option<Content>,
}

impl CustomParser {
    pub(crate) fn validate(&self, content: &Content) -> bool {
        (self.validator)(content)
    }

    pub(crate) fn transform(&self, content: &Content) -> Option<Content> {
        (self.transformer)(content)
    }
}

static ALL: &[CustomParser] = &[helm::PARSER];

pub fn for_language(language: Language) -> impl Iterator<Item = &'static CustomParser> {
    ALL.iter()
        .filter(move |custom_parser| custom_parser.languages.contains(&language))
}