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 FCONNECTION
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);
94 $2->src_index = $$->current->index;
96 $$->connections_pending = g_list_append ($$->connections_pending, $2);
98 | graph property_value { $$ = $1;
100 fprintf (stderr, "error: property value assignments must be preceded by an element definition\n");
103 $$->current->property_values = g_list_append ($$->current->property_values,
108 bin: '{' graph '}' { $$ = $2; $$->current_bin_type = "thread"; }
109 | id '.' '(' graph ')' { $$ = $4; $$->current_bin_type = $1; }
112 connection: CONNECTION
116 rconnection: '!' { $$ = g_new0 (connection_t, 1); }
117 | BCONNECTION { $$ = $1; }
118 | FCONNECTION { $$ = $1; }
119 | id ',' rconnection ',' id
121 $$->src_pads = g_list_prepend ($$->src_pads, $1);
122 $$->sink_pads = g_list_append ($$->sink_pads, $5);
128 extern FILE *_gst_parse_yyin;
129 int _gst_parse_yylex (YYSTYPE *lvalp);
131 static int yylex (void *lvalp) {
132 return _gst_parse_yylex ((YYSTYPE*) lvalp);
136 yyerror (const char *s)
138 fprintf (stderr, "error: %s\n", s);
142 int _gst_parse_yy_scan_string (char*);
144 graph_t * _gst_parse_launch (const gchar *str, GError **error)
149 g_return_val_if_fail (str != NULL, NULL);
151 dstr = g_strdup (str);
152 _gst_parse_yy_scan_string (dstr);
155 _gst_parse_yydebug = 1;
158 if (yyparse (&g) != 0) {
161 GST_PARSE_ERROR_SYNTAX,
167 g_assert (g != NULL);
171 /* if the toplevel only contains one bin, make that bin top-level */
172 if (g->elements == NULL && g->bins && g->bins->next == NULL) {
173 g = (graph_t*)g->bins->data;