master
Raymon Zutekouw 4 days ago
parent 2aeb187b36
commit e1cfdb7953
Signed by: raymon
GPG Key ID: 0E62222846283925
  1. 15
      src/main.rs

@ -97,7 +97,7 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
let memcell = state
.variables
.get(variable_name)
.ok_or_else(|| format!("Variable '{}' did not exists", variable_name))
.ok_or_else(|| format!("Variable '{variable_name}' did not exists"))
.unwrap();
state.free_list.push(memcell.address);
state.variables.remove(&String::from(variable_name));
@ -215,7 +215,7 @@ fn instruct(statement: Pair<Rule>, state: &mut State, out: &mut Builder) {
Rule::include => {
let file_path_raw = extract_operand(statement);
let file_path = &file_path_raw[1..file_path_raw.len() - 1];
let content = std::fs::read_to_string(&file_path).unwrap();
let content = std::fs::read_to_string(file_path).unwrap();
let parsed_file = MblfParser::parse(Rule::file, &content)
.expect("Parse Error")
.next()
@ -270,15 +270,12 @@ mod tests {
#[test]
fn test_parse_constant() {
assert_eq!(parse_constant(&"42"), Ok(42));
assert_eq!(parse_constant(&"0x2A"), Ok(42));
assert_eq!(parse_constant(&"\"*\""), Ok(42));
assert_eq!(parse_constant("42"), Ok(42));
assert_eq!(parse_constant("0x2A"), Ok(42));
assert_eq!(parse_constant("\"*\""), Ok(42));
assert!(
matches!(
parse_constant(&"\'*\'"),
Err(std::num::ParseIntError { .. })
),
matches!(parse_constant("\'*\'"), Err(std::num::ParseIntError { .. })),
"Char literals are declared with \"_\", not \'_\'"
);
}

Loading…
Cancel
Save