OpenCores
URL https://opencores.org/ocsvn/jtag_stapl_player/jtag_stapl_player/trunk

Subversion Repositories jtag_stapl_player

[/] [jtag_stapl_player/] [trunk/] [jamexp.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sukhanov
 
2
/****************************************************************************/
3
/*                                                                                                                                                      */
4
/*      Actel version 1.1             May 2003                                                                  */
5
/*                                                                                                                                                      */
6
/****************************************************************************/
7
 
8
/* # line 15 "jamexp.y" */
9
 
10
/* #include <stdio.h> */
11
#include "jamexprt.h"
12
#include "jamdefs.h"
13
#include "jamexp.h"
14
#include "jamsym.h"
15
#include "jamheap.h"
16
#include "jamarray.h"
17
#include "jamutil.h"
18
#include "jamytab.h"
19
 
20
/* ------------- LEXER DEFINITIONS -----------------------------------------*/
21
/****************************************************************************/
22
/*                                                                                                                                                      */
23
/*      Operation of GET_FIRST_CH, GET_NEXT_CH, UNGET_CH, and DELETE_CH:                */
24
/*                                                                                                                                                      */
25
/*      Call GET_FIRST_CH to read a character from mdl_lexer_fp and put it into */
26
/*      jam_ch and jam_token_buffer.                                                                                    */
27
/*                                                                                                                                                      */
28
/*              jam_ch = first char                                                                                                     */
29
/*              jam_token_buffer[0] = first char                                                                        */
30
/*              jam_token_buffer[1] = '\0';                                                                                     */
31
/*              jam_token_buffer[2] = ?                                                                                         */
32
/*              jam_token_buffer[3] = ?                                                                                         */
33
/*                                                                                                                                                      */
34
/*      Call GET_NEXT_CH to read a character from jam_lexer_fp, put it in               */
35
/*      jam_ch, and append it to jam_token_buffer.                                                              */
36
/*                                                                                                                                                      */
37
/*              jam_ch = second char                                                                                            */
38
/*              jam_token_buffer[0] = first char                                                                        */
39
/*              jam_token_buffer[1] = second char                                                                       */
40
/*              jam_token_buffer[2] = '\0';                                                                                     */
41
/*              jam_token_buffer[3] = ?                                                                                         */
42
/*                                                                                                                                                      */
43
/*      Call UNGET_CH remove the last character from the buffer but leave it in */
44
/*      jam_ch and set a flag.  (The next call to GET_FIRST_CH will use jam_ch  */
45
/*      as the first char of the token and clear the flag.)                                             */
46
/*                                                                                                                                                      */
47
/*              jam_ch = second char                                                                                            */
48
/*              jam_token_buffer[0] = first char                                                                        */
49
/*              jam_token_buffer[1] = '\0';                                                                                     */
50
/*              jam_token_buffer[2] = ?                                                                                         */
51
/*              jam_token_buffer[3] = ?                                                                                         */
52
/*                                                                                                                                                      */
53
/*      Call DELETE_CH to remove the last character from the buffer.  Use this  */
54
/*      macro to discard the quotes surrounding a string, for example.  Unlike  */
55
/*      UNGET_CH, the deleted character will not be reused.                                             */
56
/*                                                                                                                                                      */
57
/****************************************************************************/
58
 
59
#define MAX_BUFFER_LENGTH       1024
60
#define END_OF_STRING           -1
61
 
62
#define BOOL int
63
#define TRUE 1
64
#define FALSE 0
65
 
66
#define GET_FIRST_CH \
67
        jam_token_buffer_index = 0; \
68
        GET_NEXT_CH;
69
 
70
#define GET_NEXT_CH \
71
        CH = jam_parse_string[jam_strptr++]; \
72
        jam_token_buffer [jam_token_buffer_index++] = CH; \
73
        if (jam_token_buffer_index >= MAX_BUFFER_LENGTH) { \
74
                --jam_token_buffer_index; \
75
                --jam_strptr; \
76
        } \
77
        jam_token_buffer [jam_token_buffer_index] = '\0';
78
 
79
#define UNGET_CH \
80
        jam_strptr--; \
81
        jam_token_buffer[--jam_token_buffer_index] = '\0';
82
 
83
#define DELETE_CH       jam_token_buffer [--jam_token_buffer_index] = '\0'
84
#define CH                      jam_ch
85
 
86
 
87
/****************************************************************************/
88
/*                                                                                                                                                      */
89
/*      Operation of BEGIN_MACHINE, END_MACHINE, and ACCEPT:                                    */
90
/*                                                                                                                                                      */
91
/*      BEGIN_MACHINE and END_MACHINE should be at the beginning the end of an  */
92
/*      integer function.  Inside the function, define states of the machine    */
93
/*      with normal C labels, and jump to states with normal C goto statements. */
94
/*      Use ACCEPT(token) to return an integer value token to the calling               */
95
/*      routine.                                                                                                                                */
96
/*                                                                                                                                                      */
97
/*              int foo (void)                                                                                                          */
98
/*              {                                                                                                                                       */
99
/*                      BEGIN_MACHINE;                                                                                                  */
100
/*                                                                                                                                                      */
101
/*                      start:                                                                                                                  */
102
/*                              if (whatever) goto next;                                                                        */
103
/*                              else goto start;                                                                                        */
104
/*                                                                                                                                                      */
105
/*                      next:                                                                                                                   */
106
/*                              if (done) ACCEPT (a_token_id);                                                          */
107
/*                              else goto start;                                                                                        */
108
/*                                                                                                                                                      */
109
/*                      END_MACHINE;                                                                                                    */
110
/*              }                                                                                                                                       */
111
/*                                                                                                                                                      */
112
/*      Be sure that there is an ACCEPT() or goto at the end of every state.    */
113
/*      Otherwise, control will "flow" from one state to the next illegally.    */
114
/*                                                                                                                                                      */
115
/****************************************************************************/
116
 
117
#define BEGIN_MACHINE   {int ret
118
 
119
#define ACCEPT(token)   {ret = (token); goto accept;}
120
 
121
#define END_MACHINE             accept: jam_token = ret; \
122
                                                }
123
 
124
struct {
125
        char *string;
126
        int length;
127
        int token;
128
} jam_keyword_table[] = {
129
        { "&&",         2,      AND_TOK },
130
        { "||",         2,      OR_TOK },
131
        { "==",         2,      EQUALITY_TOK },
132
        { "!=",         2,      INEQUALITY_TOK },
133
        { ">",          2,      GREATER_TOK },
134
        { "<",          2,      LESS_TOK },
135
        { ">=",         2,      GREATER_EQ_TOK },
136
        { "<=",         2,      LESS_OR_EQ_TOK },
137
        { "<<",         2,      LEFT_SHIFT_TOK },
138
        { ">>",         2,      RIGHT_SHIFT_TOK },
139
        { "..",         2,      DOT_DOT_TOK },
140
        { "OR",         2,      OR_TOK },
141
        { "AND",        3,      AND_TOK },
142
        { "ABS",        3,      ABS_TOK },
143
        { "INT",        3,      INT_TOK },
144
        { "LOG2",       4,      LOG2_TOK },
145
        { "SQRT",       4,      SQRT_TOK },
146
        { "CEIL",       4,      CIEL_TOK },
147
        { "FLOOR",      5,      FLOOR_TOK }
148
};
149
 
150
#define NUM_KEYWORDS ((int) \
151
        (sizeof(jam_keyword_table) / sizeof(jam_keyword_table[0])))
152
 
153
char            jam_ch = '\0';          /* next character from input file */
154
int                     jam_strptr = 0;
155
int                     jam_token = 0;
156
char            jam_token_buffer[MAX_BUFFER_LENGTH];
157
int                     jam_token_buffer_index;
158
char            jam_parse_string[MAX_BUFFER_LENGTH];
159
long            jam_parse_value = 0;
160
int                     jam_expression_type = 0;
161
JAMS_SYMBOL_RECORD *jam_array_symbol_rec = NULL;
162
 
163
#define YYMAXDEPTH 300  /* This fixes a stack depth problem on  */
164
                        /* all platforms.                       */
165
 
166
#define YYMAXTLIST 25   /* Max valid next tokens for any state. */
167
                        /* If there are more, error reporting   */
168
                        /* will be incomplete.                  */
169
 
170
enum OPERATOR_TYPE
171
{
172
        ADD = 0,
173
        SUB,
174
        UMINUS,
175
        MULT,
176
        DIV,
177
        MOD,
178
        NOT,
179
        AND,
180
        OR,
181
        BITWISE_NOT,
182
        BITWISE_AND,
183
        BITWISE_OR,
184
        BITWISE_XOR,
185
        LEFT_SHIFT,
186
        RIGHT_SHIFT,
187
        DOT_DOT,
188
        EQUALITY,
189
        INEQUALITY,
190
        GREATER_THAN,
191
        LESS_THAN,
192
        GREATER_OR_EQUAL,
193
        LESS_OR_EQUAL,
194
        ABS,
195
        INT,
196
        LOG2,
197
        SQRT,
198
        CIEL,
199
        FLOOR,
200
        ARRAY,
201
        POUND,
202
        DOLLAR,
203
        ARRAY_RANGE,
204
        ARRAY_ALL
205
};
206
 
