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

Subversion Repositories diogenes

[/] [diogenes/] [trunk/] [asm/] [yacc.in.tab.c] - Blame information for rev 236

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 100 fellnhofer
 
2
/*  A Bison parser, made from yacc.in
3
 by  GNU Bison version 1.27
4
  */
5
 
6
#define YYBISON 1  /* Identify Bison output.  */
7
 
8
#define C       257
9
#define OBRA    258
10
#define CBRA    259
11
#define NUM     260
12
#define IMM     261
13
#define IMMHEX  262
14
#define REG     263
15
#define SKIP    264
16
#define SKIPAL  265
17
#define COND    266
18
#define MOV     267
19
#define ARI     268
20
#define CMP     269
21
#define CMPTYP  270
22
#define SC      271
23
#define BL      272
24
#define MEM     273
25
#define IO      274
26
#define LABEL   275
27
 
28
#line 3 "yacc.in"
29
 
30
#include <stdio.h>
31
#include <string.h>
32
#include "tools.h"
33
 
34
#define YYERROR_VERBOSE 
35
 
36
int temp;
37
 
38
void yyerror(const char *str)
39
{
40
        fprintf(stderr,"error: %s\n",str);
41
}
42
 
43
int yywrap()
44
{
45
        return 1;
46
}
47
 
48
int main(int argc, char **argv)
49
{
50
//      if(argc==2) 
51
//              stdin = fopen(argv[1], "r");    
52
 
53
    yyparse();
54
}
55
 
56
 
57
#line 34 "yacc.in"
58
typedef union
59
{
60
        int num;
61
        char *str;
62
} YYSTYPE;
63
#include <stdio.h>
64
 
65
#ifndef __cplusplus
66
#ifndef __STDC__
67
#define const
68
#endif
69
#endif
70
 
71
 
72
 
73
#define YYFINAL         43
74
#define YYFLAG          -32768
75
#define YYNTBASE        22
76
 
77
#define YYTRANSLATE(x) ((unsigned)(x) <= 275 ? yytranslate[x] : 32)
78
 
79
static const char yytranslate[] = {     0,
80
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
81
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
82
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
83
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
84
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
85
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
86
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
87
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
88
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
89
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
90
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
91
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
92
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
93
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
94
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
95
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
96
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
97
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
98
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
99
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
100
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
101
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
102
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
103
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
104
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
105
     2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
106
     7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
107
    17,    18,    19,    20,    21
108
};
109
 
110
#if YYDEBUG != 0
111
static const short yyprhs[] = {     0,
112
     0,     2,     5,     7,     9,    11,    13,    15,    17,    22,
113
    27,    34,    39,    44,    51,    54,    59,    61,    63,    65
114
};
115
 
116
static const short yyrhs[] = {    23,
117
     0,    22,    23,     0,    21,     0,    24,     0,    25,     0,
118
    28,     0,    26,     0,    27,     0,    13,     9,     3,     9,
119
     0,    13,     9,     3,    29,     0,    14,     9,     3,     9,
120
     3,     9,     0,    14,     9,     3,    31,     0,    15,     9,
121
     3,     9,     0,    19,     9,     3,     4,     9,     5,     0,
122
    11,    30,     0,    10,     9,     3,    30,     0,     7,     0,
123
     7,     0,    21,     0,     7,     0
124
};
125
 
126
#endif
127
 
128
#if YYDEBUG != 0
129
static const short yyrline[] = { 0,
130
    50,    50,    52,    53,    54,    55,    56,    57,    60,    64,
131
    69,    73,    78,    80,    85,    86,    88,    94,    99,   104
132
};
133
#endif
134
 
135
 
136
#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
137
 
138
static const char * const yytname[] = {   "$","error","$undefined.","C","OBRA",
139
"CBRA","NUM","IMM","IMMHEX","REG","SKIP","SKIPAL","COND","MOV","ARI","CMP","CMPTYP",
140
"SC","BL","MEM","IO","LABEL","asms","asm","mov","arit","cmp","mem","skip","imm",
141
"immsk","imm5b", NULL
142
};
143
#endif
144
 
145
static const short yyr1[] = {     0,
146
    22,    22,    23,    23,    23,    23,    23,    23,    24,    24,
147
    25,    25,    26,    27,    28,    28,    29,    30,    30,    31
148
};
149
 
150
static const short yyr2[] = {     0,
151
     1,     2,     1,     1,     1,     1,     1,     1,     4,     4,
152
     6,     4,     4,     6,     2,     4,     1,     1,     1,     1
153
};
154
 
