6 #include <grammar.tab.h>
8 #ifdef G_HAVE_ISO_VARARGS
11 # define PRINT(...) printf(__VAR_ARGS__)
16 #elif defined(G_HAVE_GNUC_VARARGS)
19 # define PRINT(a...) printf(##a)
26 #define CHAR(x) PRINT ("char: %c\n", *yytext); return *yytext;
28 #define YY_DECL int _gst_parse_yylex (YYSTYPE *lvalp)
32 _integer [-+]?[[:digit:]]+
33 _double [-+]?[[:digit:]]+"."*[[:digit:]]*
34 _number {_integer}|{_double}
35 _boolean "true"|"false"|"TRUE"|"FALSE"
36 _identifier [[:alpha:]][[:alnum:]\-_%:]*
37 _lconnection ({_identifier}\.)?{_identifier}!
38 _rconnection !({_identifier}\.)?{_identifier}
39 _bconnection ({_identifier}\.)?{_identifier}!({_identifier}\.)?{_identifier}
40 _char ([^[:space:]])|("\\".)
41 _string {_char}+|("\""([^\"]|"\\\"")*"\"")
49 PRINT ("An integer: %s (%d)\n", yytext,
51 lvalp->v = g_new0 (GValue, 1);
52 g_value_init (lvalp->v, G_TYPE_INT);
53 g_value_set_int (lvalp->v, atoi (yytext));
59 PRINT ("A double: %s (%g)\n", yytext, atof (yytext));
60 lvalp->v = g_new0 (GValue, 1);
61 g_value_init (lvalp->v, G_TYPE_DOUBLE);
62 g_value_set_double (lvalp->v, atof (yytext));
68 PRINT ("A boolean: %s (%d)\n", yytext, tolower (*yytext) == 't' ? 1 : 0);
69 lvalp->v = g_new0 (GValue, 1);
70 g_value_init (lvalp->v, G_TYPE_BOOLEAN);
71 g_value_set_boolean (lvalp->v, tolower (*yytext) == 't' ? TRUE : FALSE);
79 *(yytext + strlen (yytext) - 1) = '\0';
81 _gst_parse_unescape (yytext);
82 PRINT ("A string: \"%s\"\n", yytext);
83 lvalp->v = g_new0 (GValue, 1);
84 g_value_init (lvalp->v, G_TYPE_STRING);
85 g_value_set_string (lvalp->v, yytext);
90 [[:space:]]+ { /* PRINT ("space: [%s]\n", yytext); */ }
95 lvalp->c = g_new0 (connection_t, 1);
96 PRINT ("An connection: %s\n", yytext);
97 q = strchr (yytext, '!');
98 d1 = strchr (yytext, '.');
100 lvalp->c->src_name = g_strndup (yytext, d1 - yytext);
101 lvalp->c->src_pads = g_list_append (lvalp->c->src_pads, g_strndup (d1 + 1, q - d1 - 1));
103 lvalp->c->src_pads = g_list_append (lvalp->c->src_pads, g_strndup (yytext, q - yytext));
111 lvalp->c = g_new0 (connection_t, 1);
112 PRINT ("An rconnection: %s\n", yytext);
113 d2 = strchr (yytext, '.');
115 lvalp->c->sink_name = g_strndup (yytext + 1, d2 - yytext - 1);
116 lvalp->c->sink_pads = g_list_append (lvalp->c->sink_pads, g_strdup (d2 + 1));
118 lvalp->c->sink_pads = g_list_append (lvalp->c->sink_pads, g_strdup (yytext + 1));
126 lvalp->c = g_new0 (connection_t, 1);
127 PRINT ("A bconnection: %s\n", yytext);
128 q = strchr (yytext, '!');
129 d1 = strchr (yytext, '.');
130 d2 = strchr (q, '.');
132 lvalp->c->src_name = g_strndup (yytext, d1 - yytext);
133 lvalp->c->src_pads = g_list_append (lvalp->c->src_pads, g_strndup (d1 + 1, q - d1 - 1));
135 lvalp->c->src_pads = g_list_append (lvalp->c->src_pads, g_strndup (yytext, q - yytext));
139 lvalp->c->sink_name = g_strndup (q + 1, d2 - q - 1);
140 lvalp->c->sink_pads = g_list_append (lvalp->c->sink_pads, g_strdup (d2 + 1));
142 lvalp->c->sink_pads = g_list_append (lvalp->c->sink_pads, g_strdup (q + 1));
149 PRINT ("An identifier: %s\n", yytext);
150 lvalp->s = g_strdup (yytext);
154 "=" { BEGIN (value); CHAR ('='); }
167 [[:space:]]+ { PRINT ("space: [%s]\n", yytext); }
170 printf ("unknown: %s\n", yytext);