2
/* A Bison parser, made from gparser.y
3
by GNU Bison version 1.28 */
5
#define YYBISON 1 /* Identify Bison output. */
9
#define COMMAND_SEPERATOR 259
22
void add_argument(const char*);
23
int gpparser_execute_command(const char*,GList*);
24
extern void gpparser_reinit_parser(void);
44
#define YYTRANSLATE(x) ((unsigned)(x) <= 259 ? yytranslate[x] : 13)
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
76
static const short yyprhs[] = { 0,
77
0, 2, 5, 9, 12, 14, 16, 17, 18, 20,
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
90
static const short yyrline[] = { 0,
91
22, 24, 27, 30, 34, 37, 39, 42, 43, 44,
97
#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
99
static const char * const yytname[] = { "$","error","$undefined.","WORD","INT_NUMBER",
100
"COMMAND_SEPERATOR","'?'","','","statements","statement","command","arguments",
105
static const short yyr1[] = { 0,
106
8, 8, 9, 9, 10, 10, 10, 11, 11, 11,
110
static const short yyr2[] = { 0,
111
1, 2, 3, 2, 1, 1, 0, 0, 1, 3,
115
static const short yydefact[] = { 7,
116
5, 6, 7, 8, 2, 12, 13, 4, 8, 3,
120
static const short yydefgoto[] = { 5,
124
static const short yypact[] = { 1,
125
-32768,-32768, 0, 8,-32768,-32768,-32768, 4, -2,-32768,
126
8,-32768,-32768, 13, 14,-32768
129
static const short yypgoto[] = { 15,
130
-32768,-32768, -1,-32768
137
static const short yytable[] = { -1,
138
6, 7, 1, 1, 11, 2, 2, 12, 10, 13,
142
static const short yycheck[] = { 0,
143
3, 4, 3, 3, 7, 6, 6, 9, 5, 11,
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. */
150
/* Skeleton output parser for bison,
151
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
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)
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.
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. */
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. */
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. */
178
#ifndef YYSTACK_USE_ALLOCA
180
#define YYSTACK_USE_ALLOCA
181
#else /* alloca not defined */
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
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. */
198
#else /* not MSDOS, or __TURBOC__ */
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> */
204
#define YYSTACK_USE_ALLOCA
205
#else /* not MSDOS, or __TURBOC__, or _AIX */
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
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 */
220
#ifdef YYSTACK_USE_ALLOCA
221
#define YYSTACK_ALLOC alloca
223
#define YYSTACK_ALLOC malloc
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. */
230
#define yyerrok (yyerrstatus = 0)
231
#define yyclearin (yychar = YYEMPTY)
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) \
245
if (yychar == YYEMPTY && yylen == 1) \
246
{ yychar = (token), yylval = (value); \
247
yychar1 = YYTRANSLATE (yychar); \
252
{ yyerror ("syntax error: cannot back up"); YYERROR; } \
256
#define YYERRCODE 256
259
#define YYLEX yylex()
265
#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
267
#define YYLEX yylex(&yylval, &yylloc)
269
#else /* not YYLSP_NEEDED */
271
#define YYLEX yylex(&yylval, YYLEX_PARAM)
273
#define YYLEX yylex(&yylval)
275
#endif /* not YYLSP_NEEDED */
278
/* If nonreentrant, generate the variables here */
282
int yychar; /* the lookahead symbol */
283
YYSTYPE yylval; /* the semantic value of the */
284
/* lookahead symbol */
287
YYLTYPE yylloc; /* location data for the lookahead */
291
int yynerrs; /* number of parse errors so far */
292
#endif /* not YYPURE */
295
int yydebug; /* nonzero means print parse trace */
296
/* Since this is uninitialized, it does not stop multiple parsers
300
/* YYINITDEPTH indicates the initial size of the parser's stacks */
303
#define YYINITDEPTH 200
306
/* YYMAXDEPTH is the maximum size the stacks can grow to
307
(effective only if the built-in stack extension method is used). */
314
#define YYMAXDEPTH 10000
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. */
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++ */
327
/* This is the most reliable way to avoid incompatibilities
328
in available built-in functions on various systems. */
330
__yy_memcpy (to, from, count)
335
register char *f = from;
336
register char *t = to;
337
register int i = count;
343
#else /* __cplusplus */
345
/* This is the most reliable way to avoid incompatibilities
346
in available built-in functions on various systems. */
348
__yy_memcpy (char *to, char *from, unsigned int count)
350
register char *t = to;
351
register char *f = from;
352
register int i = count;
361
#line 217 "/usr/lib/bison.simple"
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. */
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 */
382
/* Prevent warning if -Wstrict-prototypes. */
385
int yyparse (void *);
392
yyparse(YYPARSE_PARAM_ARG)
395
register int yystate;
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 */
402
short yyssa[YYINITDEPTH]; /* the state stack */
403
YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
405
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
406
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
409
YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
410
YYLTYPE *yyls = yylsa;
413
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
415
#define YYPOPSTACK (yyvsp--, yyssp--)
418
int yystacksize = YYINITDEPTH;
419
int yyfree_stacks = 0;
430
YYSTYPE yyval; /* the variable used to return */
431
/* semantic values from the action */
438
fprintf(stderr, "Starting parse\n");
444
yychar = YYEMPTY; /* Cause a token to be read. */
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. */
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. */
464
if (yyssp >= yyss + yystacksize - 1)
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;
471
YYLTYPE *yyls1 = yyls;
474
/* Get the current used size of the three stacks, in elements. */
475
int size = yyssp - yyss + 1;
478
/* Each stack pointer address is followed by the size of
479
the data in use in that stack, in bytes. */
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),
489
yyoverflow("parser stack overflow",
490
&yyss1, size * sizeof (*yyssp),
491
&yyvs1, size * sizeof (*yyvsp),
495
yyss = yyss1; yyvs = yyvs1;
499
#else /* no yyoverflow */
500
/* Extend the stack our own way. */
501
if (yystacksize >= YYMAXDEPTH)
503
yyerror("parser stack overflow");
515
if (yystacksize > YYMAXDEPTH)
516
yystacksize = YYMAXDEPTH;
517
#ifndef YYSTACK_USE_ALLOCA
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));
527
yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
528
__yy_memcpy ((char *)yyls, (char *)yyls1,
529
size * (unsigned int) sizeof (*yylsp));
531
#endif /* no yyoverflow */
533
yyssp = yyss + size - 1;
534
yyvsp = yyvs + size - 1;
536
yylsp = yyls + size - 1;
541
fprintf(stderr, "Stack size increased to %d\n", yystacksize);
544
if (yyssp >= yyss + yystacksize - 1)
550
fprintf(stderr, "Entering state %d\n", yystate);
556
/* Do appropriate processing given the current state. */
557
/* Read a lookahead token if we need one and don't already have one. */
560
/* First try to decide what to do without reference to lookahead token. */
562
yyn = yypact[yystate];
566
/* Not known => get a lookahead token if don't already have one. */
568
/* yychar is either YYEMPTY or YYEOF
569
or a valid token in external form. */
571
if (yychar == YYEMPTY)
575
fprintf(stderr, "Reading a token: ");
580
/* Convert token to internal form (in yychar1) for indexing tables with */
582
if (yychar <= 0) /* This means end of input. */
585
yychar = YYEOF; /* Don't call YYLEX any more */
589
fprintf(stderr, "Now at end of input.\n");
594
yychar1 = YYTRANSLATE(yychar);
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. */
603
YYPRINT (stderr, yychar, yylval);
605
fprintf (stderr, ")\n");
611
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
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,
621
0, or most negative number => error. */
636
/* Shift the lookahead token. */
640
fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
643
/* Discard the token being shifted unless it is eof. */
652
/* count tokens shifted since error; after three, turn off error status. */
653
if (yyerrstatus) yyerrstatus--;
658
/* Do the default action for the current state. */
661
yyn = yydefact[yystate];
665
/* Do a reduction. yyn is the number of a rule to reduce with. */
669
yyval = yyvsp[1-yylen]; /* implement default value of the action */
676
fprintf (stderr, "Reducing via rule %d (line %d), ",
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]]);
691
{ gpparser_execute_command(command,args); gpparser_reinit_parser(); ;
695
{ gpparser_execute_command(command,args); gpparser_reinit_parser(); ;
699
{ if(debug)printf("parse: command\n"); strncpy(command,yytext,1024); ;
703
{ if(debug)printf("parse: command\n"); strncpy(command,"help",1024); ;
707
{ command[0] = '\0'; ;
711
{ if(debug)printf("parse: word\n"); add_argument(yytext); ;
715
{ if(debug)printf("parse: number\n"); add_argument(yytext); ;
718
/* the action file gets copied in in place of this dollarsign */
719
#line 543 "/usr/lib/bison.simple"
730
short *ssp1 = yyss - 1;
731
fprintf (stderr, "state stack now");
732
while (ssp1 != yyssp)
733
fprintf (stderr, " %d", *++ssp1);
734
fprintf (stderr, "\n");
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;
752
yylsp->last_line = (yylsp+yylen-1)->last_line;
753
yylsp->last_column = (yylsp+yylen-1)->last_column;
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. */
764
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
765
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
766
yystate = yytable[yystate];
768
yystate = yydefgoto[yyn - YYNTBASE];
772
yyerrlab: /* here on detecting error */
775
/* If not already recovering from an error, report this error. */
779
#ifdef YYERROR_VERBOSE
780
yyn = yypact[yystate];
782
if (yyn > YYFLAG && yyn < YYLAST)
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);
797
strcpy(msg, "parse error");
802
for (x = (yyn < 0 ? -yyn : 0);
803
x < (sizeof(yytname) / sizeof(char *)); x++)
804
if (yycheck[x + yyn] == x)
806
strcat(msg, count == 0 ? ", expecting `" : " or `");
807
strcat(msg, yytname[x]);
816
yyerror ("parse error; also virtual memory exceeded");
819
#endif /* YYERROR_VERBOSE */
820
yyerror("parse error");
824
yyerrlab1: /* here on error raised explicitly by an action */
826
if (yyerrstatus == 3)
828
/* if just tried and failed to reuse lookahead token after an error, discard it. */
830
/* return failure if at end of input */
836
fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
842
/* Else will try to reuse lookahead token
843
after shifting the error token. */
845
yyerrstatus = 3; /* Each real token shifted decrements this */
849
yyerrdefault: /* current state does not do anything special for the error token. */
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;
858
yyerrpop: /* pop the current state because it cannot handle the error token */
860
if (yyssp == yyss) YYABORT;
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");
880
yyn = yypact[yystate];
885
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
904
fprintf(stderr, "Shifting error token, ");
916
/* YYACCEPT comes here. */
928
/* YYABORT comes here. */
944
printf("parser error: %s\n",s);
947
void init_parser(void)
949
args = g_list_alloc();
952
void arg_reaper(gpointer data, gpointer nothing)
957
void cleanup_parser(void)
959
g_list_foreach(args,arg_reaper,NULL);
963
void add_argument(const char*arg)
965
char *s = g_strdup(arg);
966
g_list_append(args,s);