1 /* 2 tcbasic - a small BASIC Interpreter written in C. 3 Copyright (C) 2015, 2016, 2017 Thomas Cort <linuxgeek@gmail.com> 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef __FACTOR_H 20 #define __FACTOR_H 21 22 struct expression; 23 struct number; 24 struct rnd; 25 struct time; 26 struct var; 27 struct sin; 28 struct cos; 29 struct tan; 30 struct cot; 31 struct atn; 32 struct exp; 33 struct log; 34 struct abs; 35 struct sgn; 36 struct sqr; 37 38 struct factor { 39 int type; 40 union factor_union { 41 struct expression *e; 42 struct number *n; 43 struct rnd *r; 44 struct time *time; 45 struct sin *sin; 46 struct cos *cos; 47 struct tan *tan; 48 struct cot *cot; 49 struct atn *atn; 50 struct exp *exp; 51 struct log *log; 52 struct abs *abs; 53 struct sgn *sgn; 54 struct sqr *sqr; 55 struct var *v; 56 } u; 57 }; 58 59 struct factor *new_factor(int type, void *value); 60 struct factor *parse_factor(struct tokenizer *t); 61 struct number *eval_factor(struct factor *f); 62 void print_factor(struct factor *f); 63 void free_factor(struct factor *f); 64 65 #endif 66