155
static const short yydefact[] = {     0,
156
     0,     0,     0,     0,     0,     0,     3,     0,     1,     4,
157
     5,     7,     8,     6,     0,    18,    19,    15,     0,     0,
158
     0,     0,     2,     0,     0,     0,     0,     0,    16,    17,
159
     9,    10,    20,     0,    12,    13,     0,     0,     0,    11,
160
    14,     0,     0
161
};
162
 
163
static const short yydefgoto[] = {     8,
164
     9,    10,    11,    12,    13,    14,    32,    18,    35
165
};
166
 
167
static const short yypact[] = {    12,
168
    -4,    -5,    -2,    -1,     3,     8,-32768,     0,-32768,-32768,
169
-32768,-32768,-32768,-32768,     6,-32768,-32768,-32768,    15,    17,
170
    21,    25,-32768,    -5,    -6,    -3,    20,    26,-32768,-32768,
171
-32768,-32768,-32768,    29,-32768,-32768,    27,    28,    30,-32768,
172
-32768,    34,-32768
173
};
174
 
175
static const short yypgoto[] = {-32768,
176
    31,-32768,-32768,-32768,-32768,-32768,-32768,    14,-32768
177
};
178
 
179
 
180
#define YYLAST          39
181
 
182
 
183
static const short yytable[] = {    42,
184
    30,    16,    31,    33,    15,    34,    19,    20,    24,     1,
185
     2,    21,     3,     4,     5,    17,    22,    25,     6,    26,
186
     7,     1,     2,    27,     3,     4,     5,    28,    36,    37,
187
     6,    38,     7,    43,    41,    39,    40,    29,    23
188
};
189
 
190
static const short yycheck[] = {     0,
191
     7,     7,     9,     7,     9,     9,     9,     9,     3,    10,
192
    11,     9,    13,    14,    15,    21,     9,     3,    19,     3,
193
    21,    10,    11,     3,    13,    14,    15,     3,     9,     4,
194
    19,     3,    21,     0,     5,     9,     9,    24,     8
195
};
196
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
197
#line 3 "bison.simple"
198
/* This file comes from bison-1.27.  */
199
 
200
/* Skeleton output parser for bison,
201
   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
202
 
203
   This program is free software; you can redistribute it and/or modify
204
   it under the terms of the GNU General Public License as published by
205
   the Free Software Foundation; either version 2, or (at your option)
206
   any later version.
207
 
208
   This program is distributed in the hope that it will be useful,
209
   but WITHOUT ANY WARRANTY; without even the implied warranty of
210
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
211
   GNU General Public License for more details.
212
 
213
   You should have received a copy of the GNU General Public License
214
   along with this program; if not, write to the Free Software
215
   Foundation, Inc., 59 Temple Place - Suite 330,
216
   Boston, MA 02111-1307, USA.  */
217
 
218
/* As a special exception, when this file is copied by Bison into a
219
   Bison output file, you may use that output file without restriction.
220
   This special exception was added by the Free Software Foundation
221
   in version 1.24 of Bison.  */
222
 
223
/* This is the parser code that is written into each bison parser
224
  when the %semantic_parser declaration is not specified in the grammar.
225
  It was written by Richard Stallman by simplifying the hairy parser
226
  used when %semantic_parser is specified.  */
227
 
228
#ifndef YYSTACK_USE_ALLOCA
229
#ifdef alloca
230
#define YYSTACK_USE_ALLOCA
231
#else /* alloca not defined */
232
#ifdef __GNUC__
233
#define YYSTACK_USE_ALLOCA
234
#define alloca __builtin_alloca
235
#else /* not GNU C.  */
236
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
237
#define YYSTACK_USE_ALLOCA
238
#include <alloca.h>
239
#else /* not sparc */
240
/* We think this test detects Watcom and Microsoft C.  */
241
/* This used to test MSDOS, but that is a bad idea
242
   since that symbol is in the user namespace.  */
243
#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
244
#if 0 /* No need for malloc.h, which pollutes the namespace;
245
         instead, just don't use alloca.  */
246
#include <malloc.h>
247
#endif
248
#else /* not MSDOS, or __TURBOC__ */
249
#if defined(_AIX)
250
/* I don't know what this was needed for, but it pollutes the namespace.
251
   So I turned it off.   rms, 2 May 1997.  */
252
/* #include <malloc.h>  */
253
 #pragma alloca
254
#define YYSTACK_USE_ALLOCA
255
#else /* not MSDOS, or __TURBOC__, or _AIX */
256
#if 0
257
#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
258
                 and on HPUX 10.  Eventually we can turn this on.  */
