rewritten pipeline parsing lands. Have fun breaking it.
[platform/upstream/gstreamer.git] / gst / parse / parse.l
1 %{
2 #include <math.h>
3 #include <ctype.h>
4 #include <string.h>
5 #include "types.h"
6 #include "../gstinfo.h"
7 #include "grammar.tab.h"
8
9 #ifdef HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12
13 #ifdef G_HAVE_ISO_VARARGS
14 #  ifdef GST_DEBUG_ENABLED
15 #    define PRINT(...) GST_DEBUG (GST_CAT_PIPELINE, "flex: "__VA_ARGS__)
16 #  endif
17 #elif defined(G_HAVE_GNUC_VARARGS)
18 #  ifdef GST_DEBUG_ENABLED
19 #    define PRINT(...) GST_DEBUG (GST_CAT_PIPELINE, "flex: "##args)
20 #  endif
21 #else
22 #  ifdef GST_DEBUG_ENABLED
23 #    define PRINT(a...) GST_DEBUG (GST_CAT_PIPELINE, "flex: "##a)
24 #  endif
25 #endif // G_HAVE_ISO_VARARGS
26
27 #define YY_DECL int _gst_parse_yylex (YYSTYPE *lvalp)
28 #define YY_NO_UNPUT
29 %}
30
31 _operators [(){}.:!,=]
32 _identifier [[:alpha:]][[:alnum:]\-_%]*
33
34 _char ("\\".)|([^[:space:]])
35 _string {_char}+|("\""([^\"]|"\\\"")*"\"")
36
37 _comma [[:space:]]*","[[:space:]]*
38 _assign [[:space:]]*"="[[:space:]]*
39
40 /* we must do this here, because nearly everything matches a {_string} */ 
41 _assignment {_identifier}{_assign}{_string}
42
43 /* get pad/element references and stuff with dots right */
44 _padref "."{_identifier}
45 _ref {_identifier}"."{_identifier}?
46 _binref {_identifier}[[:space:]]*"."[[:space:]]*"("
47
48 %x value
49 %option noyywrap
50 %%
51
52 {_assignment} {
53     /* "=" */
54     PRINT ("ASSIGNMENT: %s\n", yytext);
55     lvalp->s = gst_parse_strdup (yytext);
56     BEGIN (INITIAL);
57     return ASSIGNMENT;
58 }
59
60 {_padref} {
61     yytext++;
62     PRINT ("PADREF: %s\n", yytext);
63     lvalp->s = gst_parse_strdup (yytext);
64     BEGIN (INITIAL);
65     return PADREF;
66 }
67
68 {_ref} {
69     PRINT ("REF: %s\n", yytext);
70     lvalp->s = gst_parse_strdup (yytext);
71     BEGIN (INITIAL);
72     return REF;
73 }
74
75 {_binref} {
76     gchar *pos = yytext;
77     while (!g_ascii_isspace (*pos) && (*pos != '.')) pos++;
78     *pos = '\0';
79     PRINT ("BINREF: %s\n", yytext);
80     lvalp->s = gst_parse_strdup (yytext);
81     BEGIN (INITIAL);
82     return BINREF;
83 }
84
85 {_identifier} {
86     PRINT ("IDENTIFIER: %s\n", yytext);
87     lvalp->s = gst_parse_strdup (yytext);
88     BEGIN (INITIAL);
89     return IDENTIFIER;
90 }
91
92 {_operators} { PRINT ("OPERATOR: [%s]\n", yytext); return *yytext; }
93
94 [[:space:]]+ { PRINT ("SPACE: [%s]\n", yytext); }
95
96 . {
97     printf ("???: %s\n", yytext);
98     return *yytext;
99 }
100
101 %%