2002-03-31 21:09:17 +00:00
|
|
|
%{
|
|
|
|
#include <glib.h>
|
|
|
|
#include <stdio.h>
|
2002-04-10 16:50:00 +00:00
|
|
|
#include <string.h>
|
2002-04-07 23:32:16 +00:00
|
|
|
#include "../gstparse.h"
|
2002-04-01 06:30:39 +00:00
|
|
|
#include "types.h"
|
2002-04-07 23:32:16 +00:00
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
#define YYDEBUG 1
|
|
|
|
#define YYERROR_VERBOSE 1
|
2002-04-07 23:32:16 +00:00
|
|
|
#define YYPARSE_PARAM pgraph
|
|
|
|
|
|
|
|
static int yylex (void *lvalp);
|
|
|
|
static int yyerror (const char *s);
|
2002-03-31 21:09:17 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
%union {
|
|
|
|
gchar *s;
|
2002-04-07 23:32:16 +00:00
|
|
|
GValue *v;
|
2002-04-01 06:30:39 +00:00
|
|
|
graph_t *g;
|
|
|
|
connection_t *c;
|
|
|
|
property_t *p;
|
|
|
|
element_t *e;
|
2002-03-31 21:09:17 +00:00
|
|
|
}
|
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
%token <s> IDENTIFIER
|
|
|
|
%token <c> CONNECTION BCONNECTION
|
|
|
|
%token <v> VALUE
|
2002-03-31 21:09:17 +00:00
|
|
|
|
2002-04-01 06:30:39 +00:00
|
|
|
%type <s> id
|
|
|
|
%type <g> graph bin
|
|
|
|
%type <e> element
|
|
|
|
%type <p> property_value value
|
2002-04-07 23:32:16 +00:00
|
|
|
%type <c> connection rconnection
|
2002-04-01 06:30:39 +00:00
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
%left '{' '}' '(' ')'
|
|
|
|
%left '!' '='
|
2002-04-07 23:32:16 +00:00
|
|
|
%left ','
|
2002-04-01 04:36:56 +00:00
|
|
|
%left '.'
|
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
%pure_parser
|
|
|
|
|
2002-04-01 04:36:56 +00:00
|
|
|
%start graph
|
2002-03-31 21:09:17 +00:00
|
|
|
%%
|
|
|
|
|
2002-04-01 06:30:39 +00:00
|
|
|
id: IDENTIFIER
|
2002-04-01 04:36:56 +00:00
|
|
|
;
|
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
value: VALUE { $$ = g_new0 (property_t, 1); $$->value = $1; }
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-01 06:30:39 +00:00
|
|
|
property_value: id '=' value { $$ = $3; $$->name = $1; }
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
element: id { static int i = 0; $$ = g_new0 (element_t, 1);
|
|
|
|
$$->type = $1; $$->index = ++i; }
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
graph: /* empty */ { $$ = g_new0 (graph_t, 1); *((graph_t**) pgraph) = $$; }
|
|
|
|
| graph element { GList *l;
|
|
|
|
$$ = $1; l = $$->connections_pending;
|
2002-04-01 06:30:39 +00:00
|
|
|
$$->elements = g_list_append ($$->elements, $2);
|
|
|
|
$$->current = $2;
|
2002-04-07 23:32:16 +00:00
|
|
|
if (!$$->first)
|
|
|
|
$$->first = $$->current;
|
|
|
|
while (l) {
|
|
|
|
((connection_t*) l->data)->sink_index = $$->current->index;
|
|
|
|
l = g_list_next (l);
|
|
|
|
}
|
|
|
|
if ($$->connections_pending) {
|
|
|
|
g_list_free ($$->connections_pending);
|
|
|
|
$$->connections_pending = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
| graph bin { GList *l; $$ = $1; l = $$->connections_pending;
|
|
|
|
*((graph_t**) pgraph) = $$;
|
|
|
|
$$->bins = g_list_append ($$->bins, $2);
|
|
|
|
$2->parent = $$;
|
|
|
|
$$->current = $2->first;
|
|
|
|
if (!$$->first)
|
|
|
|
$$->first = $$->current;
|
2002-04-01 06:30:39 +00:00
|
|
|
while (l) {
|
2002-04-07 23:32:16 +00:00
|
|
|
((connection_t*) l->data)->sink_index = $$->current->index;
|
2002-04-01 06:30:39 +00:00
|
|
|
l = g_list_next (l);
|
|
|
|
}
|
|
|
|
if ($$->connections_pending) {
|
|
|
|
g_list_free ($$->connections_pending);
|
|
|
|
$$->connections_pending = NULL;
|
|
|
|
}
|
2002-04-07 23:32:16 +00:00
|
|
|
$$->current = $2->current;
|
2002-04-01 06:30:39 +00:00
|
|
|
}
|
2002-04-07 23:32:16 +00:00
|
|
|
| graph connection { $$ = $1;
|
|
|
|
$$->connections = g_list_append ($$->connections, $2);
|
|
|
|
$2->src_index = $$->current->index;
|
|
|
|
if (!$2->sink_name)
|
2002-04-01 06:30:39 +00:00
|
|
|
$$->connections_pending = g_list_append ($$->connections_pending, $2);
|
|
|
|
}
|
|
|
|
| graph property_value { $$ = $1;
|
2002-04-11 20:35:18 +00:00
|
|
|
if (!$$->current) {
|
|
|
|
fprintf (stderr, "error: property value assignments must be preceded by an element definition\n");
|
|
|
|
YYABORT;
|
|
|
|
}
|
2002-04-01 06:30:39 +00:00
|
|
|
$$->current->property_values = g_list_append ($$->current->property_values,
|
|
|
|
$2);
|
|
|
|
}
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
bin: '{' graph '}' { $$ = $2; $$->current_bin_type = "thread"; }
|
2002-04-01 06:30:39 +00:00
|
|
|
| id '.' '(' graph ')' { $$ = $4; $$->current_bin_type = $1; }
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
connection: CONNECTION
|
2002-03-31 21:09:17 +00:00
|
|
|
| rconnection
|
|
|
|
;
|
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
rconnection: '!' { $$ = g_new0 (connection_t, 1); }
|
|
|
|
| BCONNECTION { $$ = $1; }
|
|
|
|
| id ',' rconnection ',' id
|
2002-04-01 06:30:39 +00:00
|
|
|
{ $$ = $3;
|
2002-04-07 23:32:16 +00:00
|
|
|
$$->src_pads = g_list_prepend ($$->src_pads, $1);
|
2002-04-01 06:30:39 +00:00
|
|
|
$$->sink_pads = g_list_append ($$->sink_pads, $5);
|
|
|
|
}
|
2002-03-31 21:09:17 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
extern FILE *yyin;
|
2002-04-07 23:32:16 +00:00
|
|
|
int _gst_parse_yylex (YYSTYPE *lvalp);
|
|
|
|
|
|
|
|
static int yylex (void *lvalp) {
|
|
|
|
return _gst_parse_yylex ((YYSTYPE*) lvalp);
|
|
|
|
}
|
2002-03-31 21:09:17 +00:00
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
static int
|
2002-03-31 21:09:17 +00:00
|
|
|
yyerror (const char *s)
|
|
|
|
{
|
2002-04-11 20:35:18 +00:00
|
|
|
fprintf (stderr, "error: %s\n", s);
|
2002-03-31 21:09:17 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
int yy_scan_string (char*);
|
|
|
|
|
|
|
|
graph_t * _gst_parse_launch (const gchar *str, GError **error)
|
2002-03-31 21:09:17 +00:00
|
|
|
{
|
2002-04-07 23:32:16 +00:00
|
|
|
graph_t *g = NULL;
|
|
|
|
gchar *dstr;
|
|
|
|
|
|
|
|
g_return_val_if_fail (str != NULL, NULL);
|
|
|
|
|
|
|
|
dstr = g_strdup (str);
|
|
|
|
yy_scan_string (dstr);
|
2002-04-01 06:30:39 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
yydebug = 1;
|
|
|
|
#endif
|
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
if (yyparse (&g) != 0) {
|
|
|
|
g_set_error (error,
|
|
|
|
GST_PARSE_ERROR,
|
|
|
|
GST_PARSE_ERROR_SYNTAX,
|
|
|
|
"Invalid syntax");
|
|
|
|
g_free (dstr);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert (g != NULL);
|
|
|
|
|
|
|
|
g_free (dstr);
|
|
|
|
|
2002-05-05 17:45:41 +00:00
|
|
|
/* if the toplevel only contains one bin, make that bin top-level */
|
|
|
|
if (g->elements == NULL && g->bins && g->bins->next == NULL) {
|
|
|
|
g = (graph_t*)g->bins->data;
|
|
|
|
g_free (g->parent);
|
|
|
|
g->parent = NULL;
|
|
|
|
}
|
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
return g;
|
2002-03-31 21:09:17 +00:00
|
|
|
}
|