259
#define YYSTACK_USE_ALLOCA
260
#define alloca __builtin_alloca
261
#endif /* __hpux */
262
#endif
263
#endif /* not _AIX */
264
#endif /* not MSDOS, or __TURBOC__ */
265
#endif /* not sparc */
266
#endif /* not GNU C */
267
#endif /* alloca not defined */
268
#endif /* YYSTACK_USE_ALLOCA not defined */
269
 
270
#ifdef YYSTACK_USE_ALLOCA
271
#define YYSTACK_ALLOC alloca
272
#else
273
#define YYSTACK_ALLOC malloc
274
#endif
275
 
276
/* Note: there must be only one dollar sign in this file.
277
   It is replaced by the list of actions, each action
278
   as one case of the switch.  */
279
 
280
#define yyerrok         (yyerrstatus = 0)
281
#define yyclearin       (yychar = YYEMPTY)
282
#define YYEMPTY         -2
283
#define YYEOF           0
284
#define YYACCEPT        goto yyacceptlab
285
#define YYABORT         goto yyabortlab
286
#define YYERROR         goto yyerrlab1
287
/* Like YYERROR except do call yyerror.
288
   This remains here temporarily to ease the
289
   transition to the new meaning of YYERROR, for GCC.
290
   Once GCC version 2 has supplanted version 1, this can go.  */
291
#define YYFAIL          goto yyerrlab
292
#define YYRECOVERING()  (!!yyerrstatus)
293
#define YYBACKUP(token, value) \
294
do                                                              \
295
  if (yychar == YYEMPTY && yylen == 1)                          \
296
    { yychar = (token), yylval = (value);                       \
297
      yychar1 = YYTRANSLATE (yychar);                           \
298
      YYPOPSTACK;                                               \
299
      goto yybackup;                                            \
300
    }                                                           \
301
  else                                                          \
302
    { yyerror ("syntax error: cannot back up"); YYERROR; }      \
303
while (0)
304
 
305
#define YYTERROR        1
306
#define YYERRCODE       256
307
 
308
#ifndef YYPURE
309
#define YYLEX           yylex()
310
#endif
311
 
312
#ifdef YYPURE
313
#ifdef YYLSP_NEEDED
314
#ifdef YYLEX_PARAM
315
#define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
316
#else
317
#define YYLEX           yylex(&yylval, &yylloc)
318
#endif
319
#else /* not YYLSP_NEEDED */
320
#ifdef YYLEX_PARAM
321
#define YYLEX           yylex(&yylval, YYLEX_PARAM)
322
#else
323
#define YYLEX           yylex(&yylval)
324
#endif
325
#endif /* not YYLSP_NEEDED */
326
#endif
327
 
328
/* If nonreentrant, generate the variables here */
329
 
330
#ifndef YYPURE
331
 
332
int     yychar;                 /*  the lookahead symbol                */
333
YYSTYPE yylval;                 /*  the semantic value of the           */
334
                                /*  lookahead symbol                    */
335
 
336
#ifdef YYLSP_NEEDED
337
YYLTYPE yylloc;                 /*  location data for the lookahead     */
338
                                /*  symbol                              */
339
#endif
340
 
341
int yynerrs;                    /*  number of parse errors so far       */
342
#endif  /* not YYPURE */
343
 
344
#if YYDEBUG != 0
345
int yydebug;                    /*  nonzero means print parse trace     */
346
/* Since this is uninitialized, it does not stop multiple parsers
347
   from coexisting.  */
348
#endif
349
 
350
/*  YYINITDEPTH indicates the initial size of the parser's stacks       */
351
 
352
#ifndef YYINITDEPTH
353
#define YYINITDEPTH 200
354
#endif
355
 
356
/*  YYMAXDEPTH is the maximum size the stacks can grow to
357
    (effective only if the built-in stack extension method is used).  */
358
 
359
#if YYMAXDEPTH == 0
360
#undef YYMAXDEPTH
361
#endif
362
 
363
#ifndef YYMAXDEPTH
364
#define YYMAXDEPTH 10000
365
#endif
366
 
367
/* Define __yy_memcpy.  Note that the size argument
368
   should be passed with type unsigned int, because that is what the non-GCC
369
   definitions require.  With GCC, __builtin_memcpy takes an arg
370
   of type size_t, but it can handle unsigned int.  */
371
 
372
#if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
373
#define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
374
#else                           /* not GNU C or C++ */
375
#ifndef __cplusplus
376
 
377
/* This is the most reliable way to avoid incompatibilities
378
   in available built-in functions on various systems.  */
379
static void
380
__yy_memcpy (to, from, count)
381
     char *to;
382
     char *from;
