1
2
3
4
5
6
7
8
9
10
11
use crate::codegen::ValueNode;
use nyar_error::{FileCache, FileID, NyarError};
use std::str::FromStr;

pub fn parse(file: FileID, cache: &mut FileCache) -> Result<ValueNode, NyarError> {
    let text = cache.fetch(&file)?.to_string();
    match ValueNode::from_str(&text) {
        Ok(o) => Ok(o),
        Err(e) => Err(NyarError::from(e).with_file(file)),
    }
}