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