*/
#define YYERROR_VERBOSE 1
-#define YYPARSE_PARAM graph
+#define YYLEX_PARAM scanner
+
+typedef void* yyscan_t;
+
+int _gst_parse_yylex (void * yylval_param , yyscan_t yyscanner);
+int _gst_parse_yylex_init (yyscan_t scanner);
+int _gst_parse_yylex_destroy (yyscan_t scanner);
+struct yy_buffer_state * _gst_parse_yy_scan_string (char* , yyscan_t);
+void _gst_parse_yypush_buffer_state (void * new_buffer ,yyscan_t yyscanner );
+void _gst_parse_yypop_buffer_state (yyscan_t yyscanner );
+
#ifdef __GST_PARSE_TRACE
static guint __strings;
}
-static int yylex (void *lvalp);
-static int yyerror (const char *s);
+static int yyerror (graph_t *graph, const char *s);
%}
%union {
%right '.'
%left '!' '='
-%pure_parser
+%parse-param { void *scanner, graph_t *graph }
+%pure-parser
%start graph
%%
%%
-extern FILE *_gst_parse_yyin;
-int _gst_parse_yylex (YYSTYPE *lvalp);
-
-static int yylex (void *lvalp) {
- return _gst_parse_yylex ((YYSTYPE*) lvalp);
-}
static int
-yyerror (const char *s)
+yyerror (graph_t *graph, const char *s)
{
/* FIXME: This should go into the GError somehow, but how? */
GST_WARNING ("Error during parsing: %s", s);
return -1;
}
-struct yy_buffer_state * _gst_parse_yy_scan_string (char*);
-void _gst_parse_yy_delete_buffer (struct yy_buffer_state *);
+
GstElement *
_gst_parse_launch (const gchar *str, GError **error)
{
GSList *walk;
GstBin *bin = NULL;
GstElement *ret;
- struct yy_buffer_state *buf;
-
+ yyscan_t scanner;
+
g_return_val_if_fail (str != NULL, NULL);
g.chain = NULL;
#endif /* __GST_PARSE_TRACE */
dstr = g_strdup (str);
- buf = _gst_parse_yy_scan_string (dstr);
+ _gst_parse_yylex_init( &scanner );
+ _gst_parse_yy_scan_string (dstr, scanner);
#ifndef YYDEBUG
yydebug = 1;
#endif
- if (yyparse (&g) != 0) {
+ if (yyparse (scanner, &g) != 0) {
SET_ERROR (error, GST_PARSE_ERROR_SYNTAX,
"Unrecoverable syntax error while parsing pipeline %s", str);
goto error1;
}
+ _gst_parse_yylex_destroy( scanner );
g_free (dstr);
- _gst_parse_yy_delete_buffer (buf);
-
+
GST_CAT_DEBUG (GST_CAT_PIPELINE, "got %u elements and %u links",
g.chain ? g_slist_length (g.chain->elements) : 0,
g_slist_length (g.links));
}
#endif
-#define YY_DECL int _gst_parse_yylex (YYSTYPE *lvalp)
%}
_operator [(){}.!,;=]
%x value
%option noyywrap
%option nounput
+%option reentrant
+%option bison-bridge
%%
{_assignment} {
/* "=" */
PRINT ("ASSIGNMENT: %s", yytext);
- lvalp->s = gst_parse_strdup (yytext);
+ yylval->s = gst_parse_strdup (yytext);
BEGIN (INITIAL);
return ASSIGNMENT;
}
{_padref} {
yytext++;
PRINT ("PADREF: %s", yytext);
- lvalp->s = gst_parse_strdup (yytext);
+ yylval->s = gst_parse_strdup (yytext);
BEGIN (INITIAL);
return PADREF;
}
{_ref} {
PRINT ("REF: %s", yytext);
- lvalp->s = gst_parse_strdup (yytext);
+ yylval->s = gst_parse_strdup (yytext);
BEGIN (INITIAL);
return REF;
}
while (!g_ascii_isspace (*pos) && (*pos != '.')) pos++;
*pos = '\0';
PRINT ("BINREF: %s", yytext);
- lvalp->s = gst_parse_strdup (yytext);
+ yylval->s = gst_parse_strdup (yytext);
BEGIN (INITIAL);
return BINREF;
}
{_identifier} {
PRINT ("IDENTIFIER: %s", yytext);
- lvalp->s = gst_parse_strdup (yytext);
+ yylval->s = gst_parse_strdup (yytext);
BEGIN (INITIAL);
return IDENTIFIER;
}
c++;
if (*c) {
while (g_ascii_isspace (*c)) c++;
- c = lvalp->s = gst_parse_strdup (c);
+ c = yylval->s = gst_parse_strdup (c);
while (*c) c++;
if (*--c != '!')
g_assert_not_reached ();
while (g_ascii_isspace (*--c));
*++c = '\0';
} else {
- lvalp->s = NULL;
+ yylval->s = NULL;
}
BEGIN (INITIAL);
return LINK;
}
{_url} {
PRINT ("URL: %s", yytext);
- lvalp->s = g_strdup (yytext);
- gst_parse_unescape (lvalp->s);
+ yylval->s = g_strdup (yytext);
+ gst_parse_unescape (yylval->s);
BEGIN (INITIAL);
return PARSE_URL;
}