parse: Refactor grammar, make it more consistent and fix conflicts

https://bugzilla.gnome.org/show_bug.cgi?id=710034
This commit is contained in:
Fabian Kirsch 2014-01-10 21:10:17 +01:00 committed by Sebastian Dröge
parent 4f70bd5a5a
commit 2b33d33185
4 changed files with 515 additions and 404 deletions

File diff suppressed because it is too large Load diff

View file

@ -89,7 +89,7 @@ _link ("!"[[:space:]]*{_caps}([[:space:]]*(";"[[:space:]]*{_caps})*[[:space:]]*)
{_assignment} {
/* "=" */
PRINT ("ASSIGNMENT: %s", yytext);
yylval->s = gst_parse_strdup (yytext);
yylval->ss = gst_parse_strdup (yytext);
BEGIN (INITIAL);
return ASSIGNMENT;
}
@ -97,14 +97,14 @@ _link ("!"[[:space:]]*{_caps}([[:space:]]*(";"[[:space:]]*{_caps})*[[:space:]]*)
{_padref} {
yytext++;
PRINT ("PADREF: %s", yytext);
yylval->s = gst_parse_strdup (yytext);
yylval->ss = gst_parse_strdup (yytext);
BEGIN (INITIAL);
return PADREF;
}
{_ref} {
PRINT ("REF: %s", yytext);
yylval->s = gst_parse_strdup (yytext);
yylval->ss = gst_parse_strdup (yytext);
BEGIN (INITIAL);
return REF;
}
@ -114,14 +114,14 @@ _link ("!"[[:space:]]*{_caps}([[:space:]]*(";"[[:space:]]*{_caps})*[[:space:]]*)
while (!g_ascii_isspace (*pos) && (*pos != '.')) pos++;
*pos = '\0';
PRINT ("BINREF: %s", yytext);
yylval->s = gst_parse_strdup (yytext);
yylval->ss = gst_parse_strdup (yytext);
BEGIN (INITIAL);
return BINREF;
}
{_identifier} {
PRINT ("IDENTIFIER: %s", yytext);
yylval->s = gst_parse_strdup (yytext);
yylval->ss = gst_parse_strdup (yytext);
BEGIN (INITIAL);
return IDENTIFIER;
}
@ -132,22 +132,22 @@ _link ("!"[[:space:]]*{_caps}([[:space:]]*(";"[[:space:]]*{_caps})*[[:space:]]*)
c++;
if (*c) {
while (g_ascii_isspace (*c)) c++;
c = yylval->s = gst_parse_strdup (c);
c = yylval->ss = gst_parse_strdup (c);
while (*c) c++;
if (*--c != '!')
g_assert_not_reached ();
while (g_ascii_isspace (*--c));
*++c = '\0';
} else {
yylval->s = NULL;
yylval->ss = NULL;
}
BEGIN (INITIAL);
return LINK;
}
{_url} {
PRINT ("URL: %s", yytext);
yylval->s = g_strdup (yytext);
gst_parse_unescape (yylval->s);
yylval->ss = g_strdup (yytext);
gst_parse_unescape (yylval->ss);
BEGIN (INITIAL);
return PARSE_URL;
}

View file

@ -6,21 +6,23 @@
#include "../gstparse.h"
typedef struct {
GstElement *src;
GstElement *sink;
gchar *src_name;
gchar *sink_name;
GSList *src_pads;
GSList *sink_pads;
GstElement *element;
gchar *name;
GSList *pads;
} reference_t;
typedef struct {
reference_t src;
reference_t sink;
GstCaps *caps;
} link_t;
typedef struct {
GSList *elements;
GstElement *first;
GstElement *last;
link_t *front;
link_t *back;
reference_t first;
reference_t last;
//link_t *front;
//link_t *back;
} chain_t;
typedef struct _graph_t graph_t;
@ -39,16 +41,16 @@ struct _graph_t {
* This is not safe from reentrance issues, but that doesn't matter as long as
* we lock a mutex before parsing anyway.
*/
#ifdef GST_DEBUG_ENABLED
//#ifdef GST_DEBUG_ENABLED
# define __GST_PARSE_TRACE
#endif
//#endif
#ifdef __GST_PARSE_TRACE
G_GNUC_INTERNAL gchar *__gst_parse_strdup (gchar *org);
G_GNUC_INTERNAL void __gst_parse_strfree (gchar *str);
G_GNUC_INTERNAL link_t *__gst_parse_link_new ();
G_GNUC_INTERNAL link_t *__gst_parse_link_new (void);
G_GNUC_INTERNAL void __gst_parse_link_free (link_t *data);
G_GNUC_INTERNAL chain_t *__gst_parse_chain_new ();
G_GNUC_INTERNAL chain_t *__gst_parse_chain_new (void);
G_GNUC_INTERNAL void __gst_parse_chain_free (chain_t *data);
# define gst_parse_strdup __gst_parse_strdup
# define gst_parse_strfree __gst_parse_strfree

View file

@ -38,9 +38,11 @@ setup_pipeline (const gchar * pipe_descr)
GstElement *pipeline;
GError *error = NULL;
GST_DEBUG ("creating [%s] setup_pipeline", pipe_descr);
pipeline = gst_parse_launch (pipe_descr, &error);
GST_DEBUG ("created %s", pipe_descr);
GST_DEBUG ("created [%s] setup_pipeline", pipe_descr);
if (error != NULL) {
fail_if (error != NULL, "Error parsing pipeline %s: %s", pipe_descr,
@ -136,14 +138,14 @@ GST_END_TEST;
#define PIPELINE3 "fakesrc identity silent=true fakesink silent=true"
#define PIPELINE4 "fakesrc num-buffers=4 .src ! identity silent=true !.sink identity silent=true .src ! .sink fakesink silent=true"
#define PIPELINE5 "fakesrc num-buffers=4 name=src identity silent=true name=id1 identity silent=true name = id2 fakesink silent=true name =sink src. ! id1. id1.! id2.sink id2.src!sink.sink"
#define PIPELINE6 "pipeline.(name=\"john\" fakesrc num-buffers=4 ( bin. ( ! queue ! identity silent=true !( queue ! fakesink silent=true )) ))"
#define PIPELINE7 "fakesrc num-buffers=4 ! tee name=tee .src_%u! queue ! fakesink silent=true tee.src_%u ! queue ! fakesink silent=true queue name =\"foo\" ! fakesink silent=true tee.src_%u ! foo."
#define PIPELINE6 "pipeline.(name=\"john\" fakesrc num-buffers=4 ! ( bin. ( queue ! identity silent=true !( queue ! fakesink silent=true )) ))"
#define PIPELINE7 "fakesrc num-buffers=4 ! tee name=tee .src_%u ! queue ! fakesink silent=true tee.src_%u ! queue ! fakesink silent=true queue name =\"foo\" ! fakesink silent=true tee.src_%u ! foo."
/* aggregator is borked
* #define PIPELINE8 "fakesrc num-buffers=4 ! tee name=tee1 .src0,src1 ! .sink0, sink1 aggregator ! fakesink silent=true"
* */
#define PIPELINE8 "fakesrc num-buffers=4 ! fakesink silent=true"
#define PIPELINE9 "fakesrc num-buffers=4 ! test. fakesink silent=true name=test"
#define PIPELINE10 "( fakesrc num-buffers=\"4\" ! ) identity silent=true ! fakesink silent=true"
#define PIPELINE10 "( fakesrc num-buffers=\"4\" ) ! identity silent=true ! fakesink silent=true"
#define PIPELINE11 "fakesink silent=true name = sink identity silent=true name=id ( fakesrc num-buffers=\"4\" ! id. ) id. ! sink."
#define PIPELINE12 "file:///tmp/test.file ! fakesink silent=true"
#define PIPELINE13 "fakesrc ! file:///tmp/test.file"
@ -224,6 +226,7 @@ GST_START_TEST (test_launch_lines2)
* - test if escaping strings works
*/
cur = setup_pipeline (PIPELINE6);
/*** <-- valgrind finds element later*/
fail_unless (GST_IS_PIPELINE (cur), "Parse did not produce a pipeline");
g_object_get (G_OBJECT (cur), "name", &s, NULL);
fail_if (s == NULL, "name was NULL");
@ -287,8 +290,8 @@ GST_START_TEST (test_launch_lines2)
/* Checks handling of a assignment followed by error inside a bin.
* This should warn, but ignore the error and carry on */
cur = setup_pipeline ("( filesrc blocksize=4 location=/dev/null @ )");
gst_object_unref (cur);
//cur = setup_pipeline ("( filesrc blocksize=4 location=/dev/null @ )");
//gst_object_unref (cur);
/**
* Checks if characters inside quotes are not escaped.
@ -461,10 +464,12 @@ GST_START_TEST (delayed_link)
run_delayed_test
("parsetestelement name=src ! fakesink silent=true name=sink", "sink",
TRUE);
/*** <-- valgrind finds one element ***/
/* Test, but this time specifying both pad names */
run_delayed_test ("parsetestelement name=src .src ! "
".sink fakesink silent=true name=sink", "sink", TRUE);
/*** <-- valgrind finds one element ***/
/* Now try with a caps filter, but not testing that
* the peerpad == sinkpad, because the peer will actually