5 #include "../gstparse.h"
9 #define YYERROR_VERBOSE 1
10 #define YYPARSE_PARAM pgraph
12 static int yylex (void *lvalp);
13 static int yyerror (const char *s);
26 %token <c> CONNECTION BCONNECTION
32 %type <p> property_value value
33 %type <c> connection rconnection
48 value: VALUE { $$ = g_new0 (property_t, 1); $$->value = $1; }
51 property_value: id '=' value { $$ = $3; $$->name = $1; }
54 element: id { static int i = 0; $$ = g_new0 (element_t, 1);
55 $$->type = $1; $$->index = ++i; }
58 graph: /* empty */ { $$ = g_new0 (graph_t, 1); *((graph_t**) pgraph) = $$; }
59 | graph element { GList *l;
60 $$ = $1; l = $$->connections_pending;
61 $$->elements = g_list_append ($$->elements, $2);
64 $$->first = $$->current;
66 ((connection_t*) l->data)->sink_index = $$->current->index;
69 if ($$->connections_pending) {
70 g_list_free ($$->connections_pending);
71 $$->connections_pending = NULL;
74 | graph bin { GList *l; $$ = $1; l = $$->connections_pending;
75 *((graph_t**) pgraph) = $$;
76 $$->bins = g_list_append ($$->bins, $2);
78 $$->current = $2->first;
80 $$->first = $$->current;
82 ((connection_t*) l->data)->sink_index = $$->current->index;
85 if ($$->connections_pending) {
86 g_list_free ($$->connections_pending);
87 $$->connections_pending = NULL;
89 $$->current = $2->current;
91 | graph connection { $$ = $1;
92 $$->connections = g_list_append ($$->connections, $2);
93 $2->src_index = $$->current->index;
95 $$->connections_pending = g_list_append ($$->connections_pending, $2);
97 | graph property_value { $$ = $1;
99 fprintf (stderr, "error: property value assignments must be preceded by an element definition\n");
102 $$->current->property_values = g_list_append ($$->current->property_values,
107 bin: '{' graph '}' { $$ = $2; $$->current_bin_type = "thread"; }
108 | id '.' '(' graph ')' { $$ = $4; $$->current_bin_type = $1; }
111 connection: CONNECTION
115 rconnection: '!' { $$ = g_new0 (connection_t, 1); }
116 | BCONNECTION { $$ = $1; }
117 | id ',' rconnection ',' id
119 $$->src_pads = g_list_prepend ($$->src_pads, $1);
120 $$->sink_pads = g_list_append ($$->sink_pads, $5);
126 extern FILE *_gst_parse_yyin;
127 int _gst_parse_yylex (YYSTYPE *lvalp);
129 static int yylex (void *lvalp) {
130 return _gst_parse_yylex ((YYSTYPE*) lvalp);
134 yyerror (const char *s)
136 fprintf (stderr, "error: %s\n", s);
140 int _gst_parse_yy_scan_string (char*);
142 graph_t * _gst_parse_launch (const gchar *str, GError **error)
147 g_return_val_if_fail (str != NULL, NULL);
149 dstr = g_strdup (str);
150 _gst_parse_yy_scan_string (dstr);
153 _gst_parse_yydebug = 1;
156 if (yyparse (&g) != 0) {
159 GST_PARSE_ERROR_SYNTAX,
165 g_assert (g != NULL);
169 /* if the toplevel only contains one bin, make that bin top-level */
170 if (g->elements == NULL && g->bins && g->bins->next == NULL) {
171 g = (graph_t*)g->bins->data;