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 c42fcccabd
commit 3fad899daa

View File

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