7 * Copyright (C) 2004-2005 Sami Pietila
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 #include <sys/types.h>
31 #include "ce_parser.h"
32 #include "ce_parser.tab.h"
42 NUMBER [DIGIT}*{DECIMAL}{DIGIT}+|{DIGIT}
48 "Acosh" {return tACOSH;}
49 "Acos" {return tACOS;}
52 "Asinh" {return tASINH;}
53 "Asin" {return tASIN;}
54 "Atanh" {return tATANH;}
55 "Atan" {return tATAN;}
56 "Cbrt" {return tCBRT;}
59 "Cosh" {return tCOSH;}
61 "Ctrm" {return tCTRM;}
64 "Frac" {return tFRAC;}
68 "Log" {return tLOG10;}
75 "Rand" {return tRAND;}
76 "Rate" {return tRATE;}
78 "Sinh" {return tSINH;}
81 "Sqrt" {return tSQRT;}
84 "Tanh" {return tTANH;}
86 "Term" {return tTERM;}
89 "Xnor" {return tXNOR;}
93 celval.integer = atoi(yytext+1);
99 if (strlen(yytext) > 40) parser_state.error = -PARSER_ERR_TOO_LONG_NUMBER;
100 check_numbase(yytext);
101 MPstr_to_num(yytext, v->base, celval.int_t);
105 {DIGIT}*{DECIMAL}{DIGIT}+ {
106 if (strlen(yytext) > 40) parser_state.error = -PARSER_ERR_TOO_LONG_NUMBER;
107 check_numbase(yytext);
108 MPstr_to_num(yytext, v->base, celval.int_t);
121 ce_flush_buffer(YY_CURRENT_BUFFER);
128 {DIGIT}*{DECIMAL}*{DIGIT}+{SEPARATOR}{DIGIT}+ {
129 check_numbase(yytext);
130 MPstr_to_num(yytext, v->base, celval.int_t);
135 // TODO: fix memory leak (look also following sections)
136 char *number = ce_strndup(yytext, strlen(yytext)-1);
137 MPstr_to_num(number, HEX, celval.int_t);
143 char *number = ce_strndup(yytext, strlen(yytext)-1);
144 MPstr_to_num(number, BIN, celval.int_t);
150 char *number = ce_strndup(yytext, strlen(yytext)-1);
151 MPstr_to_num(number, OCT, celval.int_t);
157 char *number = ce_strndup(yytext, strlen(yytext)-1);
158 MPstr_to_num(number, DEC, celval.int_t);
163 {DIGIT}*{DECIMAL}{DIGIT}+"d" {
164 char *number = ce_strndup(yytext, strlen(yytext)-1);
165 MPstr_to_num(number, DEC, celval.int_t);