mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
BUGFIX: Error message for parse errors reported wrong file name.
This commit is contained in:
parent
6418533562
commit
ca982dfc02
@ -41,4 +41,4 @@ let server_config = {
|
|||||||
l = ["foo", "bar"]
|
l = ["foo", "bar"]
|
||||||
};
|
};
|
||||||
|
|
||||||
out json server_config;
|
out "json" server_config;
|
@ -298,8 +298,9 @@ pub struct AssertCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Builder handles building ucg code for a single file..
|
/// Builder handles building ucg code for a single file..
|
||||||
pub struct Builder {
|
pub struct Builder<'a> {
|
||||||
root: PathBuf,
|
root: PathBuf,
|
||||||
|
curr_file: Option<&'a str>,
|
||||||
validate_mode: bool,
|
validate_mode: bool,
|
||||||
assert_collector: AssertCollector,
|
assert_collector: AssertCollector,
|
||||||
env: Rc<Val>,
|
env: Rc<Val>,
|
||||||
@ -339,7 +340,7 @@ macro_rules! eval_binary_expr {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Builder {
|
impl<'a> Builder<'a> {
|
||||||
// TOOD(jwall): This needs some unit tests.
|
// TOOD(jwall): This needs some unit tests.
|
||||||
fn tuple_to_val(&self, fields: &Vec<(Token, Expression)>) -> Result<Rc<Val>, Box<Error>> {
|
fn tuple_to_val(&self, fields: &Vec<(Token, Expression)>) -> Result<Rc<Val>, Box<Error>> {
|
||||||
let mut new_fields = Vec::<(Positioned<String>, Rc<Val>)>::new();
|
let mut new_fields = Vec::<(Positioned<String>, Rc<Val>)>::new();
|
||||||
@ -409,6 +410,7 @@ impl Builder {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
Builder {
|
Builder {
|
||||||
root: root.into(),
|
root: root.into(),
|
||||||
|
curr_file: None,
|
||||||
validate_mode: false,
|
validate_mode: false,
|
||||||
assert_collector: AssertCollector {
|
assert_collector: AssertCollector {
|
||||||
success: true,
|
success: true,
|
||||||
@ -463,7 +465,10 @@ impl Builder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => Err(Box::new(error::Error::new_with_cause(
|
Err(err) => Err(Box::new(error::Error::new_with_cause(
|
||||||
format!("Error while parsing file: {}", self.root.to_string_lossy()),
|
format!(
|
||||||
|
"Error while parsing file: {}",
|
||||||
|
self.curr_file.unwrap_or("<eval>")
|
||||||
|
),
|
||||||
error::ErrorType::ParseError,
|
error::ErrorType::ParseError,
|
||||||
err,
|
err,
|
||||||
))),
|
))),
|
||||||
@ -471,8 +476,9 @@ impl Builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a ucg file at the named path.
|
/// Builds a ucg file at the named path.
|
||||||
pub fn build_file(&mut self, name: &str) -> BuildResult {
|
pub fn build_file(&mut self, name: &'a str) -> BuildResult {
|
||||||
eprintln!("building ucg file {}", name);
|
eprintln!("building ucg file {}", name);
|
||||||
|
self.curr_file = Some(name);
|
||||||
let mut f = try!(File::open(name));
|
let mut f = try!(File::open(name));
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
try!(f.read_to_string(&mut s));
|
try!(f.read_to_string(&mut s));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user