/* rygel-search-criteria-parser.c generated by valac 0.56.19, the Vala compiler
 * generated from rygel-search-criteria-parser.vala, do not modify */

/*
 * Copyright (C) 2009 Nokia Corporation.
 *
 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
 *
 * This file is part of Rygel.
 *
 * Rygel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Rygel is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <glib.h>
#include <glib-object.h>
#include <libgupnp-av/gupnp-av.h>
#include <stdlib.h>
#include <string.h>
#include "rygel-core.h"
#include "rygel-server.h"
#include <gio/gio.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define RYGEL_TYPE_SEARCH_CRITERIA_ERROR (rygel_search_criteria_error_get_type ())
typedef enum  {
	RYGEL_SEARCH_CRITERIA_SYMBOL_EQ = GUPNP_SEARCH_CRITERIA_OP_EQ,
	RYGEL_SEARCH_CRITERIA_SYMBOL_NEQ,
	RYGEL_SEARCH_CRITERIA_SYMBOL_LESS,
	RYGEL_SEARCH_CRITERIA_SYMBOL_LEQ,
	RYGEL_SEARCH_CRITERIA_SYMBOL_GREATER,
	RYGEL_SEARCH_CRITERIA_SYMBOL_GEQ,
	RYGEL_SEARCH_CRITERIA_SYMBOL_CONTAINS,
	RYGEL_SEARCH_CRITERIA_SYMBOL_DOES_NOT_CONTAIN,
	RYGEL_SEARCH_CRITERIA_SYMBOL_DERIVED_FROM,
	RYGEL_SEARCH_CRITERIA_SYMBOL_EXISTS,
	RYGEL_SEARCH_CRITERIA_SYMBOL_ASTERISK,
	RYGEL_SEARCH_CRITERIA_SYMBOL_AND,
	RYGEL_SEARCH_CRITERIA_SYMBOL_OR,
	RYGEL_SEARCH_CRITERIA_SYMBOL_TRUE,
	RYGEL_SEARCH_CRITERIA_SYMBOL_FALSE
} RygelSearchCriteriaSymbol;

#define RYGEL_TYPE_SEARCH_CRITERIA_SYMBOL (rygel_search_criteria_symbol_get_type ())

#define RYGEL_TYPE_SEARCH_CRITERIA_TOKEN (rygel_search_criteria_token_get_type ())
typedef struct _RygelSearchCriteriaToken RygelSearchCriteriaToken;
#define _g_free0(var) (var = (g_free (var), NULL))

#define RYGEL_TYPE_SEARCH_CRITERIA_PARSER (rygel_search_criteria_parser_get_type ())
#define RYGEL_SEARCH_CRITERIA_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_SEARCH_CRITERIA_PARSER, RygelSearchCriteriaParser))
#define RYGEL_SEARCH_CRITERIA_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_SEARCH_CRITERIA_PARSER, RygelSearchCriteriaParserClass))
#define RYGEL_IS_SEARCH_CRITERIA_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_SEARCH_CRITERIA_PARSER))
#define RYGEL_IS_SEARCH_CRITERIA_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_SEARCH_CRITERIA_PARSER))
#define RYGEL_SEARCH_CRITERIA_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_SEARCH_CRITERIA_PARSER, RygelSearchCriteriaParserClass))

typedef struct _RygelSearchCriteriaParser RygelSearchCriteriaParser;
typedef struct _RygelSearchCriteriaParserClass RygelSearchCriteriaParserClass;
typedef struct _RygelSearchCriteriaParserPrivate RygelSearchCriteriaParserPrivate;
enum  {
	RYGEL_SEARCH_CRITERIA_PARSER_0_PROPERTY,
	RYGEL_SEARCH_CRITERIA_PARSER_CANCELLABLE_PROPERTY,
	RYGEL_SEARCH_CRITERIA_PARSER_NUM_PROPERTIES
};
static GParamSpec* rygel_search_criteria_parser_properties[RYGEL_SEARCH_CRITERIA_PARSER_NUM_PROPERTIES];
#define _rygel_search_expression_unref0(var) ((var == NULL) ? NULL : (var = (rygel_search_expression_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_scanner_destroy0(var) ((var == NULL) ? NULL : (var = (g_scanner_destroy (var), NULL)))
typedef struct _RygelSearchCriteriaParserRunData RygelSearchCriteriaParserRunData;

typedef enum  {
	RYGEL_SEARCH_CRITERIA_ERROR_SYNTAX_ERROR
} RygelSearchCriteriaError;
#define RYGEL_SEARCH_CRITERIA_ERROR rygel_search_criteria_error_quark ()

struct _RygelSearchCriteriaToken {
	gchar* str_symbol;
	RygelSearchCriteriaSymbol symbol;
};

struct _RygelSearchCriteriaParser {
	GObject parent_instance;
	RygelSearchCriteriaParserPrivate * priv;
	gchar* str;
	RygelSearchExpression* expression;
	GError* err;
};

struct _RygelSearchCriteriaParserClass {
	GObjectClass parent_class;
};

struct _RygelSearchCriteriaParserPrivate {
	GCancellable* _cancellable;
	GScanner* scanner;
};

struct _RygelSearchCriteriaParserRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelSearchCriteriaParser* self;
	const gchar* _tmp0_;
	GScanner* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	GScanner* _tmp6_;
	RygelSearchExpression* _tmp7_;
	RygelSearchExpression* _tmp8_;
	RygelSearchExpression* _tmp9_;
	GError* err;
	GError* _tmp10_;
	GError* _tmp11_;
	GError* _inner_error0_;
};

static gint RygelSearchCriteriaParser_private_offset;
static gpointer rygel_search_criteria_parser_parent_class = NULL;
static RygelStateMachineIface * rygel_search_criteria_parser_rygel_state_machine_parent_iface = NULL;

VALA_EXTERN GQuark rygel_search_criteria_error_quark (void);
VALA_EXTERN GType rygel_search_criteria_error_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType rygel_search_criteria_symbol_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType rygel_search_criteria_token_get_type (void) G_GNUC_CONST ;
VALA_EXTERN RygelSearchCriteriaToken* rygel_search_criteria_token_dup (const RygelSearchCriteriaToken* self);
VALA_EXTERN void rygel_search_criteria_token_free (RygelSearchCriteriaToken* self);
VALA_EXTERN void rygel_search_criteria_token_copy (const RygelSearchCriteriaToken* self,
                                       RygelSearchCriteriaToken* dest);
VALA_EXTERN void rygel_search_criteria_token_destroy (RygelSearchCriteriaToken* self);
VALA_EXTERN GType rygel_search_criteria_parser_get_type (void) G_GNUC_CONST ;
VALA_EXTERN RygelSearchCriteriaParser* rygel_search_criteria_parser_new (const gchar* str,
                                                             GError** error);
VALA_EXTERN RygelSearchCriteriaParser* rygel_search_criteria_parser_construct (GType object_type,
                                                                   const gchar* str,
                                                                   GError** error);
static void rygel_search_criteria_parser_real_run_data_free (gpointer _data);
static void rygel_search_criteria_parser_real_run (RygelStateMachine* base,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
static gboolean rygel_search_criteria_parser_real_run_co (RygelSearchCriteriaParserRunData* _data_);
static RygelSearchExpression* rygel_search_criteria_parser_parse_or_expression (RygelSearchCriteriaParser* self,
                                                                         GError** error);
static RygelSearchExpression* rygel_search_criteria_parser_parse_and_expression (RygelSearchCriteriaParser* self,
                                                                          GError** error);
static RygelSearchExpression* rygel_search_criteria_parser_parse_rel_expression (RygelSearchCriteriaParser* self,
                                                                          GError** error);
static RygelSearchCriteriaSymbol rygel_search_criteria_parser_get_token (RygelSearchCriteriaParser* self);
static gchar* rygel_search_criteria_parser_get_context (RygelSearchCriteriaParser* self);
static void rygel_search_criteria_parser_finalize (GObject * obj);
static GType rygel_search_criteria_parser_get_type_once (void);
static void _vala_rygel_search_criteria_parser_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec);
static void _vala_rygel_search_criteria_parser_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static const RygelSearchCriteriaToken RYGEL_SEARCH_CRITERIA_PARSER_TOKENS[15] = {{"=", RYGEL_SEARCH_CRITERIA_SYMBOL_EQ}, {"!=", RYGEL_SEARCH_CRITERIA_SYMBOL_NEQ}, {"<", RYGEL_SEARCH_CRITERIA_SYMBOL_LESS}, {"<=", RYGEL_SEARCH_CRITERIA_SYMBOL_LEQ}, {">", RYGEL_SEARCH_CRITERIA_SYMBOL_GREATER}, {">=", RYGEL_SEARCH_CRITERIA_SYMBOL_GEQ}, {"contains", RYGEL_SEARCH_CRITERIA_SYMBOL_CONTAINS}, {"doesNotContain", RYGEL_SEARCH_CRITERIA_SYMBOL_DOES_NOT_CONTAIN}, {"derivedfrom", RYGEL_SEARCH_CRITERIA_SYMBOL_DERIVED_FROM}, {"exists", RYGEL_SEARCH_CRITERIA_SYMBOL_EXISTS}, {"*", RYGEL_SEARCH_CRITERIA_SYMBOL_ASTERISK}, {"and", RYGEL_SEARCH_CRITERIA_SYMBOL_AND}, {"or", RYGEL_SEARCH_CRITERIA_SYMBOL_OR}, {"true", RYGEL_SEARCH_CRITERIA_SYMBOL_TRUE}, {"false", RYGEL_SEARCH_CRITERIA_SYMBOL_FALSE}};

GQuark
rygel_search_criteria_error_quark (void)
{
	return g_quark_from_static_string ("rygel-search-criteria-error-quark");
}

 G_GNUC_NO_INLINE static GType
rygel_search_criteria_error_get_type_once (void)
{
	static const GEnumValue values[] = {{RYGEL_SEARCH_CRITERIA_ERROR_SYNTAX_ERROR, "RYGEL_SEARCH_CRITERIA_ERROR_SYNTAX_ERROR", "syntax-error"}, {0, NULL, NULL}};
	GType rygel_search_criteria_error_type_id;
	rygel_search_criteria_error_type_id = g_enum_register_static ("RygelSearchCriteriaError", values);
	return rygel_search_criteria_error_type_id;
}

GType
rygel_search_criteria_error_get_type (void)
{
	static volatile gsize rygel_search_criteria_error_type_id__once = 0;
	if (g_once_init_enter (&rygel_search_criteria_error_type_id__once)) {
		GType rygel_search_criteria_error_type_id;
		rygel_search_criteria_error_type_id = rygel_search_criteria_error_get_type_once ();
		g_once_init_leave (&rygel_search_criteria_error_type_id__once, rygel_search_criteria_error_type_id);
	}
	return rygel_search_criteria_error_type_id__once;
}

 G_GNUC_NO_INLINE static GType
rygel_search_criteria_symbol_get_type_once (void)
{
	static const GEnumValue values[] = {{RYGEL_SEARCH_CRITERIA_SYMBOL_EQ, "RYGEL_SEARCH_CRITERIA_SYMBOL_EQ", "eq"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_NEQ, "RYGEL_SEARCH_CRITERIA_SYMBOL_NEQ", "neq"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_LESS, "RYGEL_SEARCH_CRITERIA_SYMBOL_LESS", "less"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_LEQ, "RYGEL_SEARCH_CRITERIA_SYMBOL_LEQ", "leq"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_GREATER, "RYGEL_SEARCH_CRITERIA_SYMBOL_GREATER", "greater"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_GEQ, "RYGEL_SEARCH_CRITERIA_SYMBOL_GEQ", "geq"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_CONTAINS, "RYGEL_SEARCH_CRITERIA_SYMBOL_CONTAINS", "contains"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_DOES_NOT_CONTAIN, "RYGEL_SEARCH_CRITERIA_SYMBOL_DOES_NOT_CONTAIN", "does-not-contain"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_DERIVED_FROM, "RYGEL_SEARCH_CRITERIA_SYMBOL_DERIVED_FROM", "derived-from"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_EXISTS, "RYGEL_SEARCH_CRITERIA_SYMBOL_EXISTS", "exists"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_ASTERISK, "RYGEL_SEARCH_CRITERIA_SYMBOL_ASTERISK", "asterisk"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_AND, "RYGEL_SEARCH_CRITERIA_SYMBOL_AND", "and"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_OR, "RYGEL_SEARCH_CRITERIA_SYMBOL_OR", "or"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_TRUE, "RYGEL_SEARCH_CRITERIA_SYMBOL_TRUE", "true"}, {RYGEL_SEARCH_CRITERIA_SYMBOL_FALSE, "RYGEL_SEARCH_CRITERIA_SYMBOL_FALSE", "false"}, {0, NULL, NULL}};
	GType rygel_search_criteria_symbol_type_id;
	rygel_search_criteria_symbol_type_id = g_enum_register_static ("RygelSearchCriteriaSymbol", values);
	return rygel_search_criteria_symbol_type_id;
}

GType
rygel_search_criteria_symbol_get_type (void)
{
	static volatile gsize rygel_search_criteria_symbol_type_id__once = 0;
	if (g_once_init_enter (&rygel_search_criteria_symbol_type_id__once)) {
		GType rygel_search_criteria_symbol_type_id;
		rygel_search_criteria_symbol_type_id = rygel_search_criteria_symbol_get_type_once ();
		g_once_init_leave (&rygel_search_criteria_symbol_type_id__once, rygel_search_criteria_symbol_type_id);
	}
	return rygel_search_criteria_symbol_type_id__once;
}

void
rygel_search_criteria_token_copy (const RygelSearchCriteriaToken* self,
                                  RygelSearchCriteriaToken* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	_tmp0_ = (*self).str_symbol;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).str_symbol);
	(*dest).str_symbol = _tmp1_;
	(*dest).symbol = (*self).symbol;
}

void
rygel_search_criteria_token_destroy (RygelSearchCriteriaToken* self)
{
	_g_free0 ((*self).str_symbol);
}

RygelSearchCriteriaToken*
rygel_search_criteria_token_dup (const RygelSearchCriteriaToken* self)
{
	RygelSearchCriteriaToken* dup;
	dup = g_new0 (RygelSearchCriteriaToken, 1);
	rygel_search_criteria_token_copy (self, dup);
	return dup;
}

void
rygel_search_criteria_token_free (RygelSearchCriteriaToken* self)
{
	rygel_search_criteria_token_destroy (self);
	g_free (self);
}

 G_GNUC_NO_INLINE static GType
rygel_search_criteria_token_get_type_once (void)
{
	GType rygel_search_criteria_token_type_id;
	rygel_search_criteria_token_type_id = g_boxed_type_register_static ("RygelSearchCriteriaToken", (GBoxedCopyFunc) rygel_search_criteria_token_dup, (GBoxedFreeFunc) rygel_search_criteria_token_free);
	return rygel_search_criteria_token_type_id;
}

GType
rygel_search_criteria_token_get_type (void)
{
	static volatile gsize rygel_search_criteria_token_type_id__once = 0;
	if (g_once_init_enter (&rygel_search_criteria_token_type_id__once)) {
		GType rygel_search_criteria_token_type_id;
		rygel_search_criteria_token_type_id = rygel_search_criteria_token_get_type_once ();
		g_once_init_leave (&rygel_search_criteria_token_type_id__once, rygel_search_criteria_token_type_id);
	}
	return rygel_search_criteria_token_type_id__once;
}

static inline gpointer
rygel_search_criteria_parser_get_instance_private (RygelSearchCriteriaParser* self)
{
	return G_STRUCT_MEMBER_P (self, RygelSearchCriteriaParser_private_offset);
}

RygelSearchCriteriaParser*
rygel_search_criteria_parser_construct (GType object_type,
                                        const gchar* str,
                                        GError** error)
{
	RygelSearchCriteriaParser * self = NULL;
	gchar* _tmp0_;
	GScanner* _tmp1_;
	GScanner* _tmp2_;
	GScannerConfig* _tmp3_;
	GScanner* _tmp4_;
	GScannerConfig* _tmp5_;
	GScanner* _tmp6_;
	GScannerConfig* _tmp7_;
	GScanner* _tmp8_;
	GScannerConfig* _tmp9_;
	GScanner* _tmp10_;
	GScannerConfig* _tmp11_;
	g_return_val_if_fail (str != NULL, NULL);
	self = (RygelSearchCriteriaParser*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (str);
	_g_free0 (self->str);
	self->str = _tmp0_;
	_tmp1_ = g_scanner_new (NULL);
	_g_scanner_destroy0 (self->priv->scanner);
	self->priv->scanner = _tmp1_;
	_tmp2_ = self->priv->scanner;
	_tmp3_ = _tmp2_->config;
	(*_tmp3_).cset_skip_characters = " \t\n\r\012" "\013\014\015";
	_tmp4_ = self->priv->scanner;
	_tmp5_ = _tmp4_->config;
	(*_tmp5_).scan_identifier_1char = TRUE;
	_tmp6_ = self->priv->scanner;
	_tmp7_ = _tmp6_->config;
	(*_tmp7_).cset_identifier_first = G_CSET_a_2_z "_*<>=!@" G_CSET_A_2_Z;
	_tmp8_ = self->priv->scanner;
	_tmp9_ = _tmp8_->config;
	(*_tmp9_).cset_identifier_nth = G_CSET_a_2_z "_" G_CSET_DIGITS "=:@" G_CSET_A_2_Z G_CSET_LATINS G_CSET_LATINC;
	_tmp10_ = self->priv->scanner;
	_tmp11_ = _tmp10_->config;
	(*_tmp11_).symbol_2_token = TRUE;
	{
		RygelSearchCriteriaToken* token_collection = NULL;
		gint token_collection_length1 = 0;
		gint _token_collection_size_ = 0;
		gint token_it = 0;
		token_collection = RYGEL_SEARCH_CRITERIA_PARSER_TOKENS;
		token_collection_length1 = G_N_ELEMENTS (RYGEL_SEARCH_CRITERIA_PARSER_TOKENS);
		for (token_it = 0; token_it < token_collection_length1; token_it = token_it + 1) {
			RygelSearchCriteriaToken token = {0};
			token = token_collection[token_it];
			{
				GScanner* _tmp12_;
				RygelSearchCriteriaToken _tmp13_;
				const gchar* _tmp14_;
				RygelSearchCriteriaToken _tmp15_;
				void* _tmp16_;
				_tmp12_ = self->priv->scanner;
				_tmp13_ = token;
				_tmp14_ = _tmp13_.str_symbol;
				_tmp15_ = token;
				_tmp16_ = GINT_TO_POINTER ((gint) _tmp15_.symbol);
				g_scanner_scope_add_symbol (_tmp12_, (guint) 0, _tmp14_, _tmp16_);
			}
		}
	}
	return self;
}

RygelSearchCriteriaParser*
rygel_search_criteria_parser_new (const gchar* str,
                                  GError** error)
{
	return rygel_search_criteria_parser_construct (RYGEL_TYPE_SEARCH_CRITERIA_PARSER, str, error);
}

static void
rygel_search_criteria_parser_real_run_data_free (gpointer _data)
{
	RygelSearchCriteriaParserRunData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelSearchCriteriaParserRunData, _data_);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
rygel_search_criteria_parser_real_run (RygelStateMachine* base,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_)
{
	RygelSearchCriteriaParser * self;
	RygelSearchCriteriaParserRunData* _data_;
	RygelSearchCriteriaParser* _tmp0_;
	self = (RygelSearchCriteriaParser*) base;
	_data_ = g_slice_new0 (RygelSearchCriteriaParserRunData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_search_criteria_parser_real_run_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	rygel_search_criteria_parser_real_run_co (_data_);
}

static void
rygel_search_criteria_parser_run_finish (RygelStateMachine* base,
                                         GAsyncResult* _res_)
{
	RygelSearchCriteriaParserRunData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}

static gboolean
rygel_search_criteria_parser_real_run_co (RygelSearchCriteriaParserRunData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->str;
	if (g_strcmp0 (_data_->_tmp0_, "*") == 0) {
		g_signal_emit_by_name ((RygelStateMachine*) _data_->self, "completed");
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp1_ = _data_->self->priv->scanner;
	_data_->_tmp2_ = _data_->self->str;
	_data_->_tmp3_ = _data_->self->str;
	_data_->_tmp4_ = strlen (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	g_scanner_input_text (_data_->_tmp1_, _data_->_tmp2_, (guint) _data_->_tmp5_);
	_data_->_tmp6_ = _data_->self->priv->scanner;
	g_scanner_get_next_token (_data_->_tmp6_);
	{
		_data_->_tmp8_ = rygel_search_criteria_parser_parse_or_expression (_data_->self, &_data_->_inner_error0_);
		_data_->_tmp7_ = _data_->_tmp8_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp9_ = _data_->_tmp7_;
		_data_->_tmp7_ = NULL;
		_rygel_search_expression_unref0 (_data_->self->expression);
		_data_->self->expression = _data_->_tmp9_;
		_rygel_search_expression_unref0 (_data_->_tmp7_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp10_ = _data_->err;
		_data_->_tmp11_ = _g_error_copy0 (_data_->_tmp10_);
		_g_error_free0 (_data_->self->err);
		_data_->self->err = _data_->_tmp11_;
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_signal_emit_by_name ((RygelStateMachine*) _data_->self, "completed");
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gpointer
_rygel_search_expression_ref0 (gpointer self)
{
	return self ? rygel_search_expression_ref (self) : NULL;
}

static RygelSearchExpression*
rygel_search_criteria_parser_parse_and_expression (RygelSearchCriteriaParser* self,
                                                   GError** error)
{
	RygelSearchExpression* exp = NULL;
	RygelSearchExpression* _tmp0_;
	GError* _inner_error0_ = NULL;
	RygelSearchExpression* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = rygel_search_criteria_parser_parse_rel_expression (self, &_inner_error0_);
	exp = _tmp0_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	while (TRUE) {
		RygelSearchCriteriaSymbol _tmp1_;
		RygelSearchCriteriaSymbol _tmp2_;
		GScanner* _tmp3_;
		RygelLogicalExpression* exp2 = NULL;
		RygelLogicalExpression* _tmp4_;
		RygelLogicalExpression* _tmp5_;
		RygelSearchExpression* _tmp6_;
		RygelSearchExpression* _tmp7_;
		RygelLogicalExpression* _tmp8_;
		RygelSearchExpression* _tmp9_ = NULL;
		RygelSearchExpression* _tmp10_;
		RygelLogicalExpression* _tmp11_;
		RygelSearchExpression* _tmp12_;
		RygelLogicalExpression* _tmp13_;
		RygelSearchExpression* _tmp14_;
		_tmp1_ = rygel_search_criteria_parser_get_token (self);
		_tmp2_ = _tmp1_;
		if (!(_tmp2_ == RYGEL_SEARCH_CRITERIA_SYMBOL_AND)) {
			break;
		}
		_tmp3_ = self->priv->scanner;
		g_scanner_get_next_token (_tmp3_);
		_tmp4_ = rygel_logical_expression_new ();
		exp2 = _tmp4_;
		_tmp5_ = exp2;
		_tmp6_ = exp;
		_tmp7_ = _rygel_search_expression_ref0 (_tmp6_);
		_rygel_search_expression_unref0 (((RygelSearchExpression*) _tmp5_)->operand1);
		((RygelSearchExpression*) _tmp5_)->operand1 = _tmp7_;
		_tmp8_ = exp2;
		((RygelSearchExpression*) _tmp8_)->op = (gpointer) ((gintptr) RYGEL_LOGICAL_OPERATOR_AND);
		_tmp10_ = rygel_search_criteria_parser_parse_rel_expression (self, &_inner_error0_);
		_tmp9_ = _tmp10_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_rygel_search_expression_unref0 (exp2);
			_rygel_search_expression_unref0 (exp);
			return NULL;
		}
		_tmp11_ = exp2;
		_tmp12_ = _tmp9_;
		_tmp9_ = NULL;
		_rygel_search_expression_unref0 (((RygelSearchExpression*) _tmp11_)->operand2);
		((RygelSearchExpression*) _tmp11_)->operand2 = _tmp12_;
		_tmp13_ = exp2;
		_tmp14_ = _rygel_search_expression_ref0 ((RygelSearchExpression*) _tmp13_);
		_rygel_search_expression_unref0 (exp);
		exp = _tmp14_;
		_rygel_search_expression_unref0 (_tmp9_);
		_rygel_search_expression_unref0 (exp2);
	}
	result = exp;
	return result;
}

static RygelSearchExpression*
rygel_search_criteria_parser_parse_rel_expression (RygelSearchCriteriaParser* self,
                                                   GError** error)
{
	RygelRelationalExpression* exp = NULL;
	RygelRelationalExpression* _tmp0_;
	GScanner* _tmp1_;
	GError* _inner_error0_ = NULL;
	RygelSearchExpression* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = rygel_relational_expression_new ();
	exp = _tmp0_;
	_tmp1_ = self->priv->scanner;
	if (_tmp1_->token == G_TOKEN_IDENTIFIER) {
		RygelRelationalExpression* _tmp2_;
		GScanner* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		GScanner* _tmp6_;
		RygelSearchCriteriaSymbol _tmp7_;
		RygelSearchCriteriaSymbol _tmp8_;
		gboolean _tmp18_ = FALSE;
		gboolean _tmp19_ = FALSE;
		gboolean _tmp20_ = FALSE;
		gboolean _tmp21_ = FALSE;
		gboolean _tmp22_ = FALSE;
		gboolean _tmp23_ = FALSE;
		gboolean _tmp24_ = FALSE;
		gboolean _tmp25_ = FALSE;
		RygelSearchCriteriaSymbol _tmp26_;
		RygelSearchCriteriaSymbol _tmp27_;
		_tmp2_ = exp;
		_tmp3_ = self->priv->scanner;
		_tmp4_ = _tmp3_->value.v_identifier;
		_tmp5_ = g_strdup (_tmp4_);
		_g_free0 (((RygelSearchExpression*) _tmp2_)->operand1);
		((RygelSearchExpression*) _tmp2_)->operand1 = _tmp5_;
		_tmp6_ = self->priv->scanner;
		g_scanner_get_next_token (_tmp6_);
		_tmp7_ = rygel_search_criteria_parser_get_token (self);
		_tmp8_ = _tmp7_;
		if (_tmp8_ == RYGEL_SEARCH_CRITERIA_SYMBOL_DERIVED_FROM) {
			RygelRelationalExpression* _tmp9_;
			gconstpointer _tmp10_;
			_tmp9_ = exp;
			_tmp10_ = ((RygelSearchExpression*) _tmp9_)->operand1;
			if (g_strcmp0 ((const gchar*) _tmp10_, "upnp:class") != 0) {
				gchar* _tmp11_;
				gchar* _tmp12_;
				gchar* _tmp13_;
				gchar* _tmp14_;
				gchar* _tmp15_;
				GError* _tmp16_;
				GError* _tmp17_;
				_tmp11_ = rygel_search_criteria_parser_get_context (self);
				_tmp12_ = _tmp11_;
				_tmp13_ = _tmp12_;
				_tmp14_ = g_strconcat (_tmp13_, ": \"derivedFrom\" requires \"upnp:class\" lhs", NULL);
				_tmp15_ = _tmp14_;
				_tmp16_ = g_error_new_literal (RYGEL_SEARCH_CRITERIA_ERROR, RYGEL_SEARCH_CRITERIA_ERROR_SYNTAX_ERROR, _tmp15_);
				_tmp17_ = _tmp16_;
				_g_free0 (_tmp15_);
				_g_free0 (_tmp13_);
				_inner_error0_ = _tmp17_;
				g_propagate_error (error, _inner_error0_);
				_rygel_search_expression_unref0 (exp);
				return NULL;
			}
		}
		_tmp26_ = rygel_search_criteria_parser_get_token (self);
		_tmp27_ = _tmp26_;
		if (_tmp27_ == RYGEL_SEARCH_CRITERIA_SYMBOL_EQ) {
			_tmp25_ = TRUE;
		} else {
			RygelSearchCriteriaSymbol _tmp28_;
			RygelSearchCriteriaSymbol _tmp29_;
			_tmp28_ = rygel_search_criteria_parser_get_token (self);
			_tmp29_ = _tmp28_;
			_tmp25_ = _tmp29_ == RYGEL_SEARCH_CRITERIA_SYMBOL_NEQ;
		}
		if (_tmp25_) {
			_tmp24_ = TRUE;
		} else {
			RygelSearchCriteriaSymbol _tmp30_;
			RygelSearchCriteriaSymbol _tmp31_;
			_tmp30_ = rygel_search_criteria_parser_get_token (self);
			_tmp31_ = _tmp30_;
			_tmp24_ = _tmp31_ == RYGEL_SEARCH_CRITERIA_SYMBOL_LESS;
		}
		if (_tmp24_) {
			_tmp23_ = TRUE;
		} else {
			RygelSearchCriteriaSymbol _tmp32_;
			RygelSearchCriteriaSymbol _tmp33_;
			_tmp32_ = rygel_search_criteria_parser_get_token (self);
			_tmp33_ = _tmp32_;
			_tmp23_ = _tmp33_ == RYGEL_SEARCH_CRITERIA_SYMBOL_LEQ;
		}
		if (_tmp23_) {
			_tmp22_ = TRUE;
		} else {
			RygelSearchCriteriaSymbol _tmp34_;
			RygelSearchCriteriaSymbol _tmp35_;
			_tmp34_ = rygel_search_criteria_parser_get_token (self);
			_tmp35_ = _tmp34_;
			_tmp22_ = _tmp35_ == RYGEL_SEARCH_CRITERIA_SYMBOL_GREATER;
		}
		if (_tmp22_) {
			_tmp21_ = TRUE;
		} else {
			RygelSearchCriteriaSymbol _tmp36_;
			RygelSearchCriteriaSymbol _tmp37_;
			_tmp36_ = rygel_search_criteria_parser_get_token (self);
			_tmp37_ = _tmp36_;
			_tmp21_ = _tmp37_ == RYGEL_SEARCH_CRITERIA_SYMBOL_GEQ;
		}
		if (_tmp21_) {
			_tmp20_ = TRUE;
		} else {
			RygelSearchCriteriaSymbol _tmp38_;
			RygelSearchCriteriaSymbol _tmp39_;
			_tmp38_ = rygel_search_criteria_parser_get_token (self);
			_tmp39_ = _tmp38_;
			_tmp20_ = _tmp39_ == RYGEL_SEARCH_CRITERIA_SYMBOL_CONTAINS;
		}
		if (_tmp20_) {
			_tmp19_ = TRUE;
		} else {
			RygelSearchCriteriaSymbol _tmp40_;
			RygelSearchCriteriaSymbol _tmp41_;
			_tmp40_ = rygel_search_criteria_parser_get_token (self);
			_tmp41_ = _tmp40_;
			_tmp19_ = _tmp41_ == RYGEL_SEARCH_CRITERIA_SYMBOL_DOES_NOT_CONTAIN;
		}
		if (_tmp19_) {
			_tmp18_ = TRUE;
		} else {
			RygelSearchCriteriaSymbol _tmp42_;
			RygelSearchCriteriaSymbol _tmp43_;
			_tmp42_ = rygel_search_criteria_parser_get_token (self);
			_tmp43_ = _tmp42_;
			_tmp18_ = _tmp43_ == RYGEL_SEARCH_CRITERIA_SYMBOL_DERIVED_FROM;
		}
		if (_tmp18_) {
			RygelRelationalExpression* _tmp44_;
			GScanner* _tmp45_;
			GScanner* _tmp46_;
			GScanner* _tmp47_;
			_tmp44_ = exp;
			_tmp45_ = self->priv->scanner;
			((RygelSearchExpression*) _tmp44_)->op = (gpointer) ((gintptr) _tmp45_->token);
			_tmp46_ = self->priv->scanner;
			g_scanner_get_next_token (_tmp46_);
			_tmp47_ = self->priv->scanner;
			if (_tmp47_->token == G_TOKEN_STRING) {
				RygelRelationalExpression* _tmp48_;
				GScanner* _tmp49_;
				const gchar* _tmp50_;
				gchar* _tmp51_;
				GScanner* _tmp52_;
				_tmp48_ = exp;
				_tmp49_ = self->priv->scanner;
				_tmp50_ = _tmp49_->value.v_string;
				_tmp51_ = g_strdup (_tmp50_);
				_g_free0 (((RygelSearchExpression*) _tmp48_)->operand2);
				((RygelSearchExpression*) _tmp48_)->operand2 = _tmp51_;
				_tmp52_ = self->priv->scanner;
				g_scanner_get_next_token (_tmp52_);
				result = (RygelSearchExpression*) exp;
				return result;
			} else {
				gchar* _tmp53_;
				gchar* _tmp54_;
				gchar* _tmp55_;
				gchar* _tmp56_;
				gchar* _tmp57_;
				gchar* _tmp58_;
				gchar* _tmp59_;
				GError* _tmp60_;
				GError* _tmp61_;
				_tmp53_ = rygel_search_criteria_parser_get_context (self);
				_tmp54_ = _tmp53_;
				_tmp55_ = _tmp54_;
				_tmp56_ = g_strconcat (_tmp55_, ": expected ", NULL);
				_tmp57_ = _tmp56_;
				_tmp58_ = g_strconcat (_tmp57_, "\"STRING\"", NULL);
				_tmp59_ = _tmp58_;
				_tmp60_ = g_error_new_literal (RYGEL_SEARCH_CRITERIA_ERROR, RYGEL_SEARCH_CRITERIA_ERROR_SYNTAX_ERROR, _tmp59_);
				_tmp61_ = _tmp60_;
				_g_free0 (_tmp59_);
				_g_free0 (_tmp57_);
				_g_free0 (_tmp55_);
				_inner_error0_ = _tmp61_;
				g_propagate_error (error, _inner_error0_);
				_rygel_search_expression_unref0 (exp);
				return NULL;
			}
		} else {
			RygelSearchCriteriaSymbol _tmp62_;
			RygelSearchCriteriaSymbol _tmp63_;
			_tmp62_ = rygel_search_criteria_parser_get_token (self);
			_tmp63_ = _tmp62_;
			if (_tmp63_ == RYGEL_SEARCH_CRITERIA_SYMBOL_EXISTS) {
				RygelRelationalExpression* _tmp64_;
				GScanner* _tmp65_;
				GScanner* _tmp66_;
				RygelSearchCriteriaSymbol _tmp67_;
				RygelSearchCriteriaSymbol _tmp68_;
				_tmp64_ = exp;
				_tmp65_ = self->priv->scanner;
				((RygelSearchExpression*) _tmp64_)->op = (gpointer) ((gintptr) _tmp65_->token);
				_tmp66_ = self->priv->scanner;
				g_scanner_get_next_token (_tmp66_);
				_tmp67_ = rygel_search_criteria_parser_get_token (self);
				_tmp68_ = _tmp67_;
				if (_tmp68_ == RYGEL_SEARCH_CRITERIA_SYMBOL_TRUE) {
					RygelRelationalExpression* _tmp69_;
					gchar* _tmp70_;
					GScanner* _tmp71_;
					_tmp69_ = exp;
					_tmp70_ = g_strdup ("true");
					_g_free0 (((RygelSearchExpression*) _tmp69_)->operand2);
					((RygelSearchExpression*) _tmp69_)->operand2 = _tmp70_;
					_tmp71_ = self->priv->scanner;
					g_scanner_get_next_token (_tmp71_);
					result = (RygelSearchExpression*) exp;
					return result;
				} else {
					RygelSearchCriteriaSymbol _tmp72_;
					RygelSearchCriteriaSymbol _tmp73_;
					_tmp72_ = rygel_search_criteria_parser_get_token (self);
					_tmp73_ = _tmp72_;
					if (_tmp73_ == RYGEL_SEARCH_CRITERIA_SYMBOL_FALSE) {
						RygelRelationalExpression* _tmp74_;
						gchar* _tmp75_;
						GScanner* _tmp76_;
						_tmp74_ = exp;
						_tmp75_ = g_strdup ("false");
						_g_free0 (((RygelSearchExpression*) _tmp74_)->operand2);
						((RygelSearchExpression*) _tmp74_)->operand2 = _tmp75_;
						_tmp76_ = self->priv->scanner;
						g_scanner_get_next_token (_tmp76_);
						result = (RygelSearchExpression*) exp;
						return result;
					} else {
						gchar* _tmp77_;
						gchar* _tmp78_;
						gchar* _tmp79_;
						gchar* _tmp80_;
						gchar* _tmp81_;
						gchar* _tmp82_;
						gchar* _tmp83_;
						gchar* _tmp84_;
						gchar* _tmp85_;
						GError* _tmp86_;
						GError* _tmp87_;
						_tmp77_ = rygel_search_criteria_parser_get_context (self);
						_tmp78_ = _tmp77_;
						_tmp79_ = _tmp78_;
						_tmp80_ = g_strconcat (_tmp79_, ": expected ", NULL);
						_tmp81_ = _tmp80_;
						_tmp82_ = g_strconcat (_tmp81_, "\"true\"|\"", NULL);
						_tmp83_ = _tmp82_;
						_tmp84_ = g_strconcat (_tmp83_, "false\"", NULL);
						_tmp85_ = _tmp84_;
						_tmp86_ = g_error_new_literal (RYGEL_SEARCH_CRITERIA_ERROR, RYGEL_SEARCH_CRITERIA_ERROR_SYNTAX_ERROR, _tmp85_);
						_tmp87_ = _tmp86_;
						_g_free0 (_tmp85_);
						_g_free0 (_tmp83_);
						_g_free0 (_tmp81_);
						_g_free0 (_tmp79_);
						_inner_error0_ = _tmp87_;
						g_propagate_error (error, _inner_error0_);
						_rygel_search_expression_unref0 (exp);
						return NULL;
					}
				}
			} else {
				gchar* _tmp88_;
				gchar* _tmp89_;
				gchar* _tmp90_;
				gchar* _tmp91_;
				gchar* _tmp92_;
				gchar* _tmp93_;
				gchar* _tmp94_;
				GError* _tmp95_;
				GError* _tmp96_;
				_tmp88_ = rygel_search_criteria_parser_get_context (self);
				_tmp89_ = _tmp88_;
				_tmp90_ = _tmp89_;
				_tmp91_ = g_strconcat (_tmp90_, ": expected ", NULL);
				_tmp92_ = _tmp91_;
				_tmp93_ = g_strconcat (_tmp92_, "operator", NULL);
				_tmp94_ = _tmp93_;
				_tmp95_ = g_error_new_literal (RYGEL_SEARCH_CRITERIA_ERROR, RYGEL_SEARCH_CRITERIA_ERROR_SYNTAX_ERROR, _tmp94_);
				_tmp96_ = _tmp95_;
				_g_free0 (_tmp94_);
				_g_free0 (_tmp92_);
				_g_free0 (_tmp90_);
				_inner_error0_ = _tmp96_;
				g_propagate_error (error, _inner_error0_);
				_rygel_search_expression_unref0 (exp);
				return NULL;
			}
		}
	} else {
		GScanner* _tmp97_;
		_tmp97_ = self->priv->scanner;
		if (_tmp97_->token == G_TOKEN_LEFT_PAREN) {
			GScanner* _tmp98_;
			RygelSearchExpression* exp2 = NULL;
			RygelSearchExpression* _tmp99_;
			GScanner* _tmp100_;
			_tmp98_ = self->priv->scanner;
			g_scanner_get_next_token (_tmp98_);
			_tmp99_ = rygel_search_criteria_parser_parse_or_expression (self, &_inner_error0_);
			exp2 = _tmp99_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_rygel_search_expression_unref0 (exp);
				return NULL;
			}
			_tmp100_ = self->priv->scanner;
			if (_tmp100_->token != G_TOKEN_RIGHT_PAREN) {
				gchar* _tmp101_;
				gchar* _tmp102_;
				gchar* _tmp103_;
				gchar* _tmp104_;
				gchar* _tmp105_;
				GError* _tmp106_;
				GError* _tmp107_;
				_tmp101_ = rygel_search_criteria_parser_get_context (self);
				_tmp102_ = _tmp101_;
				_tmp103_ = _tmp102_;
				_tmp104_ = g_strconcat (_tmp103_, ": expected ')'", NULL);
				_tmp105_ = _tmp104_;
				_tmp106_ = g_error_new_literal (RYGEL_SEARCH_CRITERIA_ERROR, RYGEL_SEARCH_CRITERIA_ERROR_SYNTAX_ERROR, _tmp105_);
				_tmp107_ = _tmp106_;
				_g_free0 (_tmp105_);
				_g_free0 (_tmp103_);
				_inner_error0_ = _tmp107_;
				g_propagate_error (error, _inner_error0_);
				_rygel_search_expression_unref0 (exp2);
				_rygel_search_expression_unref0 (exp);
				return NULL;
			} else {
				GScanner* _tmp108_;
				_tmp108_ = self->priv->scanner;
				g_scanner_get_next_token (_tmp108_);
				result = exp2;
				_rygel_search_expression_unref0 (exp);
				return result;
			}
			_rygel_search_expression_unref0 (exp2);
		} else {
			gchar* _tmp109_;
			gchar* _tmp110_;
			gchar* _tmp111_;
			gchar* _tmp112_;
			gchar* _tmp113_;
			gchar* _tmp114_;
			gchar* _tmp115_;
			GError* _tmp116_;
			GError* _tmp117_;
			_tmp109_ = rygel_search_criteria_parser_get_context (self);
			_tmp110_ = _tmp109_;
			_tmp111_ = _tmp110_;
			_tmp112_ = g_strconcat (_tmp111_, ": expected ", NULL);
			_tmp113_ = _tmp112_;
			_tmp114_ = g_strconcat (_tmp113_, "identifier or '('", NULL);
			_tmp115_ = _tmp114_;
			_tmp116_ = g_error_new_literal (RYGEL_SEARCH_CRITERIA_ERROR, RYGEL_SEARCH_CRITERIA_ERROR_SYNTAX_ERROR, _tmp115_);
			_tmp117_ = _tmp116_;
			_g_free0 (_tmp115_);
			_g_free0 (_tmp113_);
			_g_free0 (_tmp111_);
			_inner_error0_ = _tmp117_;
			g_propagate_error (error, _inner_error0_);
			_rygel_search_expression_unref0 (exp);
			return NULL;
		}
	}
}

static RygelSearchExpression*
rygel_search_criteria_parser_parse_or_expression (RygelSearchCriteriaParser* self,
                                                  GError** error)
{
	RygelSearchExpression* exp = NULL;
	RygelSearchExpression* _tmp0_;
	GError* _inner_error0_ = NULL;
	RygelSearchExpression* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = rygel_search_criteria_parser_parse_and_expression (self, &_inner_error0_);
	exp = _tmp0_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	while (TRUE) {
		RygelSearchCriteriaSymbol _tmp1_;
		RygelSearchCriteriaSymbol _tmp2_;
		GScanner* _tmp3_;
		RygelLogicalExpression* exp2 = NULL;
		RygelLogicalExpression* _tmp4_;
		RygelLogicalExpression* _tmp5_;
		RygelSearchExpression* _tmp6_;
		RygelSearchExpression* _tmp7_;
		RygelLogicalExpression* _tmp8_;
		RygelSearchExpression* _tmp9_ = NULL;
		RygelSearchExpression* _tmp10_;
		RygelLogicalExpression* _tmp11_;
		RygelSearchExpression* _tmp12_;
		RygelLogicalExpression* _tmp13_;
		RygelSearchExpression* _tmp14_;
		_tmp1_ = rygel_search_criteria_parser_get_token (self);
		_tmp2_ = _tmp1_;
		if (!(_tmp2_ == RYGEL_SEARCH_CRITERIA_SYMBOL_OR)) {
			break;
		}
		_tmp3_ = self->priv->scanner;
		g_scanner_get_next_token (_tmp3_);
		_tmp4_ = rygel_logical_expression_new ();
		exp2 = _tmp4_;
		_tmp5_ = exp2;
		_tmp6_ = exp;
		_tmp7_ = _rygel_search_expression_ref0 (_tmp6_);
		_rygel_search_expression_unref0 (((RygelSearchExpression*) _tmp5_)->operand1);
		((RygelSearchExpression*) _tmp5_)->operand1 = _tmp7_;
		_tmp8_ = exp2;
		((RygelSearchExpression*) _tmp8_)->op = (gpointer) ((gintptr) RYGEL_LOGICAL_OPERATOR_OR);
		_tmp10_ = rygel_search_criteria_parser_parse_and_expression (self, &_inner_error0_);
		_tmp9_ = _tmp10_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_rygel_search_expression_unref0 (exp2);
			_rygel_search_expression_unref0 (exp);
			return NULL;
		}
		_tmp11_ = exp2;
		_tmp12_ = _tmp9_;
		_tmp9_ = NULL;
		_rygel_search_expression_unref0 (((RygelSearchExpression*) _tmp11_)->operand2);
		((RygelSearchExpression*) _tmp11_)->operand2 = _tmp12_;
		_tmp13_ = exp2;
		_tmp14_ = _rygel_search_expression_ref0 ((RygelSearchExpression*) _tmp13_);
		_rygel_search_expression_unref0 (exp);
		exp = _tmp14_;
		_rygel_search_expression_unref0 (_tmp9_);
		_rygel_search_expression_unref0 (exp2);
	}
	result = exp;
	return result;
}

static GCancellable*
rygel_search_criteria_parser_real_get_cancellable (RygelStateMachine* base)
{
	GCancellable* result;
	RygelSearchCriteriaParser* self;
	GCancellable* _tmp0_;
	self = (RygelSearchCriteriaParser*) base;
	_tmp0_ = self->priv->_cancellable;
	result = _tmp0_;
	return result;
}

static void
rygel_search_criteria_parser_real_set_cancellable (RygelStateMachine* base,
                                                   GCancellable* value)
{
	RygelSearchCriteriaParser* self;
	GCancellable* old_value;
	self = (RygelSearchCriteriaParser*) base;
	old_value = rygel_search_criteria_parser_real_get_cancellable (base);
	if (old_value != value) {
		GCancellable* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_cancellable);
		self->priv->_cancellable = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, rygel_search_criteria_parser_properties[RYGEL_SEARCH_CRITERIA_PARSER_CANCELLABLE_PROPERTY]);
	}
}

static RygelSearchCriteriaSymbol
rygel_search_criteria_parser_get_token (RygelSearchCriteriaParser* self)
{
	RygelSearchCriteriaSymbol result;
	GScanner* _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->scanner;
	result = (RygelSearchCriteriaSymbol) _tmp0_->token;
	return result;
}

static gchar*
rygel_search_criteria_parser_get_context (RygelSearchCriteriaParser* self)
{
	gchar* result;
	GScanner* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GScanner* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->scanner;
	_tmp1_ = g_strdup_printf ("%u", _tmp0_->line);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat (_tmp2_, ".", NULL);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->scanner;
	_tmp6_ = g_strdup_printf ("%u", _tmp5_->position);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp4_, _tmp7_, NULL);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	result = _tmp9_;
	return result;
}

static void
rygel_search_criteria_parser_class_init (RygelSearchCriteriaParserClass * klass,
                                         gpointer klass_data)
{
	rygel_search_criteria_parser_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RygelSearchCriteriaParser_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_rygel_search_criteria_parser_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_rygel_search_criteria_parser_set_property;
	G_OBJECT_CLASS (klass)->finalize = rygel_search_criteria_parser_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_SEARCH_CRITERIA_PARSER_CANCELLABLE_PROPERTY, rygel_search_criteria_parser_properties[RYGEL_SEARCH_CRITERIA_PARSER_CANCELLABLE_PROPERTY] = g_param_spec_object ("cancellable", "cancellable", "cancellable", g_cancellable_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
rygel_search_criteria_parser_rygel_state_machine_interface_init (RygelStateMachineIface * iface,
                                                                 gpointer iface_data)
{
	rygel_search_criteria_parser_rygel_state_machine_parent_iface = g_type_interface_peek_parent (iface);
	iface->run = (void (*) (RygelStateMachine*, GAsyncReadyCallback, gpointer)) rygel_search_criteria_parser_real_run;
	iface->run_finish = (void (*) (RygelStateMachine*, GAsyncResult*)) rygel_search_criteria_parser_run_finish;
	iface->get_cancellable = rygel_search_criteria_parser_real_get_cancellable;
	iface->set_cancellable = rygel_search_criteria_parser_real_set_cancellable;
}

static void
rygel_search_criteria_parser_instance_init (RygelSearchCriteriaParser * self,
                                            gpointer klass)
{
	self->priv = rygel_search_criteria_parser_get_instance_private (self);
}

static void
rygel_search_criteria_parser_finalize (GObject * obj)
{
	RygelSearchCriteriaParser * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_SEARCH_CRITERIA_PARSER, RygelSearchCriteriaParser);
	_g_free0 (self->str);
	_rygel_search_expression_unref0 (self->expression);
	_g_error_free0 (self->err);
	_g_object_unref0 (self->priv->_cancellable);
	_g_scanner_destroy0 (self->priv->scanner);
	G_OBJECT_CLASS (rygel_search_criteria_parser_parent_class)->finalize (obj);
}

/**
 * Parses a search criteria string and creates SearchExpression as a result.
 */
 G_GNUC_NO_INLINE static GType