207
typedef enum OPERATOR_TYPE OPERATOR_TYPE;
208
 
209
typedef struct EXP_STACK
210
{
211
  OPERATOR_TYPE         child_otype;
212
  JAME_EXPRESSION_TYPE type;
213
  long                          val;
214
  long                          loper;          /* left and right operands for DIV */
215
  long                          roper;          /* we save it for CEIL/FLOOR's use */
216
} EXPN_STACK;
217
 
218
#define YYSTYPE EXPN_STACK              /* must be a #define for yacc */
219
 
220
YYSTYPE jam_null_expression= {0,0,0,0,0};
221
 
222
JAM_RETURN_TYPE jam_return_code = JAMC_SUCCESS;
223
 
224
JAME_EXPRESSION_TYPE jam_expr_type = JAM_ILLEGAL_EXPR_TYPE;
225
 
226
#define NULL_EXP jam_null_expression  /* .. for 1 operand operators */
227
 
228
#define CALC(operator, lval, rval) jam_exp_eval((operator), (lval), (rval))
229
 
230
/* --- FUNCTION PROTOTYPES -------------------------------------------- */
231
 
232
int jam_yyparse(void);
233
int jam_yylex(void);
234
 
235
#define AND_TOK 257
236
#define OR_TOK 258
237
#define EQUALITY_TOK 259
238
#define INEQUALITY_TOK 260
239
#define GREATER_TOK 261
240
#define LESS_TOK 262
241
#define GREATER_EQ_TOK 263
242
#define LESS_OR_EQ_TOK 264
243
#define LEFT_SHIFT_TOK 265
244
#define RIGHT_SHIFT_TOK 266
245
#define DOT_DOT_TOK 267
246
#define ABS_TOK 268
247
#define INT_TOK 269
248
#define LOG2_TOK 270
249
#define SQRT_TOK 271
250
#define CIEL_TOK 272
251
#define FLOOR_TOK 273
252
#define VALUE_TOK 274
253
#define IDENTIFIER_TOK 275
254
#define ARRAY_TOK 276
255
#define ERROR_TOK 277
256
#define UNARY_MINUS 278
257
#define UNARY_PLUS 279
258
#ifndef YYSTYPE
259
#define YYSTYPE int
260
#endif
261
YYSTYPE jam_yylval, jam_yyval;
262
#define YYERRCODE 256
263
 
264
/* # line 333 "jamexp.y" */
265
 
266
 
267
 
268
/************************************************************************/
269
/*                                                                                                                                              */
270
 
271
long jam_exponentiate(long x, long y)
272
 
273
/*      Calculate x^y in logarithmic time wrt y.                                                        */
274
/*                                                                                                                                              */
275
{
276
        long retval = 1;
277
        long partial, exponent;
278
 
279
        partial = x;
280
        exponent = y;
281
        while (exponent > 0)
282
        {
283
                while ( ((exponent % 2) == 0) &&
284
                                exponent != 0)
285
                {
286
                        partial = partial * partial;
287
                        exponent = exponent / 2;
288
                }
289
                exponent = exponent - 1;
290
                retval = retval * partial;
291
        }
292
 
293
        return(retval);
294
}
295
 
296
 
297
/************************************************************************/
298
/*                                                                                                                                              */
299
long jam_square_root(long num)
300
{
301
        long sqrt = num;
302
        long a_squared = 0L;
303
        long b_squared = 0L;
304
        long two_ab = 0L;
305
        long square = 0L;
306
        int order = 0;
307
 
308
        if (num < 0L) sqrt = 0L;
309
 
310
        while (sqrt > 0L)
311
        {
312
                sqrt >>= 2L;
313
                ++order;
314
        }
315
 
316
        while (order >= 0)
317
        {
318
                /* (a+b)^2 = a^2 + 2ab + b^2 */
319
                /* a is bit being tested, b is previous result */
320
 
321
                a_squared = 1L << (order << 1);
322
 
323
                two_ab = sqrt << (order + 1);
324
 
325
                /* b_squared starts out at zero */
326
 
327
                square = (a_squared + two_ab + b_squared);
328
 
329
                if (square <= num)
330
                {
331
                        sqrt |= (1 << order);
332
                        b_squared = square;
333
                }
334
 
335
                --order;
336
        }
337
 
338
        return (sqrt);
339
}
340
 
341
/*
342
*       Used by INT() function to convert Boolean array data to integer.  "msb"
343
*       is the index of the most significant bit of the array, and "lsb" is the
344
*       index of the least significant bit.  Typically msb > lsb, otherwise the
345
*       bit order will be reversed when converted into integer format.
346
*/
347
long jam_convert_bool_to_int(long *data, long msb, long lsb)
348
{
349
        long i, increment = (msb > lsb) ? 1 : -1;
350
        long mask = 1L, result = 0L;
351
 
352
        msb += increment;
353
        for (i = lsb; i != msb; i += increment)
354
        {
355
                if (data[i >> 5] & (1L << (i & 0x1f))) result |= mask;
356
                mask <<= 1;
357
        }
358
 
359
        return (result);
360
}
361
 
362
 
363
/************************************************************************/
364
/*                                                                                                                                              */
365
 
366
YYSTYPE jam_exp_eval(OPERATOR_TYPE otype, YYSTYPE op1, YYSTYPE op2)
367
 
