00001 // Simple mathematical formula processing library 00002 // Written by Atsushi Watanabe 00003 // Intelligent Robot Laboratory, University of Tsukuba 00004 // 00005 // Copyright 2011 Atsushi Watanabe, All rights reserved. 00006 // 00007 // Redistribution and use in source and binary forms, with or without 00008 // modification, are permitted provided that the following conditions are met: 00009 // 00010 // * Redistributions of source code must retain the above copyright notice, this 00011 // list of conditions and the following disclaimer. 00012 // * Redistributions in binary form must reproduce the above copyright notice, 00013 // this list of conditions and the following disclaimer in the documentation 00014 // and/or other materials provided with the distribution. 00015 // 00016 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 00017 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 00019 // EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00020 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00021 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00022 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00023 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00024 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00025 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 00027 #ifndef FORMULA_H 00028 #define FORMULA_H 00029 00030 #include <formula-calc.h> 00031 00032 struct stack_t 00033 { 00034 int rank; 00035 enum rpf_type_t type; 00036 void *value; 00037 }; 00038 00039 struct operation_t 00040 { 00041 char op[8]; 00042 int rank; 00043 enum rpf_type_t type; 00044 double (*func)(double **); 00045 int narg; 00046 }; 00047 00048 struct rpf_t *rpf_push(struct rpf_t *rpf, struct stack_t *obj); 00049 struct rpf_t *rpf_join(struct rpf_t *rpf, struct rpf_t *rpf2); 00050 int rpf_count_num(struct rpf_t *rpf); 00051 struct rpf_t *rpf_last(struct rpf_t *rpf); 00052 struct rpf_t *formula_output(struct stack_t *num, int *sp_num, struct stack_t *op, int *sp_op, int rank); 00053 00054 #endif // FORMULA_H