gst/parse/: Update the prebuild parser sources.
[platform/upstream/gstreamer.git] / gst / parse / grammar.tab.pre.c
1 #ifdef HAVE_CONFIG_H
2 #include <config.h>
3 #endif
4 /* A Bison parser, made by GNU Bison 2.3.  */
5
6 /* Skeleton implementation for Bison's Yacc-like parsers in C
7
8    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
9    Free Software Foundation, Inc.
10
11    This program is free software; you can redistribute it and/or modify
12    it under the terms of the GNU General Public License as published by
13    the Free Software Foundation; either version 2, or (at your option)
14    any later version.
15
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19    GNU General Public License for more details.
20
21    You should have received a copy of the GNU General Public License
22    along with this program; if not, write to the Free Software
23    Foundation, Inc., 51 Franklin Street, Fifth Floor,
24    Boston, MA 02110-1301, USA.  */
25
26 /* As a special exception, you may create a larger work that contains
27    part or all of the Bison parser skeleton and distribute that work
28    under terms of your choice, so long as that work isn't itself a
29    parser generator using the skeleton or a modified version thereof
30    as a parser skeleton.  Alternatively, if you modify or redistribute
31    the parser skeleton itself, you may (at your option) remove this
32    special exception, which will cause the skeleton and the resulting
33    Bison output files to be licensed under the GNU General Public
34    License without this special exception.
35
36    This special exception was added by the Free Software Foundation in
37    version 2.2 of Bison.  */
38
39 /* C LALR(1) parser skeleton written by Richard Stallman, by
40    simplifying the original so-called "semantic" parser.  */
41
42 /* All symbols defined below should begin with yy or YY, to avoid
43    infringing on user name space.  This should be done even for local
44    variables, as they might otherwise be expanded by user macros.
45    There are some unavoidable exceptions within include files to
46    define necessary library symbols; they are noted "INFRINGES ON
47    USER NAME SPACE" below.  */
48
49 /* Identify Bison output.  */
50 #define YYBISON 1
51
52 /* Bison version.  */
53 #define YYBISON_VERSION "2.3"
54
55 /* Skeleton name.  */
56 #define YYSKELETON_NAME "yacc.c"
57
58 /* Pure parsers.  */
59 #define YYPURE 1
60
61 /* Using locations.  */
62 #define YYLSP_NEEDED 0
63
64 /* Substitute the variable and function names.  */
65 #define yyparse _gst_parse_yyparse
66 #define yylex   _gst_parse_yylex
67 #define yyerror _gst_parse_yyerror
68 #define yylval  _gst_parse_yylval
69 #define yychar  _gst_parse_yychar
70 #define yydebug _gst_parse_yydebug
71 #define yynerrs _gst_parse_yynerrs
72
73
74 /* Tokens.  */
75 #ifndef YYTOKENTYPE
76 # define YYTOKENTYPE
77    /* Put the tokens into the symbol table, so that GDB and other debuggers
78       know about them.  */
79 enum yytokentype
80 {
81   PARSE_URL = 258,
82   IDENTIFIER = 259,
83   BINREF = 260,
84   PADREF = 261,
85   REF = 262,
86   ASSIGNMENT = 263,
87   LINK = 264
88 };
89 #endif
90 /* Tokens.  */
91 #define PARSE_URL 258
92 #define IDENTIFIER 259
93 #define BINREF 260
94 #define PADREF 261
95 #define REF 262
96 #define ASSIGNMENT 263
97 #define LINK 264
98
99
100
101
102 /* Copy the first part of user declarations.  */
103 #line 1 "./grammar.y"
104
105 #include <glib-object.h>
106 #include <glib.h>
107 #include <stdio.h>
108 #include <string.h>
109 #include <stdlib.h>
110
111 #include "../gst_private.h"
112 #include "../gst-i18n-lib.h"
113
114 #include "../gstconfig.h"
115 #include "../gstparse.h"
116 #include "../gstinfo.h"
117 #include "../gsterror.h"
118 #include "../gsturi.h"
119 #include "../gstutils.h"
120 #include "../gstvalue.h"
121 #include "../gstchildproxy.h"
122 #include "types.h"
123
124 /* All error messages in this file are user-visible and need to be translated.
125  * Don't start the message with a capital, and don't end them with a period,
126  * as they will be presented inside a sentence/error.
127  */
128
129 #define YYERROR_VERBOSE 1
130 #define YYLEX_PARAM scanner
131
132 typedef void *yyscan_t;
133
134 int _gst_parse_yylex (void *yylval_param, yyscan_t yyscanner);
135 int _gst_parse_yylex_init (yyscan_t scanner);
136 int _gst_parse_yylex_destroy (yyscan_t scanner);
137 struct yy_buffer_state *_gst_parse_yy_scan_string (char *, yyscan_t);
138 void _gst_parse_yypush_buffer_state (void *new_buffer, yyscan_t yyscanner);
139 void _gst_parse_yypop_buffer_state (yyscan_t yyscanner);
140
141
142 #ifdef __GST_PARSE_TRACE
143 static guint __strings;
144 static guint __links;
145 static guint __chains;
146 gchar *
147 __gst_parse_strdup (gchar * org)
148 {
149   gchar *ret;
150
151   __strings++;
152   ret = g_strdup (org);
153   /* g_print ("ALLOCATED STR   (%3u): %p %s\n", __strings, ret, ret); */
154   return ret;
155 }
156
157 void
158 __gst_parse_strfree (gchar * str)
159 {
160   if (str) {
161     /* g_print ("FREEING STR     (%3u): %p %s\n", __strings - 1, str, str); */
162     g_free (str);
163     g_return_if_fail (__strings > 0);
164     __strings--;
165   }
166 }
167 link_t *
168 __gst_parse_link_new ()
169 {
170   link_t *ret;
171
172   __links++;
173   ret = g_new0 (link_t, 1);
174   /* g_print ("ALLOCATED LINK  (%3u): %p\n", __links, ret); */
175   return ret;
176 }
177
178 void
179 __gst_parse_link_free (link_t * data)
180 {
181   if (data) {
182     /* g_print ("FREEING LINK    (%3u): %p\n", __links - 1, data); */
183     g_free (data);
184     g_return_if_fail (__links > 0);
185     __links--;
186   }
187 }
188 chain_t *
189 __gst_parse_chain_new ()
190 {
191   chain_t *ret;
192
193   __chains++;
194   ret = g_new0 (chain_t, 1);
195   /* g_print ("ALLOCATED CHAIN (%3u): %p\n", __chains, ret); */
196   return ret;
197 }
198
199 void
200 __gst_parse_chain_free (chain_t * data)
201 {
202   /* g_print ("FREEING CHAIN   (%3u): %p\n", __chains - 1, data); */
203   g_free (data);
204   g_return_if_fail (__chains > 0);
205   __chains--;
206 }
207
208 #endif /* __GST_PARSE_TRACE */
209
210 typedef struct
211 {
212   gchar *src_pad;
213   gchar *sink_pad;
214   GstElement *sink;
215   GstCaps *caps;
216   gulong signal_id;
217   /* FIXME: need to connect to "disposed" signal to clean up,
218    * but there is no such signal */
219 } DelayedLink;
220
221 /*** define SET_ERROR and ERROR macros/functions */
222
223 #ifdef G_HAVE_ISO_VARARGS
224
225 #  define SET_ERROR(error, type, ...) \
226 G_STMT_START { \
227   GST_CAT_ERROR (GST_CAT_PIPELINE, __VA_ARGS__); \
228   if ((error) && !*(error)) { \
229     g_set_error ((error), GST_PARSE_ERROR, (type), __VA_ARGS__); \
230   } \
231 } G_STMT_END
232
233 #  define ERROR(type, ...) \
234   SET_ERROR (((graph_t *) graph)->error, (type), __VA_ARGS__ )
235
236 #elif defined(G_HAVE_GNUC_VARARGS)
237
238 #  define SET_ERROR(error, type, args...) \
239 G_STMT_START { \
240   GST_CAT_ERROR (GST_CAT_PIPELINE, args ); \
241   if ((error) && !*(error)) { \
242     g_set_error ((error), GST_PARSE_ERROR, (type), args ); \
243   } \
244 } G_STMT_END
245
246 #  define ERROR(type, args...) \
247   SET_ERROR (((graph_t *) graph)->error,(type) , args )
248
249 #else
250
251 static inline void
252 SET_ERROR (GError ** error, gint type, const char *format, ...)
253 {
254   if (error) {
255     if (*error) {
256       g_warning ("error while parsing");
257     } else {
258       va_list varargs;
259       char *string;
260
261       va_start (varargs, format);
262       string = g_strdup_vprintf (format, varargs);
263       va_end (varargs);
264
265       g_set_error (error, GST_PARSE_ERROR, type, string);
266
267       g_free (string);
268     }
269   }
270 }
271
272 #endif /* G_HAVE_ISO_VARARGS */
273
274 /*** define YYPRINTF macro/function if we're debugging */
275
276 /* bison 1.35 calls this macro with side effects, we need to make sure the
277    side effects work - crappy bison */
278
279 #ifndef GST_DISABLE_GST_DEBUG
280 #  define YYDEBUG 1
281
282 #  ifdef G_HAVE_ISO_VARARGS
283
284 /* #  define YYFPRINTF(a, ...) GST_CAT_DEBUG (GST_CAT_PIPELINE, __VA_ARGS__) */
285 #    define YYFPRINTF(a, ...) \
286 G_STMT_START { \
287      gchar *temp = g_strdup_printf (__VA_ARGS__); \
288      GST_CAT_LOG (GST_CAT_PIPELINE, temp); \
289      g_free (temp); \
290 } G_STMT_END
291
292 #  elif defined(G_HAVE_GNUC_VARARGS)
293
294 #    define YYFPRINTF(a, args...) \
295 G_STMT_START { \
296      gchar *temp = g_strdup_printf ( args ); \
297      GST_CAT_LOG (GST_CAT_PIPELINE, temp); \
298      g_free (temp); \
299 } G_STMT_END
300
301 #  else
302
303 static inline void
304 YYPRINTF (const char *format, ...)
305 {
306   va_list varargs;
307   gchar *temp;
308
309   va_start (varargs, format);
310   temp = g_strdup_vprintf (format, varargs);
311   GST_CAT_LOG (GST_CAT_PIPELINE, "%s", temp);
312   g_free (temp);
313   va_end (varargs);
314 }
315
316 #  endif /* G_HAVE_ISO_VARARGS */
317
318 #endif /* GST_DISABLE_GST_DEBUG */
319
320 #define GST_BIN_MAKE(res, type, chainval, assign, free_string) \
321 G_STMT_START { \
322   chain_t *chain = chainval; \
323   GSList *walk; \
324   GstBin *bin = (GstBin *) gst_element_factory_make (type, NULL); \
325   if (!chain) { \
326     SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_EMPTY_BIN, \
327         _("specified empty bin \"%s\", not allowed"), type); \
328     g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
329     g_slist_free (assign); \
330     gst_object_unref (bin); \
331     if (free_string) \
332       gst_parse_strfree (type); /* Need to clean up the string */ \
333     YYERROR; \
334   } else if (!bin) { \
335     SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, \
336         _("no bin \"%s\", skipping"), type); \
337     g_slist_foreach (assign, (GFunc) gst_parse_strfree, NULL); \
338     g_slist_free (assign); \
339     res = chain; \
340   } else { \
341     for (walk = chain->elements; walk; walk = walk->next ) \
342       gst_bin_add (bin, GST_ELEMENT (walk->data)); \
343     g_slist_free (chain->elements); \
344     chain->elements = g_slist_prepend (NULL, bin); \
345     res = chain; \
346     /* set the properties now */ \
347     for (walk = assign; walk; walk = walk->next) \
348       gst_parse_element_set ((gchar *) walk->data, GST_ELEMENT (bin), graph); \
349     g_slist_free (assign); \
350   } \
351 } G_STMT_END
352
353 #define MAKE_LINK(link, _src, _src_name, _src_pads, _sink, _sink_name, _sink_pads) \
354 G_STMT_START { \
355   link = gst_parse_link_new (); \
356   link->src = _src; \
357   link->sink = _sink; \
358   link->src_name = _src_name; \
359   link->sink_name = _sink_name; \
360   link->src_pads = _src_pads; \
361   link->sink_pads = _sink_pads; \
362   link->caps = NULL; \
363 } G_STMT_END
364
365 #define MAKE_REF(link, _src, _pads) \
366 G_STMT_START { \
367   gchar *padname = _src; \
368   GSList *pads = _pads; \
369   if (padname) { \
370     while (*padname != '.') padname++; \
371     *padname = '\0'; \
372     padname++; \
373     if (*padname != '\0') \
374       pads = g_slist_prepend (pads, gst_parse_strdup (padname)); \
375   } \
376   MAKE_LINK (link, NULL, _src, pads, NULL, NULL, NULL); \
377 } G_STMT_END
378
379 static void
380 gst_parse_element_set (gchar * value, GstElement * element, graph_t * graph)
381 {
382   GParamSpec *pspec;
383   gchar *pos = value;
384   GValue v = { 0, };
385   GstObject *target;
386   GType value_type;
387
388   /* parse the string, so the property name is null-terminated an pos points
389      to the beginning of the value */
390   while (!g_ascii_isspace (*pos) && (*pos != '='))
391     pos++;
392   if (*pos == '=') {
393     *pos = '\0';
394   } else {
395     *pos = '\0';
396     pos++;
397     while (g_ascii_isspace (*pos))
398       pos++;
399   }
400   pos++;
401   while (g_ascii_isspace (*pos))
402     pos++;
403   if (*pos == '"') {
404     pos++;
405     pos[strlen (pos) - 1] = '\0';
406   }
407   gst_parse_unescape (pos);
408
409   if (gst_child_proxy_lookup (GST_OBJECT (element), value, &target, &pspec)) {
410     value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
411     GST_CAT_LOG (GST_CAT_PIPELINE, "parsing property %s as a %s", pspec->name,
412         g_type_name (value_type));
413     g_value_init (&v, value_type);
414     if (!gst_value_deserialize (&v, pos))
415       goto error;
416     g_object_set_property (G_OBJECT (target), pspec->name, &v);
417     gst_object_unref (target);
418   } else {
419     SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_PROPERTY,
420         _("no property \"%s\" in element \"%s\""), value,
421         GST_ELEMENT_NAME (element));
422   }
423
424 out:
425   gst_parse_strfree (value);
426   if (G_IS_VALUE (&v))
427     g_value_unset (&v);
428   return;
429
430 error:
431   gst_object_unref (target);
432   SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
433       _("could not set property \"%s\" in element \"%s\" to \"%s\""),
434       value, GST_ELEMENT_NAME (element), pos);
435   goto out;
436 }
437 static inline void
438 gst_parse_free_link (link_t * link)
439 {
440   gst_parse_strfree (link->src_name);
441   gst_parse_strfree (link->sink_name);
442   g_slist_foreach (link->src_pads, (GFunc) gst_parse_strfree, NULL);
443   g_slist_foreach (link->sink_pads, (GFunc) gst_parse_strfree, NULL);
444   g_slist_free (link->src_pads);
445   g_slist_free (link->sink_pads);
446   if (link->caps)
447     gst_caps_unref (link->caps);
448   gst_parse_link_free (link);
449 }
450
451 static void
452 gst_parse_found_pad (GstElement * src, GstPad * pad, gpointer data)
453 {
454   DelayedLink *link = (DelayedLink *) data;
455
456   GST_CAT_INFO (GST_CAT_PIPELINE, "trying delayed linking %s:%s to %s:%s",
457       GST_STR_NULL (GST_ELEMENT_NAME (src)), GST_STR_NULL (link->src_pad),
458       GST_STR_NULL (GST_ELEMENT_NAME (link->sink)),
459       GST_STR_NULL (link->sink_pad));
460
461   if (gst_element_link_pads_filtered (src, link->src_pad, link->sink,
462           link->sink_pad, link->caps)) {
463     /* do this here, we don't want to get any problems later on when
464      * unlocking states */
465     GST_CAT_DEBUG (GST_CAT_PIPELINE, "delayed linking %s:%s to %s:%s worked",
466         GST_STR_NULL (GST_ELEMENT_NAME (src)), GST_STR_NULL (link->src_pad),
467         GST_STR_NULL (GST_ELEMENT_NAME (link->sink)),
468         GST_STR_NULL (link->sink_pad));
469     g_signal_handler_disconnect (src, link->signal_id);
470     g_free (link->src_pad);
471     g_free (link->sink_pad);
472     if (link->caps)
473       gst_caps_unref (link->caps);
474     g_free (link);
475   }
476 }
477
478 /* both padnames and the caps may be NULL */
479 static gboolean
480 gst_parse_perform_delayed_link (GstElement * src, const gchar * src_pad,
481     GstElement * sink, const gchar * sink_pad, GstCaps * caps)
482 {
483   GList *templs =
484       gst_element_class_get_pad_template_list (GST_ELEMENT_GET_CLASS (src));
485
486   for (; templs; templs = templs->next) {
487     GstPadTemplate *templ = (GstPadTemplate *) templs->data;
488
489     if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) &&
490         (GST_PAD_TEMPLATE_PRESENCE (templ) == GST_PAD_SOMETIMES)) {
491       DelayedLink *data = g_new (DelayedLink, 1);
492
493       /* TODO: maybe we should check if src_pad matches this template's names */
494
495       GST_CAT_DEBUG (GST_CAT_PIPELINE, "trying delayed link %s:%s to %s:%s",
496           GST_STR_NULL (GST_ELEMENT_NAME (src)), GST_STR_NULL (src_pad),
497           GST_STR_NULL (GST_ELEMENT_NAME (sink)), GST_STR_NULL (sink_pad));
498
499       data->src_pad = g_strdup (src_pad);
500       data->sink = sink;
501       data->sink_pad = g_strdup (sink_pad);
502       if (caps) {
503         data->caps = gst_caps_copy (caps);
504       } else {
505         data->caps = NULL;
506       }
507       data->signal_id = g_signal_connect (G_OBJECT (src), "pad-added",
508           G_CALLBACK (gst_parse_found_pad), data);
509       return TRUE;
510     }
511   }
512   return FALSE;
513 }
514
515 /*
516  * performs a link and frees the struct. src and sink elements must be given
517  * return values   0 - link performed
518  *                 1 - link delayed
519  *                <0 - error
520  */
521 static gint
522 gst_parse_perform_link (link_t * link, graph_t * graph)
523 {
524   GstElement *src = link->src;
525   GstElement *sink = link->sink;
526   GSList *srcs = link->src_pads;
527   GSList *sinks = link->sink_pads;
528
529   g_assert (GST_IS_ELEMENT (src));
530   g_assert (GST_IS_ELEMENT (sink));
531
532   GST_CAT_INFO (GST_CAT_PIPELINE,
533       "linking %s:%s to %s:%s (%u/%u) with caps \"%" GST_PTR_FORMAT "\"",
534       GST_ELEMENT_NAME (src), link->src_name ? link->src_name : "(any)",
535       GST_ELEMENT_NAME (sink), link->sink_name ? link->sink_name : "(any)",
536       g_slist_length (srcs), g_slist_length (sinks), link->caps);
537
538   if (!srcs || !sinks) {
539     if (gst_element_link_pads_filtered (src,
540             srcs ? (const gchar *) srcs->data : NULL, sink,
541             sinks ? (const gchar *) sinks->data : NULL, link->caps)) {
542       goto success;
543     } else {
544       if (gst_parse_perform_delayed_link (src,
545               srcs ? (const gchar *) srcs->data : NULL,
546               sink, sinks ? (const gchar *) sinks->data : NULL, link->caps)) {
547         goto success;
548       } else {
549         goto error;
550       }
551     }
552   }
553   if (g_slist_length (link->src_pads) != g_slist_length (link->src_pads)) {
554     goto error;
555   }
556   while (srcs && sinks) {
557     const gchar *src_pad = (const gchar *) srcs->data;
558     const gchar *sink_pad = (const gchar *) sinks->data;
559
560     srcs = g_slist_next (srcs);
561     sinks = g_slist_next (sinks);
562     if (gst_element_link_pads_filtered (src, src_pad, sink, sink_pad,
563             link->caps)) {
564       continue;
565     } else {
566       if (gst_parse_perform_delayed_link (src, src_pad,
567               sink, sink_pad, link->caps)) {
568         continue;
569       } else {
570         goto error;
571       }
572     }
573   }
574
575 success:
576   gst_parse_free_link (link);
577   return 0;
578
579 error:
580   SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
581       _("could not link %s to %s"), GST_ELEMENT_NAME (src),
582       GST_ELEMENT_NAME (sink));
583   gst_parse_free_link (link);
584   return -1;
585 }
586
587
588 static int yyerror (void *scanner, graph_t * graph, const char *s);
589
590
591 /* Enabling traces.  */
592 #ifndef YYDEBUG
593 # define YYDEBUG 0
594 #endif
595
596 /* Enabling verbose error messages.  */
597 #ifdef YYERROR_VERBOSE
598 # undef YYERROR_VERBOSE
599 # define YYERROR_VERBOSE 1
600 #else
601 # define YYERROR_VERBOSE 0
602 #endif
603
604 /* Enabling the token table.  */
605 #ifndef YYTOKEN_TABLE
606 # define YYTOKEN_TABLE 0
607 #endif
608
609 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
610 typedef union YYSTYPE
611 #line 471 "./grammar.y"
612 {
613   gchar *s;
614   chain_t *c;
615   link_t *l;
616   GstElement *e;
617   GSList *p;
618   graph_t *g;
619 }
620 /* Line 187 of yacc.c.  */
621 #line 601 "grammar.tab.c"
622 YYSTYPE;
623
624 # define yystype YYSTYPE        /* obsolescent; will be withdrawn */
625 # define YYSTYPE_IS_DECLARED 1
626 # define YYSTYPE_IS_TRIVIAL 1
627 #endif
628
629
630
631 /* Copy the second part of user declarations.  */
632
633
634 /* Line 216 of yacc.c.  */
635 #line 614 "grammar.tab.c"
636
637 #ifdef short
638 # undef short
639 #endif
640
641 #ifdef YYTYPE_UINT8
642 typedef YYTYPE_UINT8 yytype_uint8;
643 #else
644 typedef unsigned char yytype_uint8;
645 #endif
646
647 #ifdef YYTYPE_INT8
648 typedef YYTYPE_INT8 yytype_int8;
649 #elif (defined __STDC__ || defined __C99__FUNC__ \
650      || defined __cplusplus || defined _MSC_VER)
651 typedef signed char yytype_int8;
652 #else
653 typedef short int yytype_int8;
654 #endif
655
656 #ifdef YYTYPE_UINT16
657 typedef YYTYPE_UINT16 yytype_uint16;
658 #else
659 typedef unsigned short int yytype_uint16;
660 #endif
661
662 #ifdef YYTYPE_INT16
663 typedef YYTYPE_INT16 yytype_int16;
664 #else
665 typedef short int yytype_int16;
666 #endif
667
668 #ifndef YYSIZE_T
669 # ifdef __SIZE_TYPE__
670 #  define YYSIZE_T __SIZE_TYPE__
671 # elif defined size_t
672 #  define YYSIZE_T size_t
673 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
674      || defined __cplusplus || defined _MSC_VER)
675 #  include <stddef.h>           /* INFRINGES ON USER NAME SPACE */
676 #  define YYSIZE_T size_t
677 # else
678 #  define YYSIZE_T unsigned int
679 # endif
680 #endif
681
682 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
683
684 #ifndef YY_
685 # if YYENABLE_NLS
686 #  if ENABLE_NLS
687 #   include <libintl.h>         /* INFRINGES ON USER NAME SPACE */
688 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
689 #  endif
690 # endif
691 # ifndef YY_
692 #  define YY_(msgid) msgid
693 # endif
694 #endif
695
696 /* Suppress unused-variable warnings by "using" E.  */
697 #if ! defined lint || defined __GNUC__
698 # define YYUSE(e) ((void) (e))
699 #else
700 # define YYUSE(e)               /* empty */
701 #endif
702
703 /* Identity function, used to suppress warnings about constant conditions.  */
704 #ifndef lint
705 # define YYID(n) (n)
706 #else
707 #if (defined __STDC__ || defined __C99__FUNC__ \
708      || defined __cplusplus || defined _MSC_VER)
709 static int
710 YYID (int i)
711 #else
712 static int
713 YYID (i)
714      int i;
715 #endif
716 {
717   return i;
718 }
719 #endif
720
721 #if ! defined yyoverflow || YYERROR_VERBOSE
722
723 /* The parser invokes alloca or malloc; define the necessary symbols.  */
724
725 # ifdef YYSTACK_USE_ALLOCA
726 #  if YYSTACK_USE_ALLOCA
727 #   ifdef __GNUC__
728 #    define YYSTACK_ALLOC __builtin_alloca
729 #   elif defined __BUILTIN_VA_ARG_INCR
730 #    include <alloca.h>         /* INFRINGES ON USER NAME SPACE */
731 #   elif defined _AIX
732 #    define YYSTACK_ALLOC __alloca
733 #   elif defined _MSC_VER
734 #    include <malloc.h>         /* INFRINGES ON USER NAME SPACE */
735 #    define alloca _alloca
736 #   else
737 #    define YYSTACK_ALLOC alloca
738 #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
739      || defined __cplusplus || defined _MSC_VER)
740 #     include <stdlib.h>        /* INFRINGES ON USER NAME SPACE */
741 #     ifndef _STDLIB_H
742 #      define _STDLIB_H 1
743 #     endif
744 #    endif
745 #   endif
746 #  endif
747 # endif
748
749 # ifdef YYSTACK_ALLOC
750    /* Pacify GCC's `empty if-body' warning.  */
751 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
752 #  ifndef YYSTACK_ALLOC_MAXIMUM
753     /* The OS might guarantee only one guard page at the bottom of the stack,
754        and a page size can be as small as 4096 bytes.  So we cannot safely
755        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
756        to allow for a few compiler-allocated temporary stack slots.  */
757 #   define YYSTACK_ALLOC_MAXIMUM 4032   /* reasonable circa 2006 */
758 #  endif
759 # else
760 #  define YYSTACK_ALLOC YYMALLOC
761 #  define YYSTACK_FREE YYFREE
762 #  ifndef YYSTACK_ALLOC_MAXIMUM
763 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
764 #  endif
765 #  if (defined __cplusplus && ! defined _STDLIB_H \
766        && ! ((defined YYMALLOC || defined malloc) \
767              && (defined YYFREE || defined free)))
768 #   include <stdlib.h>          /* INFRINGES ON USER NAME SPACE */
769 #   ifndef _STDLIB_H
770 #    define _STDLIB_H 1
771 #   endif
772 #  endif
773 #  ifndef YYMALLOC
774 #   define YYMALLOC malloc
775 #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
776      || defined __cplusplus || defined _MSC_VER)
777 void *malloc (YYSIZE_T);        /* INFRINGES ON USER NAME SPACE */
778 #   endif
779 #  endif
780 #  ifndef YYFREE
781 #   define YYFREE free
782 #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
783      || defined __cplusplus || defined _MSC_VER)
784 void free (void *);             /* INFRINGES ON USER NAME SPACE */
785 #   endif
786 #  endif
787 # endif
788 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
789
790
791 #if (! defined yyoverflow \
792      && (! defined __cplusplus \
793          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
794
795 /* A type that is properly aligned for any stack member.  */
796 union yyalloc
797 {
798   yytype_int16 yyss;
799   YYSTYPE yyvs;
800 };
801
802 /* The size of the maximum gap between one aligned stack and the next.  */
803 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
804
805 /* The size of an array large to enough to hold all stacks, each with
806    N elements.  */
807 # define YYSTACK_BYTES(N) \
808      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
809       + YYSTACK_GAP_MAXIMUM)
810
811 /* Copy COUNT objects from FROM to TO.  The source and destination do
812    not overlap.  */
813 # ifndef YYCOPY
814 #  if defined __GNUC__ && 1 < __GNUC__
815 #   define YYCOPY(To, From, Count) \
816       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
817 #  else
818 #   define YYCOPY(To, From, Count)              \
819       do                                        \
820         {                                       \
821           YYSIZE_T yyi;                         \
822           for (yyi = 0; yyi < (Count); yyi++)   \
823             (To)[yyi] = (From)[yyi];            \
824         }                                       \
825       while (YYID (0))
826 #  endif
827 # endif
828
829 /* Relocate STACK from its old location to the new one.  The
830    local variables YYSIZE and YYSTACKSIZE give the old and new number of
831    elements in the stack, and YYPTR gives the new location of the
832    stack.  Advance YYPTR to a properly aligned location for the next
833    stack.  */
834 # define YYSTACK_RELOCATE(Stack)                                        \
835     do                                                                  \
836       {                                                                 \
837         YYSIZE_T yynewbytes;                                            \
838         YYCOPY (&yyptr->Stack, Stack, yysize);                          \
839         Stack = &yyptr->Stack;                                          \
840         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
841         yyptr += yynewbytes / sizeof (*yyptr);                          \
842       }                                                                 \
843     while (YYID (0))
844
845 #endif
846
847 /* YYFINAL -- State number of the termination state.  */
848 #define YYFINAL  29
849 /* YYLAST -- Last index in YYTABLE.  */
850 #define YYLAST   176
851
852 /* YYNTOKENS -- Number of terminals.  */
853 #define YYNTOKENS  16
854 /* YYNNTS -- Number of nonterminals.  */
855 #define YYNNTS  12
856 /* YYNRULES -- Number of rules.  */
857 #define YYNRULES  32
858 /* YYNRULES -- Number of states.  */
859 #define YYNSTATES  43
860
861 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
862 #define YYUNDEFTOK  2
863 #define YYMAXUTOK   264
864
865 #define YYTRANSLATE(YYX)                                                \
866   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
867
868 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
869 static const yytype_uint8 yytranslate[] = {
870   0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
871   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
872   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
873   2, 2, 2, 14, 2, 2, 2, 2, 2, 2,
874   10, 11, 2, 2, 12, 2, 13, 2, 2, 2,
875   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
876   2, 15, 2, 2, 2, 2, 2, 2, 2, 2,
877   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
878   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
879   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
880   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
881   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
882   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
883   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
884   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
885   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
886   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
887   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
888   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
889   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
890   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
891   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
892   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
893   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
894   2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
895   2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
896   5, 6, 7, 8, 9
897 };
898
899 #if YYDEBUG
900 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
901    YYRHS.  */
902 static const yytype_uint8 yyprhs[] = {
903   0, 0, 3, 5, 8, 9, 12, 17, 22, 26,
904   31, 33, 36, 39, 43, 45, 48, 50, 52, 53,
905   57, 59, 62, 65, 67, 69, 72, 75, 78, 81,
906   84, 87, 88
907 };
908
909 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
910 static const yytype_int8 yyrhs[] = {
911   27, 0, -1, 4, -1, 17, 8, -1, -1, 18,
912   8, -1, 10, 18, 26, 11, -1, 5, 18, 26,
913   11, -1, 5, 18, 11, -1, 5, 18, 1, 11,
914   -1, 6, -1, 6, 21, -1, 12, 4, -1, 12,
915   4, 21, -1, 7, -1, 7, 21, -1, 22, -1,
916   20, -1, -1, 23, 9, 23, -1, 24, -1, 24,
917   25, -1, 25, 1, -1, 17, -1, 19, -1, 26,
918   26, -1, 26, 25, -1, 26, 1, -1, 24, 26,
919   -1, 3, 26, -1, 24, 3, -1, -1, 26, -1
920 };
921
922 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
923 static const yytype_uint16 yyrline[] = {
924   0, 506, 506, 514, 518, 519, 521, 522, 525, 528,
925   533, 534, 538, 539, 542, 543, 546, 547, 548, 551,
926   564, 565, 566, 569, 574, 575, 610, 638, 639, 653,
927   673, 698, 701
928 };
929 #endif
930
931 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
932 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
933    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
934 static const char *const yytname[] = {
935   "$end", "error", "$undefined", "PARSE_URL", "IDENTIFIER", "BINREF",
936   "PADREF", "REF", "ASSIGNMENT", "LINK", "'('", "')'", "','", "'.'", "'!'",
937   "'='", "$accept", "element", "assignments", "bin", "pads", "padlist",
938   "reference", "linkpart", "link", "linklist", "chain", "graph", 0
939 };
940 #endif
941
942 # ifdef YYPRINT
943 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
944    token YYLEX-NUM.  */
945 static const yytype_uint16 yytoknum[] = {
946   0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
947   40, 41, 44, 46, 33, 61
948 };
949 # endif
950
951 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
952 static const yytype_uint8 yyr1[] = {
953   0, 16, 17, 17, 18, 18, 19, 19, 19, 19,
954   20, 20, 21, 21, 22, 22, 23, 23, 23, 24,
955   25, 25, 25, 26, 26, 26, 26, 26, 26, 26,
956   26, 27, 27
957 };
958
959 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
960 static const yytype_uint8 yyr2[] = {
961   0, 2, 1, 2, 0, 2, 4, 4, 3, 4,
962   1, 2, 2, 3, 1, 2, 1, 1, 0, 3,
963   1, 2, 2, 1, 1, 2, 2, 2, 2, 2,
964   2, 0, 1
965 };
966
967 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
968    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
969    means the default is an error.  */
970 static const yytype_uint8 yydefact[] = {
971   18, 18, 2, 4, 10, 14, 4, 23, 24, 17,
972   16, 0, 18, 0, 0, 0, 0, 0, 11, 15,
973   18, 3, 18, 30, 0, 27, 20, 0, 0, 1,
974   0, 5, 8, 0, 12, 0, 19, 0, 22, 9,
975   7, 13, 6
976 };
977
978 /* YYDEFGOTO[NTERM-NUM].  */
979 static const yytype_int8 yydefgoto[] = {
980   -1, 7, 16, 8, 9, 18, 10, 11, 26, 27,
981   28, 14
982 };
983
984 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
985    STATE-NUM.  */
986 #define YYPACT_NINF -6
987 static const yytype_int16 yypact[] = {
988   134, 158, -6, -6, -1, -1, -6, 6, -6, -6,
989   -6, 7, 166, 101, 18, 30, 89, 16, -6, -6,
990   2, -6, 129, 142, 42, -6, 150, 54, 66, -6,
991   11, -6, -6, 111, -1, 122, -6, 78, -6, -6,
992   -6, -6, -6
993 };
994
995 /* YYPGOTO[NTERM-NUM].  */
996 static const yytype_int8 yypgoto[] = {
997   -6, -6, 19, -6, -6, -5, -6, 10, 3, 12,
998   1, -6
999 };
1000
1001 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
1002    positive, shift that token.  If negative, reduce the rule which
1003    number is the opposite.  If zero, do what YYDEFACT says.
1004    If YYTABLE_NINF, syntax error.  */
1005 #define YYTABLE_NINF -33
1006 static const yytype_int8 yytable[] = {
1007   19, 13, 15, 12, 12, 1, 2, 3, 4, 5,
1008   31, 17, 6, 24, 21, 12, 22, 33, 29, 12,
1009   34, 35, 39, 12, 15, 20, 12, 24, 0, 41,
1010   -29, 25, 36, 1, 2, 3, 4, 5, 37, -18,
1011   6, -29, -28, 25, 0, 1, 2, 3, 4, 5,
1012   0, -18, 6, -28, -26, 38, 0, -26, -26, -26,
1013   -26, -26, 0, -26, -26, -26, -25, 25, 0, 1,
1014   2, 3, 4, 5, 0, -18, 6, -25, -21, 38,
1015   0, -21, -21, -21, -21, -21, 0, -21, -21, -21,
1016   30, 0, 1, 2, 3, 4, 5, 31, -18, 6,
1017   32, -32, 25, 0, 1, 2, 3, 4, 5, 0,
1018   -18, 6, 25, 0, 1, 2, 3, 4, 5, 0,
1019   -18, 6, 40, 25, 0, 1, 2, 3, 4, 5,
1020   0, -18, 6, 42, -31, 4, 5, 1, 2, 3,
1021   4, 5, 0, 0, 6, 1, 2, 3, 4, 5,
1022   0, -18, 6, 23, 2, 3, 4, 5, 0, -18,
1023   6, 1, 2, 3, 4, 5, 0, 0, 6, 23,
1024   2, 3, 4, 5, 0, 0, 6
1025 };
1026
1027 static const yytype_int8 yycheck[] = {
1028   5, 0, 1, 0, 1, 3, 4, 5, 6, 7,
1029   8, 12, 10, 12, 8, 12, 9, 16, 0, 16,
1030   4, 20, 11, 20, 23, 6, 23, 26, -1, 34,
1031   0, 1, 22, 3, 4, 5, 6, 7, 26, 9,
1032   10, 11, 0, 1, -1, 3, 4, 5, 6, 7,
1033   -1, 9, 10, 11, 0, 1, -1, 3, 4, 5,
1034   6, 7, -1, 9, 10, 11, 0, 1, -1, 3,
1035   4, 5, 6, 7, -1, 9, 10, 11, 0, 1,
1036   -1, 3, 4, 5, 6, 7, -1, 9, 10, 11,
1037   1, -1, 3, 4, 5, 6, 7, 8, 9, 10,
1038   11, 0, 1, -1, 3, 4, 5, 6, 7, -1,
1039   9, 10, 1, -1, 3, 4, 5, 6, 7, -1,
1040   9, 10, 11, 1, -1, 3, 4, 5, 6, 7,
1041   -1, 9, 10, 11, 0, 6, 7, 3, 4, 5,
1042   6, 7, -1, -1, 10, 3, 4, 5, 6, 7,
1043   -1, 9, 10, 3, 4, 5, 6, 7, -1, 9,
1044   10, 3, 4, 5, 6, 7, -1, -1, 10, 3,
1045   4, 5, 6, 7, -1, -1, 10
1046 };
1047
1048 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1049    symbol of state STATE-NUM.  */
1050 static const yytype_uint8 yystos[] = {
1051   0, 3, 4, 5, 6, 7, 10, 17, 19, 20,
1052   22, 23, 24, 26, 27, 26, 18, 12, 21, 21,
1053   18, 8, 9, 3, 26, 1, 24, 25, 26, 0,
1054   1, 8, 11, 26, 4, 26, 23, 25, 1, 11,
1055   11, 21, 11
1056 };
1057
1058 #define yyerrok         (yyerrstatus = 0)
1059 #define yyclearin       (yychar = YYEMPTY)
1060 #define YYEMPTY         (-2)
1061 #define YYEOF           0
1062
1063 #define YYACCEPT        goto yyacceptlab
1064 #define YYABORT         goto yyabortlab
1065 #define YYERROR         goto yyerrorlab
1066
1067
1068 /* Like YYERROR except do call yyerror.  This remains here temporarily
1069    to ease the transition to the new meaning of YYERROR, for GCC.
1070    Once GCC version 2 has supplanted version 1, this can go.  */
1071
1072 #define YYFAIL          goto yyerrlab
1073
1074 #define YYRECOVERING()  (!!yyerrstatus)
1075
1076 #define YYBACKUP(Token, Value)                                  \
1077 do                                                              \
1078   if (yychar == YYEMPTY && yylen == 1)                          \
1079     {                                                           \
1080       yychar = (Token);                                         \
1081       yylval = (Value);                                         \
1082       yytoken = YYTRANSLATE (yychar);                           \
1083       YYPOPSTACK (1);                                           \
1084       goto yybackup;                                            \
1085     }                                                           \
1086   else                                                          \
1087     {                                                           \
1088       yyerror (scanner, graph, YY_("syntax error: cannot back up")); \
1089       YYERROR;                                                  \
1090     }                                                           \
1091 while (YYID (0))
1092
1093
1094 #define YYTERROR        1
1095 #define YYERRCODE       256
1096
1097
1098 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1099    If N is 0, then set CURRENT to the empty location which ends
1100    the previous symbol: RHS[0] (always defined).  */
1101
1102 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
1103 #ifndef YYLLOC_DEFAULT
1104 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
1105     do                                                                  \
1106       if (YYID (N))                                                    \
1107         {                                                               \
1108           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
1109           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
1110           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
1111           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
1112         }                                                               \
1113       else                                                              \
1114         {                                                               \
1115           (Current).first_line   = (Current).last_line   =              \
1116             YYRHSLOC (Rhs, 0).last_line;                                \
1117           (Current).first_column = (Current).last_column =              \
1118             YYRHSLOC (Rhs, 0).last_column;                              \
1119         }                                                               \
1120     while (YYID (0))
1121 #endif
1122
1123
1124 /* YY_LOCATION_PRINT -- Print the location on the stream.
1125    This macro was not mandated originally: define only if we know
1126    we won't break user code: when these are the locations we know.  */
1127
1128 #ifndef YY_LOCATION_PRINT
1129 # if YYLTYPE_IS_TRIVIAL
1130 #  define YY_LOCATION_PRINT(File, Loc)                  \
1131      fprintf (File, "%d.%d-%d.%d",                      \
1132               (Loc).first_line, (Loc).first_column,     \
1133               (Loc).last_line,  (Loc).last_column)
1134 # else
1135 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1136 # endif
1137 #endif
1138
1139
1140 /* YYLEX -- calling `yylex' with the right arguments.  */
1141
1142 #ifdef YYLEX_PARAM
1143 # define YYLEX yylex (&yylval, YYLEX_PARAM)
1144 #else
1145 # define YYLEX yylex (&yylval)
1146 #endif
1147
1148 /* Enable debugging if requested.  */
1149 #if YYDEBUG
1150
1151 # ifndef YYFPRINTF
1152 #  include <stdio.h>            /* INFRINGES ON USER NAME SPACE */
1153 #  define YYFPRINTF fprintf
1154 # endif
1155
1156 # define YYDPRINTF(Args)                        \
1157 do {                                            \
1158   if (yydebug)                                  \
1159     YYFPRINTF Args;                             \
1160 } while (YYID (0))
1161
1162 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
1163 do {                                                                      \
1164   if (yydebug)                                                            \
1165     {                                                                     \
1166       YYFPRINTF (stderr, "%s ", Title);                                   \
1167       yy_symbol_print (stderr,                                            \
1168                   Type, Value, scanner, graph); \
1169       YYFPRINTF (stderr, "\n");                                           \
1170     }                                                                     \
1171 } while (YYID (0))
1172
1173
1174 /*--------------------------------.
1175 | Print this symbol on YYOUTPUT.  |
1176 `--------------------------------*/
1177
1178  /*ARGSUSED*/
1179 #if (defined __STDC__ || defined __C99__FUNC__ \
1180      || defined __cplusplus || defined _MSC_VER)
1181     static void
1182 yy_symbol_value_print (FILE * yyoutput, int yytype,
1183     YYSTYPE const *const yyvaluep, void *scanner, graph_t * graph)
1184 #else
1185     static void
1186 yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, graph)
1187      FILE *yyoutput;
1188      int yytype;
1189      YYSTYPE const *const yyvaluep;
1190      void *scanner;
1191      graph_t *graph;
1192 #endif
1193 {
1194   if (!yyvaluep)
1195     return;
1196   YYUSE (scanner);
1197   YYUSE (graph);
1198 # ifdef YYPRINT
1199   if (yytype < YYNTOKENS)
1200     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1201 # else
1202   YYUSE (yyoutput);
1203 # endif
1204   switch (yytype) {
1205     default:
1206       break;
1207   }
1208 }
1209
1210
1211 /*--------------------------------.
1212 | Print this symbol on YYOUTPUT.  |
1213 `--------------------------------*/
1214
1215 #if (defined __STDC__ || defined __C99__FUNC__ \
1216      || defined __cplusplus || defined _MSC_VER)
1217 static void
1218 yy_symbol_print (FILE * yyoutput, int yytype, YYSTYPE const *const yyvaluep,
1219     void *scanner, graph_t * graph)
1220 #else
1221 static void
1222 yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, graph)
1223      FILE *yyoutput;
1224      int yytype;
1225      YYSTYPE const *const yyvaluep;
1226      void *scanner;
1227      graph_t *graph;
1228 #endif
1229 {
1230   if (yytype < YYNTOKENS)
1231     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1232   else
1233     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1234
1235   yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, graph);
1236   YYFPRINTF (yyoutput, ")");
1237 }
1238
1239 /*------------------------------------------------------------------.
1240 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1241 | TOP (included).                                                   |
1242 `------------------------------------------------------------------*/
1243
1244 #if (defined __STDC__ || defined __C99__FUNC__ \
1245      || defined __cplusplus || defined _MSC_VER)
1246 static void
1247 yy_stack_print (yytype_int16 * bottom, yytype_int16 * top)
1248 #else
1249 static void
1250 yy_stack_print (bottom, top)
1251      yytype_int16 *bottom;
1252      yytype_int16 *top;
1253 #endif
1254 {
1255   YYFPRINTF (stderr, "Stack now");
1256   for (; bottom <= top; ++bottom)
1257     YYFPRINTF (stderr, " %d", *bottom);
1258   YYFPRINTF (stderr, "\n");
1259 }
1260
1261 # define YY_STACK_PRINT(Bottom, Top)                            \
1262 do {                                                            \
1263   if (yydebug)                                                  \
1264     yy_stack_print ((Bottom), (Top));                           \
1265 } while (YYID (0))
1266
1267
1268 /*------------------------------------------------.
1269 | Report that the YYRULE is going to be reduced.  |
1270 `------------------------------------------------*/
1271
1272 #if (defined __STDC__ || defined __C99__FUNC__ \
1273      || defined __cplusplus || defined _MSC_VER)
1274 static void
1275 yy_reduce_print (YYSTYPE * yyvsp, int yyrule, void *scanner, graph_t * graph)
1276 #else
1277 static void
1278 yy_reduce_print (yyvsp, yyrule, scanner, graph)
1279      YYSTYPE *yyvsp;
1280      int yyrule;
1281      void *scanner;
1282      graph_t *graph;
1283 #endif
1284 {
1285   int yynrhs = yyr2[yyrule];
1286   int yyi;
1287   unsigned long int yylno = yyrline[yyrule];
1288
1289   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1290       yyrule - 1, yylno);
1291   /* The symbols being reduced.  */
1292   for (yyi = 0; yyi < yynrhs; yyi++) {
1293     fprintf (stderr, "   $%d = ", yyi + 1);
1294     yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1295         &(yyvsp[(yyi + 1) - (yynrhs)])
1296         , scanner, graph);
1297     fprintf (stderr, "\n");
1298   }
1299 }
1300
1301 # define YY_REDUCE_PRINT(Rule)          \
1302 do {                                    \
1303   if (yydebug)                          \
1304     yy_reduce_print (yyvsp, Rule, scanner, graph); \
1305 } while (YYID (0))
1306
1307 /* Nonzero means print parse trace.  It is left uninitialized so that
1308    multiple parsers can coexist.  */
1309 int yydebug;
1310 #else /* !YYDEBUG */
1311 # define YYDPRINTF(Args)
1312 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1313 # define YY_STACK_PRINT(Bottom, Top)
1314 # define YY_REDUCE_PRINT(Rule)
1315 #endif /* !YYDEBUG */
1316
1317
1318 /* YYINITDEPTH -- initial size of the parser's stacks.  */
1319 #ifndef YYINITDEPTH
1320 # define YYINITDEPTH 200
1321 #endif
1322
1323 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1324    if the built-in stack extension method is used).
1325
1326    Do not make this value too large; the results are undefined if
1327    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1328    evaluated with infinite-precision integer arithmetic.  */
1329
1330 #ifndef YYMAXDEPTH
1331 # define YYMAXDEPTH 10000
1332 #endif
1333 \f
1334
1335
1336 #if YYERROR_VERBOSE
1337
1338 # ifndef yystrlen
1339 #  if defined __GLIBC__ && defined _STRING_H
1340 #   define yystrlen strlen
1341 #  else
1342 /* Return the length of YYSTR.  */
1343 #if (defined __STDC__ || defined __C99__FUNC__ \
1344      || defined __cplusplus || defined _MSC_VER)
1345 static YYSIZE_T
1346 yystrlen (const char *yystr)
1347 #else
1348 static YYSIZE_T
1349 yystrlen (yystr)
1350      const char *yystr;
1351 #endif
1352 {
1353   YYSIZE_T yylen;
1354
1355   for (yylen = 0; yystr[yylen]; yylen++)
1356     continue;
1357   return yylen;
1358 }
1359 #  endif
1360 # endif
1361
1362 # ifndef yystpcpy
1363 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1364 #   define yystpcpy stpcpy
1365 #  else
1366 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1367    YYDEST.  */
1368 #if (defined __STDC__ || defined __C99__FUNC__ \
1369      || defined __cplusplus || defined _MSC_VER)
1370 static char *
1371 yystpcpy (char *yydest, const char *yysrc)
1372 #else
1373 static char *
1374 yystpcpy (yydest, yysrc)
1375      char *yydest;
1376      const char *yysrc;
1377 #endif
1378 {
1379   char *yyd = yydest;
1380   const char *yys = yysrc;
1381
1382   while ((*yyd++ = *yys++) != '\0')
1383     continue;
1384
1385   return yyd - 1;
1386 }
1387 #  endif
1388 # endif
1389
1390 # ifndef yytnamerr
1391 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1392    quotes and backslashes, so that it's suitable for yyerror.  The
1393    heuristic is that double-quoting is unnecessary unless the string
1394    contains an apostrophe, a comma, or backslash (other than
1395    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1396    null, do not copy; instead, return the length of what the result
1397    would have been.  */
1398 static YYSIZE_T
1399 yytnamerr (char *yyres, const char *yystr)
1400 {
1401   if (*yystr == '"') {
1402     YYSIZE_T yyn = 0;
1403     char const *yyp = yystr;
1404
1405     for (;;)
1406       switch (*++yyp) {
1407         case '\'':
1408         case ',':
1409           goto do_not_strip_quotes;
1410
1411         case '\\':
1412           if (*++yyp != '\\')
1413             goto do_not_strip_quotes;
1414           /* Fall through.  */
1415         default:
1416           if (yyres)
1417             yyres[yyn] = *yyp;
1418           yyn++;
1419           break;
1420
1421         case '"':
1422           if (yyres)
1423             yyres[yyn] = '\0';
1424           return yyn;
1425       }
1426   do_not_strip_quotes:;
1427   }
1428
1429   if (!yyres)
1430     return yystrlen (yystr);
1431
1432   return yystpcpy (yyres, yystr) - yyres;
1433 }
1434 # endif
1435
1436 /* Copy into YYRESULT an error message about the unexpected token
1437    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
1438    including the terminating null byte.  If YYRESULT is null, do not
1439    copy anything; just return the number of bytes that would be
1440    copied.  As a special case, return 0 if an ordinary "syntax error"
1441    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
1442    size calculation.  */
1443 static YYSIZE_T
1444 yysyntax_error (char *yyresult, int yystate, int yychar)
1445 {
1446   int yyn = yypact[yystate];
1447
1448   if (!(YYPACT_NINF < yyn && yyn <= YYLAST))
1449     return 0;
1450   else {
1451     int yytype = YYTRANSLATE (yychar);
1452     YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1453     YYSIZE_T yysize = yysize0;
1454     YYSIZE_T yysize1;
1455     int yysize_overflow = 0;
1456     enum
1457     { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1458     char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1459     int yyx;
1460
1461 # if 0
1462     /* This is so xgettext sees the translatable formats that are
1463        constructed on the fly.  */
1464     YY_ ("syntax error, unexpected %s");
1465     YY_ ("syntax error, unexpected %s, expecting %s");
1466     YY_ ("syntax error, unexpected %s, expecting %s or %s");
1467     YY_ ("syntax error, unexpected %s, expecting %s or %s or %s");
1468     YY_ ("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1469 # endif
1470     char *yyfmt;
1471     char const *yyf;
1472     static char const yyunexpected[] = "syntax error, unexpected %s";
1473     static char const yyexpecting[] = ", expecting %s";
1474     static char const yyor[] = " or %s";
1475     char yyformat[sizeof yyunexpected
1476         + sizeof yyexpecting - 1 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1477             * (sizeof yyor - 1))];
1478     char const *yyprefix = yyexpecting;
1479
1480     /* Start YYX at -YYN if negative to avoid negative indexes in
1481        YYCHECK.  */
1482     int yyxbegin = yyn < 0 ? -yyn : 0;
1483
1484     /* Stay within bounds of both yycheck and yytname.  */
1485     int yychecklim = YYLAST - yyn + 1;
1486     int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1487     int yycount = 1;
1488
1489     yyarg[0] = yytname[yytype];
1490     yyfmt = yystpcpy (yyformat, yyunexpected);
1491
1492     for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1493       if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
1494         if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) {
1495           yycount = 1;
1496           yysize = yysize0;
1497           yyformat[sizeof yyunexpected - 1] = '\0';
1498           break;
1499         }
1500         yyarg[yycount++] = yytname[yyx];
1501         yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1502         yysize_overflow |= (yysize1 < yysize);
1503         yysize = yysize1;
1504         yyfmt = yystpcpy (yyfmt, yyprefix);
1505         yyprefix = yyor;
1506       }
1507
1508     yyf = YY_ (yyformat);
1509     yysize1 = yysize + yystrlen (yyf);
1510     yysize_overflow |= (yysize1 < yysize);
1511     yysize = yysize1;
1512
1513     if (yysize_overflow)
1514       return YYSIZE_MAXIMUM;
1515
1516     if (yyresult) {
1517       /* Avoid sprintf, as that infringes on the user's name space.
1518          Don't have undefined behavior even if the translation
1519          produced a string with the wrong number of "%s"s.  */
1520       char *yyp = yyresult;
1521       int yyi = 0;
1522
1523       while ((*yyp = *yyf) != '\0') {
1524         if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) {
1525           yyp += yytnamerr (yyp, yyarg[yyi++]);
1526           yyf += 2;
1527         } else {
1528           yyp++;
1529           yyf++;
1530         }
1531       }
1532     }
1533     return yysize;
1534   }
1535 }
1536 #endif /* YYERROR_VERBOSE */
1537 \f
1538
1539 /*-----------------------------------------------.
1540 | Release the memory associated to this symbol.  |
1541 `-----------------------------------------------*/
1542
1543  /*ARGSUSED*/
1544 #if (defined __STDC__ || defined __C99__FUNC__ \
1545      || defined __cplusplus || defined _MSC_VER)
1546     static void
1547 yydestruct (const char *yymsg, int yytype, YYSTYPE * yyvaluep, void *scanner,
1548     graph_t * graph)
1549 #else
1550     static void
1551 yydestruct (yymsg, yytype, yyvaluep, scanner, graph)
1552      const char *yymsg;
1553      int yytype;
1554      YYSTYPE *yyvaluep;
1555      void *scanner;
1556      graph_t *graph;
1557 #endif
1558 {
1559   YYUSE (yyvaluep);
1560   YYUSE (scanner);
1561   YYUSE (graph);
1562
1563   if (!yymsg)
1564     yymsg = "Deleting";
1565   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1566
1567   switch (yytype) {
1568
1569     default:
1570       break;
1571   }
1572 }
1573 \f
1574
1575 /* Prevent warnings from -Wmissing-prototypes.  */
1576
1577 #ifdef YYPARSE_PARAM
1578 #if defined __STDC__ || defined __cplusplus
1579 int yyparse (void *YYPARSE_PARAM);
1580 #else
1581 int yyparse ();
1582 #endif
1583 #else /* ! YYPARSE_PARAM */
1584 #if defined __STDC__ || defined __cplusplus
1585 int yyparse (void *scanner, graph_t * graph);
1586 #else
1587 int yyparse ();
1588 #endif
1589 #endif /* ! YYPARSE_PARAM */
1590
1591
1592
1593
1594
1595
1596 /*----------.
1597 | yyparse.  |
1598 `----------*/
1599
1600 #ifdef YYPARSE_PARAM
1601 #if (defined __STDC__ || defined __C99__FUNC__ \
1602      || defined __cplusplus || defined _MSC_VER)
1603 int
1604 yyparse (void *YYPARSE_PARAM)
1605 #else
1606 int
1607 yyparse (YYPARSE_PARAM)
1608      void *YYPARSE_PARAM;
1609 #endif
1610 #else /* ! YYPARSE_PARAM */
1611 #if (defined __STDC__ || defined __C99__FUNC__ \
1612      || defined __cplusplus || defined _MSC_VER)
1613 int
1614 yyparse (void *scanner, graph_t * graph)
1615 #else
1616 int
1617 yyparse (scanner, graph)
1618      void *scanner;
1619      graph_t *graph;
1620 #endif
1621 #endif
1622 {
1623   /* The look-ahead symbol.  */
1624   int yychar;
1625
1626 /* The semantic value of the look-ahead symbol.  */
1627   YYSTYPE yylval;
1628
1629 /* Number of syntax errors so far.  */
1630   int yynerrs;
1631
1632   int yystate;
1633   int yyn;
1634   int yyresult;
1635
1636   /* Number of tokens to shift before error messages enabled.  */
1637   int yyerrstatus;
1638
1639   /* Look-ahead token as an internal (translated) token number.  */
1640   int yytoken = 0;
1641
1642 #if YYERROR_VERBOSE
1643   /* Buffer for error messages, and its allocated size.  */
1644   char yymsgbuf[128];
1645   char *yymsg = yymsgbuf;
1646   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1647 #endif
1648
1649   /* Three stacks and their tools:
1650      `yyss': related to states,
1651      `yyvs': related to semantic values,
1652      `yyls': related to locations.
1653
1654      Refer to the stacks thru separate pointers, to allow yyoverflow
1655      to reallocate them elsewhere.  */
1656
1657   /* The state stack.  */
1658   yytype_int16 yyssa[YYINITDEPTH];
1659   yytype_int16 *yyss = yyssa;
1660   yytype_int16 *yyssp;
1661
1662   /* The semantic value stack.  */
1663   YYSTYPE yyvsa[YYINITDEPTH];
1664   YYSTYPE *yyvs = yyvsa;
1665   YYSTYPE *yyvsp;
1666
1667
1668
1669 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1670
1671   YYSIZE_T yystacksize = YYINITDEPTH;
1672
1673   /* The variables used to return semantic value and location from the
1674      action routines.  */
1675   YYSTYPE yyval;
1676
1677
1678   /* The number of symbols on the RHS of the reduced rule.
1679      Keep to zero when no symbol should be popped.  */
1680   int yylen = 0;
1681
1682   YYDPRINTF ((stderr, "Starting parse\n"));
1683
1684   yystate = 0;
1685   yyerrstatus = 0;
1686   yynerrs = 0;
1687   yychar = YYEMPTY;             /* Cause a token to be read.  */
1688
1689   /* Initialize stack pointers.
1690      Waste one element of value and location stack
1691      so that they stay on the same level as the state stack.
1692      The wasted elements are never initialized.  */
1693
1694   yyssp = yyss;
1695   yyvsp = yyvs;
1696
1697   goto yysetstate;
1698
1699 /*------------------------------------------------------------.
1700 | yynewstate -- Push a new state, which is found in yystate.  |
1701 `------------------------------------------------------------*/
1702 yynewstate:
1703   /* In all cases, when you get here, the value and location stacks
1704      have just been pushed.  So pushing a state here evens the stacks.  */
1705   yyssp++;
1706
1707 yysetstate:
1708   *yyssp = yystate;
1709
1710   if (yyss + yystacksize - 1 <= yyssp) {
1711     /* Get the current used size of the three stacks, in elements.  */
1712     YYSIZE_T yysize = yyssp - yyss + 1;
1713
1714 #ifdef yyoverflow
1715     {
1716       /* Give user a chance to reallocate the stack.  Use copies of
1717          these so that the &'s don't force the real ones into
1718          memory.  */
1719       YYSTYPE *yyvs1 = yyvs;
1720       yytype_int16 *yyss1 = yyss;
1721
1722
1723       /* Each stack pointer address is followed by the size of the
1724          data in use in that stack, in bytes.  This used to be a
1725          conditional around just the two extra args, but that might
1726          be undefined if yyoverflow is a macro.  */
1727       yyoverflow (YY_ ("memory exhausted"),
1728           &yyss1, yysize * sizeof (*yyssp),
1729           &yyvs1, yysize * sizeof (*yyvsp), &yystacksize);
1730
1731       yyss = yyss1;
1732       yyvs = yyvs1;
1733     }
1734 #else /* no yyoverflow */
1735 # ifndef YYSTACK_RELOCATE
1736     goto yyexhaustedlab;
1737 # else
1738     /* Extend the stack our own way.  */
1739     if (YYMAXDEPTH <= yystacksize)
1740       goto yyexhaustedlab;
1741     yystacksize *= 2;
1742     if (YYMAXDEPTH < yystacksize)
1743       yystacksize = YYMAXDEPTH;
1744
1745     {
1746       yytype_int16 *yyss1 = yyss;
1747       union yyalloc *yyptr =
1748           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1749       if (!yyptr)
1750         goto yyexhaustedlab;
1751       YYSTACK_RELOCATE (yyss);
1752       YYSTACK_RELOCATE (yyvs);
1753
1754 #  undef YYSTACK_RELOCATE
1755       if (yyss1 != yyssa)
1756         YYSTACK_FREE (yyss1);
1757     }
1758 # endif
1759 #endif /* no yyoverflow */
1760
1761     yyssp = yyss + yysize - 1;
1762     yyvsp = yyvs + yysize - 1;
1763
1764
1765     YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1766             (unsigned long int) yystacksize));
1767
1768     if (yyss + yystacksize - 1 <= yyssp)
1769       YYABORT;
1770   }
1771
1772   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1773
1774   goto yybackup;
1775
1776 /*-----------.
1777 | yybackup.  |
1778 `-----------*/
1779 yybackup:
1780
1781   /* Do appropriate processing given the current state.  Read a
1782      look-ahead token if we need one and don't already have one.  */
1783
1784   /* First try to decide what to do without reference to look-ahead token.  */
1785   yyn = yypact[yystate];
1786   if (yyn == YYPACT_NINF)
1787     goto yydefault;
1788
1789   /* Not known => get a look-ahead token if don't already have one.  */
1790
1791   /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
1792   if (yychar == YYEMPTY) {
1793     YYDPRINTF ((stderr, "Reading a token: "));
1794     yychar = YYLEX;
1795   }
1796
1797   if (yychar <= YYEOF) {
1798     yychar = yytoken = YYEOF;
1799     YYDPRINTF ((stderr, "Now at end of input.\n"));
1800   } else {
1801     yytoken = YYTRANSLATE (yychar);
1802     YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1803   }
1804
1805   /* If the proper action on seeing token YYTOKEN is to reduce or to
1806      detect an error, take that action.  */
1807   yyn += yytoken;
1808   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1809     goto yydefault;
1810   yyn = yytable[yyn];
1811   if (yyn <= 0) {
1812     if (yyn == 0 || yyn == YYTABLE_NINF)
1813       goto yyerrlab;
1814     yyn = -yyn;
1815     goto yyreduce;
1816   }
1817
1818   if (yyn == YYFINAL)
1819     YYACCEPT;
1820
1821   /* Count tokens shifted since error; after three, turn off error
1822      status.  */
1823   if (yyerrstatus)
1824     yyerrstatus--;
1825
1826   /* Shift the look-ahead token.  */
1827   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1828
1829   /* Discard the shifted token unless it is eof.  */
1830   if (yychar != YYEOF)
1831     yychar = YYEMPTY;
1832
1833   yystate = yyn;
1834   *++yyvsp = yylval;
1835
1836   goto yynewstate;
1837
1838
1839 /*-----------------------------------------------------------.
1840 | yydefault -- do the default action for the current state.  |
1841 `-----------------------------------------------------------*/
1842 yydefault:
1843   yyn = yydefact[yystate];
1844   if (yyn == 0)
1845     goto yyerrlab;
1846   goto yyreduce;
1847
1848
1849 /*-----------------------------.
1850 | yyreduce -- Do a reduction.  |
1851 `-----------------------------*/
1852 yyreduce:
1853   /* yyn is the number of a rule to reduce with.  */
1854   yylen = yyr2[yyn];
1855
1856   /* If YYLEN is nonzero, implement the default value of the action:
1857      `$$ = $1'.
1858
1859      Otherwise, the following line sets YYVAL to garbage.
1860      This behavior is undocumented and Bison
1861      users should not rely upon it.  Assigning to YYVAL
1862      unconditionally makes the parser a bit smaller, and it avoids a
1863      GCC warning that YYVAL may be used uninitialized.  */
1864   yyval = yyvsp[1 - yylen];
1865
1866
1867   YY_REDUCE_PRINT (yyn);
1868   switch (yyn) {
1869     case 2:
1870 #line 506 "./grammar.y"
1871     {
1872       (yyval.e) = gst_element_factory_make ((yyvsp[(1) - (1)].s), NULL);
1873       if ((yyval.e) == NULL) {
1874         SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
1875             _("no element \"%s\""), (yyvsp[(1) - (1)].s));
1876         gst_parse_strfree ((yyvsp[(1) - (1)].s));
1877         YYERROR;
1878       }
1879       gst_parse_strfree ((yyvsp[(1) - (1)].s));
1880       ;
1881     }
1882       break;
1883
1884     case 3:
1885 #line 514 "./grammar.y"
1886     {
1887       gst_parse_element_set ((yyvsp[(2) - (2)].s), (yyvsp[(1) - (2)].e), graph);
1888       (yyval.e) = (yyvsp[(1) - (2)].e);
1889       ;
1890     }
1891       break;
1892
1893     case 4:
1894 #line 518 "./grammar.y"
1895     {
1896       (yyval.p) = NULL;;
1897     }
1898       break;
1899
1900     case 5:
1901 #line 519 "./grammar.y"
1902     {
1903       (yyval.p) = g_slist_prepend ((yyvsp[(1) - (2)].p), (yyvsp[(2) - (2)].s));;
1904     }
1905       break;
1906
1907     case 6:
1908 #line 521 "./grammar.y"
1909     {
1910       GST_BIN_MAKE ((yyval.c), "bin", (yyvsp[(3) - (4)].c),
1911           (yyvsp[(2) - (4)].p), FALSE);;
1912     }
1913       break;
1914
1915     case 7:
1916 #line 522 "./grammar.y"
1917     {
1918       GST_BIN_MAKE ((yyval.c), (yyvsp[(1) - (4)].s), (yyvsp[(3) - (4)].c),
1919           (yyvsp[(2) - (4)].p), TRUE);
1920       gst_parse_strfree ((yyvsp[(1) - (4)].s));
1921       ;
1922     }
1923       break;
1924
1925     case 8:
1926 #line 525 "./grammar.y"
1927     {
1928       GST_BIN_MAKE ((yyval.c), (yyvsp[(1) - (3)].s), NULL, (yyvsp[(2) - (3)].p),
1929           TRUE);
1930       gst_parse_strfree ((yyvsp[(1) - (3)].s));
1931       ;
1932     }
1933       break;
1934
1935     case 9:
1936 #line 528 "./grammar.y"
1937     {
1938       GST_BIN_MAKE ((yyval.c), (yyvsp[(1) - (4)].s), NULL, (yyvsp[(2) - (4)].p),
1939           TRUE);
1940       gst_parse_strfree ((yyvsp[(1) - (4)].s));
1941       ;
1942     }
1943       break;
1944
1945     case 10:
1946 #line 533 "./grammar.y"
1947     {
1948       (yyval.p) = g_slist_prepend (NULL, (yyvsp[(1) - (1)].s));;
1949     }
1950       break;
1951
1952     case 11:
1953 #line 534 "./grammar.y"
1954     {
1955       (yyval.p) = (yyvsp[(2) - (2)].p);
1956       (yyval.p) = g_slist_prepend ((yyval.p), (yyvsp[(1) - (2)].s));
1957       ;
1958     }
1959       break;
1960
1961     case 12:
1962 #line 538 "./grammar.y"
1963     {
1964       (yyval.p) = g_slist_prepend (NULL, (yyvsp[(2) - (2)].s));;
1965     }
1966       break;
1967
1968     case 13:
1969 #line 539 "./grammar.y"
1970     {
1971       (yyval.p) = g_slist_prepend ((yyvsp[(3) - (3)].p), (yyvsp[(2) - (3)].s));;
1972     }
1973       break;
1974
1975     case 14:
1976 #line 542 "./grammar.y"
1977     {
1978       MAKE_REF ((yyval.l), (yyvsp[(1) - (1)].s), NULL);;
1979     }
1980       break;
1981
1982     case 15:
1983 #line 543 "./grammar.y"
1984     {
1985       MAKE_REF ((yyval.l), (yyvsp[(1) - (2)].s), (yyvsp[(2) - (2)].p));;
1986     }
1987       break;
1988
1989     case 16:
1990 #line 546 "./grammar.y"
1991     {
1992       (yyval.l) = (yyvsp[(1) - (1)].l);;
1993     }
1994       break;
1995
1996     case 17:
1997 #line 547 "./grammar.y"
1998     {
1999       MAKE_REF ((yyval.l), NULL, (yyvsp[(1) - (1)].p));;
2000     }
2001       break;
2002
2003     case 18:
2004 #line 548 "./grammar.y"
2005     {
2006       MAKE_REF ((yyval.l), NULL, NULL);;
2007     }
2008       break;
2009
2010     case 19:
2011 #line 551 "./grammar.y"
2012     {
2013       (yyval.l) = (yyvsp[(1) - (3)].l);
2014       if ((yyvsp[(2) - (3)].s)) {
2015         (yyval.l)->caps = gst_caps_from_string ((yyvsp[(2) - (3)].s));
2016         if ((yyval.l)->caps == NULL)
2017           SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
2018               _("could not parse caps \"%s\""), (yyvsp[(2) - (3)].s));
2019         gst_parse_strfree ((yyvsp[(2) - (3)].s));
2020       }
2021       (yyval.l)->sink_name = (yyvsp[(3) - (3)].l)->src_name;
2022       (yyval.l)->sink_pads = (yyvsp[(3) - (3)].l)->src_pads;
2023       gst_parse_link_free ((yyvsp[(3) - (3)].l));
2024       ;
2025     }
2026       break;
2027
2028     case 20:
2029 #line 564 "./grammar.y"
2030     {
2031       (yyval.p) = g_slist_prepend (NULL, (yyvsp[(1) - (1)].l));;
2032     }
2033       break;
2034
2035     case 21:
2036 #line 565 "./grammar.y"
2037     {
2038       (yyval.p) = g_slist_prepend ((yyvsp[(2) - (2)].p), (yyvsp[(1) - (2)].l));;
2039     }
2040       break;
2041
2042     case 22:
2043 #line 566 "./grammar.y"
2044     {
2045       (yyval.p) = (yyvsp[(1) - (2)].p);;
2046     }
2047       break;
2048
2049     case 23:
2050 #line 569 "./grammar.y"
2051     {
2052       (yyval.c) = gst_parse_chain_new ();
2053       (yyval.c)->first = (yyval.c)->last = (yyvsp[(1) - (1)].e);
2054       (yyval.c)->front = (yyval.c)->back = NULL;
2055       (yyval.c)->elements = g_slist_prepend (NULL, (yyvsp[(1) - (1)].e));
2056       ;
2057     }
2058       break;
2059
2060     case 24:
2061 #line 574 "./grammar.y"
2062     {
2063       (yyval.c) = (yyvsp[(1) - (1)].c);;
2064     }
2065       break;
2066
2067     case 25:
2068 #line 575 "./grammar.y"
2069     {
2070       if ((yyvsp[(1) - (2)].c)->back && (yyvsp[(2) - (2)].c)->front) {
2071         if (!(yyvsp[(1) - (2)].c)->back->sink_name) {
2072           SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
2073               _("link without source element"));
2074           gst_parse_free_link ((yyvsp[(1) - (2)].c)->back);
2075         } else {
2076           ((graph_t *) graph)->links =
2077               g_slist_prepend (((graph_t *) graph)->links,
2078               (yyvsp[(1) - (2)].c)->back);
2079         }
2080         if (!(yyvsp[(2) - (2)].c)->front->src_name) {
2081           SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
2082               _("link without sink element"));
2083           gst_parse_free_link ((yyvsp[(2) - (2)].c)->front);
2084         } else {
2085           ((graph_t *) graph)->links =
2086               g_slist_prepend (((graph_t *) graph)->links,
2087               (yyvsp[(2) - (2)].c)->front);
2088         }
2089         (yyvsp[(1) - (2)].c)->back = NULL;
2090       } else if ((yyvsp[(1) - (2)].c)->back) {
2091         if (!(yyvsp[(1) - (2)].c)->back->sink_name) {
2092           (yyvsp[(1) - (2)].c)->back->sink = (yyvsp[(2) - (2)].c)->first;
2093         }
2094       } else if ((yyvsp[(2) - (2)].c)->front) {
2095         if (!(yyvsp[(2) - (2)].c)->front->src_name) {
2096           (yyvsp[(2) - (2)].c)->front->src = (yyvsp[(1) - (2)].c)->last;
2097         }
2098         (yyvsp[(1) - (2)].c)->back = (yyvsp[(2) - (2)].c)->front;
2099       }
2100
2101       if ((yyvsp[(1) - (2)].c)->back) {
2102         ((graph_t *) graph)->links =
2103             g_slist_prepend (((graph_t *) graph)->links,
2104             (yyvsp[(1) - (2)].c)->back);
2105       }
2106       (yyvsp[(1) - (2)].c)->last = (yyvsp[(2) - (2)].c)->last;
2107       (yyvsp[(1) - (2)].c)->back = (yyvsp[(2) - (2)].c)->back;
2108       (yyvsp[(1) - (2)].c)->elements =
2109           g_slist_concat ((yyvsp[(1) - (2)].c)->elements,
2110           (yyvsp[(2) - (2)].c)->elements);
2111       if ((yyvsp[(2) - (2)].c))
2112         gst_parse_chain_free ((yyvsp[(2) - (2)].c));
2113       (yyval.c) = (yyvsp[(1) - (2)].c);
2114       ;
2115     }
2116       break;
2117
2118     case 26:
2119 #line 610 "./grammar.y"
2120     {
2121       GSList *walk;
2122
2123       if ((yyvsp[(1) - (2)].c)->back) {
2124         (yyvsp[(2) - (2)].p) =
2125             g_slist_prepend ((yyvsp[(2) - (2)].p), (yyvsp[(1) - (2)].c)->back);
2126         (yyvsp[(1) - (2)].c)->back = NULL;
2127       } else {
2128         if (!((link_t *) (yyvsp[(2) - (2)].p)->data)->src_name) {
2129           ((link_t *) (yyvsp[(2) - (2)].p)->data)->src =
2130               (yyvsp[(1) - (2)].c)->last;
2131         }
2132       }
2133       for (walk = (yyvsp[(2) - (2)].p); walk; walk = walk->next) {
2134         link_t *link = (link_t *) walk->data;
2135
2136         if (!link->sink_name && walk->next) {
2137           SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
2138               _("link without sink element"));
2139           gst_parse_free_link (link);
2140         } else if (!link->src_name && !link->src) {
2141           SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
2142               _("link without source element"));
2143           gst_parse_free_link (link);
2144         } else {
2145           if (walk->next) {
2146             ((graph_t *) graph)->links =
2147                 g_slist_prepend (((graph_t *) graph)->links, link);
2148           } else {
2149             (yyvsp[(1) - (2)].c)->back = link;
2150           }
2151         }
2152       }
2153       g_slist_free ((yyvsp[(2) - (2)].p));
2154       (yyval.c) = (yyvsp[(1) - (2)].c);
2155       ;
2156     }
2157       break;
2158
2159     case 27:
2160 #line 638 "./grammar.y"
2161     {
2162       (yyval.c) = (yyvsp[(1) - (2)].c);;
2163     }
2164       break;
2165
2166     case 28:
2167 #line 639 "./grammar.y"
2168     {
2169       if ((yyvsp[(2) - (2)].c)->front) {
2170         if (!(yyvsp[(2) - (2)].c)->front->src_name) {
2171           SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
2172               _("link without source element"));
2173           gst_parse_free_link ((yyvsp[(2) - (2)].c)->front);
2174         } else {
2175           ((graph_t *) graph)->links =
2176               g_slist_prepend (((graph_t *) graph)->links,
2177               (yyvsp[(2) - (2)].c)->front);
2178         }
2179       }
2180       if (!(yyvsp[(1) - (2)].l)->sink_name) {
2181         (yyvsp[(1) - (2)].l)->sink = (yyvsp[(2) - (2)].c)->first;
2182       }
2183       (yyvsp[(2) - (2)].c)->front = (yyvsp[(1) - (2)].l);
2184       (yyval.c) = (yyvsp[(2) - (2)].c);
2185       ;
2186     }
2187       break;
2188
2189     case 29:
2190 #line 653 "./grammar.y"
2191     {
2192       (yyval.c) = (yyvsp[(2) - (2)].c);
2193       if ((yyval.c)->front) {
2194         GstElement *element =
2195             gst_element_make_from_uri (GST_URI_SRC, (yyvsp[(1) - (2)].s), NULL);
2196         if (!element) {
2197           SET_ERROR (((graph_t *) graph)->error,
2198               GST_PARSE_ERROR_NO_SUCH_ELEMENT,
2199               _("no source element for URI \"%s\""), (yyvsp[(1) - (2)].s));
2200         } else {
2201           (yyval.c)->front->src = element;
2202           ((graph_t *) graph)->links = g_slist_prepend (
2203               ((graph_t *) graph)->links, (yyval.c)->front);
2204           (yyval.c)->front = NULL;
2205           (yyval.c)->elements = g_slist_prepend ((yyval.c)->elements, element);
2206         }
2207       } else {
2208         SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
2209             _("no element to link URI \"%s\" to"), (yyvsp[(1) - (2)].s));
2210       }
2211       g_free ((yyvsp[(1) - (2)].s));
2212       ;
2213     }
2214       break;
2215
2216     case 30:
2217 #line 673 "./grammar.y"
2218     {
2219       GstElement *element =
2220           gst_element_make_from_uri (GST_URI_SINK, (yyvsp[(2) - (2)].s), NULL);
2221       if (!element) {
2222         SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
2223             _("no sink element for URI \"%s\""), (yyvsp[(2) - (2)].s));
2224         gst_parse_link_free ((yyvsp[(1) - (2)].l));
2225         g_free ((yyvsp[(2) - (2)].s));
2226         YYERROR;
2227       } else if ((yyvsp[(1) - (2)].l)->sink_name
2228           || (yyvsp[(1) - (2)].l)->sink_pads) {
2229         gst_object_unref (element);
2230         SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
2231             _("could not link sink element for URI \"%s\""),
2232             (yyvsp[(2) - (2)].s));
2233         gst_parse_link_free ((yyvsp[(1) - (2)].l));
2234         g_free ((yyvsp[(2) - (2)].s));
2235         YYERROR;
2236       } else {
2237         (yyval.c) = gst_parse_chain_new ();
2238         (yyval.c)->first = (yyval.c)->last = element;
2239         (yyval.c)->front = (yyvsp[(1) - (2)].l);
2240         (yyval.c)->front->sink = element;
2241         (yyval.c)->elements = g_slist_prepend (NULL, element);
2242       }
2243       g_free ((yyvsp[(2) - (2)].s));
2244       ;
2245     }
2246       break;
2247
2248     case 31:
2249 #line 698 "./grammar.y"
2250     {
2251       SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_EMPTY,
2252           _("empty pipeline not allowed"));
2253       (yyval.g) = (graph_t *) graph;
2254       ;
2255     }
2256       break;
2257
2258     case 32:
2259 #line 701 "./grammar.y"
2260     {
2261       (yyval.g) = (graph_t *) graph;
2262       if ((yyvsp[(1) - (1)].c)->front) {
2263         if (!(yyvsp[(1) - (1)].c)->front->src_name) {
2264           SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
2265               _("link without source element"));
2266           gst_parse_free_link ((yyvsp[(1) - (1)].c)->front);
2267         } else {
2268           (yyval.g)->links =
2269               g_slist_prepend ((yyval.g)->links, (yyvsp[(1) - (1)].c)->front);
2270         }
2271         (yyvsp[(1) - (1)].c)->front = NULL;
2272       }
2273       if ((yyvsp[(1) - (1)].c)->back) {
2274         if (!(yyvsp[(1) - (1)].c)->back->sink_name) {
2275           SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK,
2276               _("link without sink element"));
2277           gst_parse_free_link ((yyvsp[(1) - (1)].c)->back);
2278         } else {
2279           (yyval.g)->links =
2280               g_slist_prepend ((yyval.g)->links, (yyvsp[(1) - (1)].c)->back);
2281         }
2282         (yyvsp[(1) - (1)].c)->back = NULL;
2283       }
2284       (yyval.g)->chain = (yyvsp[(1) - (1)].c);
2285       ;
2286     }
2287       break;
2288
2289
2290 /* Line 1267 of yacc.c.  */
2291 #line 2202 "grammar.tab.c"
2292     default:
2293       break;
2294   }
2295   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2296
2297   YYPOPSTACK (yylen);
2298   yylen = 0;
2299   YY_STACK_PRINT (yyss, yyssp);
2300
2301   *++yyvsp = yyval;
2302
2303
2304   /* Now `shift' the result of the reduction.  Determine what state
2305      that goes to, based on the state we popped back to and the rule
2306      number reduced by.  */
2307
2308   yyn = yyr1[yyn];
2309
2310   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2311   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2312     yystate = yytable[yystate];
2313   else
2314     yystate = yydefgoto[yyn - YYNTOKENS];
2315
2316   goto yynewstate;
2317
2318
2319 /*------------------------------------.
2320 | yyerrlab -- here on detecting error |
2321 `------------------------------------*/
2322 yyerrlab:
2323   /* If not already recovering from an error, report this error.  */
2324   if (!yyerrstatus) {
2325     ++yynerrs;
2326 #if ! YYERROR_VERBOSE
2327     yyerror (scanner, graph, YY_ ("syntax error"));
2328 #else
2329     {
2330       YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2331
2332       if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) {
2333         YYSIZE_T yyalloc = 2 * yysize;
2334
2335         if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2336           yyalloc = YYSTACK_ALLOC_MAXIMUM;
2337         if (yymsg != yymsgbuf)
2338           YYSTACK_FREE (yymsg);
2339         yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2340         if (yymsg)
2341           yymsg_alloc = yyalloc;
2342         else {
2343           yymsg = yymsgbuf;
2344           yymsg_alloc = sizeof yymsgbuf;
2345         }
2346       }
2347
2348       if (0 < yysize && yysize <= yymsg_alloc) {
2349         (void) yysyntax_error (yymsg, yystate, yychar);
2350         yyerror (scanner, graph, yymsg);
2351       } else {
2352         yyerror (scanner, graph, YY_ ("syntax error"));
2353         if (yysize != 0)
2354           goto yyexhaustedlab;
2355       }
2356     }
2357 #endif
2358   }
2359
2360
2361
2362   if (yyerrstatus == 3) {
2363     /* If just tried and failed to reuse look-ahead token after an
2364        error, discard it.  */
2365
2366     if (yychar <= YYEOF) {
2367       /* Return failure if at end of input.  */
2368       if (yychar == YYEOF)
2369         YYABORT;
2370     } else {
2371       yydestruct ("Error: discarding", yytoken, &yylval, scanner, graph);
2372       yychar = YYEMPTY;
2373     }
2374   }
2375
2376   /* Else will try to reuse look-ahead token after shifting the error
2377      token.  */
2378   goto yyerrlab1;
2379
2380
2381 /*---------------------------------------------------.
2382 | yyerrorlab -- error raised explicitly by YYERROR.  |
2383 `---------------------------------------------------*/
2384 yyerrorlab:
2385
2386   /* Pacify compilers like GCC when the user code never invokes
2387      YYERROR and the label yyerrorlab therefore never appears in user
2388      code.  */
2389   if ( /*CONSTCOND*/ 0)
2390     goto yyerrorlab;
2391
2392   /* Do not reclaim the symbols of the rule which action triggered
2393      this YYERROR.  */
2394   YYPOPSTACK (yylen);
2395   yylen = 0;
2396   YY_STACK_PRINT (yyss, yyssp);
2397   yystate = *yyssp;
2398   goto yyerrlab1;
2399
2400
2401 /*-------------------------------------------------------------.
2402 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
2403 `-------------------------------------------------------------*/
2404 yyerrlab1:
2405   yyerrstatus = 3;              /* Each real token shifted decrements this.  */
2406
2407   for (;;) {
2408     yyn = yypact[yystate];
2409     if (yyn != YYPACT_NINF) {
2410       yyn += YYTERROR;
2411       if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
2412         yyn = yytable[yyn];
2413         if (0 < yyn)
2414           break;
2415       }
2416     }
2417
2418     /* Pop the current state because it cannot handle the error token.  */
2419     if (yyssp == yyss)
2420       YYABORT;
2421
2422
2423     yydestruct ("Error: popping", yystos[yystate], yyvsp, scanner, graph);
2424     YYPOPSTACK (1);
2425     yystate = *yyssp;
2426     YY_STACK_PRINT (yyss, yyssp);
2427   }
2428
2429   if (yyn == YYFINAL)
2430     YYACCEPT;
2431
2432   *++yyvsp = yylval;
2433
2434
2435   /* Shift the error token.  */
2436   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2437
2438   yystate = yyn;
2439   goto yynewstate;
2440
2441
2442 /*-------------------------------------.
2443 | yyacceptlab -- YYACCEPT comes here.  |
2444 `-------------------------------------*/
2445 yyacceptlab:
2446   yyresult = 0;
2447   goto yyreturn;
2448
2449 /*-----------------------------------.
2450 | yyabortlab -- YYABORT comes here.  |
2451 `-----------------------------------*/
2452 yyabortlab:
2453   yyresult = 1;
2454   goto yyreturn;
2455
2456 #ifndef yyoverflow
2457 /*-------------------------------------------------.
2458 | yyexhaustedlab -- memory exhaustion comes here.  |
2459 `-------------------------------------------------*/
2460 yyexhaustedlab:
2461   yyerror (scanner, graph, YY_ ("memory exhausted"));
2462   yyresult = 2;
2463   /* Fall through.  */
2464 #endif
2465
2466 yyreturn:
2467   if (yychar != YYEOF && yychar != YYEMPTY)
2468     yydestruct ("Cleanup: discarding lookahead",
2469         yytoken, &yylval, scanner, graph);
2470   /* Do not reclaim the symbols of the rule which action triggered
2471      this YYABORT or YYACCEPT.  */
2472   YYPOPSTACK (yylen);
2473   YY_STACK_PRINT (yyss, yyssp);
2474   while (yyssp != yyss) {
2475     yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp, scanner, graph);
2476     YYPOPSTACK (1);
2477   }
2478 #ifndef yyoverflow
2479   if (yyss != yyssa)
2480     YYSTACK_FREE (yyss);
2481 #endif
2482 #if YYERROR_VERBOSE
2483   if (yymsg != yymsgbuf)
2484     YYSTACK_FREE (yymsg);
2485 #endif
2486   /* Make sure YYID is used.  */
2487   return YYID (yyresult);
2488 }
2489
2490
2491 #line 724 "./grammar.y"
2492
2493
2494
2495 static int
2496 yyerror (void *scanner, graph_t * graph, const char *s)
2497 {
2498   /* FIXME: This should go into the GError somehow, but how? */
2499   GST_WARNING ("Error during parsing: %s", s);
2500   return -1;
2501 }
2502
2503
2504 GstElement *
2505 _gst_parse_launch (const gchar * str, GError ** error)
2506 {
2507   graph_t g;
2508   gchar *dstr;
2509   GSList *walk;
2510   GstBin *bin = NULL;
2511   GstElement *ret;
2512   yyscan_t scanner;
2513
2514   g_return_val_if_fail (str != NULL, NULL);
2515
2516   g.chain = NULL;
2517   g.links = NULL;
2518   g.error = error;
2519
2520 #ifdef __GST_PARSE_TRACE
2521   GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: tracing enabled");
2522   __strings = __chains = __links = 0;
2523 #endif /* __GST_PARSE_TRACE */
2524
2525   dstr = g_strdup (str);
2526   _gst_parse_yylex_init (&scanner);
2527   _gst_parse_yy_scan_string (dstr, scanner);
2528
2529 #ifndef YYDEBUG
2530   yydebug = 1;
2531 #endif
2532
2533   if (yyparse (scanner, &g) != 0) {
2534     SET_ERROR (error, GST_PARSE_ERROR_SYNTAX,
2535         "Unrecoverable syntax error while parsing pipeline %s", str);
2536
2537     _gst_parse_yylex_destroy (scanner);
2538     g_free (dstr);
2539
2540     goto error1;
2541   }
2542   _gst_parse_yylex_destroy (scanner);
2543   g_free (dstr);
2544
2545   GST_CAT_DEBUG (GST_CAT_PIPELINE, "got %u elements and %u links",
2546       g.chain ? g_slist_length (g.chain->elements) : 0,
2547       g_slist_length (g.links));
2548
2549   if (!g.chain) {
2550     ret = NULL;
2551   } else if (!(((chain_t *) g.chain)->elements->next)) {
2552     /* only one toplevel element */
2553     ret = (GstElement *) ((chain_t *) g.chain)->elements->data;
2554     g_slist_free (((chain_t *) g.chain)->elements);
2555     if (GST_IS_BIN (ret))
2556       bin = GST_BIN (ret);
2557     gst_parse_chain_free (g.chain);
2558   } else {
2559     /* put all elements in our bin */
2560     bin = GST_BIN (gst_element_factory_make ("pipeline", NULL));
2561     g_assert (bin);
2562
2563     for (walk = g.chain->elements; walk; walk = walk->next) {
2564       if (walk->data != NULL)
2565         gst_bin_add (bin, GST_ELEMENT (walk->data));
2566     }
2567
2568     g_slist_free (g.chain->elements);
2569     ret = GST_ELEMENT (bin);
2570     gst_parse_chain_free (g.chain);
2571   }
2572
2573   /* remove links */
2574   for (walk = g.links; walk; walk = walk->next) {
2575     link_t *l = (link_t *) walk->data;
2576
2577     if (!l->src) {
2578       if (l->src_name) {
2579         if (bin) {
2580           l->src = gst_bin_get_by_name_recurse_up (bin, l->src_name);
2581           if (l->src)
2582             gst_object_unref (l->src);
2583         } else {
2584           l->src =
2585               strcmp (GST_ELEMENT_NAME (ret), l->src_name) == 0 ? ret : NULL;
2586         }
2587       }
2588       if (!l->src) {
2589         SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
2590             "No element named \"%s\" - omitting link", l->src_name);
2591         gst_parse_free_link (l);
2592         continue;
2593       }
2594     }
2595     if (!l->sink) {
2596       if (l->sink_name) {
2597         if (bin) {
2598           l->sink = gst_bin_get_by_name_recurse_up (bin, l->sink_name);
2599           if (l->sink)
2600             gst_object_unref (l->sink);
2601         } else {
2602           l->sink =
2603               strcmp (GST_ELEMENT_NAME (ret), l->sink_name) == 0 ? ret : NULL;
2604         }
2605       }
2606       if (!l->sink) {
2607         SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
2608             "No element named \"%s\" - omitting link", l->sink_name);
2609         gst_parse_free_link (l);
2610         continue;
2611       }
2612     }
2613     gst_parse_perform_link (l, &g);
2614   }
2615   g_slist_free (g.links);
2616
2617 out:
2618 #ifdef __GST_PARSE_TRACE
2619   GST_CAT_DEBUG (GST_CAT_PIPELINE,
2620       "TRACE: %u strings, %u chains and %u links left", __strings, __chains,
2621       __links);
2622   if (__strings || __chains || __links) {
2623     g_warning ("TRACE: %u strings, %u chains and %u links left", __strings,
2624         __chains, __links);
2625   }
2626 #endif /* __GST_PARSE_TRACE */
2627
2628   return ret;
2629
2630 error1:
2631   if (g.chain) {
2632     g_slist_foreach (g.chain->elements, (GFunc) gst_object_unref, NULL);
2633     g_slist_free (g.chain->elements);
2634     gst_parse_chain_free (g.chain);
2635   }
2636
2637   g_slist_foreach (g.links, (GFunc) gst_parse_free_link, NULL);
2638   g_slist_free (g.links);
2639
2640   if (error)
2641     g_assert (*error);
2642   ret = NULL;
2643
2644   goto out;
2645 }