383
     unsigned int count;
384
{
385
  register char *f = from;
386
  register char *t = to;
387
  register int i = count;
388
 
389
  while (i-- > 0)
390
    *t++ = *f++;
391
}
392
 
393
#else /* __cplusplus */
394
 
395
/* This is the most reliable way to avoid incompatibilities
396
   in available built-in functions on various systems.  */
397
static void
398
__yy_memcpy (char *to, char *from, unsigned int count)
399
{
400
  register char *t = to;
401
  register char *f = from;
402
  register int i = count;
403
 
404
  while (i-- > 0)
405
    *t++ = *f++;
406
}
407
 
408
#endif
409
#endif
410
 
411
#line 216 "bison.simple"
412
 
413
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
414
   into yyparse.  The argument should have type void *.
415
   It should actually point to an object.
416
   Grammar actions can access the variable by casting it
417
   to the proper pointer type.  */
418
 
419
#ifdef YYPARSE_PARAM
420
#ifdef __cplusplus
421
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
422
#define YYPARSE_PARAM_DECL
423
#else /* not __cplusplus */
424
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
425
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
426
#endif /* not __cplusplus */
427
#else /* not YYPARSE_PARAM */
428
#define YYPARSE_PARAM_ARG
429
#define YYPARSE_PARAM_DECL
430
#endif /* not YYPARSE_PARAM */
431
 
432
/* Prevent warning if -Wstrict-prototypes.  */
433
#ifdef __GNUC__
434
#ifdef YYPARSE_PARAM
435
int yyparse (void *);
436
#else
437
int yyparse (void);
438
#endif
439
#endif
440
 
441
int
442
yyparse(YYPARSE_PARAM_ARG)
443
     YYPARSE_PARAM_DECL
444
{
445
  register int yystate;
446
  register int yyn;
447
  register short *yyssp;
448
  register YYSTYPE *yyvsp;
449
  int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
450
  int yychar1 = 0;               /*  lookahead token as an internal (translated) token number */
451
 
452
  short yyssa[YYINITDEPTH];     /*  the state stack                     */
453
  YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
454
 
455
  short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
456
  YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
457
 
458
#ifdef YYLSP_NEEDED
459
  YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
460
  YYLTYPE *yyls = yylsa;
461
  YYLTYPE *yylsp;
462
 
463
#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
464
#else
465
#define YYPOPSTACK   (yyvsp--, yyssp--)
466
#endif
467
 
468
  int yystacksize = YYINITDEPTH;
469
  int yyfree_stacks = 0;
470
 
471
#ifdef YYPURE
472
  int yychar;
473
  YYSTYPE yylval;
474
  int yynerrs;
475
#ifdef YYLSP_NEEDED
476
  YYLTYPE yylloc;
477
#endif
478
#endif
479
 
480
  YYSTYPE yyval;                /*  the variable used to return         */
481
                                /*  semantic values from the action     */
482
                                /*  routines                            */
483
 
484
  int yylen;
485
 
486
#if YYDEBUG != 0
487
  if (yydebug)
488
    fprintf(stderr, "Starting parse\n");
489
#endif
490
 
491
  yystate = 0;
492
  yyerrstatus = 0;
493
  yynerrs = 0;
494
  yychar = YYEMPTY;             /* Cause a token to be read.  */
495
 
496
  /* Initialize stack pointers.
497
     Waste one element of value and location stack
498
     so that they stay on the same level as the state stack.
499
     The wasted elements are never initialized.  */
500
 
501
  yyssp = yyss - 1;
502
  yyvsp = yyvs;
503
#ifdef YYLSP_NEEDED
504
  yylsp = yyls;
505
#endif
506
 
507
/* Push a new state, which is found in  yystate  .  */
508
/* In all cases, when you get here, the value and location stacks
509
   have just been pushed. so pushing a state here evens the stacks.  */
510
yynewstate:
511
 
512
  *++yyssp = yystate;
513
 
514
  if (yyssp >= yyss + yystacksize - 1)
515
    {
516
      /* Give user a chance to reallocate the stack */
517
      /* Use copies of these so that the &'s don't force the real ones into memory. */
518
      YYSTYPE *yyvs1 = yyvs;
519
      short *yyss1 = yyss;
520
#ifdef YYLSP_NEEDED
521
      YYLTYPE *yyls1 = yyls;
522
#endif
523
 
524
      /* Get the current used size of the three stacks, in elements.  */
525
      int size = yyssp - yyss + 1;
526
 
527
#ifdef yyoverflow
528
      /* Each stack pointer address is followed by the size of
529
         the data in use in that stack, in bytes.  */
530
#ifdef YYLSP_NEEDED
531
      /* This used to be a conditional around just the two extra args,
532
         but that might be undefined if yyoverflow is a macro.  */
533
      yyoverflow("parser stack overflow",
534
                 &yyss1, size * sizeof (*yyssp),
535
                 &yyvs1, size * sizeof (*yyvsp),
536
                 &yyls1, size * sizeof (*yylsp),
537
                 &yystacksize);
538
#else
539
      yyoverflow("parser stack overflow",
540
                 &yyss1, size * sizeof (*yyssp),
541
                 &yyvs1, size * sizeof (*yyvsp),
542
                 &yystacksize);
543
#endif
544
 
545
      yyss = yyss1; yyvs = yyvs1;
546
#ifdef YYLSP_NEEDED
547
      yyls = yyls1;
548
#endif
549
#else /* no yyoverflow */
550
      /* Extend the stack our own way.  */
551
      if (yystacksize >= YYMAXDEPTH)
552
        {
553
          yyerror("parser stack overflow");
554
          if (yyfree_stacks)
555
            {
556
              free (yyss);
557
              free (yyvs);
558
#ifdef YYLSP_NEEDED
559
              free (yyls);
560
#endif
561
            }
562
          return 2;
563
        }
564
      yystacksize *= 2;
565
      if (yystacksize > YYMAXDEPTH)
566
        yystacksize = YYMAXDEPTH;
567
#ifndef YYSTACK_USE_ALLOCA
568
      yyfree_stacks = 1;
569
#endif
570
      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
571
      __yy_memcpy ((char *)yyss, (char *)yyss1,
572
                   size * (unsigned int) sizeof (*yyssp));
573
      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
574
      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
575
                   size * (unsigned int) sizeof (*yyvsp));
576
#ifdef YYLSP_NEEDED
577
      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
578
      __yy_memcpy ((char *)yyls, (char *)yyls1,
579
                   size * (unsigned int) sizeof (*yylsp));
580
#endif
581
#endif /* no yyoverflow */
582
 
583
      yyssp = yyss + size - 1;
584
      yyvsp = yyvs + size - 1;
585
#ifdef YYLSP_NEEDED
586
      yylsp = yyls + size - 1;
587
#endif
588
 
589
#if YYDEBUG != 0
590
      if (yydebug)
591
        fprintf(stderr, "Stack size increased to %d\n", yystacksize);
592
#endif
593
 
594
      if (yyssp >= yyss + yystacksize - 1)
595
        YYABORT;
596
    }
