Keep file contents in memory
This commit is contained in:
parent
1170009b4f
commit
0eda941ed7
2 changed files with 4 additions and 2 deletions
|
|
@ -424,6 +424,7 @@ pub enum Command {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct File {
|
pub struct File {
|
||||||
|
pub contents: String,
|
||||||
pub includes: Vec<String>,
|
pub includes: Vec<String>,
|
||||||
pub timezone: Option<String>,
|
pub timezone: Option<String>,
|
||||||
pub commands: Vec<Command>,
|
pub commands: Vec<Command>,
|
||||||
|
|
|
||||||
|
|
@ -759,10 +759,11 @@ fn parse_command(p: Pair<'_, Rule>, file: &mut File) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_file(p: Pair<'_, Rule>) -> Result<File> {
|
pub fn parse_file(p: Pair<'_, Rule>, contents: String) -> Result<File> {
|
||||||
assert_eq!(p.as_rule(), Rule::file);
|
assert_eq!(p.as_rule(), Rule::file);
|
||||||
|
|
||||||
let mut file = File {
|
let mut file = File {
|
||||||
|
contents,
|
||||||
includes: vec![],
|
includes: vec![],
|
||||||
timezone: None,
|
timezone: None,
|
||||||
commands: vec![],
|
commands: vec![],
|
||||||
|
|
@ -787,5 +788,5 @@ pub fn parse(path: &Path, input: &str) -> Result<File> {
|
||||||
let file_pair = pairs.next().unwrap();
|
let file_pair = pairs.next().unwrap();
|
||||||
assert_eq!(pairs.next(), None);
|
assert_eq!(pairs.next(), None);
|
||||||
|
|
||||||
parse_file(file_pair).map_err(|e| e.with_path(&pathstr))
|
parse_file(file_pair, input.to_string()).map_err(|e| e.with_path(&pathstr))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue