~ubuntu-branches/ubuntu/karmic/gcalctool/karmic-updates

« back to all changes in this revision

Viewing changes to gcalctool/ce_parser.y

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell, Robert Ancell, Daniel Holbach
  • Date: 2009-05-11 16:02:16 UTC
  • mfrom: (1.1.52 upstream)
  • Revision ID: james.westby@ubuntu.com-20090511160216-5wpmr4g8sv6vrk0m
Tags: 5.27.1-0ubuntu1
[ Robert Ancell ]
* New upstream release (LP: #373095)
  - Convert Glade UI to GtkBuilder UI
  - Fix display on startup to be replaced on entry (LP: #348699)
  - Make GConf schemas translatable
  - Replace MP number arrays with an MPNumber structure
  - Tidied up error messages
  - Tidied up GConf schema, use native GConf types, the following settings will
    be reset after upgrade:
    - The initial window position
    - The visibility of trailing zeros
    - The visibility of thousands separators
    - The visibility of the register window
  - Updated translations

* Merge from Debian unstable (5.24.3.1-1). Remaining Ubuntu changes
  - Launchpad integration:
    + debian/control.in: Build-Depends on launchpad-integration
    + inclusion of debian/patches/01_lpi.patch and
      debian/patches/99_autoconf.patch
  - debian/control.in: Add VCS link
  - debian/control.in: Remove dependency on Glade
  - debian/control: Rebuilt with contro.in changes

[ Daniel Holbach ]
* debian/watch: track current unstable release too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
%}
35
35
 
36
36
%union {
37
 
  int int_t[MP_SIZE];
 
37
  MPNumber int_t;
38
38
  int integer;
39
39
}
40
40
 
98
98
 
99
99
statement: 
100
100
  seq
101
 
| value {ret($1);}
 
101
| value {ret(&$1);}
102
102
| error {
103
103
  yyclearin; 
104
104
  reset_ce_tokeniser();
114
114
 
115
115
udf:
116
116
  value '=' {
117
 
  display_set_number(&v->display, $1);
 
117
  display_set_number(&v->display, &$1);
118
118
  }
119
119
| value '=' tSTO '(' tNUMBER ')' {
120
 
  int val = mp_cast_to_int($5);
121
 
  register_set(val, $1);
 
120
  int val = mp_cast_to_int(&$5);
 
121
  register_set(val, &$1);
122
122
}
123
123
| value tSTO '(' tNUMBER ')' {
124
 
  int val = mp_cast_to_int($4);
125
 
  register_set(val, $1);
 
124
  int val = mp_cast_to_int(&$4);
 
125
  register_set(val, &$1);
126
126
}
127
127
| tCLR {
128
128
  display_clear(&v->display);
130
130
;
131
131
 
132
132
value: 
133
 
  exp {cp($1, $$);}
134
 
| tPI %prec HIGH {mp_get_pi($$);} 
 
133
  exp {cp(&$1, &$$);}
 
134
| tPI %prec HIGH {mp_get_pi(&$$);} 
135
135
;
136
136
 
137
137
exp: 
138
 
  term {cp($1, $$);}
 
138
  term {cp(&$1, &$$);}
139
139
 
140
 
| exp '+' exp {mp_add($1, $3, $$);}
141
 
| exp '-' exp {mp_subtract($1, $3, $$);}
 
140
| exp '+' exp {mp_add(&$1, &$3, &$$);}
 
141
| exp '-' exp {mp_subtract(&$1, &$3, &$$);}
142
142
 
143
143
| exp tMOD exp %prec MED {
144
 
    if (!mp_is_integer($1) || !mp_is_integer($3)) {
 
144
    if (!mp_is_integer(&$1) || !mp_is_integer(&$3)) {
145
145
        parser_state.error = -PARSER_ERR_MODULUSOP;
146
146
    } else {
147
 
      if (mp_modulus_divide($1, $3, $$)) {
 
147
      if (mp_modulus_divide(&$1, &$3, &$$)) {
148
148
        parser_state.error = -EINVAL;
149
149
      }                    
150
150
    }
151
151
}
152
152
 
153
153
| exp tAND exp {
154
 
    if (!mp_is_natural($1) || !mp_is_natural($3)) {
 
154
    if (!mp_is_natural(&$1) || !mp_is_natural(&$3)) {
155
155
        parser_state.error = -PARSER_ERR_BITWISEOP;
156
156
    }
157
 
    mp_and($1, $3, $$);
 
157
    mp_and(&$1, &$3, &$$);
158
158
}
159
159
| exp tOR exp {
160
 
    if (!mp_is_natural($1) || !mp_is_natural($3)) {
 
160
    if (!mp_is_natural(&$1) || !mp_is_natural(&$3)) {
161
161
        parser_state.error = -PARSER_ERR_BITWISEOP;
162
162
    }
163
 
    mp_or($1, $3, $$);
 
163
    mp_or(&$1, &$3, &$$);
164
164
}
165
165
| exp tXNOR exp {
166
 
    if (!mp_is_natural($1) || !mp_is_natural($3)) {
 
166
    if (!mp_is_natural(&$1) || !mp_is_natural(&$3)) {
167
167
        parser_state.error = -PARSER_ERR_BITWISEOP;
168
168
    }
169
 
    mp_xnor($1, $3, $$);
 
169
    mp_xnor(&$1, &$3, &$$);
170
170
}
171
171
| exp tXOR exp {
172
 
    if (!mp_is_natural($1) || !mp_is_natural($3)) {
 
172
    if (!mp_is_natural(&$1) || !mp_is_natural(&$3)) {
173
173
        parser_state.error = -PARSER_ERR_BITWISEOP;
174
174
    }
175
 
    mp_xor($1, $3, $$);
 
175
    mp_xor(&$1, &$3, &$$);
176
176
}
177
177
;
178
178
 
179
179
 
180
180
term:
181
 
  number {cp($1, $$);}
182
 
| rcl {cp($1, $$);}
183
 
| term '/' term {mpdiv($1, $3, $$);}
184
 
| term '*' term {mpmul($1, $3, $$);}
185
 
| 'e' '^' term {mp_epowy($3, $$);} 
186
 
| term '!' {mp_factorial($1 ,$$);}
187
 
| term '%' {mp_percent($1, $$);}
 
181
  number {cp(&$1, &$$);}
 
182
| rcl {cp(&$1, &$$);}
 
183
| term '/' term {mpdiv(&$1, &$3, &$$);}
 
184
| term '*' term {mpmul(&$1, &$3, &$$);}
 
185
| 'e' '^' term {mp_epowy(&$3, &$$);} 
 
186
| term '!' {mp_factorial(&$1, &$$);}
 
187
| term '%' {mp_percent(&$1, &$$);}
188
188
| '~' term %prec LNEG {
189
 
    if (!mp_is_natural($2)) {
 
189
    if (!mp_is_natural(&$2)) {
190
190
        parser_state.error = -PARSER_ERR_BITWISEOP;
191
191
    }
192
 
    mp_not($2, $$);
 
192
    mp_not(&$2, &$$);
193
193
}
194
 
| '-' term %prec NEG {mp_invert_sign($2, $$);}
195
 
| '+' term %prec POS {cp($2, $$);}
196
 
| term '^' term {mp_xpowy($1, $3, $$);}
197
 
 
198
 
| func {cp($1, $$);}
199
 
| reg {cp($1, $$);}
200
 
 
201
 
| parenthesis {cp($1, $$);}
 
194
| '-' term %prec NEG {mp_invert_sign(&$2, &$$);}
 
195
| '+' term %prec POS {cp(&$2, &$$);}
 
196
| term '^' term {mp_xpowy(&$1, &$3, &$$);}
 
197
 
 
198
| func {cp(&$1, &$$);}
 
199
| reg {cp(&$1, &$$);}
 
200
 
 
201
| parenthesis {cp(&$1, &$$);}
202
202
;
203
203
 
204
204
parenthesis:
205
 
  '(' exp ')' {cp($2, $$);}
 
205
  '(' exp ')' {cp(&$2, &$$);}
206
206
  ;
207
207
 
208
208
reg: 
209
 
  tREG {register_get($1, $$);}
 
209
  tREG {register_get($1, &$$);}
210
210
  ;
211
211
 
212
212
func:
213
 
  tLOG10 term %prec HIGH {mp_logarithm(10, $2, $$);}
214
 
| tLOG2 term %prec HIGH {mp_logarithm(2, $2, $$);}
215
 
| tSQRT term %prec HIGH {mp_sqrt($2, $$);}
216
 
| tLN term %prec HIGH {mpln($2, $$);}
217
 
| tRAND %prec HIGH {mp_set_from_random($$);}
218
 
| tABS term %prec HIGH {mp_abs($2, $$);}
219
 
| tFRAC term %prec HIGH {mpcmf($2, $$);}
220
 
| tINT term %prec HIGH {mpcmim($2, $$);}
221
 
| tCHS term %prec HIGH {mp_invert_sign($2, $$);}
222
 
 
223
 
| tSIN term %prec HIGH {to_rad($2, $2); mp_sin($2, $$);}
224
 
| tCOS term %prec HIGH {to_rad($2, $2); mp_cos($2, $$);}
225
 
| tTAN term %prec HIGH {to_rad($2, $2); mp_tan($2, $$);}
226
 
| tASIN term %prec HIGH {mp_asin($2, $$); do_trig_typeconv(v->ttype, $$, $$);}
227
 
| tACOS term %prec HIGH {mp_acos($2, $$); do_trig_typeconv(v->ttype, $$, $$);}
228
 
| tATAN term %prec HIGH {mp_atan($2, $$); do_trig_typeconv(v->ttype, $$, $$);}
229
 
| tSINH term %prec HIGH {mp_sinh($2, $$);}
230
 
| tCOSH term %prec HIGH {mp_cosh($2, $$);}
231
 
| tTANH term %prec HIGH {mp_tanh($2, $$);}
232
 
| tASINH term %prec HIGH {mp_asinh($2, $$);}
233
 
| tACOSH term %prec HIGH {mp_acosh($2, $$);}
234
 
| tATANH term %prec HIGH {mp_atanh($2, $$);}
235
 
 
236
 
| tU32 term %prec HIGH {mp_mask_u32($2, $$);}
237
 
| tU16 term %prec HIGH {mp_mask_u16($2, $$);}
 
213
  tLOG10 term %prec HIGH {mp_logarithm(10, &$2, &$$);}
 
214
| tLOG2 term %prec HIGH {mp_logarithm(2, &$2, &$$);}
 
215
| tSQRT term %prec HIGH {mp_sqrt(&$2, &$$);}
 
216
| tLN term %prec HIGH {mpln(&$2, &$$);}
 
217
| tRAND %prec HIGH {mp_set_from_random(&$$);}
 
218
| tABS term %prec HIGH {mp_abs(&$2, &$$);}
 
219
| tFRAC term %prec HIGH {mpcmf(&$2, &$$);}
 
220
| tINT term %prec HIGH {mpcmim(&$2, &$$);}
 
221
| tCHS term %prec HIGH {mp_invert_sign(&$2, &$$);}
 
222
 
 
223
| tSIN term %prec HIGH {to_rad(&$2, &$2); mp_sin(&$2, &$$);}
 
224
| tCOS term %prec HIGH {to_rad(&$2, &$2); mp_cos(&$2, &$$);}
 
225
| tTAN term %prec HIGH {to_rad(&$2, &$2); mp_tan(&$2, &$$);}
 
226
| tASIN term %prec HIGH {mp_asin(&$2, &$$); do_trig_typeconv(v->ttype, &$$, &$$);}
 
227
| tACOS term %prec HIGH {mp_acos(&$2, &$$); do_trig_typeconv(v->ttype, &$$, &$$);}
 
228
| tATAN term %prec HIGH {mp_atan(&$2, &$$); do_trig_typeconv(v->ttype, &$$, &$$);}
 
229
| tSINH term %prec HIGH {mp_sinh(&$2, &$$);}
 
230
| tCOSH term %prec HIGH {mp_cosh(&$2, &$$);}
 
231
| tTANH term %prec HIGH {mp_tanh(&$2, &$$);}
 
232
| tASINH term %prec HIGH {mp_asinh(&$2, &$$);}
 
233
| tACOSH term %prec HIGH {mp_acosh(&$2, &$$);}
 
234
| tATANH term %prec HIGH {mp_atanh(&$2, &$$);}
 
235
 
 
236
| tU32 term %prec HIGH {mp_mask_u32(&$2, &$$);}
 
237
| tU16 term %prec HIGH {mp_mask_u16(&$2, &$$);}
238
238
;
239
239
 
240
240
rcl:
241
241
  tRCL '(' tNUMBER ')' {
242
 
    int val = mp_cast_to_int($3);
243
 
    register_get(val, $$);
 
242
    int val = mp_cast_to_int(&$3);
 
243
    register_get(val, &$$);
244
244
  }
245
245
  ;
246
246
 
247
247
number:
248
 
  tNUMBER {cp($1, $$);}
 
248
  tNUMBER {cp(&$1, &$$);}
249
249
| tANS {
250
 
  cp(display_get_answer(&v->display), $$);
 
250
  cp(display_get_answer(&v->display), &$$);
251
251
}
252
252
;
253
253
 
260
260
 
261
261
#if 0
262
262
 
263
 
| '(' lexp ')' {cp($2, $$);}
 
263
| '(' lexp ')' {cp(&$2, &$$);}
264
264
 
265
 
| term term {mpmul($1, $2, $$);}
 
265
| term term {mpmul(&$1, &$2, &$$);}
266
266
 
267
267
#endif