/* rygel-search-criteria-parser.c generated by valac 0.48.5, 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 <libgupnp-av/gupnp-av.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <rygel-core.h>
#include <gio/gio.h>

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;

#define RYGEL_TYPE_SEARCH_EXPRESSION (rygel_search_expression_get_type ())
#define RYGEL_SEARCH_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_SEARCH_EXPRESSION, RygelSearchExpression))
#define RYGEL_SEARCH_EXPRESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_SEARCH_EXPRESSION, RygelSearchExpressionClass))
#define RYGEL_IS_SEARCH_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_SEARCH_EXPRESSION))
#define RYGEL_IS_SEARCH_EXPRESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_SEARCH_EXPRESSION))
#define RYGEL_SEARCH_EXPRESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_SEARCH_EXPRESSION, RygelSearchExpressionClass))

typedef struct _RygelSearchExpression RygelSearchExpression;
typedef struct _RygelSearchExpressionClass RygelSearchExpressionClass;
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;

#define RYGEL_TYPE_LOGICAL_EXPRESSION (rygel_logical_expression_get_type ())
#define RYGEL_LOGICAL_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_LOGICAL_EXPRESSION, RygelLogicalExpression))
#define RYGEL_LOGICAL_EXPRESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_LOGICAL_EXPRESSION, RygelLogicalExpressionClass))
#define RYGEL_IS_LOGICAL_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_LOGICAL_EXPRESSION))
#define RYGEL_IS_LOGICAL_EXPRESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_LOGICAL_EXPRESSION))
#define RYGEL_LOGICAL_EXPRESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_LOGICAL_EXPRESSION, RygelLogicalExpressionClass))

typedef struct _RygelLogicalExpression RygelLogicalExpression;
typedef struct _RygelLogicalExpressionClass RygelLogicalExpressionClass;
typedef enum  {
	RYGEL_LOGICAL_OPERATOR_AND,
	RYGEL_LOGICAL_OPERATOR_OR
} RygelLogicalOperator;

#define RYGEL_TYPE_LOGICAL_OPERATOR (rygel_logical_operator_get_type ())
typedef struct _RygelSearchExpressionPrivate RygelSearchExpressionPrivate;

#define RYGEL_TYPE_MEDIA_OBJECT (rygel_media_object_get_type ())
#define RYGEL_MEDIA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_OBJECT, RygelMediaObject))
#define RYGEL_MEDIA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_OBJECT, RygelMediaObjectClass))
#define RYGEL_IS_MEDIA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_OBJECT))
#define RYGEL_IS_MEDIA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_OBJECT))
#define RYGEL_MEDIA_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_OBJECT, RygelMediaObjectClass))

typedef struct _RygelMediaObject RygelMediaObject;
typedef struct _RygelMediaObjectClass RygelMediaObjectClass;

#define RYGEL_TYPE_RELATIONAL_EXPRESSION (rygel_relational_expression_get_type ())
#define RYGEL_RELATIONAL_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_RELATIONAL_EXPRESSION, RygelRelationalExpression))
#define RYGEL_RELATIONAL_EXPRESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_RELATIONAL_EXPRESSION, RygelRelationalExpressionClass))
#define RYGEL_IS_RELATIONAL_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_RELATIONAL_EXPRESSION))
#define RYGEL_IS_RELATIONAL_EXPRESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_RELATIONAL_EXPRESSION))
#define RYGEL_RELATIONAL_EXPRESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_RELATIONAL_EXPRESSION, RygelRelationalExpressionClass))

typedef struct _RygelRelationalExpression RygelRelationalExpression;
typedef struct _RygelRelationalExpressionClass RygelRelationalExpressionClass;

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_;
};

struct _RygelSearchExpression {
	GTypeInstance parent_instance;
	volatile int ref_count;
	RygelSearchExpressionPrivate * priv;
	gpointer op;
	gpointer operand1;
	gpointer operand2;
};

struct _RygelSearchExpressionClass {
	GTypeClass parent_class;
	void (*finalize) (RygelSearchExpression *self);
	gboolean (*satisfied_by) (RygelSearchExpression* self, RygelMediaObject* media_object);
	gchar* (*to_string) (RygelSearchExpression* self);
};

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;

GQuark rygel_search_criteria_error_quark (void);
GType rygel_search_criteria_symbol_get_type (void) G_GNUC_CONST;
GType rygel_search_criteria_token_get_type (void) G_GNUC_CONST;
RygelSearchCriteriaToken* rygel_search_criteria_token_dup (const RygelSearchCriteriaToken* self);
void rygel_search_criteria_token_free (RygelSearchCriteriaToken* self);
void rygel_search_criteria_token_copy (const RygelSearchCriteriaToken* self,
                                       RygelSearchCriteriaToken* dest);
void rygel_search_criteria_token_destroy (RygelSearchCriteriaToken* self);
GType rygel_search_criteria_parser_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelSearchCriteriaParser, g_object_unref)
gpointer rygel_search_expression_ref (gpointer instance);
void rygel_search_expression_unref (gpointer instance);
GParamSpec* rygel_param_spec_search_expression (const gchar* name,
                                                const gchar* nick,
                                                const gchar* blurb,
                                                GType object_type,
                                                GParamFlags flags);
void rygel_value_set_search_expression (GValue* value,
                                        gpointer v_object);
void rygel_value_take_search_expression (GValue* value,
                                         gpointer v_object);
gpointer rygel_value_get_search_expression (const GValue* value);
GType rygel_search_expression_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelSearchExpression, rygel_search_expression_unref)
RygelSearchCriteriaParser* rygel_search_criteria_parser_new (const gchar* str,
                                                             GError** error);
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);
GType rygel_logical_expression_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelLogicalExpression, rygel_search_expression_unref)
RygelLogicalExpression* rygel_logical_expression_new (void);
RygelLogicalExpression* rygel_logical_expression_construct (GType object_type);
GType rygel_logical_operator_get_type (void) G_GNUC_CONST;
GType rygel_media_object_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelMediaObject, g_object_unref)
GType rygel_relational_expression_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelRelationalExpression, rygel_search_expression_unref)
RygelRelationalExpression* rygel_relational_expression_new (void);
RygelRelationalExpression* rygel_relational_expression_construct (GType object_type);
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 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");
}

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__volatile = 0;
	if (g_once_init_enter (&rygel_search_criteria_symbol_type_id__volatile)) {
		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__volatile, rygel_search_criteria_symbol_type_id);
	}
	return rygel_search_criteria_symbol_type_id__volatile;
}

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

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);
}

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__volatile = 0;
	if (g_once_init_enter (&rygel_search_criteria_token_type_id__volatile)) {
		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__volatile, rygel_search_criteria_token_type_id);
	}
	return rygel_search_criteria_token_type_id__volatile;
}

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

static RygelSearchExpression*
rygel_search_criteria_parser_parse_or_expression (RygelSearchCriteriaParser* self,
                                                  GError** error)
{
	RygelSearchExpression* exp = NULL;
	RygelSearchExpression* _tmp0_;
	GError* _inner_error0_ = NULL;
	RygelSearchExpression* result = NULL;
	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;
	self = (RygelSearchCriteriaParser*) base;
	if (rygel_search_criteria_parser_real_get_cancellable (base) != 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_;
	GTokenType _tmp1_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->scanner;
	_tmp1_ = _tmp0_->token;
	result = (RygelSearchCriteriaSymbol) _tmp1_;
	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.
 */
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__volatile = 0;
	if (g_once_init_enter (&rygel_search_criteria_parser_type_id__volatile)) {
		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__volatile, rygel_search_criteria_parser_type_id);
	}
	return rygel_search_criteria_parser_type_id__volatile;
}

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;
	}
}

