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