Fix bug in PRINT() macro
[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 #define PRINT(...) GST_DEBUG (GST_CAT_PIPELINE, "flex: "__VA_ARGS__)
15 #elif defined(G_HAVE_GNUC_VARARGS)
16 #define PRINT(args...) GST_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 _operators [(){}.:!,=]
25 _identifier [[:alpha:]][[:alnum:]\-_%]*
26
27 _char ("\\".)|([^[:space:]])
28 _string {_char}+|("\""([^\"]|"\\\"")*"\"")
29
30 _comma [[:space:]]*","[[:space:]]*
31 _assign [[:space:]]*"="[[:space:]]*
32
33 /* we must do this here, because nearly everything matches a {_string} */ 
34 _assignment {_identifier}{_assign}{_string}
35
36 /* get pad/element references and stuff with dots right */
37 _padref "."{_identifier}
38 _ref {_identifier}"."{_identifier}?
39 _binref {_identifier}[[:space:]]*"."[[:space:]]*"("
40
41 %x value
42 %option noyywrap
43 %option nounput
44 %%
45
46 {_assignment} {
47     /* "=" */
48     PRINT ("ASSIGNMENT: %s\n", yytext);
49     lvalp->s = gst_parse_strdup (yytext);
50     BEGIN (INITIAL);
51     return ASSIGNMENT;
52 }
53
54 {_padref} {
55     yytext++;
56     PRINT ("PADREF: %s\n", yytext);
57     lvalp->s = gst_parse_strdup (yytext);
58     BEGIN (INITIAL);
59     return PADREF;
60 }
61
62 {_ref} {
63     PRINT ("REF: %s\n", yytext);
64     lvalp->s = gst_parse_strdup (yytext);
65     BEGIN (INITIAL);
66     return REF;
67 }
68
69 {_binref} {
70     gchar *pos = yytext;
71     while (!g_ascii_isspace (*pos) && (*pos != '.')) pos++;
72     *pos = '\0';
73     PRINT ("BINREF: %s\n", yytext);
74     lvalp->s = gst_parse_strdup (yytext);
75     BEGIN (INITIAL);
76     return BINREF;
77 }
78
79 {_identifier} {
80     PRINT ("IDENTIFIER: %s\n", yytext);
81     lvalp->s = gst_parse_strdup (yytext);
82     BEGIN (INITIAL);
83     return IDENTIFIER;
84 }
85
86 {_operators} { PRINT ("OPERATOR: [%s]\n", yytext); return *yytext; }
87
88 [[:space:]]+ { PRINT ("SPACE: [%s]\n", yytext); }
89
90 . {
91     printf ("???: %s\n", yytext);
92     return *yytext;
93 }
94
95 %%