6 #include "../gstparse.h"
10 #define YYERROR_VERBOSE 1
11 #define YYPARSE_PARAM pgraph
13 static int yylex (void *lvalp);
14 static int yyerror (const char *s);
27 %token <c> LINK BLINK FLINK
33 %type <p> property_value value
49 value: VALUE { $$ = g_new0 (property_t, 1); $$->value = $1; }
52 property_value: id '=' value { $$ = $3; $$->name = $1; }
55 element: id { static int i = 0; $$ = g_new0 (element_t, 1);
56 $$->type = $1; $$->index = ++i; }
59 graph: /* empty */ { $$ = g_new0 (graph_t, 1); *((graph_t**) pgraph) = $$; }
60 | graph element { GList *l;
61 $$ = $1; l = $$->links_pending;
62 $$->elements = g_list_append ($$->elements, $2);
65 $$->first = $$->current;
67 ((link_t*) l->data)->sink_index = $$->current->index;
70 if ($$->links_pending) {
71 g_list_free ($$->links_pending);
72 $$->links_pending = NULL;
75 | graph bin { GList *l; $$ = $1; l = $$->links_pending;
76 *((graph_t**) pgraph) = $$;
77 $$->bins = g_list_append ($$->bins, $2);
79 $$->current = $2->first;
81 $$->first = $$->current;
83 ((link_t*) l->data)->sink_index = $$->current->index;
86 if ($$->links_pending) {
87 g_list_free ($$->links_pending);
88 $$->links_pending = NULL;
90 $$->current = $2->current;
92 | graph link { $$ = $1;
93 $$->links = g_list_append ($$->links, $2);
95 $2->src_index = $$->current->index;
97 $$->links_pending = g_list_append ($$->links_pending, $2);
99 | graph property_value { $$ = $1;
101 fprintf (stderr, "error: property value assignments must be preceded by an element definition\n");
104 $$->current->property_values = g_list_append ($$->current->property_values,
109 bin: '{' graph '}' { $$ = $2; $$->current_bin_type = "thread"; }
110 | id '.' '(' graph ')' { $$ = $4; $$->current_bin_type = $1; }
117 rlink: '!' { $$ = g_new0 (link_t, 1); }
120 | id ',' rlink ',' id
122 $$->src_pads = g_list_prepend ($$->src_pads, $1);
123 $$->sink_pads = g_list_append ($$->sink_pads, $5);
129 extern FILE *_gst_parse_yyin;
130 int _gst_parse_yylex (YYSTYPE *lvalp);
132 static int yylex (void *lvalp) {
133 return _gst_parse_yylex ((YYSTYPE*) lvalp);
137 yyerror (const char *s)
139 fprintf (stderr, "error: %s\n", s);
143 int _gst_parse_yy_scan_string (char*);
145 graph_t * _gst_parse_launch (const gchar *str, GError **error)
150 g_return_val_if_fail (str != NULL, NULL);
152 dstr = g_strdup (str);
153 _gst_parse_yy_scan_string (dstr);
156 _gst_parse_yydebug = 1;
159 if (yyparse (&g) != 0) {
162 GST_PARSE_ERROR_SYNTAX,
168 g_assert (g != NULL);
172 /* if the toplevel only contains one bin, make that bin top-level */
173 if (g->elements == NULL && g->bins && g->bins->next == NULL) {
174 g = (graph_t*)g->bins->data;