6 #include <grammar.tab.h>
9 # define PRINT(a...) printf(##a)
14 #define CHAR(x) PRINT ("char: %c\n", *yytext); return *yytext;
16 #define YY_DECL int _gst_parse_yylex (YYSTYPE *lvalp)
20 _integer [-+]?[[:digit:]]+
21 _double [-+]?[[:digit:]]+"."*[[:digit:]]*
22 _number {_integer}|{_double}
23 _boolean "true"|"false"|"TRUE"|"FALSE"
24 _identifier [[:alpha:]][[:alnum:]\-_%:]*
25 _lconnection ({_identifier}\.)?{_identifier}!
26 _rconnection !({_identifier}\.)?{_identifier}
27 _bconnection ({_identifier}\.)?{_identifier}!({_identifier}\.)?{_identifier}
28 _char ([^[:space:]])|("\\".)
29 _string {_char}+|("\""([^\"]|"\\\"")*"\"")
37 PRINT ("An integer: %s (%d)\n", yytext,
39 lvalp->v = g_new0 (GValue, 1);
40 g_value_init (lvalp->v, G_TYPE_INT);
41 g_value_set_int (lvalp->v, atoi (yytext));
47 PRINT ("A double: %s (%g)\n", yytext, atof (yytext));
48 lvalp->v = g_new0 (GValue, 1);
49 g_value_init (lvalp->v, G_TYPE_DOUBLE);
50 g_value_set_double (lvalp->v, atof (yytext));
56 PRINT ("A boolean: %s (%d)\n", yytext, tolower (*yytext) == 't' ? 1 : 0);
57 lvalp->v = g_new0 (GValue, 1);
58 g_value_init (lvalp->v, G_TYPE_BOOLEAN);
59 g_value_set_boolean (lvalp->v, tolower (*yytext) == 't' ? TRUE : FALSE);
67 *(yytext + strlen (yytext) - 1) = '\0';
69 _gst_parse_unescape (yytext);
70 PRINT ("A string: \"%s\"\n", yytext);
71 lvalp->v = g_new0 (GValue, 1);
72 g_value_init (lvalp->v, G_TYPE_STRING);
73 g_value_set_string (lvalp->v, yytext);
78 [[:space:]]+ { /* PRINT ("space: [%s]\n", yytext); */ }
83 lvalp->c = g_new0 (connection_t, 1);
84 PRINT ("An connection: %s\n", yytext);
85 q = strchr (yytext, '!');
86 d1 = strchr (yytext, '.');
88 lvalp->c->src_name = g_strndup (yytext, d1 - yytext);
89 lvalp->c->src_pads = g_list_append (lvalp->c->src_pads, g_strndup (d1 + 1, q - d1 - 1));
91 lvalp->c->src_pads = g_list_append (lvalp->c->src_pads, g_strndup (yytext, q - yytext));
99 lvalp->c = g_new0 (connection_t, 1);
100 PRINT ("An rconnection: %s\n", yytext);
101 d2 = strchr (yytext, '.');
103 lvalp->c->sink_name = g_strndup (yytext + 1, d2 - yytext - 1);
104 lvalp->c->sink_pads = g_list_append (lvalp->c->sink_pads, g_strdup (d2 + 1));
106 lvalp->c->sink_pads = g_list_append (lvalp->c->sink_pads, g_strdup (yytext + 1));
114 lvalp->c = g_new0 (connection_t, 1);
115 PRINT ("A bconnection: %s\n", yytext);
116 q = strchr (yytext, '!');
117 d1 = strchr (yytext, '.');
118 d2 = strchr (q, '.');
120 lvalp->c->src_name = g_strndup (yytext, d1 - yytext);
121 lvalp->c->src_pads = g_list_append (lvalp->c->src_pads, g_strndup (d1 + 1, q - d1 - 1));
123 lvalp->c->src_pads = g_list_append (lvalp->c->src_pads, g_strndup (yytext, q - yytext));
127 lvalp->c->sink_name = g_strndup (q + 1, d2 - q - 1);
128 lvalp->c->sink_pads = g_list_append (lvalp->c->sink_pads, g_strdup (d2 + 1));
130 lvalp->c->sink_pads = g_list_append (lvalp->c->sink_pads, g_strdup (q + 1));
137 PRINT ("An identifier: %s\n", yytext);
138 lvalp->s = g_strdup (yytext);
142 "=" { BEGIN (value); CHAR ('='); }
155 [[:space:]]+ { PRINT ("space: [%s]\n", yytext); }
158 printf ("unknown: %s\n", yytext);