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