Extended parser::eval and parser::parse documentation by explaining when None is returned.

This commit is contained in:
PaddiM8 2020-06-11 23:45:54 +02:00
parent 46a27d4129
commit 4f9f8bc63e

View File

@ -63,6 +63,8 @@ pub enum CalcError {
}
/// Evaluate expressions/declarations and return the answer.
///
/// `None` will be returned if the last statement is a declaration.
pub fn eval(
context: &mut Context,
input: &str,
@ -76,6 +78,8 @@ pub fn eval(
}
/// Parse expressions/declarations and return a syntax tree.
///
/// `None` will be returned if the last statement is a declaration.
pub fn parse(context: &mut Context, input: &str) -> Result<Vec<Stmt>, CalcError> {
context.tokens = Lexer::lex(input);
context.pos = 0;