prepare for coroutine
This commit is contained in:
parent
c626af7cd4
commit
17ffb11f34
8 changed files with 107 additions and 130 deletions
|
@ -53,6 +53,7 @@ pub struct ASLError {
|
|||
pub typ: ErrorType,
|
||||
pub subtype: ErrorSubType,
|
||||
pub code: String,
|
||||
ctx: Context
|
||||
}
|
||||
|
||||
pub fn convert_types_to_string(typ: &ErrorType) -> String {
|
||||
|
@ -190,6 +191,7 @@ pub fn create_error(message: &str, position: usize, typ: ErrorType, stype: Error
|
|||
typ,
|
||||
subtype: stype,
|
||||
code,
|
||||
ctx: ctx.clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +234,7 @@ fn get_sorrunding_lines(file: &String, line: usize) -> (String, String, String)
|
|||
(before, current, after)
|
||||
}
|
||||
|
||||
pub fn print_error(error: &ASLError, ctx: &Context) {
|
||||
pub fn print_error(error: &ASLError) {
|
||||
let mut out = String::new();
|
||||
out.push_str(&convert_types_to_string(&error.typ));
|
||||
if error.message.len() < 1 {
|
||||
|
@ -241,18 +243,18 @@ pub fn print_error(error: &ASLError, ctx: &Context) {
|
|||
out.push_str(&error.message);
|
||||
}
|
||||
|
||||
if ctx.known {
|
||||
if error.ctx.known {
|
||||
out.push_str(" at position ");
|
||||
|
||||
let (line, column) = get_exact_pos(&ctx.raw_file, error.position);
|
||||
out.push_str(&ctx.file);
|
||||
let (line, column) = get_exact_pos(&error.ctx.raw_file, error.position);
|
||||
out.push_str(&error.ctx.file);
|
||||
out.push_str(":");
|
||||
out.push_str(&line.to_string());
|
||||
out.push_str(":");
|
||||
out.push_str(&column.to_string());
|
||||
|
||||
out.push_str("\n");
|
||||
let (before, current, after) = get_sorrunding_lines(&ctx.raw_file, line);
|
||||
let (before, current, after) = get_sorrunding_lines(&error.ctx.raw_file, line);
|
||||
if line > 1 {
|
||||
out.push_str(&(line-1).to_string());
|
||||
out.push_str(" | ");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue