~ubuntu-branches/ubuntu/wily/gperiodic/wily

« back to all changes in this revision

Viewing changes to src/gparser.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2004-05-13 20:46:09 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040513204609-2ymqncvzfrqx8a7i
Tags: 2.0.7-4
Removed the DEPRECATED flags to build fine with GTK+2.4.

Show diffs side-by-side

added added

removed removed

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