rygel_search_criteria_parser_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelSearchCriteriaParserClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_search_criteria_parser_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelSearchCriteriaParser), 0, (GInstanceInitFunc) rygel_search_criteria_parser_instance_init, NULL };
	static const GInterfaceInfo rygel_state_machine_info = { (GInterfaceInitFunc) rygel_search_criteria_parser_rygel_state_machine_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType rygel_search_criteria_parser_type_id;
	rygel_search_criteria_parser_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelSearchCriteriaParser", &g_define_type_info, 0);
	g_type_add_interface_static (rygel_search_criteria_parser_type_id, RYGEL_TYPE_STATE_MACHINE, &rygel_state_machine_info);
	RygelSearchCriteriaParser_private_offset = g_type_add_instance_private (rygel_search_criteria_parser_type_id, sizeof (RygelSearchCriteriaParserPrivate));
	return rygel_search_criteria_parser_type_id;
}

GType
rygel_search_criteria_parser_get_type (void)
{
	static volatile gsize rygel_search_criteria_parser_type_id__once = 0;
	if (g_once_init_enter (&rygel_search_criteria_parser_type_id__once)) {
		GType rygel_search_criteria_parser_type_id;
		rygel_search_criteria_parser_type_id = rygel_search_criteria_parser_get_type_once ();
		g_once_init_leave (&rygel_search_criteria_parser_type_id__once, rygel_search_criteria_parser_type_id);
	}
	return rygel_search_criteria_parser_type_id__once;
}

static void
_vala_rygel_search_criteria_parser_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec)
{
	RygelSearchCriteriaParser * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_TYPE_SEARCH_CRITERIA_PARSER, RygelSearchCriteriaParser);
	switch (property_id) {
		case RYGEL_SEARCH_CRITERIA_PARSER_CANCELLABLE_PROPERTY:
		g_value_set_object (value, rygel_state_machine_get_cancellable ((RygelStateMachine*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_rygel_search_criteria_parser_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec)
{
	RygelSearchCriteriaParser * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_TYPE_SEARCH_CRITERIA_PARSER, RygelSearchCriteriaParser);
	switch (property_id) {
		case RYGEL_SEARCH_CRITERIA_PARSER_CANCELLABLE_PROPERTY:
		rygel_state_machine_set_cancellable ((RygelStateMachine*) self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