597
 
598
#if YYDEBUG != 0
599
  if (yydebug)
600
    fprintf(stderr, "Entering state %d\n", yystate);
601
#endif
602
 
603
  goto yybackup;
604
 yybackup:
605
 
606
/* Do appropriate processing given the current state.  */
607
/* Read a lookahead token if we need one and don't already have one.  */
608
/* yyresume: */
609
 
610
  /* First try to decide what to do without reference to lookahead token.  */
611
 
612
  yyn = yypact[yystate];
613
  if (yyn == YYFLAG)
614
    goto yydefault;
615
 
616
  /* Not known => get a lookahead token if don't already have one.  */
617
 
618
  /* yychar is either YYEMPTY or YYEOF
619
     or a valid token in external form.  */
620
 
621
  if (yychar == YYEMPTY)
622
    {
623
#if YYDEBUG != 0
624
      if (yydebug)
625
        fprintf(stderr, "Reading a token: ");
626
#endif
627
      yychar = YYLEX;
628
    }
629
 
630
  /* Convert token to internal form (in yychar1) for indexing tables with */
631
 
632
  if (yychar <= 0)               /* This means end of input. */
633
    {
634
      yychar1 = 0;
635
      yychar = YYEOF;           /* Don't call YYLEX any more */
636
 
637
#if YYDEBUG != 0
638
      if (yydebug)
639
        fprintf(stderr, "Now at end of input.\n");
640
#endif
641
    }
642
  else
643
    {
644
      yychar1 = YYTRANSLATE(yychar);
645
 
646
#if YYDEBUG != 0
647
      if (yydebug)
648
        {
649
          fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
650
          /* Give the individual parser a way to print the precise meaning
651
             of a token, for further debugging info.  */
652
#ifdef YYPRINT
653
          YYPRINT (stderr, yychar, yylval);
654
#endif
655
          fprintf (stderr, ")\n");
656
        }
657
#endif
658
    }
659
 
660
  yyn += yychar1;
661
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
662
    goto yydefault;
663
 
664
  yyn = yytable[yyn];
665
 
