From a960c7a7a3555af6b2ec7bf77215b3d87568a9a8 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 17 May 2003 20:45:06 +0000 Subject: [PATCH] This is filtered caps in 20 lines. Implemented full featured parsing of pipelines with filtered caps. To get a grip o... Original commit message from CVS: This is filtered caps in 20 lines. Implemented full featured parsing of pipelines with filtered caps. To get a grip of the syntax you might want to look at testsuite/caps/string-conversions.c or run that test --- gst/parse/grammar.y | 14 +++++++++++--- gst/parse/parse.l | 30 +++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/gst/parse/grammar.y b/gst/parse/grammar.y index 7bd6e2f..aacf73f 100644 --- a/gst/parse/grammar.y +++ b/gst/parse/grammar.y @@ -464,9 +464,10 @@ gst_parse_perform_link (link_t *link, graph_t *graph) g_assert (GST_IS_ELEMENT (src)); g_assert (GST_IS_ELEMENT (sink)); - GST_INFO (GST_CAT_PIPELINE, "linking %s(%s):%u to %s(%s):%u", + GST_INFO (GST_CAT_PIPELINE, "linking %s(%s):%u to %s(%s):%u with caps \"%s\"", GST_ELEMENT_NAME (src), link->src_name ? link->src_name : "---", g_slist_length (srcs), - GST_ELEMENT_NAME (sink), link->sink_name ? link->sink_name : "---", g_slist_length (sinks)); + GST_ELEMENT_NAME (sink), link->sink_name ? link->sink_name : "---", g_slist_length (sinks), + link->caps ? gst_caps_to_string (link->caps) : "-"); if (!srcs || !sinks) { if (gst_element_link_pads_filtered (src, srcs ? (const gchar *) srcs->data : NULL, @@ -535,6 +536,7 @@ static int yyerror (const char *s); %token IDENTIFIER %left REF PADREF BINREF %token ASSIGNMENT +%token LINK %type graph %type chain bin @@ -604,7 +606,13 @@ linkpart: reference { $$ = $1; } | /* NOP */ { MAKE_REF ($$, NULL, NULL); } ; -link: linkpart '!' linkpart { $$ = $1; +link: linkpart LINK linkpart { $$ = $1; + if ($2) { + $$->caps = gst_caps_from_string ($2); + if (!$$->caps) + ERROR (GST_PARSE_ERROR_LINK, "could not parse caps \"%s\"", $2); + gst_parse_strfree ($2); + } $$->sink_name = $3->src_name; $$->sink_pads = $3->src_pads; gst_parse_link_free ($3); diff --git a/gst/parse/parse.l b/gst/parse/parse.l index 4474287..71d978c 100644 --- a/gst/parse/parse.l +++ b/gst/parse/parse.l @@ -21,11 +21,11 @@ #define YY_DECL int _gst_parse_yylex (YYSTYPE *lvalp) %} -_operators [(){}.:!,=] +_operator [(){}.:!,;=] _identifier [[:alpha:]][[:alnum:]\-_%]* _char ("\\".)|([^[:space:]]) -_string {_char}+|("\""([^\"]|"\\\"")*"\"") +_string {_char}+|("\""([^\"]|"\\\"")*"\"")|("'"([^']|"\\\"")*"'") _comma [[:space:]]*","[[:space:]]* _assign [[:space:]]*"="[[:space:]]* @@ -38,6 +38,12 @@ _padref "."{_identifier} _ref {_identifier}"."{_identifier}? _binref {_identifier}[[:space:]]*"."[[:space:]]*"(" +/* links */ +_capschar ("\\".)|([^[:space:]!.,;()\]\[]) +_capsstring {_capschar}+|("\""([^\"]|"\\\"")*"\"")|("'"([^']|"\\\"")*"'") +_mimetype ({_capschar}+"/"{_capschar}+)|("\""([^\"]|"\\\"")*"\"")|("'"([^']|"\\\"")*"'") +_link ("!"[[:space:]]*{_mimetype}(","([^!]|{_capsstring})+)?[[:space:]]*"!")|("!") + %x value %option noyywrap %option nounput @@ -83,7 +89,25 @@ _binref {_identifier}[[:space:]]*"."[[:space:]]*"(" return IDENTIFIER; } -{_operators} { PRINT ("OPERATOR: [%s]\n", yytext); return *yytext; } +{_link} { + gchar *c = yytext; + PRINT ("LINK: %s\n", yytext); + c++; + if (*c) { + while (g_ascii_isspace (*c)) c++; + c = lvalp->s = gst_parse_strdup (c); + while (*c) c++; + g_assert (*--c == '!'); + while (g_ascii_isspace (*--c)); + *++c = '\0'; + } else { + lvalp->s = NULL; + } + BEGIN (INITIAL); + return LINK; +} + +{_operator} { PRINT ("OPERATOR: [%s]\n", yytext); return *yytext; } [[:space:]]+ { PRINT ("SPACE: [%s]\n", yytext); } -- 2.7.4