diff --git a/src/enviroment.rs b/src/enviroment.rs index 0d84cb7..2749805 100644 --- a/src/enviroment.rs +++ b/src/enviroment.rs @@ -233,9 +233,9 @@ fn nerd_kerek(machine: &mut Machine, op: &DecompiledOperation, args: Vec num.ceil(), - "down" => num.floor(), - "nearest" => num.round(), + "fel" => num.ceil(), + "le" => num.floor(), + "közel" => num.round(), _ => { error(format!("Unknown rounding mode: {}", mode), machine, op); return VMMemory::Null(VMMemoryNull { variable_id: 0 }); diff --git a/src/errors.rs b/src/errors.rs index 3f547dc..ad9a024 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -25,6 +25,7 @@ pub enum ErrorSubType { VariableAlreadyExists, ArgumentDuplication, TooManyArguments, + NoExpression, //Machine errors RegisterNotFound, MemoryOutOfBounds, @@ -107,6 +108,7 @@ fn convert_subtypes_to_string(stype: &ErrorSubType) -> String { ErrorSubType::TooManyArguments => String::from("Too many arguments"), ErrorSubType::FileError => String::from("File error"), ErrorSubType::RuntimeError => String::from("Runtime error"), + ErrorSubType::NoExpression => String::from("No expression found"), } } fn convert_subtypes_to_short(stype: &ErrorSubType) -> String { @@ -135,6 +137,7 @@ fn convert_subtypes_to_short(stype: &ErrorSubType) -> String { ErrorSubType::TooManyArguments => String::from("TA:"), ErrorSubType::FileError => String::from("FE:"), ErrorSubType::RuntimeError => String::from("RE:"), + ErrorSubType::NoExpression => String::from("NE:"), } } pub fn reverse_subtype_short(str: String) -> ErrorSubType { @@ -163,6 +166,7 @@ pub fn reverse_subtype_short(str: String) -> ErrorSubType { "TA" => ErrorSubType::TooManyArguments, "FE" => ErrorSubType::FileError, "RE" => ErrorSubType::RuntimeError, + "NE" => ErrorSubType::NoExpression, _ => panic!("Unknown error subtype short: {}", str), } } diff --git a/src/parser.rs b/src/parser.rs index c507b29..929ee50 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -306,6 +306,11 @@ fn shunt(input: Vec, ctx: &Context) -> ASTPart { } } } + if output.len() == 0 { + let err = create_error(&format!("No expressions found after applying order of operations"), 0, ErrorType::SemanticError, ErrorSubType::NoExpression); + print_error(&err, &ctx); + process::exit(1); + } return output[0].clone(); } fn read_function(input: &Vec, pos: &mut usize, with_args: bool, ctx: &Context) -> ASTPart { diff --git a/test.asl b/test.asl index 426b530..0c58aa7 100644 --- a/test.asl +++ b/test.asl @@ -1 +1,6 @@ -ugass(3.3) \ No newline at end of file +gethelj a = -6.5 +ugass(nerd.abs(a)) +ugass(nerd.kerek(a, szaft"fel"szaft)) +ugass(nerd.sqrt(16)) +ugass(nerd.legnagyobb(3,56,66,1,12,55,6)) +ugass(nerd.legkisebb(3,56,66,1,12,55,6)) \ No newline at end of file