This is filtered caps in 20 lines. Implemented full featured parsing of pipelines...
authorBenjamin Otte <otte@gnome.org>
Sat, 17 May 2003 20:45:06 +0000 (20:45 +0000)
committerBenjamin Otte <otte@gnome.org>
Sat, 17 May 2003 20:45:06 +0000 (20:45 +0000)
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
gst/parse/parse.l

index 7bd6e2f..aacf73f 100644 (file)
@@ -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 <s> IDENTIFIER
 %left <s> REF PADREF BINREF
 %token <s> ASSIGNMENT
+%token <s> LINK
 
 %type <g> graph
 %type <c> 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);
index 4474287..71d978c 100644 (file)
 #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); }