mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-01-21 12:38:34 +01:00
Fixed bug where symbol_table::contains_fn didn't check in the BINARY_FUNCS map
This commit is contained in:
parent
ec74089faa
commit
0c7e694648
@ -70,7 +70,7 @@ pub enum CalcError {
|
||||
InvalidNumberLiteral(String),
|
||||
InvalidOperator,
|
||||
InvalidUnit,
|
||||
UnexpectedToken(TokenKind),
|
||||
UnexpectedToken(TokenKind, TokenKind),
|
||||
UndefinedFn(String),
|
||||
UndefinedVar(String),
|
||||
UnableToInvert(String),
|
||||
@ -466,7 +466,7 @@ fn consume(context: &mut Context, kind: TokenKind) -> Result<&Token, CalcError>
|
||||
return Ok(advance(context));
|
||||
}
|
||||
|
||||
Err(CalcError::UnexpectedToken(kind))
|
||||
Err(CalcError::UnexpectedToken(peek(context).kind, kind))
|
||||
}
|
||||
|
||||
fn is_at_end(context: &Context) -> bool {
|
||||
|
@ -75,7 +75,7 @@ impl SymbolTable {
|
||||
|
||||
pub fn contains_fn(&self, identifier: &str) -> bool {
|
||||
prelude::UNARY_FUNCS.contains_key(identifier)
|
||||
|| prelude::UNARY_FUNCS.contains_key(identifier)
|
||||
|| prelude::BINARY_FUNCS.contains_key(identifier)
|
||||
|| self.hashmap.contains_key(&format!("fn.{}", identifier))
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,9 @@ fn print_calc_err(err: CalcError) {
|
||||
InvalidNumberLiteral(x) => format!("Invalid number literal: '{}'.", x),
|
||||
InvalidOperator => format!("Invalid operator."),
|
||||
InvalidUnit => format!("Invalid unit."),
|
||||
UnexpectedToken(kind) => format!("Unexpected token: '{:?}'.", kind),
|
||||
UnexpectedToken(got, expected) => {
|
||||
format!("Unexpected token: '{:?}', expected '{:?}'.", got, expected)
|
||||
}
|
||||
UnableToInvert(msg) => format!("Unable to invert: {}", msg),
|
||||
UndefinedFn(name) => format!("Undefined function: '{}'.", name),
|
||||
UndefinedVar(name) => format!("Undefined variable: '{}'.", name),
|
||||
|
Loading…
Reference in New Issue
Block a user