666
  /* yyn is what to do for this token type in this state.
667
     Negative => reduce, -yyn is rule number.
668
     Positive => shift, yyn is new state.
669
       New state is final state => don't bother to shift,
670
       just return success.
671
     0, or most negative number => error.  */
672
 
673
  if (yyn < 0)
674
    {
675
      if (yyn == YYFLAG)
676
        goto yyerrlab;
677
      yyn = -yyn;
678
      goto yyreduce;
679
    }
680
  else if (yyn == 0)
681
    goto yyerrlab;
682
 
683
  if (yyn == YYFINAL)
684
    YYACCEPT;
685
 
686
  /* Shift the lookahead token.  */
687
 
688
#if YYDEBUG != 0
689
  if (yydebug)
690
    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
691
#endif
692
 
693
  /* Discard the token being shifted unless it is eof.  */
694
  if (yychar != YYEOF)
695
    yychar = YYEMPTY;
696
 
697
  *++yyvsp = yylval;
698
#ifdef YYLSP_NEEDED
699
  *++yylsp = yylloc;
700
#endif
701
 
702
  /* count tokens shifted since error; after three, turn off error status.  */
703
  if (yyerrstatus) yyerrstatus--;
704
 
705
  yystate = yyn;
706
  goto yynewstate;
707
 
708
/* Do the default action for the current state.  */
709
yydefault:
710
 
711
  yyn = yydefact[yystate];
712
  if (yyn == 0)
713
    goto yyerrlab;
714
 
715
/* Do a reduction.  yyn is the number of a rule to reduce with.  */
716
yyreduce:
717
  yylen = yyr2[yyn];
718
  if (yylen > 0)
719
    yyval = yyvsp[1-yylen]; /* implement default value of the action */
720
 
721
#if YYDEBUG != 0
722
  if (yydebug)
723
    {
724
      int i;
725
 
726
      fprintf (stderr, "Reducing via rule %d (line %d), ",
727
               yyn, yyrline[yyn]);
728
 
729
      /* Print the symbols being reduced, and their result.  */
730
      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
731
        fprintf (stderr, "%s ", yytname[yyrhs[i]]);
732
      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
733
    }
734
#endif
735
 
736
 
737
  switch (yyn) {
738
 
739
case 3:
740
#line 52 "yacc.in"
741
{add_label(yyval.num, address);;
742
    break;}
743
case 4:
744
#line 53 "yacc.in"
745
{printf("0x%04x\n",yyvsp[0].num);address++;;
746
    break;}
747
case 5:
748
#line 54 "yacc.in"
749
{printf("0x%04x\n",yyvsp[0].num);address++;;
750
    break;}
751
case 6:
752
#line 55 "yacc.in"
753
{printf("0x%04x\n",yyvsp[0].num);address++;;
754
    break;}
755
case 7:
756
#line 56 "yacc.in"
757
{printf("0x%04x\n",yyvsp[0].num);address++;;
758
    break;}
759
case 8:
760
#line 57 "yacc.in"
761
{printf("0x%04x\n",yyvsp[0].num);address++;;
762
    break;}
763
case 9:
764
#line 61 "yacc.in"
765
{       if(yyvsp[-2].num==0) { yyerror("r0 not allowed as destination"); YYERROR; }
766
                        yyval.num = (yyvsp[-2].num<<8) | (yyvsp[0].num<<4);              // add regD, regS, reg0 
767
                ;
768
    break;}
769
case 10:
770
#line 65 "yacc.in"
771
{       if(yyvsp[-2].num==0) { yyerror("r0 not allowed as destination"); YYERROR; }
772
                        yyval.num = (0x7<<12) | (yyvsp[-2].num<<8) | (yyvsp[0].num);             // ldi regD, regS, reg0 
773
                ;
774
    break;}
775
case 11:
776
#line 70 "yacc.in"
777
{       if(yyvsp[-4].num==0) { yyerror("r0 not allowed as destination"); YYERROR; }
778
                        yyval.num = (yyvsp[-5].num<<12) | (yyvsp[-4].num<<8) | (yyvsp[-2].num<<4) | yyvsp[0].num;
779
                ;
780
    break;}
781
case 12:
782
#line 74 "yacc.in"
783
{       if(!(yyvsp[-2].num%2)) { yyerror("only odd registers allowed"); YYERROR; }
784
                        yyval.num = (yyvsp[-3].num<<12) | ((yyvsp[-2].num-1)<<4) | (yyvsp[0].num);
785
                ;
786
    break;}
787
case 13:
788
#line 78 "yacc.in"
789
{ yyval.num = 0xE000 | (yyvsp[-3].num<<9) | (yyvsp[-2].num<<4) | yyvsp[0].num; ;
790
    break;}
791
case 14:
792
#line 81 "yacc.in"
793
{       if(yyvsp[-4].num==0) { yyerror("r0 not allowed as destination"); YYERROR; }
794
                        yyval.num = 0x8000 | (yyvsp[-5].num<<12) | (yyvsp[-4].num<<4) | yyvsp[-1].num
795
                ;
796
    break;}
797
case 15:
798
#line 85 "yacc.in"
799
{       yyval.num = (0xc<<12) | ((yyvsp[0].num&0xff)<<4);  ;
800
    break;}
801
case 16:
802
#line 86 "yacc.in"
803
{       yyval.num = (0xc<<12) | (yyvsp[-3].num<<12) | ((yyvsp[0].num&0xff)<<4) | yyvsp[-2].num; ;
804
    break;}
805
case 17:
806
#line 89 "yacc.in"
807
{       temp = check_imm(yyvsp[0].str, &yyval.num, 0, 255);
808
                        if(temp==1) { yyerror("8 Bit unsigned immediate expected"); YYERROR; }
809
                        if(temp==2) { yyerror("Immediate syntax"); YYERROR; }
810
                ;
811
    break;}
812
case 18:
813
#line 95 "yacc.in"
814
{       temp = check_imm(yyvsp[0].str, &yyval.num, -128, 127);
815
                        if(temp==1) { yyerror("8 bit signed immediate expected"); YYERROR; }
816
                        if(temp==2) { yyerror("Immediate syntax"); YYERROR; }
817
                ;
818
    break;}
819
case 19:
820
#line 100 "yacc.in"
821
{
822
                        yyval.num = get_label(yyvsp[0].num) - address - 1;
823
                ;
824
    break;}
825
case 20:
826
#line 105 "yacc.in"
827
{       temp = check_imm(yyvsp[0].str, &yyval.num, 1, 32);
828
                        yyval.num--;
829
                        if(temp==1) { printf("Immediate Value %d out of range: 1..32 allowed\n", yyval.num); YYERROR; }
830
                        if(temp==2) { yyerror("Immediate syntax"); YYERROR; }
831
                ;
832
    break;}
833
}
834
   /* the action file gets copied in in place of this dollarsign */
