diff options
| -rw-r--r-- | Documentation/api.rst | 10 | ||||
| -rw-r--r-- | evaluate.h | 15 | ||||
| -rw-r--r-- | expression.h | 18 |
3 files changed, 41 insertions, 2 deletions
diff --git a/Documentation/api.rst b/Documentation/api.rst index 8b6f0401..d1a1d3ca 100644 --- a/Documentation/api.rst +++ b/Documentation/api.rst @@ -9,3 +9,13 @@ Utilities ~~~~~~~~~ .. c:autodoc:: ptrlist.c + +Parsing +~~~~~~~ + +.. c:autodoc:: expression.h + +Typing +~~~~~~ + +.. c:autodoc:: evaluate.h @@ -6,8 +6,23 @@ struct statement; struct symbol; struct symbol_list; +/// +// evaluate the type of an expression +// @expr: the expression to be evaluated +// @return: the type of the expression or ``NULL`` +// if the expression can't be evaluated struct symbol *evaluate_expression(struct expression *expr); + +/// +// evaluate the type of a statement +// @stmt: the statement to be evaluated +// @return: the type of the statement or ``NULL`` +// if it can't be evaluated struct symbol *evaluate_statement(struct statement *stmt); + +/// +// evaluate the type of a set of symbols +// @list: the list of the symbol to be evaluated void evaluate_symbol_list(struct symbol_list *list); #endif diff --git a/expression.h b/expression.h index b5fa9bc1..ba4157fd 100644 --- a/expression.h +++ b/expression.h @@ -243,9 +243,23 @@ struct expression { }; }; -/* Constant expression values */ -int is_zero_constant(struct expression *); +/// +// Constant expression values +// -------------------------- + +/// +// test if an expression evaluates to the constant ``0``. +// @return: ``1`` if @expr evaluate to ``0``, +// ``0`` otherwise. +int is_zero_constant(struct expression *expr); + +/// +// test the compile time truth value of an expression +// @return: +// * ``-1`` if @expr is not constant, +// * ``0`` or ``1`` depending on the truth value of @expr. int expr_truth_value(struct expression *expr); + long long get_expression_value(struct expression *); long long const_expression_value(struct expression *); long long get_expression_value_silent(struct expression *expr); |
