fix caps parsing. Some evil person (me?\!) disallowed the dot as a character in caps
[platform/upstream/gstreamer.git] / gst / parse / parse.l
1 %{
2 #include <math.h>
3 #include <ctype.h>
4 #include <string.h>
5
6 #include "../gst_private.h"
7
8 #include "types.h"
9 #include "../gstinfo.h"
10 #include "../gsturi.h"
11 #include "grammar.tab.h"
12
13 #ifdef G_HAVE_ISO_VARARGS
14 #define PRINT(...) GST_CAT_DEBUG (GST_CAT_PIPELINE, "flex: "__VA_ARGS__)
15 #elif defined(G_HAVE_GNUC_VARARGS)
16 #define PRINT(args...) GST_CAT_DEBUG (GST_CAT_PIPELINE, "flex: "##args)
17 #else
18 #define PRINT(args...)
19 #endif
20
21 #define YY_DECL int _gst_parse_yylex (YYSTYPE *lvalp)
22 %}
23
24 _operator [(){}.:!,;=]
25 _identifier [[:alpha:]][[:alnum:]\-_%]*
26
27 _char ("\\".)|([^[:space:]])
28 _string {_char}+|("\""([^\"]|"\\\"")*"\"")|("'"([^']|"\\\"")*"'")
29
30 _comma [[:space:]]*","[[:space:]]*
31 _assign [[:space:]]*"="[[:space:]]*
32
33 _protocol [[:alpha:]][[:alnum:]+-\.]*
34 _url {_protocol}"://"{_string}|["."{_identifier}]?"/"{_string}
35
36 /* we must do this here, because nearly everything matches a {_string} */ 
37 _assignment {_identifier}{_assign}{_string}
38
39 /* get pad/element references and stuff with dots right */
40 _padref "."{_identifier}
41 _ref {_identifier}"."{_identifier}?
42 _binref {_identifier}[[:space:]]*"."[[:space:]]*"("
43
44 /* links */
45 _mimechar ([[:alnum:]-])
46 _mimetype ({_mimechar}+"/"{_mimechar}+)|("\""([^\"]|"\\\"")*"\"")|("'"([^']|"\\\"")*"'")
47 _capschar ("\\".)|([^[:space:]\;!\,\(\)\]\[])
48 _capsstring {_capschar}+|("\""([^\"]|"\\\"")*"\"")|("'"([^']|"\\\"")*"'")
49 _caps {_mimetype}(","[^!]|{_capsstring})*
50 _link ("!"[[:space:]]*{_caps}([[:space:]]*";"[[:space:]]*{_caps})*[[:space:]]*"!")|("!")
51
52 %x value
53 %option noyywrap
54 %option nounput
55 %%
56
57 {_assignment} {
58     /* "=" */
59     PRINT ("ASSIGNMENT: %s\n", yytext);
60     lvalp->s = gst_parse_strdup (yytext);
61     BEGIN (INITIAL);
62     return ASSIGNMENT;
63 }
64
65 {_padref} {
66     yytext++;
67     PRINT ("PADREF: %s\n", yytext);
68     lvalp->s = gst_parse_strdup (yytext);
69     BEGIN (INITIAL);
70     return PADREF;
71 }
72
73 {_ref} {
74     PRINT ("REF: %s\n", yytext);
75     lvalp->s = gst_parse_strdup (yytext);
76     BEGIN (INITIAL);
77     return REF;
78 }
79
80 {_binref} {
81     gchar *pos = yytext;
82     while (!g_ascii_isspace (*pos) && (*pos != '.')) pos++;
83     *pos = '\0';
84     PRINT ("BINREF: %s\n", yytext);
85     lvalp->s = gst_parse_strdup (yytext);
86     BEGIN (INITIAL);
87     return BINREF;
88 }
89
90 {_identifier} {
91     PRINT ("IDENTIFIER: %s\n", yytext);
92     lvalp->s = gst_parse_strdup (yytext);
93     BEGIN (INITIAL);
94     return IDENTIFIER;
95 }
96
97 {_link} {
98     gchar *c = yytext;
99     PRINT ("LINK: %s\n", yytext);
100     c++;
101     if (*c) {
102       while (g_ascii_isspace (*c)) c++;
103       c = lvalp->s = gst_parse_strdup (c);
104       while (*c) c++;
105       g_assert (*--c == '!');
106       while (g_ascii_isspace (*--c));
107       *++c = '\0';
108     } else {
109       lvalp->s = NULL;
110     }
111     BEGIN (INITIAL);
112     return LINK;
113 }
114 {_url} {
115   PRINT ("URL: %s\n", yytext);
116   if (gst_uri_is_valid (yytext)) {
117     lvalp->s = g_strdup (yytext);
118   } else {
119     lvalp->s = gst_uri_construct ("file", yytext);
120   }
121   gst_parse_unescape (lvalp->s);
122   BEGIN (INITIAL);
123   return PARSE_URL;
124 }
125
126 {_operator} { PRINT ("OPERATOR: [%s]\n", yytext); return *yytext; }
127
128 [[:space:]]+ { PRINT ("SPACE: [%s]\n", yytext); }
129
130 . {
131     printf ("???: %s\n", yytext);
132     return *yytext;
133 }
134
135 %%