moved error handling to appropriate header files
parent
b127575211
commit
bcff42f74d
|
@ -9,10 +9,6 @@
|
||||||
|
|
||||||
/* --------- ERROR MESSAGES */
|
/* --------- ERROR MESSAGES */
|
||||||
#define printerr(format, ...) printf("error: " format "\n", ##__VA_ARGS__)
|
#define printerr(format, ...) printf("error: " format "\n", ##__VA_ARGS__)
|
||||||
#define ZERODIV_ERR "zero divisor"
|
|
||||||
#define DOMAIN_ERR "operand not in domain [%d, %d]"
|
|
||||||
#define NEG_ERR "negative operand %g"
|
|
||||||
#define FULL_STACK_ERR "stack full, can't push %g"
|
|
||||||
#define UNKNOWN_TOKEN_ERR "unknown token %s"
|
#define UNKNOWN_TOKEN_ERR "unknown token %s"
|
||||||
#define VAR_NOT_SET_ERR "variable %c has no value"
|
#define VAR_NOT_SET_ERR "variable %c has no value"
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,10 @@
|
||||||
#define STACK_H
|
#define STACK_H
|
||||||
#define printerr(format, ...) printf("error: " format "\n", ##__VA_ARGS__)
|
#define printerr(format, ...) printf("error: " format "\n", ##__VA_ARGS__)
|
||||||
|
|
||||||
|
/* ERROR MESSAGES */
|
||||||
#define EMPTY_STACK_ERR "stack empty"
|
#define EMPTY_STACK_ERR "stack empty"
|
||||||
#define SHORT_STACK_ERR "not enough elements on stack"
|
#define SHORT_STACK_ERR "not enough elements on stack"
|
||||||
|
#define FULL_STACK_ERR "stack full, can't push %g"
|
||||||
|
|
||||||
#ifndef MAX_STACK
|
#ifndef MAX_STACK
|
||||||
#define MAX_STACK 100
|
#define MAX_STACK 100
|
||||||
|
|
|
@ -2,6 +2,13 @@
|
||||||
|
|
||||||
#define TOKENS_H
|
#define TOKENS_H
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#define printerr(format, ...) printf("error: " format "\n", ##__VA_ARGS__)
|
||||||
|
|
||||||
|
/* ERROR MESSAGES */
|
||||||
|
#define ZERODIV_ERR "zero divisor"
|
||||||
|
#define DOMAIN_ERR "operand not in domain [%d, %d]"
|
||||||
|
#define NEG_ERR "negative operand %g"
|
||||||
|
|
||||||
/* --------- CALCULATOR FUNCTION TYPES */
|
/* --------- CALCULATOR FUNCTION TYPES */
|
||||||
/* the following macros allow us to call native c constructs
|
/* the following macros allow us to call native c constructs
|
||||||
* in a declarative style */
|
* in a declarative style */
|
||||||
|
@ -89,4 +96,5 @@
|
||||||
OPERATORS \
|
OPERATORS \
|
||||||
MATH_H_BINDINGS
|
MATH_H_BINDINGS
|
||||||
|
|
||||||
|
#undef printerr
|
||||||
#endif // TOKENS_H
|
#endif // TOKENS_H
|
||||||
|
|
Loading…
Reference in New Issue