• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* A Bison parser, made by GNU Bison 3.5.1.  */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5    Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
6    Inc.
7 
8    This program is free software: you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation, either version 3 of the License, or
11    (at your option) any later version.
12 
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20 
21 /* As a special exception, you may create a larger work that contains
22    part or all of the Bison parser skeleton and distribute that work
23    under terms of your choice, so long as that work isn't itself a
24    parser generator using the skeleton or a modified version thereof
25    as a parser skeleton.  Alternatively, if you modify or redistribute
26    the parser skeleton itself, you may (at your option) remove this
27    special exception, which will cause the skeleton and the resulting
28    Bison output files to be licensed under the GNU General Public
29    License without this special exception.
30 
31    This special exception was added by the Free Software Foundation in
32    version 2.2 of Bison.  */
33 
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35    simplifying the original so-called "semantic" parser.  */
36 
37 /* All symbols defined below should begin with yy or YY, to avoid
38    infringing on user name space.  This should be done even for local
39    variables, as they might otherwise be expanded by user macros.
40    There are some unavoidable exceptions within include files to
41    define necessary library symbols; they are noted "INFRINGES ON
42    USER NAME SPACE" below.  */
43 
44 /* Undocumented macros, especially those whose name start with YY_,
45    are private implementation details.  Do not rely on them.  */
46 
47 /* Identify Bison output.  */
48 #define YYBISON 1
49 
50 /* Bison version.  */
51 #define YYBISON_VERSION "3.5.1"
52 
53 /* Skeleton name.  */
54 #define YYSKELETON_NAME "yacc.c"
55 
56 /* Pure parsers.  */
57 #define YYPURE 2
58 
59 /* Push parsers.  */
60 #define YYPUSH 0
61 
62 /* Pull parsers.  */
63 #define YYPULL 1
64 
65 
66 /* Substitute the variable and function names.  */
67 #define yyparse         priv_gst_parse_yyparse
68 #define yylex           priv_gst_parse_yylex
69 #define yyerror         priv_gst_parse_yyerror
70 #define yydebug         priv_gst_parse_yydebug
71 #define yynerrs         priv_gst_parse_yynerrs
72 
73 /* First part of user prologue.  */
74 #line 1 "subprojects/gstreamer/gst/parse/grammar.y"
75 
76 #include "../gst_private.h"
77 
78 #include <glib-object.h>
79 #include <glib.h>
80 #include <stdio.h>
81 #include <string.h>
82 #include <stdlib.h>
83 
84 #include "../gst-i18n-lib.h"
85 
86 #include "../gstconfig.h"
87 #include "../gstparse.h"
88 #include "../gstinfo.h"
89 #include "../gsterror.h"
90 #include "../gststructure.h"
91 #include "../gsturi.h"
92 #include "../gstutils.h"
93 #include "../gstvalue.h"
94 #include "../gstchildproxy.h"
95 #include "types.h"
96 
97 /* All error messages in this file are user-visible and need to be translated.
98  * Don't start the message with a capital, and don't end them with a period,
99  * as they will be presented inside a sentence/error.
100  */
101 
102 #define YYERROR_VERBOSE 1
103 
104 #define YYENABLE_NLS 0
105 
106 #ifndef YYLTYPE_IS_TRIVIAL
107 #define YYLTYPE_IS_TRIVIAL 0
108 #endif
109 
110 /*******************************************************************************************
111 *** Tracing memory leaks
112 *******************************************************************************************/
113 
114 #ifdef __GST_PARSE_TRACE
115 static guint __strings;
116 static guint __links;
117 static guint __chains;
118 gchar *
__gst_parse_strdup(gchar * org)119 __gst_parse_strdup (gchar *org)
120 {
121   gchar *ret;
122   __strings++;
123   ret = g_strdup (org);
124   /* g_print ("ALLOCATED STR   (%3u): %p %s\n", __strings, ret, ret); */
125   return ret;
126 }
127 void
__gst_parse_strfree(gchar * str)128 __gst_parse_strfree (gchar *str)
129 {
130   if (str) {
131     /* g_print ("FREEING STR     (%3u): %p %s\n", __strings - 1, str, str); */
132     g_free (str);
133     g_return_if_fail (__strings > 0);
134     __strings--;
135   }
136 }
__gst_parse_link_new(void)137 link_t *__gst_parse_link_new (void)
138 {
139   link_t *ret;
140   __links++;
141   ret = g_slice_new0 (link_t);
142   /* g_print ("ALLOCATED LINK  (%3u): %p\n", __links, ret); */
143   return ret;
144 }
145 void
__gst_parse_link_free(link_t * data)146 __gst_parse_link_free (link_t *data)
147 {
148   if (data) {
149     /* g_print ("FREEING LINK    (%3u): %p\n", __links - 1, data); */
150     g_slice_free (link_t, data);
151     g_return_if_fail (__links > 0);
152     __links--;
153   }
154 }
155 chain_t *
__gst_parse_chain_new(void)156 __gst_parse_chain_new (void)
157 {
158   chain_t *ret;
159   __chains++;
160   ret = g_slice_new0 (chain_t);
161   /* g_print ("@%p: ALLOCATED CHAIN (%3u):\n", ret, __chains); */
162   return ret;
163 }
164 void
__gst_parse_chain_free(chain_t * data)165 __gst_parse_chain_free (chain_t *data)
166 {
167   /* g_print ("@%p: FREEING CHAIN   (%3u):\n", data, __chains - 1); */
168   g_slice_free (chain_t, data);
169   g_return_if_fail (__chains > 0);
170   __chains--;
171 }
172 
173 #endif /* __GST_PARSE_TRACE */
174 
175 /*******************************************************************************************
176 *** define SET_ERROR macro/function
177 *******************************************************************************************/
178 #ifdef G_HAVE_ISO_VARARGS
179 
180 #  define SET_ERROR(error, type, ...) \
181 G_STMT_START { \
182   GST_CAT_ERROR (GST_CAT_PIPELINE, __VA_ARGS__); \
183   if ((error) && !*(error)) { \
184     g_set_error ((error), GST_PARSE_ERROR, (type), __VA_ARGS__); \
185   } \
186 } G_STMT_END
187 
188 #elif defined(G_HAVE_GNUC_VARARGS)
189 
190 #  define SET_ERROR(error, type, args...) \
191 G_STMT_START { \
192   GST_CAT_ERROR (GST_CAT_PIPELINE, args ); \
193   if ((error) && !*(error)) { \
194     g_set_error ((error), GST_PARSE_ERROR, (type), args ); \
195   } \
196 } G_STMT_END
197 
198 #else
199 
200 static inline void
SET_ERROR(GError ** error,gint type,const char * format,...)201 SET_ERROR (GError **error, gint type, const char *format, ...)
202 {
203   if (error) {
204     if (*error) {
205       g_warning ("error while parsing");
206     } else {
207       va_list varargs;
208       char *string;
209 
210       va_start (varargs, format);
211       string = g_strdup_vprintf (format, varargs);
212       va_end (varargs);
213 
214       g_set_error (error, GST_PARSE_ERROR, type, string);
215 
216       g_free (string);
217     }
218   }
219 }
220 
221 #endif /* G_HAVE_ISO_VARARGS */
222 
223 /*** define YYPRINTF macro/function if we're debugging */
224 
225 /* bison 1.35 calls this macro with side effects, we need to make sure the
226    side effects work - crappy bison */
227 
228 #ifndef GST_DISABLE_GST_DEBUG
229 #  define YYDEBUG 1
230 
231 #  ifdef G_HAVE_ISO_VARARGS
232 
233 /* #  define YYFPRINTF(a, ...) GST_CAT_DEBUG (GST_CAT_PIPELINE, __VA_ARGS__) */
234 #    define YYFPRINTF(a, ...) \
235 G_STMT_START { \
236      GST_CAT_LOG (GST_CAT_PIPELINE, __VA_ARGS__); \
237 } G_STMT_END
238 
239 #  elif defined(G_HAVE_GNUC_VARARGS)
240 
241 #    define YYFPRINTF(a, args...) \
242 G_STMT_START { \
243      GST_CAT_LOG (GST_CAT_PIPELINE, args); \
244 } G_STMT_END
245 
246 #  else
247 
248 static inline void
YYPRINTF(const char * format,...)249 YYPRINTF(const char *format, ...)
250 {
251   va_list varargs;
252   gchar *temp;
253 
254   va_start (varargs, format);
255   temp = g_strdup_vprintf (format, varargs);
256   GST_CAT_LOG (GST_CAT_PIPELINE, "%s", temp);
257   g_free (temp);
258   va_end (varargs);
259 }
260 
261 #  endif /* G_HAVE_ISO_VARARGS */
262 
263 #endif /* GST_DISABLE_GST_DEBUG */
264 
265 
266 /*
267  * include headers generated by bison & flex, after defining (or not defining) YYDEBUG
268  */
269 #include "grammar.tab.h"
270 #include "parse_lex.h"
271 
272 /*******************************************************************************************
273 *** report missing elements/bins/..
274 *******************************************************************************************/
275 
276 
add_missing_element(graph_t * graph,gchar * name)277 static void  add_missing_element(graph_t *graph,gchar *name){
278   if ((graph)->ctx){
279     (graph)->ctx->missing_elements = g_list_append ((graph)->ctx->missing_elements, g_strdup (name));
280     }
281 }
282 
283 
284 /*******************************************************************************************
285 *** helpers for pipeline-setup
286 *******************************************************************************************/
287 
288 #define TRY_SETUP_LINK(l) G_STMT_START { \
289    if( (!(l)->src.element) && (!(l)->src.name) ){ \
290      SET_ERROR (graph->error, GST_PARSE_ERROR_LINK, _("link has no source [sink=%s@%p]"), \
291 	(l)->sink.name ? (l)->sink.name : "", \
292 	(l)->sink.element); \
293      gst_parse_free_link (l); \
294    }else if( (!(l)->sink.element) && (!(l)->sink.name) ){ \
295      SET_ERROR (graph->error, GST_PARSE_ERROR_LINK, _("link has no sink [source=%s@%p]"), \
296 	(l)->src.name ? (l)->src.name : "", \
297 	(l)->src.element); \
298      gst_parse_free_link (l); \
299    }else{ \
300      graph->links = g_slist_append (graph->links, l ); \
301    }   \
302 } G_STMT_END
303 
304 typedef struct {
305   gchar *src_pad;
306   gchar *sink_pad;
307   GstElement *sink;
308   GstCaps *caps;
309   gulong pad_added_signal_id, no_more_pads_signal_id;
310   gboolean all_pads;
311 } DelayedLink;
312 
313 typedef struct {
314   gchar *name;
315   gchar *value_str;
316   gulong signal_id;
317 } DelayedSet;
318 
gst_resolve_reference(reference_t * rr,GstElement * pipeline)319 static int  gst_resolve_reference(reference_t *rr, GstElement *pipeline){
320   GstBin *bin;
321 
322   if(rr->element) return  0;  /* already resolved! */
323   if(!rr->name)   return -2;  /* no chance! */
324 
325   if (GST_IS_BIN (pipeline)){
326     bin = GST_BIN (pipeline);
327     rr->element = gst_bin_get_by_name_recurse_up (bin, rr->name);
328   } else {
329     rr->element = strcmp (GST_ELEMENT_NAME (pipeline), rr->name) == 0 ?
330 		gst_object_ref(pipeline) : NULL;
331   }
332   if(rr->element) return 0; /* resolved */
333   else            return -1; /* not found */
334 }
335 
gst_parse_free_delayed_set(DelayedSet * set)336 static void gst_parse_free_delayed_set (DelayedSet *set)
337 {
338   g_free(set->name);
339   g_free(set->value_str);
340   g_slice_free(DelayedSet, set);
341 }
342 
343 static void gst_parse_new_child(GstChildProxy *child_proxy, GObject *object,
344     const gchar * name, gpointer data);
345 
gst_parse_add_delayed_set(GstElement * element,gchar * name,gchar * value_str)346 static void gst_parse_add_delayed_set (GstElement *element, gchar *name, gchar *value_str)
347 {
348   DelayedSet *data = g_slice_new0 (DelayedSet);
349 
350   GST_CAT_LOG_OBJECT (GST_CAT_PIPELINE, element, "delaying property set %s to %s",
351     name, value_str);
352 
353   data->name = g_strdup(name);
354   data->value_str = g_strdup(value_str);
355   data->signal_id = g_signal_connect_data(element, "child-added",
356       G_CALLBACK (gst_parse_new_child), data, (GClosureNotify)
357       gst_parse_free_delayed_set, (GConnectFlags) 0);
358 
359   /* FIXME: we would need to listen on all intermediate bins too */
360   if (GST_IS_BIN (element)) {
361     gchar **names, **current;
362     GstElement *parent, *child;
363 
364     current = names = g_strsplit (name, "::", -1);
365     parent = gst_bin_get_by_name (GST_BIN_CAST (element), current[0]);
366     current++;
367     while (parent && current[0]) {
368       child = gst_bin_get_by_name (GST_BIN (parent), current[0]);
369       if (!child && current[1]) {
370         char *sub_name = g_strjoinv ("::", &current[0]);
371 
372         gst_parse_add_delayed_set(parent, sub_name, value_str);
373         g_free (sub_name);
374       }
375       gst_object_unref (parent);
376       parent = child;
377       current++;
378     }
379     if (parent)
380       gst_object_unref (parent);
381     g_strfreev (names);
382   }
383 }
384 
gst_parse_new_child(GstChildProxy * child_proxy,GObject * object,const gchar * name,gpointer data)385 static void gst_parse_new_child(GstChildProxy *child_proxy, GObject *object,
386     const gchar * name, gpointer data)
387 {
388   DelayedSet *set = (DelayedSet *) data;
389   GParamSpec *pspec;
390   GValue v = { 0, };
391   GObject *target = NULL;
392   GType value_type;
393 
394   GST_CAT_LOG_OBJECT (GST_CAT_PIPELINE, child_proxy, "new child %s, checking property %s",
395       name, set->name);
396 
397   if (gst_child_proxy_lookup (child_proxy, set->name, &target, &pspec)) {
398     gboolean got_value = FALSE;
399 
400     value_type = pspec->value_type;
401 
402     GST_CAT_LOG_OBJECT (GST_CAT_PIPELINE, child_proxy, "parsing delayed property %s as a %s from %s",
403       pspec->name, g_type_name (value_type), set->value_str);
404     g_value_init (&v, value_type);
405     if (gst_value_deserialize_with_pspec (&v, set->value_str, pspec))
406       got_value = TRUE;
407     else if (g_type_is_a (value_type, GST_TYPE_ELEMENT)) {
408        GstElement *bin;
409 
410        bin = gst_parse_bin_from_description_full (set->value_str, TRUE, NULL,
411            GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS | GST_PARSE_FLAG_PLACE_IN_BIN, NULL);
412        if (bin) {
413          g_value_set_object (&v, bin);
414          got_value = TRUE;
415        }
416     }
417     g_signal_handler_disconnect (child_proxy, set->signal_id);
418     if (!got_value)
419       goto error;
420     g_object_set_property (target, pspec->name, &v);
421   } else {
422     const gchar *obj_name = GST_OBJECT_NAME(object);
423     gint len = strlen (obj_name);
424 
425     /* do a delayed set */
426     if ((strlen (set->name) > (len + 2)) && !strncmp (set->name, obj_name, len) && !strncmp (&set->name[len], "::", 2)) {
427       gst_parse_add_delayed_set (GST_ELEMENT(child_proxy), set->name, set->value_str);
428     }
429   }
430 
431 out:
432   if (G_IS_VALUE (&v))
433     g_value_unset (&v);
434   if (target)
435     gst_object_unref (target);
436   return;
437 
438 error:
439   GST_CAT_ERROR (GST_CAT_PIPELINE, "could not set property \"%s\" in %"
440       GST_PTR_FORMAT, pspec->name, target);
441   goto out;
442 }
443 
gst_parse_element_set(gchar * value,GstElement * element,graph_t * graph)444 static void gst_parse_element_set (gchar *value, GstElement *element, graph_t *graph)
445 {
446   GParamSpec *pspec = NULL;
447   gchar *pos = value;
448   GValue v = { 0, };
449   GObject *target = NULL;
450   GType value_type;
451 
452   /* do nothing if assignment is for missing element */
453   if (element == NULL)
454     goto out;
455 
456   /* parse the string, so the property name is null-terminated and pos points
457      to the beginning of the value */
458   while (!g_ascii_isspace (*pos) && (*pos != '=')) pos++;
459   if (*pos == '=') {
460     *pos = '\0';
461   } else {
462     *pos = '\0';
463     pos++;
464     while (g_ascii_isspace (*pos)) pos++;
465   }
466   pos++;
467   while (g_ascii_isspace (*pos)) pos++;
468   /* truncate a string if it is delimited with double quotes */
469   if (*pos == '"' && pos[strlen (pos) - 1] == '"') {
470     pos++;
471     pos[strlen (pos) - 1] = '\0';
472   }
473   gst_parse_unescape (pos);
474 
475   if (GST_IS_CHILD_PROXY (element) && strstr (value, "::") != NULL) {
476     if (!gst_child_proxy_lookup (GST_CHILD_PROXY (element), value, &target, &pspec)) {
477       /* do a delayed set */
478       gst_parse_add_delayed_set (element, value, pos);
479     }
480   } else {
481     pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), value);
482     if (pspec != NULL) {
483       target = G_OBJECT (g_object_ref (element));
484       GST_CAT_LOG_OBJECT (GST_CAT_PIPELINE, target, "found %s property", value);
485     } else {
486       SET_ERROR (graph->error, GST_PARSE_ERROR_NO_SUCH_PROPERTY, \
487           _("no property \"%s\" in element \"%s\""), value, \
488           GST_ELEMENT_NAME (element));
489     }
490   }
491 
492   if (pspec != NULL && target != NULL) {
493     gboolean got_value = FALSE;
494 
495     value_type = pspec->value_type;
496 
497     GST_CAT_LOG_OBJECT (GST_CAT_PIPELINE, element, "parsing property %s as a %s",
498         pspec->name, g_type_name (value_type));
499 
500     g_value_init (&v, value_type);
501     if (gst_value_deserialize_with_pspec (&v, pos, pspec))
502       got_value = TRUE;
503     else if (g_type_is_a (value_type, GST_TYPE_ELEMENT)) {
504        GstElement *bin;
505 
506        bin = gst_parse_bin_from_description_full (pos, TRUE, NULL,
507            GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS | GST_PARSE_FLAG_PLACE_IN_BIN, NULL);
508        if (bin) {
509          g_value_set_object (&v, bin);
510          got_value = TRUE;
511        }
512     }
513     if (!got_value)
514       goto error;
515     g_object_set_property (target, pspec->name, &v);
516   }
517 
518 out:
519   gst_parse_strfree (value);
520   if (G_IS_VALUE (&v))
521     g_value_unset (&v);
522   if (target)
523     gst_object_unref (target);
524   return;
525 
526 error:
527   SET_ERROR (graph->error, GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
528          _("could not set property \"%s\" in element \"%s\" to \"%s\""),
529 	 value, GST_ELEMENT_NAME (element), pos);
530   goto out;
531 }
532 
gst_parse_element_preset(gchar * value,GstElement * element,graph_t * graph)533 static void gst_parse_element_preset (gchar *value, GstElement *element, graph_t *graph)
534 {
535   /* do nothing if preset is for missing element or its not a preset element */
536   if (element == NULL)
537     goto out;
538 
539   if (!GST_IS_PRESET(element))
540     goto not_a_preset;
541 
542   /* do nothing if no preset is given */
543   if (value == NULL || *value == '\0')
544     goto out;
545 
546   gst_parse_unescape (value);
547   if (!gst_preset_load_preset (GST_PRESET (element), value))
548     goto error;
549 
550 out:
551   gst_parse_strfree (value);
552   return;
553 
554 not_a_preset:
555   SET_ERROR (graph->error, GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
556          _("Element \"%s\" is not a GstPreset"),
557 	 GST_ELEMENT_NAME (element));
558   goto out;
559 
560 error:
561   SET_ERROR (graph->error, GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
562          _("could not set preset \"%s\" in element \"%s\""),
563 	 value, GST_ELEMENT_NAME (element));
564   goto out;
565 }
566 
gst_parse_free_reference(reference_t * rr)567 static void gst_parse_free_reference (reference_t *rr)
568 {
569   if(rr->element) gst_object_unref(rr->element);
570   gst_parse_strfree (rr->name);
571   g_slist_foreach (rr->pads, (GFunc) gst_parse_strfree, NULL);
572   g_slist_free (rr->pads);
573 }
574 
gst_parse_free_link(link_t * link)575 static void gst_parse_free_link (link_t *link)
576 {
577   gst_parse_free_reference (&(link->src));
578   gst_parse_free_reference (&(link->sink));
579   if (link->caps) gst_caps_unref (link->caps);
580   gst_parse_link_free (link);
581 }
582 
gst_parse_free_chain(chain_t * ch)583 static void gst_parse_free_chain (chain_t *ch)
584 {
585   GSList *walk;
586   gst_parse_free_reference (&(ch->first));
587   gst_parse_free_reference (&(ch->last));
588   for(walk=ch->elements;walk;walk=walk->next)
589     gst_object_unref (walk->data);
590   g_slist_free (ch->elements);
591   gst_parse_chain_free (ch);
592 }
593 
gst_parse_free_delayed_link(DelayedLink * link)594 static void gst_parse_free_delayed_link (DelayedLink *link)
595 {
596   g_free (link->src_pad);
597   g_free (link->sink_pad);
598   if (link->caps) gst_caps_unref (link->caps);
599   g_slice_free (DelayedLink, link);
600 }
601 
602 #define PRETTY_PAD_NAME_FMT "%s %s of %s named %s"
603 #define PRETTY_PAD_NAME_ARGS(elem, pad_name) \
604   (pad_name ? "pad " : "some"), (pad_name ? pad_name : "pad"), \
605   G_OBJECT_TYPE_NAME(elem), GST_STR_NULL (GST_ELEMENT_NAME (elem))
606 
gst_parse_no_more_pads(GstElement * src,gpointer data)607 static void gst_parse_no_more_pads (GstElement *src, gpointer data)
608 {
609   DelayedLink *link = data;
610 
611   /* Don't warn for all-pads links, as we expect those to
612    * still be active at no-more-pads */
613   if (!link->all_pads) {
614     GST_ELEMENT_WARNING(src, PARSE, DELAYED_LINK,
615       (_("Delayed linking failed.")),
616       ("failed delayed linking " PRETTY_PAD_NAME_FMT " to " PRETTY_PAD_NAME_FMT,
617           PRETTY_PAD_NAME_ARGS (src, link->src_pad),
618           PRETTY_PAD_NAME_ARGS (link->sink, link->sink_pad)));
619   }
620   /* we keep the handlers connected, so that in case an element still adds a pad
621    * despite no-more-pads, we will consider it for pending delayed links */
622 }
623 
gst_parse_found_pad(GstElement * src,GstPad * pad,gpointer data)624 static void gst_parse_found_pad (GstElement *src, GstPad *pad, gpointer data)
625 {
626   DelayedLink *link = data;
627 
628   GST_CAT_INFO (GST_CAT_PIPELINE,
629                 "trying delayed linking %s " PRETTY_PAD_NAME_FMT " to " PRETTY_PAD_NAME_FMT,
630 		            link->all_pads ? "all pads" : "one pad",
631                 PRETTY_PAD_NAME_ARGS (src, link->src_pad),
632                 PRETTY_PAD_NAME_ARGS (link->sink, link->sink_pad));
633 
634   if (gst_element_link_pads_filtered (src, link->src_pad, link->sink,
635       link->sink_pad, link->caps)) {
636     /* do this here, we don't want to get any problems later on when
637      * unlocking states */
638     GST_CAT_DEBUG (GST_CAT_PIPELINE,
639                    "delayed linking %s " PRETTY_PAD_NAME_FMT " to " PRETTY_PAD_NAME_FMT " worked",
640 		               link->all_pads ? "all pads" : "one pad",
641                	   PRETTY_PAD_NAME_ARGS (src, link->src_pad),
642                    PRETTY_PAD_NAME_ARGS (link->sink, link->sink_pad));
643     /* releases 'link' */
644     if (!link->all_pads) {
645       g_signal_handler_disconnect (src, link->no_more_pads_signal_id);
646       g_signal_handler_disconnect (src, link->pad_added_signal_id);
647     }
648   }
649 }
650 
651 /* both padnames and the caps may be NULL */
652 static gboolean
gst_parse_perform_delayed_link(GstElement * src,const gchar * src_pad,GstElement * sink,const gchar * sink_pad,GstCaps * caps,gboolean all_pads)653 gst_parse_perform_delayed_link (GstElement *src, const gchar *src_pad,
654                                 GstElement *sink, const gchar *sink_pad,
655                                 GstCaps *caps, gboolean all_pads)
656 {
657   GList *templs = gst_element_class_get_pad_template_list (
658       GST_ELEMENT_GET_CLASS (src));
659 
660   for (; templs; templs = templs->next) {
661     GstPadTemplate *templ = (GstPadTemplate *) templs->data;
662     if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) &&
663         (GST_PAD_TEMPLATE_PRESENCE(templ) == GST_PAD_SOMETIMES))
664     {
665       DelayedLink *data = g_slice_new (DelayedLink);
666 
667       data->all_pads = all_pads;
668 
669       /* TODO: maybe we should check if src_pad matches this template's names */
670 
671       GST_CAT_DEBUG (GST_CAT_PIPELINE,
672                      "trying delayed link " PRETTY_PAD_NAME_FMT " to " PRETTY_PAD_NAME_FMT,
673                      PRETTY_PAD_NAME_ARGS (src, src_pad),
674                      PRETTY_PAD_NAME_ARGS (sink, sink_pad));
675 
676       data->src_pad = g_strdup (src_pad);
677       data->sink = sink;
678       data->sink_pad = g_strdup (sink_pad);
679       if (caps) {
680       	data->caps = gst_caps_copy (caps);
681       } else {
682       	data->caps = NULL;
683       }
684       data->pad_added_signal_id = g_signal_connect_data (src, "pad-added",
685           G_CALLBACK (gst_parse_found_pad), data,
686           (GClosureNotify) gst_parse_free_delayed_link, (GConnectFlags) 0);
687       data->no_more_pads_signal_id = g_signal_connect (src, "no-more-pads",
688           G_CALLBACK (gst_parse_no_more_pads), data);
689       return TRUE;
690     }
691   }
692   return FALSE;
693 }
694 
695 static gboolean
gst_parse_element_can_do_caps(GstElement * e,GstPadDirection dir,GstCaps * link_caps)696 gst_parse_element_can_do_caps (GstElement * e, GstPadDirection dir,
697     GstCaps * link_caps)
698 {
699   gboolean can_do = FALSE, done = FALSE;
700   GstIterator *it;
701 
702   it = (dir == GST_PAD_SRC) ? gst_element_iterate_src_pads (e) : gst_element_iterate_sink_pads (e);
703 
704   while (!done && !can_do) {
705     GValue v = G_VALUE_INIT;
706     GstPad *pad;
707     GstCaps *caps;
708 
709     switch (gst_iterator_next (it, &v)) {
710       case GST_ITERATOR_OK:
711         pad = g_value_get_object (&v);
712 
713         caps = gst_pad_get_current_caps (pad);
714         if (caps == NULL)
715           caps = gst_pad_query_caps (pad, NULL);
716 
717         can_do = gst_caps_can_intersect (caps, link_caps);
718 
719         GST_TRACE ("can_do: %d for %" GST_PTR_FORMAT " and %" GST_PTR_FORMAT,
720             can_do, caps, link_caps);
721 
722         gst_caps_unref (caps);
723 
724         g_value_unset (&v);
725         break;
726       case GST_ITERATOR_DONE:
727       case GST_ITERATOR_ERROR:
728         done = TRUE;
729         break;
730       case GST_ITERATOR_RESYNC:
731         gst_iterator_resync (it);
732         break;
733     }
734   }
735 
736   gst_iterator_free (it);
737 
738   return can_do;
739 }
740 
741 /*
742  * performs a link and frees the struct. src and sink elements must be given
743  * return values   0 - link performed
744  *                 1 - link delayed
745  *                <0 - error
746  */
747 static gint
gst_parse_perform_link(link_t * link,graph_t * graph)748 gst_parse_perform_link (link_t *link, graph_t *graph)
749 {
750   GstElement *src = link->src.element;
751   GstElement *sink = link->sink.element;
752   GSList *srcs = link->src.pads;
753   GSList *sinks = link->sink.pads;
754   g_assert (GST_IS_ELEMENT (src));
755   g_assert (GST_IS_ELEMENT (sink));
756 
757   GST_CAT_INFO (GST_CAT_PIPELINE,
758       "linking " PRETTY_PAD_NAME_FMT " to " PRETTY_PAD_NAME_FMT " (%u/%u) with caps \"%" GST_PTR_FORMAT "\"",
759       PRETTY_PAD_NAME_ARGS (src, link->src.name),
760       PRETTY_PAD_NAME_ARGS (sink, link->sink.name),
761       g_slist_length (srcs), g_slist_length (sinks), link->caps);
762 
763   if (!srcs || !sinks) {
764     gboolean found_one = gst_element_link_pads_filtered (src,
765         srcs ? (const gchar *) srcs->data : NULL, sink,
766         sinks ? (const gchar *) sinks->data : NULL, link->caps);
767 
768     if (found_one) {
769       if (!link->all_pads)
770         goto success; /* Linked one, and not an all-pads link = we're done */
771 
772       /* Try and link more available pads */
773       while (gst_element_link_pads_filtered (src,
774         srcs ? (const gchar *) srcs->data : NULL, sink,
775         sinks ? (const gchar *) sinks->data : NULL, link->caps));
776     }
777 
778     /* We either didn't find any static pads, or this is a all-pads link,
779      * in which case watch for future pads and link those. Not a failure
780      * in the all-pads case if there's no sometimes pads to watch */
781     if (gst_parse_perform_delayed_link (src,
782           srcs ? (const gchar *) srcs->data : NULL,
783           sink, sinks ? (const gchar *) sinks->data : NULL, link->caps,
784 	  link->all_pads) || link->all_pads) {
785       goto success;
786     } else {
787       goto error;
788     }
789   }
790   if (g_slist_length (link->src.pads) != g_slist_length (link->sink.pads)) {
791     goto error;
792   }
793   while (srcs && sinks) {
794     const gchar *src_pad = (const gchar *) srcs->data;
795     const gchar *sink_pad = (const gchar *) sinks->data;
796     srcs = g_slist_next (srcs);
797     sinks = g_slist_next (sinks);
798     if (gst_element_link_pads_filtered (src, src_pad, sink, sink_pad,
799         link->caps)) {
800       continue;
801     } else {
802       if (gst_parse_perform_delayed_link (src, src_pad,
803                                           sink, sink_pad,
804 					  link->caps, link->all_pads)) {
805 	continue;
806       } else {
807         goto error;
808       }
809     }
810   }
811 
812 success:
813   gst_parse_free_link (link);
814   return 0;
815 
816 error:
817   if (link->caps != NULL) {
818     gboolean src_can_do_caps, sink_can_do_caps;
819     gchar *caps_str = gst_caps_to_string (link->caps);
820 
821     src_can_do_caps =
822         gst_parse_element_can_do_caps (src, GST_PAD_SRC, link->caps);
823     sink_can_do_caps =
824         gst_parse_element_can_do_caps (sink, GST_PAD_SINK, link->caps);
825 
826     if (!src_can_do_caps && sink_can_do_caps) {
827       SET_ERROR (graph->error, GST_PARSE_ERROR_LINK,
828           _("could not link %s to %s, %s can't handle caps %s"),
829           GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (sink),
830           GST_ELEMENT_NAME (src), caps_str);
831     } else if (src_can_do_caps && !sink_can_do_caps) {
832       SET_ERROR (graph->error, GST_PARSE_ERROR_LINK,
833           _("could not link %s to %s, %s can't handle caps %s"),
834           GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (sink),
835           GST_ELEMENT_NAME (sink), caps_str);
836     } else if (!src_can_do_caps && !sink_can_do_caps) {
837       SET_ERROR (graph->error, GST_PARSE_ERROR_LINK,
838           _("could not link %s to %s, neither element can handle caps %s"),
839           GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (sink), caps_str);
840     } else {
841       SET_ERROR (graph->error, GST_PARSE_ERROR_LINK,
842           _("could not link %s to %s with caps %s"),
843           GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (sink), caps_str);
844     }
845     g_free (caps_str);
846   } else {
847     SET_ERROR (graph->error, GST_PARSE_ERROR_LINK,
848         _("could not link %s to %s"), GST_ELEMENT_NAME (src),
849         GST_ELEMENT_NAME (sink));
850   }
851   gst_parse_free_link (link);
852   return -1;
853 }
854 
855 
856 static int yyerror (void *scanner, graph_t *graph, const char *s);
857 
858 #line 859 "subprojects/gstreamer/gst/parse/grammar.tab.c"
859 
860 # ifndef YY_CAST
861 #  ifdef __cplusplus
862 #   define YY_CAST(Type, Val) static_cast<Type> (Val)
863 #   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
864 #  else
865 #   define YY_CAST(Type, Val) ((Type) (Val))
866 #   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
867 #  endif
868 # endif
869 # ifndef YY_NULLPTR
870 #  if defined __cplusplus
871 #   if 201103L <= __cplusplus
872 #    define YY_NULLPTR nullptr
873 #   else
874 #    define YY_NULLPTR 0
875 #   endif
876 #  else
877 #   define YY_NULLPTR ((void*)0)
878 #  endif
879 # endif
880 
881 /* Enabling verbose error messages.  */
882 #ifdef YYERROR_VERBOSE
883 # undef YYERROR_VERBOSE
884 # define YYERROR_VERBOSE 1
885 #else
886 # define YYERROR_VERBOSE 0
887 #endif
888 
889 /* Use api.header.include to #include this header
890    instead of duplicating it here.  */
891 #ifndef YY_PRIV_GST_PARSE_YY_SUBPROJECTS_GSTREAMER_GST_PARSE_GRAMMAR_TAB_H_INCLUDED
892 # define YY_PRIV_GST_PARSE_YY_SUBPROJECTS_GSTREAMER_GST_PARSE_GRAMMAR_TAB_H_INCLUDED
893 /* Debug traces.  */
894 #ifndef YYDEBUG
895 # define YYDEBUG 0
896 #endif
897 #if YYDEBUG
898 extern int priv_gst_parse_yydebug;
899 #endif
900 
901 /* Token type.  */
902 #ifndef YYTOKENTYPE
903 # define YYTOKENTYPE
904   enum yytokentype
905   {
906     PARSE_URL = 258,
907     IDENTIFIER = 259,
908     REF = 260,
909     PADREF = 261,
910     BINREF = 262,
911     ASSIGNMENT = 263,
912     PRESET = 264,
913     LINK = 265,
914     LINK_ALL = 266
915   };
916 #endif
917 
918 /* Value type.  */
919 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
920 union YYSTYPE
921 {
922 #line 785 "subprojects/gstreamer/gst/parse/grammar.y"
923 
924     gchar *ss;
925     chain_t *cc;
926     link_t *ll;
927     reference_t rr;
928     GstElement *ee;
929     GSList *pp;
930     graph_t *gg;
931 
932 #line 933 "subprojects/gstreamer/gst/parse/grammar.tab.c"
933 
934 };
935 typedef union YYSTYPE YYSTYPE;
936 # define YYSTYPE_IS_TRIVIAL 1
937 # define YYSTYPE_IS_DECLARED 1
938 #endif
939 
940 
941 
942 int priv_gst_parse_yyparse (void *scanner, graph_t *graph);
943 
944 #endif /* !YY_PRIV_GST_PARSE_YY_SUBPROJECTS_GSTREAMER_GST_PARSE_GRAMMAR_TAB_H_INCLUDED  */
945 
946 
947 
948 #ifdef short
949 # undef short
950 #endif
951 
952 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
953    <limits.h> and (if available) <stdint.h> are included
954    so that the code can choose integer types of a good width.  */
955 
956 #ifndef __PTRDIFF_MAX__
957 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
958 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
959 #  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
960 #  define YY_STDINT_H
961 # endif
962 #endif
963 
964 /* Narrow types that promote to a signed type and that can represent a
965    signed or unsigned integer of at least N bits.  In tables they can
966    save space and decrease cache pressure.  Promoting to a signed type
967    helps avoid bugs in integer arithmetic.  */
968 
969 #ifdef __INT_LEAST8_MAX__
970 typedef __INT_LEAST8_TYPE__ yytype_int8;
971 #elif defined YY_STDINT_H
972 typedef int_least8_t yytype_int8;
973 #else
974 typedef signed char yytype_int8;
975 #endif
976 
977 #ifdef __INT_LEAST16_MAX__
978 typedef __INT_LEAST16_TYPE__ yytype_int16;
979 #elif defined YY_STDINT_H
980 typedef int_least16_t yytype_int16;
981 #else
982 typedef short yytype_int16;
983 #endif
984 
985 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
986 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
987 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
988        && UINT_LEAST8_MAX <= INT_MAX)
989 typedef uint_least8_t yytype_uint8;
990 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
991 typedef unsigned char yytype_uint8;
992 #else
993 typedef short yytype_uint8;
994 #endif
995 
996 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
997 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
998 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
999        && UINT_LEAST16_MAX <= INT_MAX)
1000 typedef uint_least16_t yytype_uint16;
1001 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
1002 typedef unsigned short yytype_uint16;
1003 #else
1004 typedef int yytype_uint16;
1005 #endif
1006 
1007 #ifndef YYPTRDIFF_T
1008 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
1009 #  define YYPTRDIFF_T __PTRDIFF_TYPE__
1010 #  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
1011 # elif defined PTRDIFF_MAX
1012 #  ifndef ptrdiff_t
1013 #   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1014 #  endif
1015 #  define YYPTRDIFF_T ptrdiff_t
1016 #  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
1017 # else
1018 #  define YYPTRDIFF_T long
1019 #  define YYPTRDIFF_MAXIMUM LONG_MAX
1020 # endif
1021 #endif
1022 
1023 #ifndef YYSIZE_T
1024 # ifdef __SIZE_TYPE__
1025 #  define YYSIZE_T __SIZE_TYPE__
1026 # elif defined size_t
1027 #  define YYSIZE_T size_t
1028 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
1029 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1030 #  define YYSIZE_T size_t
1031 # else
1032 #  define YYSIZE_T unsigned
1033 # endif
1034 #endif
1035 
1036 #define YYSIZE_MAXIMUM                                  \
1037   YY_CAST (YYPTRDIFF_T,                                 \
1038            (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
1039             ? YYPTRDIFF_MAXIMUM                         \
1040             : YY_CAST (YYSIZE_T, -1)))
1041 
1042 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
1043 
1044 /* Stored state numbers (used for stacks). */
1045 typedef yytype_int8 yy_state_t;
1046 
1047 /* State numbers in computations.  */
1048 typedef int yy_state_fast_t;
1049 
1050 #ifndef YY_
1051 # if defined YYENABLE_NLS && YYENABLE_NLS
1052 #  if ENABLE_NLS
1053 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1054 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
1055 #  endif
1056 # endif
1057 # ifndef YY_
1058 #  define YY_(Msgid) Msgid
1059 # endif
1060 #endif
1061 
1062 #ifndef YY_ATTRIBUTE_PURE
1063 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
1064 #  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
1065 # else
1066 #  define YY_ATTRIBUTE_PURE
1067 # endif
1068 #endif
1069 
1070 #ifndef YY_ATTRIBUTE_UNUSED
1071 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
1072 #  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
1073 # else
1074 #  define YY_ATTRIBUTE_UNUSED
1075 # endif
1076 #endif
1077 
1078 /* Suppress unused-variable warnings by "using" E.  */
1079 #if ! defined lint || defined __GNUC__
1080 # define YYUSE(E) ((void) (E))
1081 #else
1082 # define YYUSE(E) /* empty */
1083 #endif
1084 
1085 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
1086 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
1087 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                            \
1088     _Pragma ("GCC diagnostic push")                                     \
1089     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
1090     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
1091 # define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
1092     _Pragma ("GCC diagnostic pop")
1093 #else
1094 # define YY_INITIAL_VALUE(Value) Value
1095 #endif
1096 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1097 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1098 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1099 #endif
1100 #ifndef YY_INITIAL_VALUE
1101 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1102 #endif
1103 
1104 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
1105 # define YY_IGNORE_USELESS_CAST_BEGIN                          \
1106     _Pragma ("GCC diagnostic push")                            \
1107     _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
1108 # define YY_IGNORE_USELESS_CAST_END            \
1109     _Pragma ("GCC diagnostic pop")
1110 #endif
1111 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
1112 # define YY_IGNORE_USELESS_CAST_BEGIN
1113 # define YY_IGNORE_USELESS_CAST_END
1114 #endif
1115 
1116 
1117 #define YY_ASSERT(E) ((void) (0 && (E)))
1118 
1119 #if ! defined yyoverflow || YYERROR_VERBOSE
1120 
1121 /* The parser invokes alloca or malloc; define the necessary symbols.  */
1122 
1123 # ifdef YYSTACK_USE_ALLOCA
1124 #  if YYSTACK_USE_ALLOCA
1125 #   ifdef __GNUC__
1126 #    define YYSTACK_ALLOC __builtin_alloca
1127 #   elif defined __BUILTIN_VA_ARG_INCR
1128 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1129 #   elif defined _AIX
1130 #    define YYSTACK_ALLOC __alloca
1131 #   elif defined _MSC_VER
1132 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1133 #    define alloca _alloca
1134 #   else
1135 #    define YYSTACK_ALLOC alloca
1136 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
1137 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1138       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
1139 #     ifndef EXIT_SUCCESS
1140 #      define EXIT_SUCCESS 0
1141 #     endif
1142 #    endif
1143 #   endif
1144 #  endif
1145 # endif
1146 
1147 # ifdef YYSTACK_ALLOC
1148    /* Pacify GCC's 'empty if-body' warning.  */
1149 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1150 #  ifndef YYSTACK_ALLOC_MAXIMUM
1151     /* The OS might guarantee only one guard page at the bottom of the stack,
1152        and a page size can be as small as 4096 bytes.  So we cannot safely
1153        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
1154        to allow for a few compiler-allocated temporary stack slots.  */
1155 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1156 #  endif
1157 # else
1158 #  define YYSTACK_ALLOC YYMALLOC
1159 #  define YYSTACK_FREE YYFREE
1160 #  ifndef YYSTACK_ALLOC_MAXIMUM
1161 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1162 #  endif
1163 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
1164        && ! ((defined YYMALLOC || defined malloc) \
1165              && (defined YYFREE || defined free)))
1166 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1167 #   ifndef EXIT_SUCCESS
1168 #    define EXIT_SUCCESS 0
1169 #   endif
1170 #  endif
1171 #  ifndef YYMALLOC
1172 #   define YYMALLOC malloc
1173 #   if ! defined malloc && ! defined EXIT_SUCCESS
1174 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1175 #   endif
1176 #  endif
1177 #  ifndef YYFREE
1178 #   define YYFREE free
1179 #   if ! defined free && ! defined EXIT_SUCCESS
1180 void free (void *); /* INFRINGES ON USER NAME SPACE */
1181 #   endif
1182 #  endif
1183 # endif
1184 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1185 
1186 
1187 #if (! defined yyoverflow \
1188      && (! defined __cplusplus \
1189          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1190 
1191 /* A type that is properly aligned for any stack member.  */
1192 union yyalloc
1193 {
1194   yy_state_t yyss_alloc;
1195   YYSTYPE yyvs_alloc;
1196 };
1197 
1198 /* The size of the maximum gap between one aligned stack and the next.  */
1199 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
1200 
1201 /* The size of an array large to enough to hold all stacks, each with
1202    N elements.  */
1203 # define YYSTACK_BYTES(N) \
1204      ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
1205       + YYSTACK_GAP_MAXIMUM)
1206 
1207 # define YYCOPY_NEEDED 1
1208 
1209 /* Relocate STACK from its old location to the new one.  The
1210    local variables YYSIZE and YYSTACKSIZE give the old and new number of
1211    elements in the stack, and YYPTR gives the new location of the
1212    stack.  Advance YYPTR to a properly aligned location for the next
1213    stack.  */
1214 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
1215     do                                                                  \
1216       {                                                                 \
1217         YYPTRDIFF_T yynewbytes;                                         \
1218         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
1219         Stack = &yyptr->Stack_alloc;                                    \
1220         yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
1221         yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
1222       }                                                                 \
1223     while (0)
1224 
1225 #endif
1226 
1227 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
1228 /* Copy COUNT objects from SRC to DST.  The source and destination do
1229    not overlap.  */
1230 # ifndef YYCOPY
1231 #  if defined __GNUC__ && 1 < __GNUC__
1232 #   define YYCOPY(Dst, Src, Count) \
1233       __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
1234 #  else
1235 #   define YYCOPY(Dst, Src, Count)              \
1236       do                                        \
1237         {                                       \
1238           YYPTRDIFF_T yyi;                      \
1239           for (yyi = 0; yyi < (Count); yyi++)   \
1240             (Dst)[yyi] = (Src)[yyi];            \
1241         }                                       \
1242       while (0)
1243 #  endif
1244 # endif
1245 #endif /* !YYCOPY_NEEDED */
1246 
1247 /* YYFINAL -- State number of the termination state.  */
1248 #define YYFINAL  16
1249 /* YYLAST -- Last index in YYTABLE.  */
1250 #define YYLAST   36
1251 
1252 /* YYNTOKENS -- Number of terminals.  */
1253 #define YYNTOKENS  19
1254 /* YYNNTS -- Number of nonterminals.  */
1255 #define YYNNTS  14
1256 /* YYNRULES -- Number of rules.  */
1257 #define YYNRULES  29
1258 /* YYNSTATES -- Number of states.  */
1259 #define YYNSTATES  39
1260 
1261 #define YYUNDEFTOK  2
1262 #define YYMAXUTOK   266
1263 
1264 
1265 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
1266    as returned by yylex, with out-of-bounds checking.  */
1267 #define YYTRANSLATE(YYX)                                                \
1268   (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1269 
1270 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
1271    as returned by yylex.  */
1272 static const yytype_int8 yytranslate[] =
1273 {
1274        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1275        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1276        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1277        2,     2,     2,    16,     2,     2,     2,     2,     2,     2,
1278       12,    13,     2,     2,    14,     2,    15,     2,     2,     2,
1279        2,     2,     2,     2,     2,     2,     2,     2,    18,     2,
1280        2,    17,     2,     2,     2,     2,     2,     2,     2,     2,
1281        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1282        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1283        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1284        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1285        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1286        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1287        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1288        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1289        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1290        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1291        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1292        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1293        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1294        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1295        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1296        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1297        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1298        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1299        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
1300        5,     6,     7,     8,     9,    10,    11
1301 };
1302 
1303 #if YYDEBUG
1304   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
1305 static const yytype_int16 yyrline[] =
1306 {
1307        0,   848,   848,   855,   858,   873,   881,   912,   930,   934,
1308      948,   957,   967,   968,   972,   973,   985,  1004,  1036,  1048,
1309     1056,  1087,  1088,  1097,  1109,  1110,  1113,  1114,  1116,  1160
1310 };
1311 #endif
1312 
1313 #if YYDEBUG || YYERROR_VERBOSE || 0
1314 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1315    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
1316 static const char *const yytname[] =
1317 {
1318   "$end", "error", "$undefined", "PARSE_URL", "IDENTIFIER", "REF",
1319   "PADREF", "BINREF", "ASSIGNMENT", "PRESET", "LINK", "LINK_ALL", "'('",
1320   "')'", "','", "'.'", "'!'", "'='", "':'", "$accept", "element",
1321   "elementary", "chain", "openchain", "link", "pads", "morepads",
1322   "reference", "chainlist", "assignments", "binopener", "bin", "graph", YY_NULLPTR
1323 };
1324 #endif
1325 
1326 # ifdef YYPRINT
1327 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
1328    (internal) symbol number NUM (which must be that of a token).  */
1329 static const yytype_int16 yytoknum[] =
1330 {
1331        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
1332      265,   266,    40,    41,    44,    46,    33,    61,    58
1333 };
1334 # endif
1335 
1336 #define YYPACT_NINF (-20)
1337 
1338 #define yypact_value_is_default(Yyn) \
1339   ((Yyn) == YYPACT_NINF)
1340 
1341 #define YYTABLE_NINF (-30)
1342 
1343 #define yytable_value_is_error(Yyn) \
1344   0
1345 
1346   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1347      STATE-NUM.  */
1348 static const yytype_int8 yypact[] =
1349 {
1350      -20,     0,     6,   -20,   -20,   -20,    -4,   -20,   -20,    21,
1351       18,   -20,    23,   -20,     8,   -20,   -20,    16,   -20,   -20,
1352      -20,    -4,   -20,   -20,   -20,    22,     8,   -20,    -4,   -20,
1353      -20,    14,   -20,   -20,    10,   -20,    18,   -20,   -20
1354 };
1355 
1356   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
1357      Performed when YYTABLE does not specify something else to do.  Zero
1358      means the default is an error.  */
1359 static const yytype_int8 yydefact[] =
1360 {
1361       21,     0,     0,    23,    17,     2,    14,    27,    26,     5,
1362       12,    22,     7,    19,    24,     6,     1,     0,    20,     4,
1363        3,    14,     8,    10,    11,    12,    24,    21,    14,    13,
1364       16,     0,    18,    25,     0,    15,    12,    28,     9
1365 };
1366 
1367   /* YYPGOTO[NTERM-NUM].  */
1368 static const yytype_int8 yypgoto[] =
1369 {
1370      -20,   -20,     1,   -20,   -20,   -20,   -17,   -19,    11,     4,
1371        9,   -20,   -20,   -20
1372 };
1373 
1374   /* YYDEFGOTO[NTERM-NUM].  */
1375 static const yytype_int8 yydefgoto[] =
1376 {
1377       -1,     9,    10,    11,    12,    25,    22,    18,    13,     1,
1378       27,    14,    15,     2
1379 };
1380 
1381   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
1382      positive, shift that token.  If negative, reduce the rule whose
1383      number is the opposite.  If YYTABLE_NINF, syntax error.  */
1384 static const yytype_int8 yytable[] =
1385 {
1386      -29,     3,    29,     4,     5,     6,    16,     7,    31,    35,
1387       17,     3,     8,     4,     5,     6,    26,     7,     5,    38,
1388       28,     7,     8,    37,    21,    30,     8,     6,    21,    19,
1389       20,    34,    36,    23,    24,    33,    32
1390 };
1391 
1392 static const yytype_int8 yycheck[] =
1393 {
1394        0,     1,    21,     3,     4,     5,     0,     7,    25,    28,
1395       14,     1,    12,     3,     4,     5,     8,     7,     4,    36,
1396        4,     7,    12,    13,     6,     3,    12,     5,     6,     8,
1397        9,    27,    31,    10,    11,    26,    25
1398 };
1399 
1400   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1401      symbol of state STATE-NUM.  */
1402 static const yytype_int8 yystos[] =
1403 {
1404        0,    28,    32,     1,     3,     4,     5,     7,    12,    20,
1405       21,    22,    23,    27,    30,    31,     0,    14,    26,     8,
1406        9,     6,    25,    10,    11,    24,     8,    29,     4,    26,
1407        3,    25,    27,    29,    28,    26,    21,    13,    25
1408 };
1409 
1410   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
1411 static const yytype_int8 yyr1[] =
1412 {
1413        0,    19,    20,    20,    20,    21,    21,    22,    23,    23,
1414       24,    24,    25,    25,    26,    26,    22,    23,    22,    23,
1415       27,    28,    28,    28,    29,    29,    30,    30,    31,    32
1416 };
1417 
1418   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
1419 static const yytype_int8 yyr2[] =
1420 {
1421        0,     2,     1,     2,     2,     1,     1,     1,     2,     5,
1422        1,     1,     0,     2,     0,     3,     3,     1,     3,     1,
1423        2,     0,     2,     2,     0,     2,     1,     1,     4,     1
1424 };
1425 
1426 
1427 #define yyerrok         (yyerrstatus = 0)
1428 #define yyclearin       (yychar = YYEMPTY)
1429 #define YYEMPTY         (-2)
1430 #define YYEOF           0
1431 
1432 #define YYACCEPT        goto yyacceptlab
1433 #define YYABORT         goto yyabortlab
1434 #define YYERROR         goto yyerrorlab
1435 
1436 
1437 #define YYRECOVERING()  (!!yyerrstatus)
1438 
1439 #define YYBACKUP(Token, Value)                                    \
1440   do                                                              \
1441     if (yychar == YYEMPTY)                                        \
1442       {                                                           \
1443         yychar = (Token);                                         \
1444         yylval = (Value);                                         \
1445         YYPOPSTACK (yylen);                                       \
1446         yystate = *yyssp;                                         \
1447         goto yybackup;                                            \
1448       }                                                           \
1449     else                                                          \
1450       {                                                           \
1451         yyerror (scanner, graph, YY_("syntax error: cannot back up")); \
1452         YYERROR;                                                  \
1453       }                                                           \
1454   while (0)
1455 
1456 /* Error token number */
1457 #define YYTERROR        1
1458 #define YYERRCODE       256
1459 
1460 
1461 
1462 /* Enable debugging if requested.  */
1463 #if YYDEBUG
1464 
1465 # ifndef YYFPRINTF
1466 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1467 #  define YYFPRINTF fprintf
1468 # endif
1469 
1470 # define YYDPRINTF(Args)                        \
1471 do {                                            \
1472   if (yydebug)                                  \
1473     YYFPRINTF Args;                             \
1474 } while (0)
1475 
1476 /* This macro is provided for backward compatibility. */
1477 #ifndef YY_LOCATION_PRINT
1478 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1479 #endif
1480 
1481 
1482 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
1483 do {                                                                      \
1484   if (yydebug)                                                            \
1485     {                                                                     \
1486       YYFPRINTF (stderr, "%s ", Title);                                   \
1487       yy_symbol_print (stderr,                                            \
1488                   Type, Value, scanner, graph); \
1489       YYFPRINTF (stderr, "\n");                                           \
1490     }                                                                     \
1491 } while (0)
1492 
1493 
1494 /*-----------------------------------.
1495 | Print this symbol's value on YYO.  |
1496 `-----------------------------------*/
1497 
1498 static void
yy_symbol_value_print(FILE * yyo,int yytype,YYSTYPE const * const yyvaluep,void * scanner,graph_t * graph)1499 yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, void *scanner, graph_t *graph)
1500 {
1501   FILE *yyoutput = yyo;
1502   YYUSE (yyoutput);
1503   YYUSE (scanner);
1504   YYUSE (graph);
1505   if (!yyvaluep)
1506     return;
1507 # ifdef YYPRINT
1508   if (yytype < YYNTOKENS)
1509     YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
1510 # endif
1511   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1512   YYUSE (yytype);
1513   YY_IGNORE_MAYBE_UNINITIALIZED_END
1514 }
1515 
1516 
1517 /*---------------------------.
1518 | Print this symbol on YYO.  |
1519 `---------------------------*/
1520 
1521 static void
yy_symbol_print(FILE * yyo,int yytype,YYSTYPE const * const yyvaluep,void * scanner,graph_t * graph)1522 yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, void *scanner, graph_t *graph)
1523 {
1524   YYFPRINTF (yyo, "%s %s (",
1525              yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
1526 
1527   yy_symbol_value_print (yyo, yytype, yyvaluep, scanner, graph);
1528   YYFPRINTF (yyo, ")");
1529 }
1530 
1531 /*------------------------------------------------------------------.
1532 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1533 | TOP (included).                                                   |
1534 `------------------------------------------------------------------*/
1535 
1536 static void
yy_stack_print(yy_state_t * yybottom,yy_state_t * yytop)1537 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
1538 {
1539   YYFPRINTF (stderr, "Stack now");
1540   for (; yybottom <= yytop; yybottom++)
1541     {
1542       int yybot = *yybottom;
1543       YYFPRINTF (stderr, " %d", yybot);
1544     }
1545   YYFPRINTF (stderr, "\n");
1546 }
1547 
1548 # define YY_STACK_PRINT(Bottom, Top)                            \
1549 do {                                                            \
1550   if (yydebug)                                                  \
1551     yy_stack_print ((Bottom), (Top));                           \
1552 } while (0)
1553 
1554 
1555 /*------------------------------------------------.
1556 | Report that the YYRULE is going to be reduced.  |
1557 `------------------------------------------------*/
1558 
1559 static void
yy_reduce_print(yy_state_t * yyssp,YYSTYPE * yyvsp,int yyrule,void * scanner,graph_t * graph)1560 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, int yyrule, void *scanner, graph_t *graph)
1561 {
1562   int yylno = yyrline[yyrule];
1563   int yynrhs = yyr2[yyrule];
1564   int yyi;
1565   YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
1566              yyrule - 1, yylno);
1567   /* The symbols being reduced.  */
1568   for (yyi = 0; yyi < yynrhs; yyi++)
1569     {
1570       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
1571       yy_symbol_print (stderr,
1572                        yystos[+yyssp[yyi + 1 - yynrhs]],
1573                        &yyvsp[(yyi + 1) - (yynrhs)]
1574                                               , scanner, graph);
1575       YYFPRINTF (stderr, "\n");
1576     }
1577 }
1578 
1579 # define YY_REDUCE_PRINT(Rule)          \
1580 do {                                    \
1581   if (yydebug)                          \
1582     yy_reduce_print (yyssp, yyvsp, Rule, scanner, graph); \
1583 } while (0)
1584 
1585 /* Nonzero means print parse trace.  It is left uninitialized so that
1586    multiple parsers can coexist.  */
1587 int yydebug;
1588 #else /* !YYDEBUG */
1589 # define YYDPRINTF(Args)
1590 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1591 # define YY_STACK_PRINT(Bottom, Top)
1592 # define YY_REDUCE_PRINT(Rule)
1593 #endif /* !YYDEBUG */
1594 
1595 
1596 /* YYINITDEPTH -- initial size of the parser's stacks.  */
1597 #ifndef YYINITDEPTH
1598 # define YYINITDEPTH 200
1599 #endif
1600 
1601 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1602    if the built-in stack extension method is used).
1603 
1604    Do not make this value too large; the results are undefined if
1605    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1606    evaluated with infinite-precision integer arithmetic.  */
1607 
1608 #ifndef YYMAXDEPTH
1609 # define YYMAXDEPTH 10000
1610 #endif
1611 
1612 
1613 #if YYERROR_VERBOSE
1614 
1615 # ifndef yystrlen
1616 #  if defined __GLIBC__ && defined _STRING_H
1617 #   define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
1618 #  else
1619 /* Return the length of YYSTR.  */
1620 static YYPTRDIFF_T
yystrlen(const char * yystr)1621 yystrlen (const char *yystr)
1622 {
1623   YYPTRDIFF_T yylen;
1624   for (yylen = 0; yystr[yylen]; yylen++)
1625     continue;
1626   return yylen;
1627 }
1628 #  endif
1629 # endif
1630 
1631 # ifndef yystpcpy
1632 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1633 #   define yystpcpy stpcpy
1634 #  else
1635 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1636    YYDEST.  */
1637 static char *
yystpcpy(char * yydest,const char * yysrc)1638 yystpcpy (char *yydest, const char *yysrc)
1639 {
1640   char *yyd = yydest;
1641   const char *yys = yysrc;
1642 
1643   while ((*yyd++ = *yys++) != '\0')
1644     continue;
1645 
1646   return yyd - 1;
1647 }
1648 #  endif
1649 # endif
1650 
1651 # ifndef yytnamerr
1652 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1653    quotes and backslashes, so that it's suitable for yyerror.  The
1654    heuristic is that double-quoting is unnecessary unless the string
1655    contains an apostrophe, a comma, or backslash (other than
1656    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1657    null, do not copy; instead, return the length of what the result
1658    would have been.  */
1659 static YYPTRDIFF_T
yytnamerr(char * yyres,const char * yystr)1660 yytnamerr (char *yyres, const char *yystr)
1661 {
1662   if (*yystr == '"')
1663     {
1664       YYPTRDIFF_T yyn = 0;
1665       char const *yyp = yystr;
1666 
1667       for (;;)
1668         switch (*++yyp)
1669           {
1670           case '\'':
1671           case ',':
1672             goto do_not_strip_quotes;
1673 
1674           case '\\':
1675             if (*++yyp != '\\')
1676               goto do_not_strip_quotes;
1677             else
1678               goto append;
1679 
1680           append:
1681           default:
1682             if (yyres)
1683               yyres[yyn] = *yyp;
1684             yyn++;
1685             break;
1686 
1687           case '"':
1688             if (yyres)
1689               yyres[yyn] = '\0';
1690             return yyn;
1691           }
1692     do_not_strip_quotes: ;
1693     }
1694 
1695   if (yyres)
1696     return yystpcpy (yyres, yystr) - yyres;
1697   else
1698     return yystrlen (yystr);
1699 }
1700 # endif
1701 
1702 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1703    about the unexpected token YYTOKEN for the state stack whose top is
1704    YYSSP.
1705 
1706    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1707    not large enough to hold the message.  In that case, also set
1708    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1709    required number of bytes is too large to store.  */
1710 static int
yysyntax_error(YYPTRDIFF_T * yymsg_alloc,char ** yymsg,yy_state_t * yyssp,int yytoken)1711 yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1712                 yy_state_t *yyssp, int yytoken)
1713 {
1714   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1715   /* Internationalized format string. */
1716   const char *yyformat = YY_NULLPTR;
1717   /* Arguments of yyformat: reported tokens (one for the "unexpected",
1718      one per "expected"). */
1719   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1720   /* Actual size of YYARG. */
1721   int yycount = 0;
1722   /* Cumulated lengths of YYARG.  */
1723   YYPTRDIFF_T yysize = 0;
1724 
1725   /* There are many possibilities here to consider:
1726      - If this state is a consistent state with a default action, then
1727        the only way this function was invoked is if the default action
1728        is an error action.  In that case, don't check for expected
1729        tokens because there are none.
1730      - The only way there can be no lookahead present (in yychar) is if
1731        this state is a consistent state with a default action.  Thus,
1732        detecting the absence of a lookahead is sufficient to determine
1733        that there is no unexpected or expected token to report.  In that
1734        case, just report a simple "syntax error".
1735      - Don't assume there isn't a lookahead just because this state is a
1736        consistent state with a default action.  There might have been a
1737        previous inconsistent state, consistent state with a non-default
1738        action, or user semantic action that manipulated yychar.
1739      - Of course, the expected token list depends on states to have
1740        correct lookahead information, and it depends on the parser not
1741        to perform extra reductions after fetching a lookahead from the
1742        scanner and before detecting a syntax error.  Thus, state merging
1743        (from LALR or IELR) and default reductions corrupt the expected
1744        token list.  However, the list is correct for canonical LR with
1745        one exception: it will still contain any token that will not be
1746        accepted due to an error action in a later state.
1747   */
1748   if (yytoken != YYEMPTY)
1749     {
1750       int yyn = yypact[+*yyssp];
1751       YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1752       yysize = yysize0;
1753       yyarg[yycount++] = yytname[yytoken];
1754       if (!yypact_value_is_default (yyn))
1755         {
1756           /* Start YYX at -YYN if negative to avoid negative indexes in
1757              YYCHECK.  In other words, skip the first -YYN actions for
1758              this state because they are default actions.  */
1759           int yyxbegin = yyn < 0 ? -yyn : 0;
1760           /* Stay within bounds of both yycheck and yytname.  */
1761           int yychecklim = YYLAST - yyn + 1;
1762           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1763           int yyx;
1764 
1765           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1766             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1767                 && !yytable_value_is_error (yytable[yyx + yyn]))
1768               {
1769                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1770                   {
1771                     yycount = 1;
1772                     yysize = yysize0;
1773                     break;
1774                   }
1775                 yyarg[yycount++] = yytname[yyx];
1776                 {
1777                   YYPTRDIFF_T yysize1
1778                     = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1779                   if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1780                     yysize = yysize1;
1781                   else
1782                     return 2;
1783                 }
1784               }
1785         }
1786     }
1787 
1788   switch (yycount)
1789     {
1790 # define YYCASE_(N, S)                      \
1791       case N:                               \
1792         yyformat = S;                       \
1793       break
1794     default: /* Avoid compiler warnings. */
1795       YYCASE_(0, YY_("syntax error"));
1796       YYCASE_(1, YY_("syntax error, unexpected %s"));
1797       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1798       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1799       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1800       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1801 # undef YYCASE_
1802     }
1803 
1804   {
1805     /* Don't count the "%s"s in the final size, but reserve room for
1806        the terminator.  */
1807     YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1;
1808     if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1809       yysize = yysize1;
1810     else
1811       return 2;
1812   }
1813 
1814   if (*yymsg_alloc < yysize)
1815     {
1816       *yymsg_alloc = 2 * yysize;
1817       if (! (yysize <= *yymsg_alloc
1818              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1819         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1820       return 1;
1821     }
1822 
1823   /* Avoid sprintf, as that infringes on the user's name space.
1824      Don't have undefined behavior even if the translation
1825      produced a string with the wrong number of "%s"s.  */
1826   {
1827     char *yyp = *yymsg;
1828     int yyi = 0;
1829     while ((*yyp = *yyformat) != '\0')
1830       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1831         {
1832           yyp += yytnamerr (yyp, yyarg[yyi++]);
1833           yyformat += 2;
1834         }
1835       else
1836         {
1837           ++yyp;
1838           ++yyformat;
1839         }
1840   }
1841   return 0;
1842 }
1843 #endif /* YYERROR_VERBOSE */
1844 
1845 /*-----------------------------------------------.
1846 | Release the memory associated to this symbol.  |
1847 `-----------------------------------------------*/
1848 
1849 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep,void * scanner,graph_t * graph)1850 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *scanner, graph_t *graph)
1851 {
1852   YYUSE (yyvaluep);
1853   YYUSE (scanner);
1854   YYUSE (graph);
1855   if (!yymsg)
1856     yymsg = "Deleting";
1857   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1858 
1859   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1860   switch (yytype)
1861     {
1862     case 3: /* PARSE_URL  */
1863 #line 813 "subprojects/gstreamer/gst/parse/grammar.y"
1864             {	gst_parse_strfree (((*yyvaluep).ss));		}
1865 #line 1866 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1866         break;
1867 
1868     case 4: /* IDENTIFIER  */
1869 #line 813 "subprojects/gstreamer/gst/parse/grammar.y"
1870             {	gst_parse_strfree (((*yyvaluep).ss));		}
1871 #line 1872 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1872         break;
1873 
1874     case 5: /* REF  */
1875 #line 813 "subprojects/gstreamer/gst/parse/grammar.y"
1876             {	gst_parse_strfree (((*yyvaluep).ss));		}
1877 #line 1878 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1878         break;
1879 
1880     case 6: /* PADREF  */
1881 #line 813 "subprojects/gstreamer/gst/parse/grammar.y"
1882             {	gst_parse_strfree (((*yyvaluep).ss));		}
1883 #line 1884 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1884         break;
1885 
1886     case 7: /* BINREF  */
1887 #line 813 "subprojects/gstreamer/gst/parse/grammar.y"
1888             {	gst_parse_strfree (((*yyvaluep).ss));		}
1889 #line 1890 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1890         break;
1891 
1892     case 8: /* ASSIGNMENT  */
1893 #line 813 "subprojects/gstreamer/gst/parse/grammar.y"
1894             {	gst_parse_strfree (((*yyvaluep).ss));		}
1895 #line 1896 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1896         break;
1897 
1898     case 9: /* PRESET  */
1899 #line 813 "subprojects/gstreamer/gst/parse/grammar.y"
1900             {	gst_parse_strfree (((*yyvaluep).ss));		}
1901 #line 1902 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1902         break;
1903 
1904     case 10: /* LINK  */
1905 #line 813 "subprojects/gstreamer/gst/parse/grammar.y"
1906             {	gst_parse_strfree (((*yyvaluep).ss));		}
1907 #line 1908 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1908         break;
1909 
1910     case 11: /* LINK_ALL  */
1911 #line 813 "subprojects/gstreamer/gst/parse/grammar.y"
1912             {	gst_parse_strfree (((*yyvaluep).ss));		}
1913 #line 1914 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1914         break;
1915 
1916     case 20: /* element  */
1917 #line 818 "subprojects/gstreamer/gst/parse/grammar.y"
1918             {	gst_object_unref (((*yyvaluep).ee));		}
1919 #line 1920 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1920         break;
1921 
1922     case 21: /* elementary  */
1923 #line 814 "subprojects/gstreamer/gst/parse/grammar.y"
1924             {	if(((*yyvaluep).cc))
1925 		  gst_parse_free_chain(((*yyvaluep).cc));	}
1926 #line 1927 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1927         break;
1928 
1929     case 22: /* chain  */
1930 #line 814 "subprojects/gstreamer/gst/parse/grammar.y"
1931             {	if(((*yyvaluep).cc))
1932 		  gst_parse_free_chain(((*yyvaluep).cc));	}
1933 #line 1934 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1934         break;
1935 
1936     case 23: /* openchain  */
1937 #line 814 "subprojects/gstreamer/gst/parse/grammar.y"
1938             {	if(((*yyvaluep).cc))
1939 		  gst_parse_free_chain(((*yyvaluep).cc));	}
1940 #line 1941 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1941         break;
1942 
1943     case 24: /* link  */
1944 #line 816 "subprojects/gstreamer/gst/parse/grammar.y"
1945             {	gst_parse_free_link (((*yyvaluep).ll));	}
1946 #line 1947 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1947         break;
1948 
1949     case 25: /* pads  */
1950 #line 819 "subprojects/gstreamer/gst/parse/grammar.y"
1951             {	GSList *walk;
1952 		for(walk=((*yyvaluep).pp);walk;walk=walk->next)
1953 		  gst_parse_strfree (walk->data);
1954 		g_slist_free (((*yyvaluep).pp));		}
1955 #line 1956 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1956         break;
1957 
1958     case 26: /* morepads  */
1959 #line 819 "subprojects/gstreamer/gst/parse/grammar.y"
1960             {	GSList *walk;
1961 		for(walk=((*yyvaluep).pp);walk;walk=walk->next)
1962 		  gst_parse_strfree (walk->data);
1963 		g_slist_free (((*yyvaluep).pp));		}
1964 #line 1965 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1965         break;
1966 
1967     case 27: /* reference  */
1968 #line 817 "subprojects/gstreamer/gst/parse/grammar.y"
1969             {	gst_parse_free_reference(&(((*yyvaluep).rr)));}
1970 #line 1971 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1971         break;
1972 
1973     case 28: /* chainlist  */
1974 #line 814 "subprojects/gstreamer/gst/parse/grammar.y"
1975             {	if(((*yyvaluep).cc))
1976 		  gst_parse_free_chain(((*yyvaluep).cc));	}
1977 #line 1978 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1978         break;
1979 
1980     case 29: /* assignments  */
1981 #line 819 "subprojects/gstreamer/gst/parse/grammar.y"
1982             {	GSList *walk;
1983 		for(walk=((*yyvaluep).pp);walk;walk=walk->next)
1984 		  gst_parse_strfree (walk->data);
1985 		g_slist_free (((*yyvaluep).pp));		}
1986 #line 1987 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1987         break;
1988 
1989     case 30: /* binopener  */
1990 #line 813 "subprojects/gstreamer/gst/parse/grammar.y"
1991             {	gst_parse_strfree (((*yyvaluep).ss));		}
1992 #line 1993 "subprojects/gstreamer/gst/parse/grammar.tab.c"
1993         break;
1994 
1995     case 31: /* bin  */
1996 #line 814 "subprojects/gstreamer/gst/parse/grammar.y"
1997             {	if(((*yyvaluep).cc))
1998 		  gst_parse_free_chain(((*yyvaluep).cc));	}
1999 #line 2000 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2000         break;
2001 
2002       default:
2003         break;
2004     }
2005   YY_IGNORE_MAYBE_UNINITIALIZED_END
2006 }
2007 
2008 
2009 
2010 
2011 /*----------.
2012 | yyparse.  |
2013 `----------*/
2014 
2015 int
yyparse(void * scanner,graph_t * graph)2016 yyparse (void *scanner, graph_t *graph)
2017 {
2018 /* The lookahead symbol.  */
2019 int yychar;
2020 
2021 
2022 /* The semantic value of the lookahead symbol.  */
2023 /* Default value used for initialization, for pacifying older GCCs
2024    or non-GCC compilers.  */
2025 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
2026 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
2027 
2028     /* Number of syntax errors so far.  */
2029     int yynerrs;
2030 
2031     yy_state_fast_t yystate;
2032     /* Number of tokens to shift before error messages enabled.  */
2033     int yyerrstatus;
2034 
2035     /* The stacks and their tools:
2036        'yyss': related to states.
2037        'yyvs': related to semantic values.
2038 
2039        Refer to the stacks through separate pointers, to allow yyoverflow
2040        to reallocate them elsewhere.  */
2041 
2042     /* The state stack.  */
2043     yy_state_t yyssa[YYINITDEPTH];
2044     yy_state_t *yyss;
2045     yy_state_t *yyssp;
2046 
2047     /* The semantic value stack.  */
2048     YYSTYPE yyvsa[YYINITDEPTH];
2049     YYSTYPE *yyvs;
2050     YYSTYPE *yyvsp;
2051 
2052     YYPTRDIFF_T yystacksize;
2053 
2054   int yyn;
2055   int yyresult;
2056   /* Lookahead token as an internal (translated) token number.  */
2057   int yytoken = 0;
2058   /* The variables used to return semantic value and location from the
2059      action routines.  */
2060   YYSTYPE yyval;
2061 
2062 #if YYERROR_VERBOSE
2063   /* Buffer for error messages, and its allocated size.  */
2064   char yymsgbuf[128];
2065   char *yymsg = yymsgbuf;
2066   YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
2067 #endif
2068 
2069 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
2070 
2071   /* The number of symbols on the RHS of the reduced rule.
2072      Keep to zero when no symbol should be popped.  */
2073   int yylen = 0;
2074 
2075   yyssp = yyss = yyssa;
2076   yyvsp = yyvs = yyvsa;
2077   yystacksize = YYINITDEPTH;
2078 
2079   YYDPRINTF ((stderr, "Starting parse\n"));
2080 
2081   yystate = 0;
2082   yyerrstatus = 0;
2083   yynerrs = 0;
2084   yychar = YYEMPTY; /* Cause a token to be read.  */
2085   goto yysetstate;
2086 
2087 
2088 /*------------------------------------------------------------.
2089 | yynewstate -- push a new state, which is found in yystate.  |
2090 `------------------------------------------------------------*/
2091 yynewstate:
2092   /* In all cases, when you get here, the value and location stacks
2093      have just been pushed.  So pushing a state here evens the stacks.  */
2094   yyssp++;
2095 
2096 
2097 /*--------------------------------------------------------------------.
2098 | yysetstate -- set current state (the top of the stack) to yystate.  |
2099 `--------------------------------------------------------------------*/
2100 yysetstate:
2101   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2102   YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
2103   YY_IGNORE_USELESS_CAST_BEGIN
2104   *yyssp = YY_CAST (yy_state_t, yystate);
2105   YY_IGNORE_USELESS_CAST_END
2106 
2107   if (yyss + yystacksize - 1 <= yyssp)
2108 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
2109     goto yyexhaustedlab;
2110 #else
2111     {
2112       /* Get the current used size of the three stacks, in elements.  */
2113       YYPTRDIFF_T yysize = yyssp - yyss + 1;
2114 
2115 # if defined yyoverflow
2116       {
2117         /* Give user a chance to reallocate the stack.  Use copies of
2118            these so that the &'s don't force the real ones into
2119            memory.  */
2120         yy_state_t *yyss1 = yyss;
2121         YYSTYPE *yyvs1 = yyvs;
2122 
2123         /* Each stack pointer address is followed by the size of the
2124            data in use in that stack, in bytes.  This used to be a
2125            conditional around just the two extra args, but that might
2126            be undefined if yyoverflow is a macro.  */
2127         yyoverflow (YY_("memory exhausted"),
2128                     &yyss1, yysize * YYSIZEOF (*yyssp),
2129                     &yyvs1, yysize * YYSIZEOF (*yyvsp),
2130                     &yystacksize);
2131         yyss = yyss1;
2132         yyvs = yyvs1;
2133       }
2134 # else /* defined YYSTACK_RELOCATE */
2135       /* Extend the stack our own way.  */
2136       if (YYMAXDEPTH <= yystacksize)
2137         goto yyexhaustedlab;
2138       yystacksize *= 2;
2139       if (YYMAXDEPTH < yystacksize)
2140         yystacksize = YYMAXDEPTH;
2141 
2142       {
2143         yy_state_t *yyss1 = yyss;
2144         union yyalloc *yyptr =
2145           YY_CAST (union yyalloc *,
2146                    YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
2147         if (! yyptr)
2148           goto yyexhaustedlab;
2149         YYSTACK_RELOCATE (yyss_alloc, yyss);
2150         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
2151 # undef YYSTACK_RELOCATE
2152         if (yyss1 != yyssa)
2153           YYSTACK_FREE (yyss1);
2154       }
2155 # endif
2156 
2157       yyssp = yyss + yysize - 1;
2158       yyvsp = yyvs + yysize - 1;
2159 
2160       YY_IGNORE_USELESS_CAST_BEGIN
2161       YYDPRINTF ((stderr, "Stack size increased to %ld\n",
2162                   YY_CAST (long, yystacksize)));
2163       YY_IGNORE_USELESS_CAST_END
2164 
2165       if (yyss + yystacksize - 1 <= yyssp)
2166         YYABORT;
2167     }
2168 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
2169 
2170   if (yystate == YYFINAL)
2171     YYACCEPT;
2172 
2173   goto yybackup;
2174 
2175 
2176 /*-----------.
2177 | yybackup.  |
2178 `-----------*/
2179 yybackup:
2180   /* Do appropriate processing given the current state.  Read a
2181      lookahead token if we need one and don't already have one.  */
2182 
2183   /* First try to decide what to do without reference to lookahead token.  */
2184   yyn = yypact[yystate];
2185   if (yypact_value_is_default (yyn))
2186     goto yydefault;
2187 
2188   /* Not known => get a lookahead token if don't already have one.  */
2189 
2190   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
2191   if (yychar == YYEMPTY)
2192     {
2193       YYDPRINTF ((stderr, "Reading a token: "));
2194       yychar = yylex (&yylval, scanner);
2195     }
2196 
2197   if (yychar <= YYEOF)
2198     {
2199       yychar = yytoken = YYEOF;
2200       YYDPRINTF ((stderr, "Now at end of input.\n"));
2201     }
2202   else
2203     {
2204       yytoken = YYTRANSLATE (yychar);
2205       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
2206     }
2207 
2208   /* If the proper action on seeing token YYTOKEN is to reduce or to
2209      detect an error, take that action.  */
2210   yyn += yytoken;
2211   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
2212     goto yydefault;
2213   yyn = yytable[yyn];
2214   if (yyn <= 0)
2215     {
2216       if (yytable_value_is_error (yyn))
2217         goto yyerrlab;
2218       yyn = -yyn;
2219       goto yyreduce;
2220     }
2221 
2222   /* Count tokens shifted since error; after three, turn off error
2223      status.  */
2224   if (yyerrstatus)
2225     yyerrstatus--;
2226 
2227   /* Shift the lookahead token.  */
2228   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
2229   yystate = yyn;
2230   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2231   *++yyvsp = yylval;
2232   YY_IGNORE_MAYBE_UNINITIALIZED_END
2233 
2234   /* Discard the shifted token.  */
2235   yychar = YYEMPTY;
2236   goto yynewstate;
2237 
2238 
2239 /*-----------------------------------------------------------.
2240 | yydefault -- do the default action for the current state.  |
2241 `-----------------------------------------------------------*/
2242 yydefault:
2243   yyn = yydefact[yystate];
2244   if (yyn == 0)
2245     goto yyerrlab;
2246   goto yyreduce;
2247 
2248 
2249 /*-----------------------------.
2250 | yyreduce -- do a reduction.  |
2251 `-----------------------------*/
2252 yyreduce:
2253   /* yyn is the number of a rule to reduce with.  */
2254   yylen = yyr2[yyn];
2255 
2256   /* If YYLEN is nonzero, implement the default value of the action:
2257      '$$ = $1'.
2258 
2259      Otherwise, the following line sets YYVAL to garbage.
2260      This behavior is undocumented and Bison
2261      users should not rely upon it.  Assigning to YYVAL
2262      unconditionally makes the parser a bit smaller, and it avoids a
2263      GCC warning that YYVAL may be used uninitialized.  */
2264   yyval = yyvsp[1-yylen];
2265 
2266 
2267   YY_REDUCE_PRINT (yyn);
2268   switch (yyn)
2269     {
2270   case 2:
2271 #line 848 "subprojects/gstreamer/gst/parse/grammar.y"
2272                                               { (yyval.ee) = gst_element_factory_make ((yyvsp[0].ss), NULL);
2273 						if ((yyval.ee) == NULL) {
2274 						  add_missing_element(graph, (yyvsp[0].ss));
2275 						  SET_ERROR (graph->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no element \"%s\""), (yyvsp[0].ss));
2276 						}
2277 						gst_parse_strfree ((yyvsp[0].ss));
2278                                               }
2279 #line 2280 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2280     break;
2281 
2282   case 3:
2283 #line 855 "subprojects/gstreamer/gst/parse/grammar.y"
2284                                           { gst_parse_element_preset ((yyvsp[0].ss), (yyvsp[-1].ee), graph);
2285 						(yyval.ee) = (yyvsp[-1].ee);
2286 	                                      }
2287 #line 2288 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2288     break;
2289 
2290   case 4:
2291 #line 858 "subprojects/gstreamer/gst/parse/grammar.y"
2292                                               { gst_parse_element_set ((yyvsp[0].ss), (yyvsp[-1].ee), graph);
2293 						(yyval.ee) = (yyvsp[-1].ee);
2294 	                                      }
2295 #line 2296 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2296     break;
2297 
2298   case 5:
2299 #line 873 "subprojects/gstreamer/gst/parse/grammar.y"
2300                                               { (yyval.cc) = gst_parse_chain_new ();
2301 						/* g_print ("@%p: CHAINing elementary\n", $$); */
2302 						(yyval.cc)->first.element = (yyvsp[0].ee)? gst_object_ref((yyvsp[0].ee)) : NULL;
2303 						(yyval.cc)->last.element = (yyvsp[0].ee)? gst_object_ref((yyvsp[0].ee)) : NULL;
2304 						(yyval.cc)->first.name = (yyval.cc)->last.name = NULL;
2305 						(yyval.cc)->first.pads = (yyval.cc)->last.pads = NULL;
2306 						(yyval.cc)->elements = (yyvsp[0].ee) ? g_slist_prepend (NULL, (yyvsp[0].ee)) : NULL;
2307 					      }
2308 #line 2309 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2309     break;
2310 
2311   case 6:
2312 #line 881 "subprojects/gstreamer/gst/parse/grammar.y"
2313                                               { (yyval.cc)=(yyvsp[0].cc); }
2314 #line 2315 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2315     break;
2316 
2317   case 7:
2318 #line 912 "subprojects/gstreamer/gst/parse/grammar.y"
2319                                               { (yyval.cc)=(yyvsp[0].cc);
2320 						if((yyval.cc)->last.name){
2321 							SET_ERROR (graph->error, GST_PARSE_ERROR_SYNTAX,
2322 							_("unexpected reference \"%s\" - ignoring"), (yyval.cc)->last.name);
2323 							gst_parse_strfree((yyval.cc)->last.name);
2324 							(yyval.cc)->last.name=NULL;
2325 						}
2326 						if((yyval.cc)->last.pads){
2327 							SET_ERROR (graph->error, GST_PARSE_ERROR_SYNTAX,
2328 							_("unexpected pad-reference \"%s\" - ignoring"), (gchar*)(yyval.cc)->last.pads->data);
2329 							g_slist_foreach ((yyval.cc)->last.pads, (GFunc) gst_parse_strfree, NULL);
2330 							g_slist_free ((yyval.cc)->last.pads);
2331 							(yyval.cc)->last.pads=NULL;
2332 						}
2333 					      }
2334 #line 2335 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2335     break;
2336 
2337   case 8:
2338 #line 930 "subprojects/gstreamer/gst/parse/grammar.y"
2339                                               { (yyval.cc)=(yyvsp[-1].cc);
2340 						(yyval.cc)->last.pads = g_slist_concat ((yyval.cc)->last.pads, (yyvsp[0].pp));
2341 						/* g_print ("@%p@%p: FKI elementary pads\n", $1, $$->last.pads); */
2342 					      }
2343 #line 2344 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2344     break;
2345 
2346   case 9:
2347 #line 935 "subprojects/gstreamer/gst/parse/grammar.y"
2348                                               {
2349 						(yyvsp[-3].ll)->src  = (yyvsp[-4].cc)->last;
2350 						(yyvsp[-3].ll)->sink = (yyvsp[-1].cc)->first;
2351 						(yyvsp[-3].ll)->sink.pads = g_slist_concat ((yyvsp[-2].pp), (yyvsp[-3].ll)->sink.pads);
2352 						TRY_SETUP_LINK((yyvsp[-3].ll));
2353 						(yyvsp[-1].cc)->first = (yyvsp[-4].cc)->first;
2354 						(yyvsp[-1].cc)->elements = g_slist_concat ((yyvsp[-4].cc)->elements, (yyvsp[-1].cc)->elements);
2355 						gst_parse_chain_free((yyvsp[-4].cc));
2356 						(yyval.cc) = (yyvsp[-1].cc);
2357 						(yyval.cc)->last.pads = g_slist_concat ((yyval.cc)->last.pads, (yyvsp[0].pp));
2358 					      }
2359 #line 2360 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2360     break;
2361 
2362   case 10:
2363 #line 948 "subprojects/gstreamer/gst/parse/grammar.y"
2364                                               { (yyval.ll) = gst_parse_link_new ();
2365 						(yyval.ll)->all_pads = FALSE;
2366 						if ((yyvsp[0].ss)) {
2367 						  (yyval.ll)->caps = gst_caps_from_string ((yyvsp[0].ss));
2368 						  if ((yyval.ll)->caps == NULL)
2369 						    SET_ERROR (graph->error, GST_PARSE_ERROR_LINK, _("could not parse caps \"%s\""), (yyvsp[0].ss));
2370 						  gst_parse_strfree ((yyvsp[0].ss));
2371 						}
2372 					      }
2373 #line 2374 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2374     break;
2375 
2376   case 11:
2377 #line 957 "subprojects/gstreamer/gst/parse/grammar.y"
2378                                               { (yyval.ll) = gst_parse_link_new ();
2379 						(yyval.ll)->all_pads = TRUE;
2380 						if ((yyvsp[0].ss)) {
2381 						  (yyval.ll)->caps = gst_caps_from_string ((yyvsp[0].ss));
2382 						  if ((yyval.ll)->caps == NULL)
2383 						    SET_ERROR (graph->error, GST_PARSE_ERROR_LINK, _("could not parse caps \"%s\""), (yyvsp[0].ss));
2384 						  gst_parse_strfree ((yyvsp[0].ss));
2385 						}
2386 					      }
2387 #line 2388 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2388     break;
2389 
2390   case 12:
2391 #line 967 "subprojects/gstreamer/gst/parse/grammar.y"
2392                                               { (yyval.pp) = NULL; }
2393 #line 2394 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2394     break;
2395 
2396   case 13:
2397 #line 968 "subprojects/gstreamer/gst/parse/grammar.y"
2398                                               { (yyval.pp) = (yyvsp[0].pp);
2399 						(yyval.pp) = g_slist_prepend ((yyval.pp), (yyvsp[-1].ss));
2400 					      }
2401 #line 2402 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2402     break;
2403 
2404   case 14:
2405 #line 972 "subprojects/gstreamer/gst/parse/grammar.y"
2406                                               { (yyval.pp) = NULL; }
2407 #line 2408 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2408     break;
2409 
2410   case 15:
2411 #line 973 "subprojects/gstreamer/gst/parse/grammar.y"
2412                                               { (yyval.pp) = g_slist_prepend ((yyvsp[0].pp), (yyvsp[-1].ss)); }
2413 #line 2414 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2414     break;
2415 
2416   case 16:
2417 #line 985 "subprojects/gstreamer/gst/parse/grammar.y"
2418                                               { GstElement *element =
2419 							  gst_element_make_from_uri (GST_URI_SINK, (yyvsp[0].ss), NULL, NULL);
2420 						/* FIXME: get and parse error properly */
2421 						if (!element) {
2422 						  SET_ERROR (graph->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
2423 							  _("no sink element for URI \"%s\""), (yyvsp[0].ss));
2424 						}
2425 						(yyval.cc) = (yyvsp[-2].cc);
2426 						(yyvsp[-1].ll)->sink.element = element?gst_object_ref(element):NULL;
2427 						(yyvsp[-1].ll)->src = (yyvsp[-2].cc)->last;
2428 						TRY_SETUP_LINK((yyvsp[-1].ll));
2429 						(yyval.cc)->last.element = NULL;
2430 						(yyval.cc)->last.name = NULL;
2431 						(yyval.cc)->last.pads = NULL;
2432 						if(element) (yyval.cc)->elements = g_slist_append ((yyval.cc)->elements, element);
2433 						g_free ((yyvsp[0].ss));
2434 					      }
2435 #line 2436 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2436     break;
2437 
2438   case 17:
2439 #line 1004 "subprojects/gstreamer/gst/parse/grammar.y"
2440                                               { GstElement *element =
2441 							  gst_element_make_from_uri (GST_URI_SRC, (yyvsp[0].ss), NULL, NULL);
2442 						/* FIXME: get and parse error properly */
2443 						if (!element) {
2444 						  SET_ERROR (graph->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
2445 						    _("no source element for URI \"%s\""), (yyvsp[0].ss));
2446 						}
2447 						(yyval.cc) = gst_parse_chain_new ();
2448 						/* g_print ("@%p: CHAINing srcURL\n", $$); */
2449 						(yyval.cc)->first.element = NULL;
2450 						(yyval.cc)->first.name = NULL;
2451 						(yyval.cc)->first.pads = NULL;
2452 						(yyval.cc)->last.element = element ? gst_object_ref(element):NULL;
2453 						(yyval.cc)->last.name = NULL;
2454 						(yyval.cc)->last.pads = NULL;
2455 						(yyval.cc)->elements = element ? g_slist_prepend (NULL, element)  : NULL;
2456 						g_free((yyvsp[0].ss));
2457 					      }
2458 #line 2459 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2459     break;
2460 
2461   case 18:
2462 #line 1036 "subprojects/gstreamer/gst/parse/grammar.y"
2463                                               { (yyval.cc) = (yyvsp[-2].cc);
2464 						(yyvsp[-1].ll)->sink= (yyvsp[0].rr);
2465 						(yyvsp[-1].ll)->src = (yyvsp[-2].cc)->last;
2466 						TRY_SETUP_LINK((yyvsp[-1].ll));
2467 						(yyval.cc)->last.element = NULL;
2468 						(yyval.cc)->last.name = NULL;
2469 						(yyval.cc)->last.pads = NULL;
2470 					      }
2471 #line 2472 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2472     break;
2473 
2474   case 19:
2475 #line 1048 "subprojects/gstreamer/gst/parse/grammar.y"
2476                                               { (yyval.cc) = gst_parse_chain_new ();
2477 						(yyval.cc)->last=(yyvsp[0].rr);
2478 						(yyval.cc)->first.element = NULL;
2479 						(yyval.cc)->first.name = NULL;
2480 						(yyval.cc)->first.pads = NULL;
2481 						(yyval.cc)->elements = NULL;
2482 					      }
2483 #line 2484 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2484     break;
2485 
2486   case 20:
2487 #line 1056 "subprojects/gstreamer/gst/parse/grammar.y"
2488                                               {
2489 						gchar *padname = (yyvsp[-1].ss);
2490 						GSList *pads = (yyvsp[0].pp);
2491 						if (padname) {
2492 						  while (*padname != '.') padname++;
2493 						  *padname = '\0';
2494 						  padname++;
2495 						  if (*padname != '\0')
2496 						    pads = g_slist_prepend (pads, gst_parse_strdup (padname));
2497 						}
2498 						(yyval.rr).element=NULL;
2499 						(yyval.rr).name=(yyvsp[-1].ss);
2500 						(yyval.rr).pads=pads;
2501 					      }
2502 #line 2503 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2503     break;
2504 
2505   case 21:
2506 #line 1087 "subprojects/gstreamer/gst/parse/grammar.y"
2507                                               { (yyval.cc) = NULL; }
2508 #line 2509 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2509     break;
2510 
2511   case 22:
2512 #line 1088 "subprojects/gstreamer/gst/parse/grammar.y"
2513                                               { if ((yyvsp[-1].cc)){
2514 						  gst_parse_free_reference(&((yyvsp[-1].cc)->last));
2515 						  gst_parse_free_reference(&((yyvsp[0].cc)->first));
2516 						  (yyvsp[0].cc)->first = (yyvsp[-1].cc)->first;
2517 						  (yyvsp[0].cc)->elements = g_slist_concat ((yyvsp[-1].cc)->elements, (yyvsp[0].cc)->elements);
2518 						  gst_parse_chain_free ((yyvsp[-1].cc));
2519 						}
2520 						(yyval.cc) = (yyvsp[0].cc);
2521 					      }
2522 #line 2523 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2523     break;
2524 
2525   case 23:
2526 #line 1097 "subprojects/gstreamer/gst/parse/grammar.y"
2527                                               { (yyval.cc)=(yyvsp[-1].cc);
2528 						GST_CAT_DEBUG (GST_CAT_PIPELINE,"trying to recover from syntax error");
2529 						SET_ERROR (graph->error, GST_PARSE_ERROR_SYNTAX, _("syntax error"));
2530 					      }
2531 #line 2532 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2532     break;
2533 
2534   case 24:
2535 #line 1109 "subprojects/gstreamer/gst/parse/grammar.y"
2536                                               { (yyval.pp) = NULL; }
2537 #line 2538 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2538     break;
2539 
2540   case 25:
2541 #line 1110 "subprojects/gstreamer/gst/parse/grammar.y"
2542                                               { (yyval.pp) = g_slist_prepend ((yyvsp[0].pp), (yyvsp[-1].ss)); }
2543 #line 2544 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2544     break;
2545 
2546   case 26:
2547 #line 1113 "subprojects/gstreamer/gst/parse/grammar.y"
2548                                               { (yyval.ss) = gst_parse_strdup("bin"); }
2549 #line 2550 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2550     break;
2551 
2552   case 27:
2553 #line 1114 "subprojects/gstreamer/gst/parse/grammar.y"
2554                                               { (yyval.ss) = (yyvsp[0].ss); }
2555 #line 2556 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2556     break;
2557 
2558   case 28:
2559 #line 1116 "subprojects/gstreamer/gst/parse/grammar.y"
2560                                               {
2561 						chain_t *chain = (yyvsp[-1].cc);
2562 						GSList *walk;
2563 						GstBin *bin = (GstBin *) gst_element_factory_make ((yyvsp[-3].ss), NULL);
2564 						if (!chain) {
2565 						  SET_ERROR (graph->error, GST_PARSE_ERROR_EMPTY_BIN,
2566 						    _("specified empty bin \"%s\", not allowed"), (yyvsp[-3].ss));
2567 						  chain = gst_parse_chain_new ();
2568 						  chain->first.element = chain->last.element = NULL;
2569 						  chain->first.name    = chain->last.name    = NULL;
2570 						  chain->first.pads    = chain->last.pads    = NULL;
2571 						  chain->elements = NULL;
2572 						}
2573 						if (!bin) {
2574 						  add_missing_element(graph, (yyvsp[-3].ss));
2575 						  SET_ERROR (graph->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
2576 						    _("no bin \"%s\", unpacking elements"), (yyvsp[-3].ss));
2577 						  /* clear property-list */
2578 						  g_slist_foreach ((yyvsp[-2].pp), (GFunc) gst_parse_strfree, NULL);
2579 						  g_slist_free ((yyvsp[-2].pp));
2580 						  (yyvsp[-2].pp) = NULL;
2581 						} else {
2582 						  for (walk = chain->elements; walk; walk = walk->next )
2583 						    gst_bin_add (bin, GST_ELEMENT (walk->data));
2584 						  g_slist_free (chain->elements);
2585 						  chain->elements = g_slist_prepend (NULL, bin);
2586 						}
2587 						(yyval.cc) = chain;
2588 						/* set the properties now
2589 						 * HINT: property-list cleared above, if bin==NULL
2590 						 */
2591 						for (walk = (yyvsp[-2].pp); walk; walk = walk->next)
2592 						  gst_parse_element_set ((gchar *) walk->data,
2593 							GST_ELEMENT (bin), graph);
2594 						g_slist_free ((yyvsp[-2].pp));
2595 						gst_parse_strfree ((yyvsp[-3].ss));
2596 					      }
2597 #line 2598 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2598     break;
2599 
2600   case 29:
2601 #line 1160 "subprojects/gstreamer/gst/parse/grammar.y"
2602                                               { (yyval.gg) = graph;
2603 						(yyval.gg)->chain = (yyvsp[0].cc);
2604 						if(!(yyvsp[0].cc)) {
2605 						  SET_ERROR (graph->error, GST_PARSE_ERROR_EMPTY, _("empty pipeline not allowed"));
2606 						}
2607 					      }
2608 #line 2609 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2609     break;
2610 
2611 
2612 #line 2613 "subprojects/gstreamer/gst/parse/grammar.tab.c"
2613 
2614       default: break;
2615     }
2616   /* User semantic actions sometimes alter yychar, and that requires
2617      that yytoken be updated with the new translation.  We take the
2618      approach of translating immediately before every use of yytoken.
2619      One alternative is translating here after every semantic action,
2620      but that translation would be missed if the semantic action invokes
2621      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2622      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
2623      incorrect destructor might then be invoked immediately.  In the
2624      case of YYERROR or YYBACKUP, subsequent parser actions might lead
2625      to an incorrect destructor call or verbose syntax error message
2626      before the lookahead is translated.  */
2627   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2628 
2629   YYPOPSTACK (yylen);
2630   yylen = 0;
2631   YY_STACK_PRINT (yyss, yyssp);
2632 
2633   *++yyvsp = yyval;
2634 
2635   /* Now 'shift' the result of the reduction.  Determine what state
2636      that goes to, based on the state we popped back to and the rule
2637      number reduced by.  */
2638   {
2639     const int yylhs = yyr1[yyn] - YYNTOKENS;
2640     const int yyi = yypgoto[yylhs] + *yyssp;
2641     yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
2642                ? yytable[yyi]
2643                : yydefgoto[yylhs]);
2644   }
2645 
2646   goto yynewstate;
2647 
2648 
2649 /*--------------------------------------.
2650 | yyerrlab -- here on detecting error.  |
2651 `--------------------------------------*/
2652 yyerrlab:
2653   /* Make sure we have latest lookahead translation.  See comments at
2654      user semantic actions for why this is necessary.  */
2655   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2656 
2657   /* If not already recovering from an error, report this error.  */
2658   if (!yyerrstatus)
2659     {
2660       ++yynerrs;
2661 #if ! YYERROR_VERBOSE
2662       yyerror (scanner, graph, YY_("syntax error"));
2663 #else
2664 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2665                                         yyssp, yytoken)
2666       {
2667         char const *yymsgp = YY_("syntax error");
2668         int yysyntax_error_status;
2669         yysyntax_error_status = YYSYNTAX_ERROR;
2670         if (yysyntax_error_status == 0)
2671           yymsgp = yymsg;
2672         else if (yysyntax_error_status == 1)
2673           {
2674             if (yymsg != yymsgbuf)
2675               YYSTACK_FREE (yymsg);
2676             yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
2677             if (!yymsg)
2678               {
2679                 yymsg = yymsgbuf;
2680                 yymsg_alloc = sizeof yymsgbuf;
2681                 yysyntax_error_status = 2;
2682               }
2683             else
2684               {
2685                 yysyntax_error_status = YYSYNTAX_ERROR;
2686                 yymsgp = yymsg;
2687               }
2688           }
2689         yyerror (scanner, graph, yymsgp);
2690         if (yysyntax_error_status == 2)
2691           goto yyexhaustedlab;
2692       }
2693 # undef YYSYNTAX_ERROR
2694 #endif
2695     }
2696 
2697 
2698 
2699   if (yyerrstatus == 3)
2700     {
2701       /* If just tried and failed to reuse lookahead token after an
2702          error, discard it.  */
2703 
2704       if (yychar <= YYEOF)
2705         {
2706           /* Return failure if at end of input.  */
2707           if (yychar == YYEOF)
2708             YYABORT;
2709         }
2710       else
2711         {
2712           yydestruct ("Error: discarding",
2713                       yytoken, &yylval, scanner, graph);
2714           yychar = YYEMPTY;
2715         }
2716     }
2717 
2718   /* Else will try to reuse lookahead token after shifting the error
2719      token.  */
2720   goto yyerrlab1;
2721 
2722 
2723 /*---------------------------------------------------.
2724 | yyerrorlab -- error raised explicitly by YYERROR.  |
2725 `---------------------------------------------------*/
2726 yyerrorlab:
2727   /* Pacify compilers when the user code never invokes YYERROR and the
2728      label yyerrorlab therefore never appears in user code.  */
2729   if (0)
2730     YYERROR;
2731 
2732   /* Do not reclaim the symbols of the rule whose action triggered
2733      this YYERROR.  */
2734   YYPOPSTACK (yylen);
2735   yylen = 0;
2736   YY_STACK_PRINT (yyss, yyssp);
2737   yystate = *yyssp;
2738   goto yyerrlab1;
2739 
2740 
2741 /*-------------------------------------------------------------.
2742 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
2743 `-------------------------------------------------------------*/
2744 yyerrlab1:
2745   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
2746 
2747   for (;;)
2748     {
2749       yyn = yypact[yystate];
2750       if (!yypact_value_is_default (yyn))
2751         {
2752           yyn += YYTERROR;
2753           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2754             {
2755               yyn = yytable[yyn];
2756               if (0 < yyn)
2757                 break;
2758             }
2759         }
2760 
2761       /* Pop the current state because it cannot handle the error token.  */
2762       if (yyssp == yyss)
2763         YYABORT;
2764 
2765 
2766       yydestruct ("Error: popping",
2767                   yystos[yystate], yyvsp, scanner, graph);
2768       YYPOPSTACK (1);
2769       yystate = *yyssp;
2770       YY_STACK_PRINT (yyss, yyssp);
2771     }
2772 
2773   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2774   *++yyvsp = yylval;
2775   YY_IGNORE_MAYBE_UNINITIALIZED_END
2776 
2777 
2778   /* Shift the error token.  */
2779   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2780 
2781   yystate = yyn;
2782   goto yynewstate;
2783 
2784 
2785 /*-------------------------------------.
2786 | yyacceptlab -- YYACCEPT comes here.  |
2787 `-------------------------------------*/
2788 yyacceptlab:
2789   yyresult = 0;
2790   goto yyreturn;
2791 
2792 
2793 /*-----------------------------------.
2794 | yyabortlab -- YYABORT comes here.  |
2795 `-----------------------------------*/
2796 yyabortlab:
2797   yyresult = 1;
2798   goto yyreturn;
2799 
2800 
2801 #if !defined yyoverflow || YYERROR_VERBOSE
2802 /*-------------------------------------------------.
2803 | yyexhaustedlab -- memory exhaustion comes here.  |
2804 `-------------------------------------------------*/
2805 yyexhaustedlab:
2806   yyerror (scanner, graph, YY_("memory exhausted"));
2807   yyresult = 2;
2808   /* Fall through.  */
2809 #endif
2810 
2811 
2812 /*-----------------------------------------------------.
2813 | yyreturn -- parsing is finished, return the result.  |
2814 `-----------------------------------------------------*/
2815 yyreturn:
2816   if (yychar != YYEMPTY)
2817     {
2818       /* Make sure we have latest lookahead translation.  See comments at
2819          user semantic actions for why this is necessary.  */
2820       yytoken = YYTRANSLATE (yychar);
2821       yydestruct ("Cleanup: discarding lookahead",
2822                   yytoken, &yylval, scanner, graph);
2823     }
2824   /* Do not reclaim the symbols of the rule whose action triggered
2825      this YYABORT or YYACCEPT.  */
2826   YYPOPSTACK (yylen);
2827   YY_STACK_PRINT (yyss, yyssp);
2828   while (yyssp != yyss)
2829     {
2830       yydestruct ("Cleanup: popping",
2831                   yystos[+*yyssp], yyvsp, scanner, graph);
2832       YYPOPSTACK (1);
2833     }
2834 #ifndef yyoverflow
2835   if (yyss != yyssa)
2836     YYSTACK_FREE (yyss);
2837 #endif
2838 #if YYERROR_VERBOSE
2839   if (yymsg != yymsgbuf)
2840     YYSTACK_FREE (yymsg);
2841 #endif
2842   return yyresult;
2843 }
2844 #line 1168 "subprojects/gstreamer/gst/parse/grammar.y"
2845 
2846 
2847 
2848 static int
yyerror(void * scanner,graph_t * graph,const char * s)2849 yyerror (void *scanner, graph_t *graph, const char *s)
2850 {
2851   /* FIXME: This should go into the GError somehow, but how? */
2852   GST_WARNING ("Error during parsing: %s", s);
2853   return -1;
2854 }
2855 
2856 
2857 GstElement *
priv_gst_parse_launch(const gchar * str,GError ** error,GstParseContext * ctx,GstParseFlags flags)2858 priv_gst_parse_launch (const gchar *str, GError **error, GstParseContext *ctx,
2859     GstParseFlags flags)
2860 {
2861   graph_t g;
2862   gchar *dstr;
2863   GSList *walk;
2864   GstElement *ret;
2865   yyscan_t scanner;
2866 
2867   g_return_val_if_fail (str != NULL, NULL);
2868   g_return_val_if_fail (error == NULL || *error == NULL, NULL);
2869 
2870   g.chain = NULL;
2871   g.links = NULL;
2872   g.error = error;
2873   g.ctx = ctx;
2874   g.flags = flags;
2875 
2876 #ifdef __GST_PARSE_TRACE
2877   GST_CAT_DEBUG (GST_CAT_PIPELINE, "TRACE: tracing enabled");
2878   __strings = __chains = __links = 0;
2879 #endif /* __GST_PARSE_TRACE */
2880 
2881   /* g_print("Now scanning: %s\n", str); */
2882 
2883   dstr = g_strdup (str);
2884   priv_gst_parse_yylex_init (&scanner);
2885   priv_gst_parse_yy_scan_string (dstr, scanner);
2886 
2887 #if YYDEBUG
2888   yydebug = 1;
2889 #endif
2890 
2891   if (yyparse (scanner, &g) != 0) {
2892     SET_ERROR (error, GST_PARSE_ERROR_SYNTAX,
2893         "Unrecoverable syntax error while parsing pipeline %s", str);
2894 
2895     priv_gst_parse_yylex_destroy (scanner);
2896     g_free (dstr);
2897 
2898     goto error1;
2899   }
2900   priv_gst_parse_yylex_destroy (scanner);
2901   g_free (dstr);
2902 
2903   GST_CAT_DEBUG (GST_CAT_PIPELINE, "got %u elements and %u links",
2904       g.chain ? g_slist_length (g.chain->elements) : 0,
2905       g_slist_length (g.links));
2906 
2907   /* ensure chain is not NULL */
2908   if (!g.chain){
2909     g.chain=gst_parse_chain_new ();
2910     g.chain->elements=NULL;
2911     g.chain->first.element=NULL;
2912     g.chain->first.name=NULL;
2913     g.chain->first.pads=NULL;
2914     g.chain->last.element=NULL;
2915     g.chain->last.name=NULL;
2916     g.chain->last.pads=NULL;
2917   };
2918 
2919   /* ensure elements is not empty */
2920   if(!g.chain->elements){
2921     g.chain->elements= g_slist_prepend (NULL, NULL);
2922   };
2923 
2924   /* put all elements in our bin if necessary */
2925   if(g.chain->elements->next){
2926     GstBin *bin;
2927     if (flags & GST_PARSE_FLAG_PLACE_IN_BIN)
2928       bin = GST_BIN (gst_element_factory_make ("bin", NULL));
2929     else
2930       bin = GST_BIN (gst_element_factory_make ("pipeline", NULL));
2931     g_assert (bin);
2932 
2933     for (walk = g.chain->elements; walk; walk = walk->next) {
2934       if (walk->data != NULL)
2935         gst_bin_add (bin, GST_ELEMENT (walk->data));
2936     }
2937     g_slist_free (g.chain->elements);
2938     g.chain->elements = g_slist_prepend (NULL, bin);
2939   }
2940 
2941   ret = (GstElement *) g.chain->elements->data;
2942   g_slist_free (g.chain->elements);
2943   g.chain->elements=NULL;
2944   gst_parse_free_chain (g.chain);
2945   g.chain = NULL;
2946 
2947 
2948   /* resolve and perform links */
2949   for (walk = g.links; walk; walk = walk->next) {
2950     link_t *l = (link_t *) walk->data;
2951     int err;
2952     err=gst_resolve_reference( &(l->src), ret);
2953     if (err) {
2954        if(-1==err){
2955           SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
2956               "No src-element named \"%s\" - omitting link", l->src.name);
2957        }else{
2958           /* probably a missing element which we've handled already */
2959           SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
2960               "No src-element found - omitting link");
2961        }
2962        gst_parse_free_link (l);
2963        continue;
2964     }
2965 
2966     err=gst_resolve_reference( &(l->sink), ret);
2967     if (err) {
2968        if(-1==err){
2969           SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
2970               "No sink-element named \"%s\" - omitting link", l->src.name);
2971        }else{
2972           /* probably a missing element which we've handled already */
2973           SET_ERROR (error, GST_PARSE_ERROR_NO_SUCH_ELEMENT,
2974               "No sink-element found - omitting link");
2975        }
2976        gst_parse_free_link (l);
2977        continue;
2978     }
2979     gst_parse_perform_link (l, &g);
2980   }
2981   g_slist_free (g.links);
2982 
2983 out:
2984 #ifdef __GST_PARSE_TRACE
2985   GST_CAT_DEBUG (GST_CAT_PIPELINE,
2986       "TRACE: %u strings, %u chains and %u links left", __strings, __chains,
2987       __links);
2988   if (__strings || __chains || __links) {
2989     g_warning ("TRACE: %u strings, %u chains and %u links left", __strings,
2990         __chains, __links);
2991   }
2992 #endif /* __GST_PARSE_TRACE */
2993 
2994   return ret;
2995 
2996 error1:
2997   if (g.chain) {
2998     gst_parse_free_chain (g.chain);
2999     g.chain=NULL;
3000   }
3001 
3002   g_slist_foreach (g.links, (GFunc)gst_parse_free_link, NULL);
3003   g_slist_free (g.links);
3004 
3005   if (error)
3006     g_assert (*error);
3007   ret = NULL;
3008 
3009   goto out;
3010 }
3011