835
#line 542 "bison.simple"
836
 
837
  yyvsp -= yylen;
838
  yyssp -= yylen;
839
#ifdef YYLSP_NEEDED
840
  yylsp -= yylen;
841
#endif
842
 
843
#if YYDEBUG != 0
844
  if (yydebug)
845
    {
846
      short *ssp1 = yyss - 1;
847
      fprintf (stderr, "state stack now");
848
      while (ssp1 != yyssp)
849
        fprintf (stderr, " %d", *++ssp1);
850
      fprintf (stderr, "\n");
851
    }
852
#endif
853
 
854
  *++yyvsp = yyval;
855
 
856
#ifdef YYLSP_NEEDED
857
  yylsp++;
858
  if (yylen == 0)
859
    {
860
      yylsp->first_line = yylloc.first_line;
861
      yylsp->first_column = yylloc.first_column;
862
      yylsp->last_line = (yylsp-1)->last_line;
863
      yylsp->last_column = (yylsp-1)->last_column;
864
      yylsp->text = 0;
865
    }
866
  else
867
    {
868
      yylsp->last_line = (yylsp+yylen-1)->last_line;
869
      yylsp->last_column = (yylsp+yylen-1)->last_column;
870
    }
871
#endif
872
 
873
  /* Now "shift" the result of the reduction.
874
     Determine what state that goes to,
875
     based on the state we popped back to
876
     and the rule number reduced by.  */
877
 
878
  yyn = yyr1[yyn];
879
 
880
  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
881
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
882
    yystate = yytable[yystate];
883
  else
884
    yystate = yydefgoto[yyn - YYNTBASE];
885
 
886
  goto yynewstate;
887
 
888
yyerrlab:   /* here on detecting error */
889
 
890
  if (! yyerrstatus)
891
    /* If not already recovering from an error, report this error.  */