368
/*      Evaluate op1 OTYPE op2.  op1, op2 are operands, OTYPE is operator   */
369
/*                                                                                                                                              */
370
/*      Some sneaky things are done to implement CEIL and FLOOR.                        */
371
/*                                                                                                                                              */
372
/*      We do CEIL of LOG2 by default, and FLOOR of a DIVIDE by default.        */
373
/*      Since we are lazy and we don't want to generate a parse tree,           */
374
/*      we use the parser's reduce actions to tell us when to perform           */
375
/*      an evaluation. But when CEIL and FLOOR are reduced, we know             */
376
/*      nothing about the expression tree beneath it (it's been reduced!)   */
377
/*                                                                                                                                              */
378
/*      We keep this information around so we can calculate the CEIL or         */
379
/*  FLOOR. We save value of the operand(s) or a divide in loper and             */
380
/*  roper, then when CEIL/FLOOR get reduced, we just look at their      */
381
/*      values.                                                                                                                         */
382
/*                                                                                                                                              */
383
{
384
        YYSTYPE rtn;
385
        long    tmp_val;
386
        JAMS_SYMBOL_RECORD *symbol_rec;
387
        JAMS_HEAP_RECORD *heap_rec;
388
 
389
        rtn.child_otype = 0;
390
        rtn.type = JAM_ILLEGAL_EXPR_TYPE;
391
        rtn.val = 0;
392
        rtn.loper = 0;
393
        rtn.roper = 0;
394
 
395
        switch (otype)
396
        {
397
                case UMINUS:
398
                        if ((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR))
399
                        {
400
                                rtn.val = -1 * op1.val;
401
                                rtn.type = JAM_INTEGER_EXPR;
402
                        }
403
                        else jam_return_code = JAMC_TYPE_MISMATCH;
404
                        break;
405
 
406
                case ADD:
407
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
408
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
409
                        {
410
                                rtn.val = op1.val + op2.val;
411
                                rtn.type = JAM_INTEGER_EXPR;
412
 
413
                                /* check for overflow */
414
                                if (((op1.val > 0) && (op2.val > 0) && (rtn.val < 0)) ||
415
                                        ((op1.val < 0) && (op2.val < 0) && (rtn.val > 0)))
416
                                {
417
                                        jam_return_code = JAMC_INTEGER_OVERFLOW;
418
                                }
419
                        }
420
                        else jam_return_code = JAMC_TYPE_MISMATCH;
421
                        break;
422
 
423
                case SUB:
424
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
425
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
426
                        {
427
                                rtn.val = op1.val - op2.val;
428
                                rtn.type = JAM_INTEGER_EXPR;
429
 
430
                                /* check for overflow */
431
                                if (((op1.val > 0) && (op2.val < 0) && (rtn.val < 0)) ||
432
                                        ((op1.val < 0) && (op2.val > 0) && (rtn.val > 0)))
433
                                {
434
                                        jam_return_code = JAMC_INTEGER_OVERFLOW;
435
                                }
436
                        }
437
                        else jam_return_code = JAMC_TYPE_MISMATCH;
438
                        break;
439
 
440
                case MULT:
441
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
442
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
443
                        {
444
                                rtn.val = op1.val * op2.val;
445
                                rtn.type = JAM_INTEGER_EXPR;
446
 
447
                                /* check for overflow */
448
                                if ((op1.val != 0) && (op2.val != 0) &&
449
                                        (((rtn.val / op1.val) != op2.val) ||
450
                                        ((rtn.val / op2.val) != op1.val)))
451
                                {
452
                                        jam_return_code = JAMC_INTEGER_OVERFLOW;
453
                                }
454
                        }
455
                        else jam_return_code = JAMC_TYPE_MISMATCH;
456
                        break;
457
 
458
                case DIV:
459
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
460
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
461
                        {
462
                                if (op2.val != 0)
463
                                {
464
                                        rtn.val = op1.val / op2.val;
465
                                        rtn.loper = op1.val;
466
                                        rtn.roper = op2.val;
467
                                        rtn.child_otype = DIV;  /* Save info needed by CEIL */
468
                                        rtn.type = JAM_INTEGER_EXPR;
469
                                }
470
                                else
471
                                {
472
                                        jam_return_code = JAMC_DIVIDE_BY_ZERO;
473
                                }
474
                        }
475
                        else jam_return_code = JAMC_TYPE_MISMATCH;
476
                        break;
477
 
478
                case MOD:
479
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
480
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
481
                        {
482
                                rtn.val = op1.val % op2.val;
483
                                rtn.type = JAM_INTEGER_EXPR;
484
                        }
485
                        else jam_return_code = JAMC_TYPE_MISMATCH;
486
                        break;
487
 
488
                case NOT:
489
                        if ((op1.type == JAM_BOOLEAN_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR))
490
                        {
491
                                rtn.val = (op1.val == 0) ? 1 : 0;
492
                                rtn.type = JAM_BOOLEAN_EXPR;
493
                        }
494
                        else jam_return_code = JAMC_TYPE_MISMATCH;
495
                        break;
496
 
497
                case AND:
498
                        if (((op1.type == JAM_BOOLEAN_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
499
                                ((op2.type == JAM_BOOLEAN_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
500
                        {
501
                                rtn.val = (op1.val && op2.val) ? 1 : 0;
502
                                rtn.type = JAM_BOOLEAN_EXPR;
503
                        }
504
                        else jam_return_code = JAMC_TYPE_MISMATCH;
505
                        break;
506
 
507
                case OR:
508
                        if (((op1.type == JAM_BOOLEAN_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
509
                                ((op2.type == JAM_BOOLEAN_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
510
                        {
511
                                rtn.val = (op1.val || op2.val) ? 1 : 0;
512
                                rtn.type = JAM_BOOLEAN_EXPR;
513
                        }
514
                        else jam_return_code = JAMC_TYPE_MISMATCH;
515
                        break;
516
 
517
                case BITWISE_NOT:
518
                        if ((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR))
519
                        {
520
                                rtn.val = ~ (unsigned long) op1.val;
521
                                rtn.type = JAM_INTEGER_EXPR;
522
                        }
523
                        else jam_return_code = JAMC_TYPE_MISMATCH;
524
                        break;
525
 
526
                case BITWISE_AND:
527
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
528
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
529
                        {
530
                                rtn.val = op1.val & op2.val;
531
                                rtn.type = JAM_INTEGER_EXPR;
532
                        }
533
                        else jam_return_code = JAMC_TYPE_MISMATCH;
534
                        break;
535
 
536
                case BITWISE_OR:
537
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
538
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
539
                        {
540
                                rtn.val = op1.val | op2.val;
541
                                rtn.type = JAM_INTEGER_EXPR;
542
                        }
543
                        else jam_return_code = JAMC_TYPE_MISMATCH;
544
                        break;
545
 
546
                case BITWISE_XOR:
547
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
548
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
549
                        {
550
                                rtn.val = op1.val ^ op2.val;
551
                                rtn.type = JAM_INTEGER_EXPR;
552
                        }
553
                        else jam_return_code = JAMC_TYPE_MISMATCH;
554
                        break;
555
 
556
                case LEFT_SHIFT:
557
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
558
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
559
                        {
560
                                rtn.val = op1.val << op2.val;
561
                                rtn.type = JAM_INTEGER_EXPR;
562
                        }
563
                        else jam_return_code = JAMC_TYPE_MISMATCH;
564
                        break;
565
 
566
                case RIGHT_SHIFT:
567
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
568
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
569
                        {
570
                                rtn.val = op1.val >> op2.val;
571
                                rtn.type = JAM_INTEGER_EXPR;
572
                        }
573
                        else jam_return_code = JAMC_TYPE_MISMATCH;
574
                        break;
575
 
576
                case EQUALITY:
577
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
578
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
579
                        {
580
                                rtn.val = (op1.val == op2.val) ? 1 : 0;
581
                                rtn.type = JAM_BOOLEAN_EXPR;
582
                        }
583
                        else if (((op1.type == JAM_BOOLEAN_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
584
                                ((op2.type == JAM_BOOLEAN_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
585
                        {
586
                                rtn.val = ((op1.val && op2.val) || ((!op1.val) && (!op2.val)))
587
                                                ? 1 : 0;
588
                                rtn.type = JAM_BOOLEAN_EXPR;
589
                        }
590
                        else jam_return_code = JAMC_TYPE_MISMATCH;
591
                        break;
592
 
593
                case INEQUALITY:
594
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
595
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
596
                        {
597
                                rtn.val = (op1.val == op2.val) ? 0 : 1;
598
                                rtn.type = JAM_BOOLEAN_EXPR;
599
                        }
600
                        else if (((op1.type == JAM_BOOLEAN_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
601
                                ((op2.type == JAM_BOOLEAN_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
602
                        {
603
                                rtn.val = ((op1.val && op2.val) || ((!op1.val) && (!op2.val)))
604
                                                ? 0 : 1;
605
                                rtn.type = JAM_BOOLEAN_EXPR;
606
                        }
607
                        else jam_return_code = JAMC_TYPE_MISMATCH;
608
                        break;
609
 
610
                case GREATER_THAN:
611
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
612
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
613
                        {
614
                                rtn.val = (op1.val > op2.val) ? 1 : 0;
615
                                rtn.type = JAM_BOOLEAN_EXPR;
616
                        }
617
                        else jam_return_code = JAMC_TYPE_MISMATCH;
618
                        break;
619
 
620
                case LESS_THAN:
621
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
622
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
623
                        {
624
                                rtn.val = (op1.val < op2.val) ? 1 : 0;
625
                                rtn.type = JAM_BOOLEAN_EXPR;
626
                        }
627
                        else jam_return_code = JAMC_TYPE_MISMATCH;
628
                        break;
629
 
630
                case GREATER_OR_EQUAL:
631
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
632
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
633
                        {
634
                                rtn.val = (op1.val >= op2.val) ? 1 : 0;
635
                                rtn.type = JAM_BOOLEAN_EXPR;
636
                        }
637
                        else jam_return_code = JAMC_TYPE_MISMATCH;
638
                        break;
639
 
640
                case LESS_OR_EQUAL:
641
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
642
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
643
                        {
644
                                rtn.val = (op1.val <= op2.val) ? 1 : 0;
645
                                rtn.type = JAM_BOOLEAN_EXPR;
646
                        }
647
                        else jam_return_code = JAMC_TYPE_MISMATCH;
648
                        break;
649
 
650
                case ABS:
651
                        if ((op1.type == JAM_INTEGER_EXPR) ||
652
                                (op1.type == JAM_INT_OR_BOOL_EXPR))
653
                        {
654
                                rtn.val = (op1.val < 0) ? (0 - op1.val) : op1.val;
655
                                rtn.type = JAM_INTEGER_EXPR;
656
                        }
657
                        else jam_return_code = JAMC_TYPE_MISMATCH;
658
                        break;
659
 
660
                case INT:
661
                        rtn.val = op1.val;
662
                        rtn.type = JAM_INTEGER_EXPR;
663
                        break;
664
 
665
                case LOG2:
666
                        if ((op1.type == JAM_INTEGER_EXPR) ||
667
                                (op1.type == JAM_INT_OR_BOOL_EXPR))
668
                        {
669
                                if (op1.val > 0)
670
                                {
671
                                        rtn.child_otype = LOG2;
672
                                        rtn.type = JAM_INTEGER_EXPR;
673
                                        rtn.loper = op1.val;
674
                                        tmp_val = op1.val;
675
                                        rtn.val = 0;
676
 
677
                                        while (tmp_val != 1)    /* ret_val = log2(left_val) */
678
                                        {
679
                                                tmp_val = tmp_val >> 1;
680
                                                ++rtn.val;
681
                                        }
682
 
683
                                        /* if 2^(return_val) isn't the left_val, then the log */
684
                                        /* wasn't a perfect integer, so we increment it */
685
                                        if (jam_exponentiate(2, rtn.val) != op1.val)
686
                                        {
687
                                                ++rtn.val;   /* Assume ceil of log2 */
688
                                        }
689
                                }
690
                                else
691
                                {
692
                                        jam_return_code = JAMC_INTEGER_OVERFLOW;
693
                                }
694
                        }
695
                        else jam_return_code = JAMC_TYPE_MISMATCH;
696
                        break;
697
 
698
                case SQRT:
699
                        if ((op1.type == JAM_INTEGER_EXPR) ||
700
                                (op1.type == JAM_INT_OR_BOOL_EXPR))
701
                        {
702
                                if (op1.val >= 0)
703
                                {
704
                                        rtn.child_otype = SQRT;
705
                                        rtn.type = JAM_INTEGER_EXPR;
706
                                        rtn.loper = op1.val;
707
                                        rtn.val = jam_square_root(op1.val);
708
                                }
709
                                else
710
                                {
711
                                        jam_return_code = JAMC_INTEGER_OVERFLOW;
712
                                }
713
                        }
714
                        else jam_return_code = JAMC_TYPE_MISMATCH;
715
                        break;
716
 
717
                case CIEL:
718
                        if ((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR))
719
                        {
720
                                if (op1.child_otype == DIV)
721
                                {
722
                                        /* Below is TRUE if wasn't perfect divide */
723
                                        if ((op1.loper * op1.roper) != op1.val)
724
                                        {
725
                                                rtn.val = op1.val + 1; /* add 1 to get CEIL */
726
                                        }
727
                                        else
728
                                        {
729
                                                rtn.val = op1.val;
730
                                        }
731
                                }
732
                                else if (op1.child_otype == SQRT)
733
                                {
734
                                        /* Below is TRUE if wasn't perfect square-root */
735
                                        if ((op1.val * op1.val) < op1.loper)
736
                                        {
737
                                                rtn.val = op1.val + 1; /* add 1 to get CEIL */
738
                                        }
739
                                        else
740
                                        {
741
                                                rtn.val = op1.val;
742
                                        }
743
                                }
744
                                else
745
                                {
746
                                        rtn.val = op1.val;
747
                                }
748
                                rtn.type = JAM_INTEGER_EXPR;
749
                        }
750
                        else jam_return_code = JAMC_TYPE_MISMATCH;
751
                        break;
752
 
753
                case FLOOR:
754
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
755
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
756
                        {
757
                                if (op1.child_otype == LOG2)
758
                                {
759
                                        if (jam_exponentiate(2, op1.val) != op1.loper)
760
                                        {
761
                                                rtn.val = op1.val - 1;
762
                                        }
763
                                        else
764
                                        {
765
                                                rtn.val = op1.val;
766
                                        }
767
                                }
768
                                else
769
                                {
770
                                        rtn.val = op1.val;
771
                                }
772
                                rtn.type = JAM_INTEGER_EXPR;
773
                        }
774
                        else jam_return_code = JAMC_TYPE_MISMATCH;
775
                        break;
776
 
777
                case ARRAY:
778
                        if ((op1.type == JAM_ARRAY_REFERENCE) &&
779
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
780
                        {
781
                                symbol_rec = (JAMS_SYMBOL_RECORD *)op1.val;
782
                                jam_return_code = jam_get_array_value(
783
                                        symbol_rec, op2.val, &rtn.val);
784
 
785
                                if (jam_return_code == JAMC_SUCCESS)
786
                                {
787
                                        switch (symbol_rec->type)
788
                                        {
789
                                        case JAM_INTEGER_ARRAY_WRITABLE:
790
                                        case JAM_INTEGER_ARRAY_INITIALIZED:
791
                                                rtn.type = JAM_INTEGER_EXPR;
792
                                                break;
793
 
794
                                        case JAM_BOOLEAN_ARRAY_WRITABLE:
795
                                        case JAM_BOOLEAN_ARRAY_INITIALIZED:
796
                                                rtn.type = JAM_BOOLEAN_EXPR;
797
                                                break;
798
 
799
                                        default:
800
                                                jam_return_code = JAMC_INTERNAL_ERROR;
801
                                                break;
802
                                        }
803
                                }
804
                        }
805
                        else jam_return_code = JAMC_TYPE_MISMATCH;
806
                        break;
807
 
808
                case POUND:
809
                        rtn.val = op1.val;
810
                        rtn.type = JAM_INTEGER_EXPR;
811
                        break;
812
 
813
                case DOLLAR:
814
                        rtn.val = op1.val;
815
                        rtn.type = JAM_INTEGER_EXPR;
816
                        break;
817
 
818
                case ARRAY_RANGE:
819
                        if (((op1.type == JAM_INTEGER_EXPR) || (op1.type == JAM_INT_OR_BOOL_EXPR)) &&
820
                                ((op2.type == JAM_INTEGER_EXPR) || (op2.type == JAM_INT_OR_BOOL_EXPR)))
821
                        {
822
                                symbol_rec = jam_array_symbol_rec;
823
 
824
                                if ((symbol_rec != NULL) &&
825
                                        ((symbol_rec->type == JAM_BOOLEAN_ARRAY_WRITABLE) ||
826
                                        (symbol_rec->type == JAM_BOOLEAN_ARRAY_INITIALIZED)))
827
                                {
828
                                        heap_rec = (JAMS_HEAP_RECORD *) symbol_rec->value;
829
 
830
                                        if (heap_rec != NULL)
831
                                        {
832
                                                rtn.val = jam_convert_bool_to_int(heap_rec->data,
833
                                                        op1.val, op2.val);
834
                                        }
835
                                        rtn.type = JAM_INTEGER_EXPR;
836
                                }
837
                                else jam_return_code = JAMC_TYPE_MISMATCH;
838
                        }
839
                        else jam_return_code = JAMC_TYPE_MISMATCH;
840
                        break;
841
 
842
                case ARRAY_ALL:
843
                        if (op1.type == JAM_ARRAY_REFERENCE)
844
                        {
845
                                symbol_rec = (JAMS_SYMBOL_RECORD *)op1.val;
846
 
847
                                if ((symbol_rec != NULL) &&
848
                                        ((symbol_rec->type == JAM_BOOLEAN_ARRAY_WRITABLE) ||
849
                                        (symbol_rec->type == JAM_BOOLEAN_ARRAY_INITIALIZED)))
850
                                {
851
                                        heap_rec = (JAMS_HEAP_RECORD *) symbol_rec->value;
852
 
853
                                        if (heap_rec != NULL)
854
                                        {
855
                                                rtn.val = jam_convert_bool_to_int(heap_rec->data,
856
                                                        heap_rec->dimension - 1, 0);
857
                                        }
858
                                        rtn.type = JAM_INTEGER_EXPR;
859
                                }
860
                                else jam_return_code = JAMC_TYPE_MISMATCH;
861
                        }
862
                        else jam_return_code = JAMC_TYPE_MISMATCH;
863
                        break;
864
 
865
                default:
866
                        jam_return_code = JAMC_INTERNAL_ERROR;
867
                        break;
868
        }
869
 
870
        return rtn;
871
}
872
 
873
 
874
/****************************************************************************/
875
/*                                                                                                                                                      */
876
 
877
void jam_exp_lexer (void)
878
 
879
/*                                                                                                                                                      */
880
/*      Description:    Lexical analyzer for expressions.                               */
881
/*                                                                                                                                                      */
882
/*                                      Results are returned in the global variables jam_token. */
883
/*                                      and jam_token_buffer.                                   */
884
/*                                                                                                                      */
885
/*      References:             Compilers: Principles, Techniques and Tools by ASU      */
886
/*                                      (the Green Dragon book), section 3.4, Recognition of    */
887
/*                                      tokens.                                                 */
888
/*                                                                                                                                                      */
889
/*      Returns:                Nothing                                                                                                 */
890
/*                                                                                                                                                      */
891
/****************************************************************************/
892
{
893
        BEGIN_MACHINE;
894
 
895
        start:
896
                GET_FIRST_CH;
897
                if (CH == '\0') ACCEPT(END_OF_STRING)                   /* Fake an EOF! */
898
                else if (CH == ' ' || jam_iscntrl(CH)) goto start;  /* white space */
899
                else if (jam_isalpha(CH)) goto identifier;
900
                else if (jam_isdigit(CH)) goto number;
901
                else if (CH == '&')
902
                {
903
                        GET_NEXT_CH;
904
                        if (CH == '&') ACCEPT(AND_TOK)
905
                        else
906
                        {
907
                                UNGET_CH;
908
                                ACCEPT('&')
909
                        }
910
                }
911
                else if (CH == '|')
912
                {
913
                        GET_NEXT_CH;
914
                        if (CH == '|') ACCEPT(OR_TOK)
915
                        else
916
                        {
917
                                UNGET_CH;
918
                                ACCEPT('|')
919
                        }
920
                }
921
                else if (CH == '=')
922
                {
923
                        GET_NEXT_CH;
924
                        if (CH == '=') ACCEPT(EQUALITY_TOK)
925
                        else
926
                        {
927
                                UNGET_CH;
928
                                ACCEPT('=')
929
                        }
930
                }
931
                else if (CH == '!')
932
                {
933
                        GET_NEXT_CH;
934
                        if (CH == '=') ACCEPT(INEQUALITY_TOK)
935
                        else
936
                        {
937
                                UNGET_CH;
938
                                ACCEPT('!')
939
                        }
940
                }
941
                else if (CH == '>')
942
                {
943
                        GET_NEXT_CH;
944
                        if (CH == '=') ACCEPT(GREATER_EQ_TOK)
945
                        else if (CH == '>') ACCEPT(RIGHT_SHIFT_TOK)
946
                        else
947
                        {
948
                                UNGET_CH;
949
                                ACCEPT(GREATER_TOK)
950
                        }
951
                }
952
                else if (CH == '<')
953
                {
954
                        GET_NEXT_CH;
955
                        if (CH == '=') ACCEPT(LESS_OR_EQ_TOK)
956
                        else if (CH == '<') ACCEPT(LEFT_SHIFT_TOK)
957
                        else
958
                        {
959
                                UNGET_CH;
960
                                ACCEPT(LESS_TOK)
961
                        }
962
                }
963
                else if (CH == '.')
964
                {
965
                        GET_NEXT_CH;
966
                        if (CH == '.') ACCEPT(DOT_DOT_TOK)
967
                        else
968
                        {
969
                                UNGET_CH;
970
                                ACCEPT('.')
971
                        }
972
                }
973
                else ACCEPT(CH)  /* single-chararcter token */
974
 
975
        number:
976
                GET_NEXT_CH;
977
                if (jam_isdigit(CH)) goto number;
978
                else if (jam_isalpha(CH) || CH == '_') goto identifier;
979
                else
980
                {
981
                        UNGET_CH;
982
                        ACCEPT(VALUE_TOK)
983
                }
984
 
985
        identifier:
986
                GET_NEXT_CH;
987
                if (jam_isalnum(CH) || CH == '_') goto identifier;
988
                else
989
                {
990
                        UNGET_CH;
991
                        ACCEPT(IDENTIFIER_TOK)
992
                }
993
 
994
        END_MACHINE;
995
}
996
 
997
 
998
/************************************************************************/
999
/*                                                                                                                                              */
1000
 
1001
BOOL jam_constant_is_ok(char *string)
1002
 
1003
/*      This routine returns TRUE if the value represented by string is         */
1004
/*      a valid signed decimal number.                                                                          */
1005
/*                                                                                                                                              */
1006
{
1007
        BOOL ok = TRUE;
1008
 
1009
        /* check for negative number */
1010
        if ((string[0] == '-') && (jam_isdigit(string[1])))
1011
        {
1012
                ++string;       /* skip over negative sign */
1013
        }
1014
 
1015
        while (ok && (*string != '\0'))
1016
        {
1017
                if (!jam_isdigit(*string)) ok = FALSE;
1018
                ++string;
1019
        }
1020
 
1021
        return (ok);
1022
}
1023
 
1024
 
1025
/************************************************************************/
1026
/*                                                                                                                                              */
1027
 
1028
BOOL jam_binary_constant_is_ok(char *string)
1029
 
1030
/*      This routine returns TRUE if the value represented by string is         */
1031
/*      a valid binary number (containing only '0' and '1' characters).         */
1032
/*                                                                                                                                              */
1033
{
1034
        BOOL ok = TRUE;
1035
 
1036
        while (ok && (*string != '\0'))
1037
        {
1038
                if ((*string != '0') && (*string != '1')) ok = FALSE;
1039
                ++string;
1040
        }
1041
 
1042
        return (ok);
1043
}
1044
 
1045
 
1046
/************************************************************************/
1047
/*                                                                                                                                              */
1048
 
1049
BOOL jam_hex_constant_is_ok(char *string)
1050
 
1051
/*      This routine returns TRUE if the value represented by string is         */
1052
/*      a valid hexadecimal number.                                                                                     */
1053
/*                                                                                                                                              */
1054
{
1055
        BOOL ok = TRUE;
1056
 
1057
        while (ok && (*string != '\0'))
1058
        {
1059
                if (((*string < '0') || (*string > '9')) &&
1060
                        ((*string < 'A') || (*string > 'F')) &&
1061
                        ((*string < 'a') || (*string > 'f')))
1062
                {
1063
                        ok = FALSE;
1064
                }
1065
                ++string;
1066
        }
1067
 
1068
        return (ok);
1069
}
1070
 
1071
long jam_atol_bin(char *string)
1072
{
1073
        long result = 0L;
1074
        int index = 0;
1075
 
1076
        while ((string[index] == '0') || (string[index] == '1'))
1077
        {
1078
                result = (result << 1) + (string[index] - '0');
1079
                ++index;
1080
        }
1081
 
1082
        return (result);
1083
}
1084
 
1085
long jam_atol_hex(char *string)
1086
{
1087
        long result = 0L;
1088
        int index = 0;
1089
 
1090
        while (((string[index] >= '0') && (string[index] <= '9')) ||
1091
                ((string[index] >= 'A') && (string[index] <= 'F')) ||
1092
                ((string[index] >= 'a') && (string[index] <= 'f')))
1093
        {
1094
                if ((string[index] >= '0') && (string[index] <= '9'))
1095
                {
1096
                        result = (result << 4) + (string[index] - '0');
1097
                }
1098
                else if ((string[index] >= 'A') && (string[index] <= 'F'))
1099
                {
1100
                        result = (result << 4) + 10 + (string[index] - 'A');
1101
                }
1102
                else if ((string[index] >= 'a') && (string[index] <= 'f'))
1103
                {
1104
                        result = (result << 4) + 10 + (string[index] - 'a');
1105
                }
1106
                ++index;
1107
        }
1108
 
1109
        return (result);
1110
}
1111
 
1112
 
1113
/************************************************************************/
1114
/*                                                                                                                                              */
1115
 
1116
BOOL jam_constant_value(char *string, long *value)
1117
 
1118
/*                                                                      */
1119
/*              This routine converts a string constant into its binary                 */
1120
/*              value.                                                                                                                  */
1121
/*                                                                                                                                              */
1122
/*      Returns TRUE for success, FALSE if the string could not be              */
1123
/*      converted.                                                                                                              */
1124
/*                                                                      */
1125
{
1126
        BOOL status = FALSE;
1127
 
1128
        if (jam_expression_type == '#')
1129
        {
1130
                if (jam_binary_constant_is_ok(string))
1131
                {
1132
                        *value = jam_atol_bin(string);
1133
                        jam_expression_type = 0;
1134
                        status = TRUE;
1135
                }
1136
        }
1137
        else if (jam_expression_type == '$')
1138
        {
1139
                if (jam_hex_constant_is_ok(string))
1140
                {
1141
                        *value = jam_atol_hex(string);
1142
                        jam_expression_type = 0;
1143
                        status = TRUE;
1144
                }
1145
        }
1146
        else if (jam_constant_is_ok(string))
1147
        {
1148
                if (string[0] == '-')
1149
                {
1150
                        *value = 0 - jam_atol(&string[1]);
1151
                }
1152
                else
1153
                {
1154
                        *value = jam_atol(string);
1155
                }
1156
                status = TRUE;
1157
        }
1158
 
1159
        return (status);
1160
}
1161
 
1162
 
1163
/************************************************************************/
1164
/*                                                                                                                                              */
1165
 
1166
void jam_yyerror (char *msg)
1167
 
1168
/*                                                                                                                                              */
1169
/*      WARNING: When compiling for YACC 5.0 using err_skel.c,                  */
1170
/*                       this function needs to be modified to be:                              */
1171
/*                                                                                                                                              */
1172
/*                       jam_yyerror(char *ms1, char *msg2)                                                     */
1173
/*                                                                                                                                              */
1174
/*      jam_yyerror() handles syntax error messages from the parser.                    */
1175
/*      Since we don't care about anything else but reporting the error,        */
1176
/*      just flag the error in jam_return_code.                                                         */
1177
/*                                                                                                                                              */
1178
{
1179
        msg = msg; /* Avoid compiler warning about msg unused */
1180
 
1181
        if (jam_return_code == JAMC_SUCCESS) jam_return_code = JAMC_SYNTAX_ERROR;
1182
}
1183
 
1184
 
1185
/************************************************************************/
1186
/*                                                                                                                                              */
1187
 
1188
int jam_yylex()
1189
 
1190
/*                                                                                                                                              */
1191
/*      This is the lexer function called by jam_yyparse(). It calls                    */
1192
/*      jam_exp_lexer() to run as the DFA to return a token in jam_token        */
1193
/*                                                                                                                                              */
1194
{
1195
        JAMS_SYMBOL_RECORD *symbol_rec = NULL;
1196
        long val = 0L;
1197
        JAME_EXPRESSION_TYPE type = JAM_ILLEGAL_EXPR_TYPE;
1198
        int token_length;
1199
        int i;
1200
 
1201
        jam_exp_lexer();
1202
 
1203
        token_length = jam_strlen(jam_token_buffer);
1204
 
1205
        if (token_length > 1)
1206
        {
1207
                for (i = 0; i < NUM_KEYWORDS; i++)
1208
                {
1209
                        if (token_length == jam_keyword_table[i].length)
1210
                        {
1211
                                if (!jam_strcmp(jam_token_buffer, jam_keyword_table[i].string))
1212
                                {
1213
                                        jam_token = jam_keyword_table[i].token;
1214
                                }
1215
                        }
1216
                }
1217
        }
1218
 
1219
        if (jam_token == VALUE_TOK)
1220
        {
1221
                if (jam_constant_value(jam_token_buffer, &val))
1222
                {
1223
                        /* literal 0 and 1 may be interpreted as Integer or Boolean */
1224
                        if ((val == 0) || (val == 1))
1225
                        {
1226
                                type = JAM_INT_OR_BOOL_EXPR;
1227
                        }
1228
                        else
1229
                        {
1230
                                type = JAM_INTEGER_EXPR;
1231
                        }
1232
                }
1233
                else
1234
                {
1235
                        jam_return_code = JAMC_SYNTAX_ERROR;
1236
                }
1237
        }
1238
        else if (jam_token == IDENTIFIER_TOK)
1239
        {
1240
                jam_return_code = jam_get_symbol_record(jam_token_buffer, &symbol_rec);
1241
 
1242
                if (jam_return_code == JAMC_SUCCESS)
1243
                {
1244
                        switch (symbol_rec->type)
1245
                        {
1246
                        case JAM_INTEGER_SYMBOL:
1247
                                /* Success, swap token to be a VALUE */
1248
                                jam_token = VALUE_TOK;
1249
                                val = symbol_rec->value;
1250
                                type = JAM_INTEGER_EXPR;
1251
                                break;
1252
 
1253
                        case JAM_BOOLEAN_SYMBOL:
1254
                                /* Success, swap token to be a VALUE */
1255
                                jam_token = VALUE_TOK;
1256
                                val = symbol_rec->value ? 1 : 0;
1257
                                type = JAM_BOOLEAN_EXPR;
1258
                                break;
1259
 
1260
                        case JAM_INTEGER_ARRAY_WRITABLE:
1261
                        case JAM_BOOLEAN_ARRAY_WRITABLE:
1262
                        case JAM_INTEGER_ARRAY_INITIALIZED:
1263
                        case JAM_BOOLEAN_ARRAY_INITIALIZED:
1264
                                /* Success, swap token to be an ARRAY_TOK, */
1265
                                /* save pointer to symbol record in value field */
1266
                                jam_token = ARRAY_TOK;
1267
                                val = (long) symbol_rec;
1268
                                type = JAM_ARRAY_REFERENCE;
1269
                                jam_array_symbol_rec = symbol_rec;
1270
                                break;
1271
 
1272
                        default:
1273
                                jam_return_code = JAMC_SYNTAX_ERROR;
1274
                                break;
1275
                        }
1276
                }
1277
        }
1278
        else if (jam_token == '#')
1279
        {
1280
                jam_expression_type = '#';
1281
        }
1282
        else if (jam_token == '$')
1283
        {
1284
                jam_expression_type = '$';
1285
        }
1286
 
1287
        jam_yylval.val = val;
1288
        jam_yylval.type = type;
1289
        jam_yylval.child_otype = 0;
1290
        jam_yylval.loper = 0;
1291
        jam_yylval.roper = 0;
1292
 
1293
        return jam_token;
1294
}
1295
 
1296
 
1297
/************************************************************************/
1298
/*                                                                                                                                              */
1299
 
1300
JAM_RETURN_TYPE jam_evaluate_expression
1301
(
1302
        char *expression,
1303
        long *result,
1304
        JAME_EXPRESSION_TYPE *result_type
1305
)
1306
 
1307
/*                                                                                                                                              */
1308
/*      THIS IS THE ENTRY POINT INTO THE EXPRESSION EVALUATOR.                          */
1309
/*                                                                                                                                              */
1310
/*      s = a string representing the expression to be evaluated.               */
1311
/*              (e.g. "2+2+PARAMETER")                                                                                  */
1312
/*                                                                                                                                              */
1313
/*      status = for returning TRUE if evaluation was successful.               */
1314
/*                       FALSE if not.                                                                                          */
1315
/*                                                                                                                                              */
1316
/*      This routine sets up the global variables and then calls jam_yyparse()  */
1317
/*      to do the parsing. The reduce actions of the parser evaluate the        */
1318
/*      expression.                                                                                                             */
1319
/*                                                                                                                                              */
1320
/*      RETURNS: Value of the expression if success. 0 if FAIL.                         */
1321
/*                                                                                                                                              */
1322
/*      Note: One should not rely on the return val to det.  success/fail   */
1323
/*                since it is possible for, say, "2-2" to be success and                */
1324
/*                return 0.                                                                                                     */
1325
/*                                                                                                                                              */
1326
{
1327
        jam_strcpy(jam_parse_string, expression);
1328
        jam_strptr = 0;
1329
        jam_token_buffer_index = 0;
1330
        jam_return_code = JAMC_SUCCESS;
1331
 
1332
        jam_yyparse();
1333
 
1334
        if (jam_return_code == JAMC_SUCCESS)
1335
        {
1336
                if (result != 0) *result = jam_parse_value;
1337
                if (result_type != 0) *result_type = jam_expr_type;
1338
        }
1339
 
1340
        return (jam_return_code);
1341
}
1342
const int jam_yyexca[] = {
1343
  -1, 1,
1344
  0, -1,
1345
  -2, 0,
1346
  0,
1347
};
1348
 
1349
#define YYNPROD 37
1350
#define YYLAST 626
1351
 
1352
const int jam_yyact[] = {
1353
       7,      67,      68,      79,      45,      76,      66,       4,
1354
      20,       7,       5,       1,       6,      18,      44,      43,
1355
       4,      20,      19,       5,       0,       6,      18,      16,
1356
      42,      17,      41,      19,      40,      39,       0,       0,
1357
       0,      20,      21,       0,       0,       0,      18,      16,
1358
       0,      17,       0,      19,      20,      21,       0,       0,
1359
       0,      18,      16,       0,      17,       0,      19,       0,
1360
      20,      21,       0,       0,      86,      18,      16,       0,
1361
      17,       0,      19,      20,      21,       0,       0,      83,
1362
      18,      16,       0,      17,       0,      19,      20,      21,
1363
       0,       0,      82,      18,      16,       0,      17,       0,
1364
      19,       0,      23,       0,       0,       8,       0,       0,
1365
       0,       0,      20,       0,      89,      23,       8,      18,
1366
      16,       0,      17,       0,      19,       0,       0,       0,
1367
      84,      23,       0,       0,       0,      20,      21,       0,
1368
      22,      81,      18,      16,      23,      17,       0,      19,
1369
      20,      21,       0,      22,      80,      18,      16,      23,
1370
      17,       0,      19,       0,      20,      21,       0,      22,
1371
      75,      18,      16,       0,      17,       0,      19,       0,
1372
       0,       0,      22,       0,       0,       0,       0,       0,
1373
       0,       0,       0,       0,       0,      22,       0,       0,
1374
       0,       0,       0,       0,       0,       0,      23,       0,
1375
       0,       0,       0,       0,       0,       0,       0,       0,
1376
       0,      23,       0,       0,       0,       0,      20,      21,
1377
       0,       0,       0,      18,      16,      23,      17,       0,
1378
      19,       0,       0,       0,      22,       0,       0,       0,
1379
      20,       0,       0,       0,       0,      18,      16,      22,
1380
      17,       0,      19,       0,      20,       0,       0,       0,
1381
       0,      18,      16,      22,      17,       0,      19,       0,
1382
       0,       0,       0,       9,      10,      11,      12,      13,
1383
      14,       3,      69,      15,       9,      10,      11,      12,
1384
      13,      14,       3,       0,      15,      24,      25,      28,
1385
      29,      30,      31,      32,      33,      26,      27,      87,
1386
      24,      25,      28,      29,      30,      31,      32,      33,
1387
      26,      27,       0,       0,      24,      25,      28,      29,
1388
      30,      31,      32,      33,      26,      27,       0,      24,
1389
      25,      28,      29,      30,      31,      32,      33,      26,
1390
      27,       0,      24,      25,      28,      29,      30,      31,
1391
      32,      33,      26,      27,       0,       0,       0,       0,
1392
       0,      20,      21,       0,       0,      64,      18,      16,
1393
       0,      17,       0,      19,      20,      21,      26,      27,
1394
       0,      18,      16,       0,      17,       0,      19,       0,
1395
       0,      24,      25,      28,      29,      30,      31,      32,
1396
      33,      26,      27,       0,      24,      25,      28,      29,
1397
      30,      31,      32,      33,      26,      27,       0,       0,
1398
      24,      25,      28,      29,      30,      31,      32,      33,
1399
      26,      27,      23,       0,      20,      21,       0,       0,
1400
       0,      18,      16,       0,      17,      23,      19,      20,
1401
      21,       0,       0,       0,      18,      16,       0,      17,
1402
       0,      19,       0,       0,      20,      21,       0,       0,
1403
      22,      18,      16,       0,      17,       0,      19,       0,
1404
       0,       0,       0,      22,      28,      29,      30,      31,
1405
      32,      33,      26,      27,       0,       0,       0,       0,
1406
       0,       0,       0,       0,       0,      23,      28,      29,
1407
      30,      31,      32,      33,      26,      27,       0,       0,
1408
      23,       0,       0,       0,      30,      31,      32,      33,
1409
      26,      27,       0,       0,       0,      23,       0,       0,
1410
       0,       0,       0,      22,       0,       0,       0,       0,
1411
       0,       0,       0,       0,       0,       0,      22,       0,
1412
       0,       0,       0,       0,       0,       0,       0,       0,
1413
       0,       0,       0,       0,       0,       0,       2,       0,
1414
       0,       0,       0,      34,      35,      36,      37,      38,
1415
       0,       0,       0,       0,       0,       0,       0,      46,
1416
      47,      48,      49,      50,      51,      52,      53,      54,
1417
      55,      56,      57,      58,      59,      60,      61,      62,
1418
      63,       0,       0,       0,       0,       0,      65,       0,
1419
      70,      71,      72,      73,      74,      24,      25,      28,
1420
      29,      30,      31,      32,      33,      26,      27,       0,
1421
      24,      25,      28,      29,      30,      31,      32,      33,
1422
      26,      27,      77,      78,       0,       0,       0,       0,
1423
       0,       0,       0,       0,       0,       0,      85,       0,
1424
       0,       0,       0,       0,       0,       0,      88,       0,
1425
       0,       0,       0,       0,       0,       0,       0,       0,
1426
       0,       0,       0,       0,       0,       0,       0,       0,
1427
      24,       0,      28,      29,      30,      31,      32,      33,
1428
      26,      27,       0,       0,       0,      28,      29,      30,
1429
      31,      32,      33,      26,      27,       0,       0,       0,
1430
       0,       0,      28,      29,      30,      31,      32,      33,
1431
      26,      27,
1432
};
1433
 
1434
const int jam_yypact[] = {
1435
     -24,   -1000,     287,   -1000,     -24,     -24,     -24,     -24,
1436
     -24,     -11,     -12,     -14,     -16,     -25,     -26,     -87,
1437
     -24,     -24,     -24,     -24,     -24,     -24,     -24,     -24,
1438
     -24,     -24,     -24,     -24,     -24,     -24,     -24,     -24,
1439
     -24,     -24,     276,   -1000,   -1000,   -1000,   -1000,     -24,
1440
     -34,     -24,     -24,     -24,     -24,     -24,     -29,     -29,
1441
   -1000,   -1000,   -1000,     171,     359,     153,     346,     335,
1442
     -20,     -20,     183,     183,      61,      61,      61,      61,
1443
   -1000,     103,     -36,     -24,     -24,     -88,      91,      80,
1444
      41,      30,      19,   -1000,   -1000,     287,     287,     -33,
1445
   -1000,   -1000,   -1000,   -1000,   -1000,      -4,   -1000,     -24,
1446
       7,   -1000,
1447
};
1448
 
1449
const int jam_yypgo[] = {
1450
       0,      11,     486,       6,
1451
};
1452
 
1453
const int jam_yyr1[] = {
1454
       0,       1,       3,       3,       3,       3,       2,       2,
1455
       2,       2,       2,       2,       2,       2,       2,       2,
1456
       2,       2,       2,       2,       2,       2,       2,       2,
1457
       2,       2,       2,       2,       2,       2,       2,       2,
1458
       2,       2,       2,       2,       2,
1459
};
1460
 
1461
const int jam_yyr2[] = {
1462
       0,       1,       2,       2,       6,       3,       1,       3,
1463
       2,       2,       2,       2,       3,       3,       3,       3,
1464
       3,       3,       3,       3,       3,       3,       3,       3,
1465
       3,       3,       3,       3,       3,       3,       4,       4,
1466
       4,       4,       4,       4,       4,
1467
};
1468
 
1469
const int jam_yychk[] = {
1470
   -1000,      -1,      -2,     274,      40,      43,      45,      33,
1471
     126,     268,     269,     270,     271,     272,     273,     276,
1472
      43,      45,      42,      47,      37,      38,     124,      94,
1473
     257,     258,     265,     266,     259,     260,     261,     262,
1474
     263,     264,      -2,      -2,      -2,      -2,      -2,      40,
1475
      40,      40,      40,      40,      40,      91,      -2,      -2,
1476
      -2,      -2,      -2,      -2,      -2,      -2,      -2,      -2,
1477
      -2,      -2,      -2,      -2,      -2,      -2,      -2,      -2,
1478
      41,      -2,      -3,      35,      36,     276,      -2,      -2,
1479
      -2,      -2,      -2,      41,      41,      -2,      -2,      91,
1480
      41,      41,      41,      41,      93,      -2,      93,     267,
1481
      -2,      93,
1482
};
1483
 
1484
const int jam_yydef[] = {
1485
       0,      -2,       1,       6,       0,       0,       0,       0,
1486
       0,       0,       0,       0,       0,       0,       0,       0,
1487
       0,       0,       0,       0,       0,       0,       0,       0,
1488
       0,       0,       0,       0,       0,       0,       0,       0,
1489
       0,       0,       0,       8,       9,      10,      11,       0,
1490
       0,       0,       0,       0,       0,       0,      12,      13,
1491
      14,      15,      16,      17,      18,      19,      20,      21,
1492
      22,      23,      24,      25,      26,      27,      28,      29,
1493
       7,       0,       0,       0,       0,       0,       0,       0,
1494
       0,       0,       0,      30,      31,       2,       3,       0,
1495
      32,      33,      34,      35,      36,       0,       5,       0,
1496
       0,       4,
1497
};
1498
 
1499
/****************************************************************************/
1500
/*                                                                                                                                                      */
1501
/*      Module:                 jamycskl.c                                                                                              */
1502
/*                                                                                                                                                      */
1503
/*                                      Copyright (C) Altera Corporation 1997                                   */
1504
/*                                                                                                                                                      */
1505
/*      Description:    LALR parser driver skeleton file -- used by YACC                */
1506
/*                                                                                                                                                      */
1507
/****************************************************************************/
1508
 
1509
 
1510
#ifndef INITIALIZE
1511
#define INITIALIZE
1512
#endif
1513
 
1514
#ifndef YYMAXDEPTH
1515
#define YYMAXDEPTH 200 /* default stack depth */
1516
#endif
1517
 
1518
#ifndef jam_yyerrok
1519
#define jam_yyerrok ((int) 0)
1520
#endif
1521
 
1522
#define YYFLAG -1000
1523
#define YYERROR goto jam_yyerrlab
1524
#define YYACCEPT return(0)
1525
#define YYABORT return(1)
1526
 
1527
YYSTYPE jam_yyv[YYMAXDEPTH];
1528
int token = -1; /* input token */
1529
int errct = 0;  /* error count */
1530
int errfl = 0;  /* error flag */
1531
 
1532
int jam_yyparse()
1533
{ int jam_yys[YYMAXDEPTH];
1534
  int jam_yyj, jam_yym;
1535
  YYSTYPE *jam_yypvt;
1536
  int jam_yystate, *jam_yyps, jam_yyn;
1537
 
1538
  const int *jam_yyxi;
1539
 
1540
  YYSTYPE *jam_yypv;
1541
 
1542
  jam_yystate = 0;
1543
  token = -1;
1544
  errct = 0;
1545
  errfl = 0;
1546
  jam_yyps= &jam_yys[-1];
1547
  jam_yypv= &jam_yyv[-1];
1548
 
1549
 
1550
 jam_yystack:    /* put a state and value onto the stack */
1551
 
1552
  if( ++jam_yyps> &jam_yys[YYMAXDEPTH] ) { jam_yyerror( "yacc stack overflow" ); return(1); }
1553
    *jam_yyps = jam_yystate;
1554
    ++jam_yypv;
1555
    *jam_yypv = jam_yyval;
1556
 
1557
  jam_yynewstate:
1558
 
1559
    jam_yyn = jam_yypact[jam_yystate];
1560
 
1561
    if( jam_yyn<= YYFLAG ) goto jam_yydefault; /* simple state */
1562
 
1563
    if( token<0 ) if( (token=jam_yylex())<0 ) token=0;
1564
    if( (jam_yyn += token)<0 || jam_yyn >= YYLAST ) goto jam_yydefault;
1565
 
1566
    if( jam_yychk[ jam_yyn=jam_yyact[ jam_yyn ] ] == token ){ /* valid shift */
1567
      token = -1;
1568
      jam_yyval = jam_yylval;
1569
      jam_yystate = jam_yyn;
1570
      if( errfl > 0 ) --errfl;
1571
      goto jam_yystack;
1572
    }
1573
 
1574
 jam_yydefault:
1575
 
1576
    if( (jam_yyn=jam_yydef[jam_yystate]) == -2 ) {
1577
      if( token<0 ) if( (token=jam_yylex())<0 ) token = 0;
1578
      /* look through exception table */
1579
 
1580
      for( jam_yyxi=jam_yyexca; (*jam_yyxi!= (-1)) || (jam_yyxi[1]!=jam_yystate) ; jam_yyxi += 2 ) ; /* VOID */
1581
 
1582
      while( *(jam_yyxi+=2) >= 0 ){
1583
        if( *jam_yyxi == token ) break;
1584
      }
1585
      if( (jam_yyn = jam_yyxi[1]) < 0 ) return(0);   /* accept */
1586
    }
1587
 
1588
    if( jam_yyn == 0 ){ /* error */
1589
 
1590
      switch( errfl ){
1591
        case 0:   /* brand new error */
1592
          jam_yyerror( "syntax error" );
1593
          /* jam_yyerrlab: */
1594
          ++errct;
1595
 
1596
        case 1:
1597
          case 2: /* incompletely recovered error ... try again */
1598
            errfl = 3;
1599
 
1600
            /* find a state where "error" is a legal shift action */
1601
 
1602
            while ( jam_yyps >= jam_yys ) {
1603
              jam_yyn = jam_yypact[*jam_yyps] + YYERRCODE;
1604
              if( jam_yyn>= 0 && jam_yyn < YYLAST && jam_yychk[jam_yyact[jam_yyn]] == YYERRCODE ){
1605
                jam_yystate = jam_yyact[jam_yyn];  /* simulate a shift of "error" */
1606
                goto jam_yystack;
1607
              }
1608
              jam_yyn = jam_yypact[*jam_yyps];
1609
              /* the current jam_yyps has no shift onn "error", pop stack */
1610
              --jam_yyps;
1611
              --jam_yypv;
1612
            }
1613
 
1614
            /* there is no state on the stack with an error shift ... abort */
1615
 
1616
        jam_yyabort:
1617
            return(1);
1618
            case 3:  /* no shift yet; clobber input char */
1619
 
1620
            if( token == 0 ) goto jam_yyabort; /* don't discard EOF, quit */
1621
              token = -1;
1622
              goto jam_yynewstate;   /* try again in the same state */
1623
            }
1624
 
1625
          }
1626
 
1627
          /* reduction by production jam_yyn */
1628
 
1629
          jam_yyps -= jam_yyr2[jam_yyn];
1630
          jam_yypvt = jam_yypv;
1631
          jam_yypv -= jam_yyr2[jam_yyn];
1632
          jam_yyval = jam_yypv[1];
1633
          jam_yym=jam_yyn;
1634
          /* consult goto table to find next state */
1635
          jam_yyn = jam_yyr1[jam_yyn];
1636
          jam_yyj = jam_yypgo[jam_yyn] + *jam_yyps + 1;
1637
          if( jam_yyj>=YYLAST || jam_yychk[ jam_yystate = jam_yyact[jam_yyj] ] != -jam_yyn ) jam_yystate = jam_yyact[jam_yypgo[jam_yyn]];
1638
            switch(jam_yym){
1639
 
1640
case 1:
1641
/* # line 288 "jamexp.y" */
1642
{jam_parse_value = jam_yypvt[-0].val; jam_expr_type = jam_yypvt[-0].type;} break;
1643
case 2:
1644
/* # line 292 "jamexp.y" */
1645
{jam_yyval = CALC(POUND, jam_yypvt[-0], NULL_EXP);} break;
1646
case 3:
1647
/* # line 293 "jamexp.y" */
1648
{jam_yyval = CALC(DOLLAR, jam_yypvt[-0], NULL_EXP);} break;
1649
case 4:
1650
/* # line 295 "jamexp.y" */
1651
{jam_yyval = CALC(ARRAY_RANGE, jam_yypvt[-3], jam_yypvt[-1]);} break;
1652
case 5:
1653
/* # line 296 "jamexp.y" */
1654
{jam_yyval = CALC(ARRAY_ALL, jam_yypvt[-2], NULL_EXP);} break;
1655
case 7:
1656
/* # line 301 "jamexp.y" */
1657
{jam_yyval = jam_yypvt[-1];} break;
1658
case 8:
1659
/* # line 302 "jamexp.y" */
1660
{jam_yyval = jam_yypvt[-0];} break;
1661
case 9:
1662
/* # line 303 "jamexp.y" */
1663
{jam_yyval = CALC(UMINUS, jam_yypvt[-0], NULL_EXP);} break;
1664
case 10:
1665
/* # line 304 "jamexp.y" */
1666
{jam_yyval = CALC(NOT, jam_yypvt[-0], NULL_EXP);} break;
1667
case 11:
1668
/* # line 305 "jamexp.y" */
1669
{jam_yyval = CALC(BITWISE_NOT, jam_yypvt[-0], NULL_EXP);} break;
1670
case 12:
1671
/* # line 306 "jamexp.y" */
1672
{jam_yyval = CALC(ADD, jam_yypvt[-2], jam_yypvt[-0]);} break;
1673
case 13:
1674
/* # line 307 "jamexp.y" */
1675
{jam_yyval = CALC(SUB, jam_yypvt[-2], jam_yypvt[-0]);} break;
1676
case 14:
1677
/* # line 308 "jamexp.y" */
1678
{jam_yyval = CALC(MULT, jam_yypvt[-2], jam_yypvt[-0]);} break;
1679
case 15:
1680
/* # line 309 "jamexp.y" */
1681
{jam_yyval = CALC(DIV, jam_yypvt[-2], jam_yypvt[-0]);} break;
1682
case 16:
1683
/* # line 310 "jamexp.y" */
1684
{jam_yyval = CALC(MOD, jam_yypvt[-2], jam_yypvt[-0]);} break;
1685
case 17:
1686
/* # line 311 "jamexp.y" */
1687
{jam_yyval = CALC(BITWISE_AND, jam_yypvt[-2], jam_yypvt[-0]);} break;
1688
case 18:
1689
/* # line 312 "jamexp.y" */
1690
{jam_yyval = CALC(BITWISE_OR, jam_yypvt[-2], jam_yypvt[-0]);} break;
1691
case 19:
1692
/* # line 313 "jamexp.y" */
1693
{jam_yyval = CALC(BITWISE_XOR, jam_yypvt[-2], jam_yypvt[-0]);} break;
1694
case 20:
1695
/* # line 314 "jamexp.y" */
1696
{jam_yyval = CALC(AND, jam_yypvt[-2], jam_yypvt[-0]);} break;
1697
case 21:
1698
/* # line 315 "jamexp.y" */
1699
{jam_yyval = CALC(OR, jam_yypvt[-2], jam_yypvt[-0]);} break;
1700
case 22:
1701
/* # line 316 "jamexp.y" */
1702
{jam_yyval = CALC(LEFT_SHIFT, jam_yypvt[-2], jam_yypvt[-0]);} break;
1703
case 23:
1704
/* # line 317 "jamexp.y" */
1705
{jam_yyval = CALC(RIGHT_SHIFT, jam_yypvt[-2], jam_yypvt[-0]);} break;
1706
case 24:
1707
/* # line 318 "jamexp.y" */
1708
{jam_yyval = CALC(EQUALITY, jam_yypvt[-2], jam_yypvt[-0]);} break;
1709
case 25:
1710
/* # line 319 "jamexp.y" */
1711
{jam_yyval = CALC(INEQUALITY, jam_yypvt[-2], jam_yypvt[-0]);} break;
1712
case 26:
1713
/* # line 320 "jamexp.y" */
1714
{jam_yyval = CALC(GREATER_THAN, jam_yypvt[-2], jam_yypvt[-0]);} break;
1715
case 27:
1716
/* # line 321 "jamexp.y" */
1717
{jam_yyval = CALC(LESS_THAN, jam_yypvt[-2], jam_yypvt[-0]);} break;
1718
case 28:
1719
/* # line 322 "jamexp.y" */
1720
{jam_yyval = CALC(GREATER_OR_EQUAL, jam_yypvt[-2], jam_yypvt[-0]);} break;
1721
case 29:
1722
/* # line 323 "jamexp.y" */
1723
{jam_yyval = CALC(LESS_OR_EQUAL, jam_yypvt[-2], jam_yypvt[-0]);} break;
1724
case 30:
1725
/* # line 324 "jamexp.y" */
1726
{jam_yyval = CALC(ABS, jam_yypvt[-1], NULL_EXP);} break;
1727
case 31:
1728
/* # line 325 "jamexp.y" */
1729
{jam_yyval = CALC(INT, jam_yypvt[-1], NULL_EXP);} break;
1730
case 32:
1731
/* # line 326 "jamexp.y" */
1732
{jam_yyval = CALC(LOG2, jam_yypvt[-1], NULL_EXP);} break;
1733
case 33:
1734
/* # line 327 "jamexp.y" */
1735
{jam_yyval = CALC(SQRT, jam_yypvt[-1], NULL_EXP);} break;
1736
case 34:
1737
/* # line 328 "jamexp.y" */
1738
{jam_yyval = CALC(CIEL, jam_yypvt[-1], NULL_EXP);} break;
1739
case 35:
1740
/* # line 329 "jamexp.y" */
1741
{jam_yyval = CALC(FLOOR, jam_yypvt[-1], NULL_EXP);} break;
1742
case 36:
1743
/* # line 330 "jamexp.y" */
1744
{jam_yyval = CALC(ARRAY, jam_yypvt[-3], jam_yypvt[-1]);} break;
1745
            }
1746
            goto jam_yystack;  /* stack new state and value */
1747
 
1748
        }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.