verilization-compiler 0.1.0

The verilization serialization description language compiler. This contains the core compiler library, but not the languages or CLI.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::fs;
use std::fs::File;
use std::path::Path;
use crate::lang::{OutputHandler, GeneratorError};

/// An output handler that operates directly on the file system.
pub struct FileOutputHandler {}

impl <'output> OutputHandler<'output> for FileOutputHandler {
    type FileHandle = File;
    fn create_file<P: AsRef<Path>>(&'output mut self, path: P) -> Result<Self::FileHandle, GeneratorError> {
        if let Some(dir) = path.as_ref().parent() {
            fs::create_dir_all(dir)?;
        }

        Ok(File::create(path)?)
    }
}