5 * Copyright (C) 2004-2006 Sami Pietila
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 #include "functions.h"
32 #include "parser_mac.h"
33 #include "lr_parser.h"
35 extern
struct parser_state parser_state
;
89 %token
<int_t
> tINUMBER
90 %token
<int_t
> tDNUMBER
92 %type
<int_t
> exp value term rcl number parenthesis func
95 %left
'+' '-' '*' '/' '&' '|' 'n' 'x' '^' 'e'
106 reset_lr_tokeniser
();
107 parser_state.
error = EINVAL
;
119 cp
($1, v
->MPdisp_val
);
120 show_display
(v
->MPdisp_val
);
122 | value
'=' tSTO
'(' tINUMBER
')' {
127 | value tSTO
'(' tINUMBER
')' {
134 show_display
(v
->MPdisp_val
);
144 | exp
'+' exp
{mpadd
($1, $3, $$
);}
145 | exp
'-' exp
{mpsub
($1, $3, $$
);}
146 | exp
'*' exp
{mpmul
($1, $3, $$
);}
147 | exp
'/' exp
{mpdiv
($1, $3, $$
);}
148 | exp
'&' exp
{calc_and
($$
, $1, $3);}
149 | exp
'|' exp
{calc_or
($$
, $1, $3);}
150 | exp
'n' exp
{calc_xnor
($$
, $1, $3);}
151 | exp
'x' exp
{calc_xor
($$
, $1, $3);}
153 | exp
'^' exp
{calc_xpowy
($1, $3, $$
);}
154 | exp
'e' exp
{calc_xtimestenpowx
($1, $3, $$
);}
156 | exp
'K' {do_tfunc
($1, $$
, SIN
);}
157 | exp
'J' {do_tfunc
($1, $$
, COS
);}
158 | exp
'L' {do_tfunc
($1, $$
, TAN
);}
160 | exp
'G' {mplog10
($1, $$
);}
161 | exp
's' {mpsqrt
($1, $$
);}
162 | exp
'N' {mpln
($1, $$
);}
163 | exp
'u' {mpabs
($1, $$
);}
164 | exp
':' {mpcmf
($1, $$
);}
165 | exp
'i' {mpcmim
($1, $$
);}
166 | exp
'c' {mpneg
($1, $$
);}
167 | exp
'!' {do_factorial
($1, $$
);}
168 | exp
'~' {calc_not
($1, $$
);}
169 | exp
']' {calc_u16
($1, $$
);}
170 | exp
'[' {calc_u32
($1, $$
);}
171 | exp
'}' {calc_tenpowx
($1, $$
);}
172 | exp
'{' {mpexp
($1, $$
);}
178 tLOG10 parenthesis
{mplog10
($2, $$
);}
179 | term tLOG10
{mplog10
($1, $$
);}
180 | tSQRT parenthesis
{mpsqrt
($2, $$
);}
181 | term tSQRT
{mpsqrt
($1, $$
);}
182 | tLN parenthesis
{mpln
($2, $$
);}
183 | term tLN
{mpln
($1, $$
);}
184 | tABS parenthesis
{mpabs
($2, $$
);}
185 | term tABS
{mpabs
($1, $$
);}
186 | tFRAC parenthesis
{mpcmf
($2, $$
);}
187 | term tFRAC
{mpcmf
($1, $$
);}
188 | tINT parenthesis
{mpcmim
($2, $$
);}
189 | term tINT
{mpcmim
($1, $$
);}
190 | tSIN parenthesis
{calc_trigfunc
(sin_t
, $2, $$
);}
191 | term tSIN
{calc_trigfunc
(sin_t
, $1, $$
);}
192 | tCOS parenthesis
{calc_trigfunc
(cos_t
, $2, $$
);}
193 | term tCOS
{calc_trigfunc
(cos_t
, $1, $$
);}
194 | tTAN parenthesis
{calc_trigfunc
(tan_t
, $2, $$
);}
195 | term tTAN
{calc_trigfunc
(tan_t
, $1, $$
);}
199 '(' exp
')' {cp
($2, $$
);}
205 | parenthesis
{cp
($1, $$
);}
206 |
'-' term %prec POS
{mpneg
($2, $$
);}
207 |
'+' term %prec POS
{cp
($2, $$
);}
211 tRCL
'(' tINUMBER
')' {
219 tINUMBER
{cp
($1, $$
);}
220 | tDNUMBER
{cp
($1, $$
);}
225 int lrerror
(char *s
) {return
0;}