Improved contracts

This commit is contained in:
Vera Lewis
2026-01-04 01:09:19 -06:00
parent f4528e64b9
commit 90d63cbcbf

View File

@@ -3,8 +3,13 @@ int error = 0;
void printStack(STACK);
int
main (const int argc, const char* argv[])
{
main (const int argc, const char* argv[]) {
/* if argv is an array of strings corresponding to a well-formed RPN
* expression, then main prints the value of the expression and returns 0
* otherwise, main will return one of ERR_NO_EXPR, ERR_INVALID_INPUT,
* ERR_NS_OPERANDS, or ERR_NS_OPERATORS, as defined in ee.h, depending
* on the type of malformed expression.
*/
STACK expr = NULL;
@@ -58,9 +63,7 @@ int
isNum(const char* query)
{
/*
* If query is a string, isNum(query) iff query represents a number.
*/
// If query is a string, isNum(query) iff query represents a number.
char *extra_char;
strtod(query, &extra_char);
@@ -90,6 +93,10 @@ arrity(const char query)
bool
isDivByZero(double *_operands)
{
/* if _operands represents an array of operands, isDivByZero(_operands)
* iff the first operand (corresponding to the divisor) is zero
*/
return _operands[0] == 0;
}