892
    {
893
      ++yynerrs;
894
 
895
#ifdef YYERROR_VERBOSE
896
      yyn = yypact[yystate];
897
 
898
      if (yyn > YYFLAG && yyn < YYLAST)
899
        {
900
          int size = 0;
901
          char *msg;
902
          int x, count;
903
 
904
          count = 0;
905
          /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
906
          for (x = (yyn < 0 ? -yyn : 0);
907
               x < (sizeof(yytname) / sizeof(char *)); x++)
908
            if (yycheck[x + yyn] == x)
909
              size += strlen(yytname[x]) + 15, count++;
910
          msg = (char *) malloc(size + 15);
911
          if (msg != 0)
912
            {
913
              strcpy(msg, "parse error");
914
 
915
              if (count < 5)
916
                {
917
                  count = 0;
918
                  for (x = (yyn < 0 ? -yyn : 0);
919
                       x < (sizeof(yytname) / sizeof(char *)); x++)
920
                    if (yycheck[x + yyn] == x)
921
                      {
922
                        strcat(msg, count == 0 ? ", expecting `" : " or `");
923
                        strcat(msg, yytname[x]);
924
                        strcat(msg, "'");
925
                        count++;
926
                      }
927
                }
928
              yyerror(msg);
929
              free(msg);
930
            }
931
          else
932
            yyerror ("parse error; also virtual memory exceeded");
933
        }
934
      else
935
#endif /* YYERROR_VERBOSE */
936
        yyerror("parse error");
937
    }
938
 
939
  goto yyerrlab1;
940
yyerrlab1:   /* here on error raised explicitly by an action */
941
 
942
  if (yyerrstatus == 3)
943
    {
944
      /* if just tried and failed to reuse lookahead token after an error, discard it.  */
945
 
946
      /* return failure if at end of input */
947
      if (yychar == YYEOF)
948
        YYABORT;
949
 
950
#if YYDEBUG != 0
951
      if (yydebug)
952
        fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
953
#endif
954
 
955
      yychar = YYEMPTY;
956
    }
957
 
958
  /* Else will try to reuse lookahead token
959
     after shifting the error token.  */
960
 
961
  yyerrstatus = 3;              /* Each real token shifted decrements this */
962
 
963
  goto yyerrhandle;
964
 
965
yyerrdefault:  /* current state does not do anything special for the error token. */
966
 
967
#if 0
968
  /* This is wrong; only states that explicitly want error tokens
969
     should shift them.  */
970
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
971
  if (yyn) goto yydefault;
972
#endif
973
 
974
yyerrpop:   /* pop the current state because it cannot handle the error token */
975
 
976
  if (yyssp == yyss) YYABORT;
977
  yyvsp--;
978
  yystate = *--yyssp;
979
#ifdef YYLSP_NEEDED
980
  yylsp--;
981
#endif
982
 
983
#if YYDEBUG != 0
984
  if (yydebug)
985
    {
986
      short *ssp1 = yyss - 1;
987
      fprintf (stderr, "Error: state stack now");
988
      while (ssp1 != yyssp)
989
        fprintf (stderr, " %d", *++ssp1);
990
      fprintf (stderr, "\n");
991
    }
992
#endif
993
 
994
yyerrhandle:
995
 
996
  yyn = yypact[yystate];
997
  if (yyn == YYFLAG)
998
    goto yyerrdefault;
999
 
1000
  yyn += YYTERROR;
1001
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1002
    goto yyerrdefault;
1003
 
1004
  yyn = yytable[yyn];
1005
  if (yyn < 0)
1006
    {
1007
      if (yyn == YYFLAG)
1008
        goto yyerrpop;
1009
      yyn = -yyn;
1010
      goto yyreduce;
1011
    }
1012
  else if (yyn == 0)
1013
    goto yyerrpop;
1014
 
1015
  if (yyn == YYFINAL)
1016
    YYACCEPT;
1017
 
1018
#if YYDEBUG != 0
1019
  if (yydebug)
1020
    fprintf(stderr, "Shifting error token, ");
1021
#endif
1022
 
1023
  *++yyvsp = yylval;
1024
#ifdef YYLSP_NEEDED
1025
  *++yylsp = yylloc;
1026
#endif
1027
 
1028
  yystate = yyn;
1029
  goto yynewstate;
1030
 
1031
 yyacceptlab:
1032
  /* YYACCEPT comes here.  */
1033
  if (yyfree_stacks)
1034
    {
1035
      free (yyss);
1036
      free (yyvs);
1037
#ifdef YYLSP_NEEDED
1038
      free (yyls);
1039
#endif
1040
    }
1041
  return 0;
1042
 
1043
 yyabortlab:
1044
  /* YYABORT comes here.  */
1045
  if (yyfree_stacks)
1046
    {
1047
      free (yyss);
1048
      free (yyvs);
1049
#ifdef YYLSP_NEEDED
1050
      free (yyls);
1051
#endif
1052
    }
1053
  return 1;
1054
}
1055
#line 112 "yacc.in"
1056
 

powered by: WebSVN 2.1.0

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