Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions calc/bc_util/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,20 @@ fn parse_stmt(
in_loop: bool,
statements: &mut Vec<StmtInstruction>,
source_locations: &mut Vec<usize>,
) -> Result<usize, PestError> {
) -> Result<usize, Box<PestError>> {
let stmt = first_child(stmt);
let (line, _) = stmt.line_col();
source_locations.push(line);
let mut instruction_count = 1;
match stmt.as_rule() {
Rule::break_stmt => {
if !in_loop {
return Err(pest::error::Error::new_from_span(
return Err(Box::new(pest::error::Error::new_from_span(
pest::error::ErrorVariant::CustomError {
message: "break outside of loop".to_string(),
},
stmt.as_span(),
));
)));
}
statements.push(StmtInstruction::Break);
}
Expand All @@ -286,12 +286,12 @@ fn parse_stmt(
Rule::return_stmt => {
// return ( "(" expr? ")" )?
if !in_function {
return Err(pest::error::Error::new_from_span(
return Err(Box::new(pest::error::Error::new_from_span(
pest::error::ErrorVariant::CustomError {
message: "return outside of function".to_string(),
},
stmt.as_span(),
));
)));
}
let mut inner = stmt.into_inner();
if let Some(expr) = inner.next() {
Expand Down Expand Up @@ -381,7 +381,7 @@ fn parse_stmt(
Ok(instruction_count)
}

fn parse_function(func: Pair<Rule>, file: Rc<str>) -> Result<Function, PestError> {
fn parse_function(func: Pair<Rule>, file: Rc<str>) -> Result<Function, Box<PestError>> {
let mut function = func.into_inner();

// define letter ( parameter_list ) auto_define_list statement_list end
Expand Down Expand Up @@ -586,7 +586,7 @@ pub fn parse_program(text: &str, file_path: Option<&str>) -> Result<Program, Par
if let Err(e) =
parse_stmt(stmt, false, false, &mut instructions, &mut source_locations)
{
errors.push(e);
errors.push(*e);
}
}
}
Expand All @@ -595,7 +595,7 @@ pub fn parse_program(text: &str, file_path: Option<&str>) -> Result<Program, Par
name: f.name,
function: f,
}),
Err(e) => errors.push(e),
Err(e) => errors.push(*e),
},
Rule::EOI => {}
_ => unreachable!(),
Expand Down
1 change: 1 addition & 0 deletions screen/stty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ fn stty_show_long(ti: Termios) -> io::Result<()> {
}

// display compact, parse-able form stty values
#[allow(clippy::unnecessary_cast)] // tcflag_t is u64 on macOS, u32 on Linux
fn stty_show_compact(ti: Termios) -> io::Result<()> {
// encode settings as pairs of (String,u64)
let mut tiv = vec![
Expand Down