/* sequencerule.c generated by valac, the Vala compiler
 * generated from sequencerule.vala, do not modify */

/* sequencerule.vala
 *
 * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
 *
 * This library 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.
 *
 * This library 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
 *
 * Author:
 * 	Didier 'Ptitjes Villevalois <ptitjes@free.fr>
 */

#include <glib.h>
#include <glib-object.h>
#include "valadoc.h"
#include <stdlib.h>
#include <string.h>


#define VALADOC_TYPE_SEQUENCE_RULE (valadoc_sequence_rule_get_type ())
#define VALADOC_SEQUENCE_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALADOC_TYPE_SEQUENCE_RULE, ValadocSequenceRule))
#define VALADOC_SEQUENCE_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALADOC_TYPE_SEQUENCE_RULE, ValadocSequenceRuleClass))
#define VALADOC_IS_SEQUENCE_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALADOC_TYPE_SEQUENCE_RULE))
#define VALADOC_IS_SEQUENCE_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALADOC_TYPE_SEQUENCE_RULE))
#define VALADOC_SEQUENCE_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALADOC_TYPE_SEQUENCE_RULE, ValadocSequenceRuleClass))

typedef struct _ValadocSequenceRule ValadocSequenceRule;
typedef struct _ValadocSequenceRuleClass ValadocSequenceRuleClass;
typedef struct _ValadocSequenceRulePrivate ValadocSequenceRulePrivate;
enum  {
	VALADOC_SEQUENCE_RULE_0_PROPERTY,
	VALADOC_SEQUENCE_RULE_NUM_PROPERTIES
};
static GParamSpec* valadoc_sequence_rule_properties[VALADOC_SEQUENCE_RULE_NUM_PROPERTIES];

#define VALADOC_SEQUENCE_RULE_TYPE_STATE (valadoc_sequence_rule_state_get_type ())
#define VALADOC_SEQUENCE_RULE_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALADOC_SEQUENCE_RULE_TYPE_STATE, ValadocSequenceRuleState))
#define VALADOC_SEQUENCE_RULE_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALADOC_SEQUENCE_RULE_TYPE_STATE, ValadocSequenceRuleStateClass))
#define VALADOC_SEQUENCE_RULE_IS_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALADOC_SEQUENCE_RULE_TYPE_STATE))
#define VALADOC_SEQUENCE_RULE_IS_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALADOC_SEQUENCE_RULE_TYPE_STATE))
#define VALADOC_SEQUENCE_RULE_STATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALADOC_SEQUENCE_RULE_TYPE_STATE, ValadocSequenceRuleStateClass))

typedef struct _ValadocSequenceRuleState ValadocSequenceRuleState;
typedef struct _ValadocSequenceRuleStateClass ValadocSequenceRuleStateClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _ValadocSequenceRuleStatePrivate ValadocSequenceRuleStatePrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	VALADOC_SEQUENCE_RULE_STATE_0_PROPERTY,
	VALADOC_SEQUENCE_RULE_STATE_NUM_PROPERTIES
};
static GParamSpec* valadoc_sequence_rule_state_properties[VALADOC_SEQUENCE_RULE_STATE_NUM_PROPERTIES];

struct _ValadocSequenceRule {
	ValadocRule parent_instance;
	ValadocSequenceRulePrivate * priv;
};

struct _ValadocSequenceRuleClass {
	ValadocRuleClass parent_class;
};

struct _ValadocSequenceRulePrivate {
	GObject** _scheme;
	gint _scheme_length1;
	gint __scheme_size_;
};

struct _ValadocSequenceRuleState {
	GObject parent_instance;
	ValadocSequenceRuleStatePrivate * priv;
	gint index;
};

struct _ValadocSequenceRuleStateClass {
	GObjectClass parent_class;
};


static gpointer valadoc_sequence_rule_parent_class = NULL;
static gpointer valadoc_sequence_rule_state_parent_class = NULL;

G_GNUC_INTERNAL GType valadoc_sequence_rule_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
#define VALADOC_SEQUENCE_RULE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALADOC_TYPE_SEQUENCE_RULE, ValadocSequenceRulePrivate))
G_GNUC_INTERNAL ValadocSequenceRule* valadoc_sequence_rule_new (GObject** scheme, int scheme_length1);
G_GNUC_INTERNAL ValadocSequenceRule* valadoc_sequence_rule_construct (GType object_type, GObject** scheme, int scheme_length1);
static GObject** _vala_array_dup3 (GObject** self, int length);
static gboolean valadoc_sequence_rule_real_is_optional (ValadocRule* base);
static gboolean valadoc_sequence_rule_real_starts_with_token (ValadocRule* base, ValadocToken* token);
static gboolean valadoc_sequence_rule_test_token (ValadocSequenceRule* self, gint from_index, ValadocToken* token);
static gboolean valadoc_sequence_rule_test_reduce (ValadocSequenceRule* self, gint from_index, ValadocToken* token);
static gboolean valadoc_sequence_rule_real_accept_token (ValadocRule* base, ValadocToken* token, ValadocParserCallback* parser, ValadocRuleForward forward, GError** error);
static GType valadoc_sequence_rule_state_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
static ValadocSequenceRuleState* valadoc_sequence_rule_state_new (void);
static ValadocSequenceRuleState* valadoc_sequence_rule_state_construct (GType object_type);
static gboolean valadoc_sequence_rule_real_would_accept_token (ValadocRule* base, ValadocToken* token, GObject* rule_state);
static gboolean valadoc_sequence_rule_real_would_reduce (ValadocRule* base, ValadocToken* token, GObject* rule_state);
static gchar* valadoc_sequence_rule_real_to_string (ValadocRule* base, GObject* rule_state);
static void valadoc_sequence_rule_state_finalize (GObject * obj);
static void valadoc_sequence_rule_finalize (GObject * obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


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


static GObject** _vala_array_dup3 (GObject** self, int length) {
	GObject** result;
	int i;
	result = g_new0 (GObject*, length + 1);
	for (i = 0; i < length; i++) {
		GObject* _tmp0_;
		_tmp0_ = _g_object_ref0 (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


G_GNUC_INTERNAL ValadocSequenceRule* valadoc_sequence_rule_construct (GType object_type, GObject** scheme, int scheme_length1) {
	ValadocSequenceRule * self = NULL;
	GObject** _tmp0_;
	gint _tmp0__length1;
	GObject** _tmp1_;
	gint _tmp1__length1;
	self = (ValadocSequenceRule*) valadoc_rule_construct (object_type);
	_tmp0_ = scheme;
	_tmp0__length1 = scheme_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup3 (_tmp0_, _tmp0__length1) : ((gpointer) _tmp0_);
	_tmp1__length1 = _tmp0__length1;
	self->priv->_scheme = (_vala_array_free (self->priv->_scheme, self->priv->_scheme_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->_scheme = _tmp1_;
	self->priv->_scheme_length1 = _tmp1__length1;
	self->priv->__scheme_size_ = self->priv->_scheme_length1;
	return self;
}


G_GNUC_INTERNAL ValadocSequenceRule* valadoc_sequence_rule_new (GObject** scheme, int scheme_length1) {
	return valadoc_sequence_rule_construct (VALADOC_TYPE_SEQUENCE_RULE, scheme, scheme_length1);
}


static gboolean valadoc_sequence_rule_real_is_optional (ValadocRule* base) {
	ValadocSequenceRule * self;
	gboolean result = FALSE;
	self = (ValadocSequenceRule*) base;
	result = FALSE;
	return result;
}


static gboolean valadoc_sequence_rule_real_starts_with_token (ValadocRule* base, ValadocToken* token) {
	ValadocSequenceRule * self;
	gboolean result = FALSE;
	ValadocToken* _tmp0_;
	gboolean _tmp1_;
	self = (ValadocSequenceRule*) base;
	g_return_val_if_fail (token != NULL, FALSE);
	_tmp0_ = token;
	_tmp1_ = valadoc_sequence_rule_test_token (self, 0, _tmp0_);
	result = _tmp1_;
	return result;
}


static gboolean valadoc_sequence_rule_test_token (ValadocSequenceRule* self, gint from_index, ValadocToken* token) {
	gboolean result = FALSE;
	gint i = 0;
	gint _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (token != NULL, FALSE);
	_tmp0_ = from_index;
	i = _tmp0_;
	while (TRUE) {
		gint _tmp1_;
		GObject** _tmp2_;
		gint _tmp2__length1;
		GObject** _tmp3_;
		gint _tmp3__length1;
		gint _tmp4_;
		GObject* _tmp5_;
		ValadocToken* _tmp6_;
		gboolean _tmp7_;
		GObject** _tmp8_;
		gint _tmp8__length1;
		gint _tmp9_;
		GObject* _tmp10_;
		gboolean _tmp11_;
		gint _tmp12_;
		_tmp1_ = i;
		_tmp2_ = self->priv->_scheme;
		_tmp2__length1 = self->priv->_scheme_length1;
		if (!(_tmp1_ < _tmp2__length1)) {
			break;
		}
		_tmp3_ = self->priv->_scheme;
		_tmp3__length1 = self->priv->_scheme_length1;
		_tmp4_ = i;
		_tmp5_ = _tmp3_[_tmp4_];
		_tmp6_ = token;
		_tmp7_ = valadoc_rule_has_start_token ((ValadocRule*) self, _tmp5_, _tmp6_);
		if (_tmp7_) {
			result = TRUE;
			return result;
		}
		_tmp8_ = self->priv->_scheme;
		_tmp8__length1 = self->priv->_scheme_length1;
		_tmp9_ = i;
		_tmp10_ = _tmp8_[_tmp9_];
		_tmp11_ = valadoc_rule_is_optional_rule ((ValadocRule*) self, _tmp10_);
		if (!_tmp11_) {
			break;
		}
		_tmp12_ = i;
		i = _tmp12_ + 1;
	}
	result = FALSE;
	return result;
}


static gboolean valadoc_sequence_rule_test_reduce (ValadocSequenceRule* self, gint from_index, ValadocToken* token) {
	gboolean result = FALSE;
	gint i = 0;
	gint _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (token != NULL, FALSE);
	_tmp0_ = from_index;
	i = _tmp0_;
	while (TRUE) {
		gint _tmp1_;
		GObject** _tmp2_;
		gint _tmp2__length1;
		GObject** _tmp3_;
		gint _tmp3__length1;
		gint _tmp4_;
		GObject* _tmp5_;
		gboolean _tmp6_;
		gint _tmp7_;
		_tmp1_ = i;
		_tmp2_ = self->priv->_scheme;
		_tmp2__length1 = self->priv->_scheme_length1;
		if (!(_tmp1_ < _tmp2__length1)) {
			break;
		}
		_tmp3_ = self->priv->_scheme;
		_tmp3__length1 = self->priv->_scheme_length1;
		_tmp4_ = i;
		_tmp5_ = _tmp3_[_tmp4_];
		_tmp6_ = valadoc_rule_is_optional_rule ((ValadocRule*) self, _tmp5_);
		if (!_tmp6_) {
			result = FALSE;
			return result;
		}
		_tmp7_ = i;
		i = _tmp7_ + 1;
	}
	result = TRUE;
	return result;
}


static gboolean valadoc_sequence_rule_real_accept_token (ValadocRule* base, ValadocToken* token, ValadocParserCallback* parser, ValadocRuleForward forward, GError** error) {
	ValadocSequenceRule * self;
	gboolean result = FALSE;
	ValadocSequenceRuleState* state = NULL;
	ValadocParserCallback* _tmp0_;
	GObject* _tmp1_;
	ValadocSequenceRuleState* _tmp2_;
	ValadocSequenceRuleState* _tmp3_;
	ValadocSequenceRuleState* _tmp7_;
	gint _tmp8_;
	GObject* scheme_element = NULL;
	gboolean handled = FALSE;
	ValadocSequenceRuleState* _tmp45_;
	gint _tmp46_;
	GObject** _tmp47_;
	gint _tmp47__length1;
	GObject* _tmp51_;
	GError * _inner_error_ = NULL;
	self = (ValadocSequenceRule*) base;
	g_return_val_if_fail (token != NULL, FALSE);
	g_return_val_if_fail (parser != NULL, FALSE);
	_tmp0_ = parser;
	_tmp1_ = valadoc_parser_callback_get_rule_state (_tmp0_);
	_tmp2_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, VALADOC_SEQUENCE_RULE_TYPE_STATE) ? ((ValadocSequenceRuleState*) _tmp1_) : NULL;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (_tmp1_);
	}
	state = _tmp2_;
	_tmp3_ = state;
	if (_tmp3_ == NULL) {
		ValadocSequenceRuleState* _tmp4_;
		ValadocParserCallback* _tmp5_;
		ValadocSequenceRuleState* _tmp6_;
		_tmp4_ = valadoc_sequence_rule_state_new ();
		_g_object_unref0 (state);
		state = _tmp4_;
		_tmp5_ = parser;
		_tmp6_ = state;
		valadoc_parser_callback_set_rule_state (_tmp5_, (GObject*) _tmp6_);
	}
	_tmp7_ = state;
	_tmp8_ = _tmp7_->index;
	if (_tmp8_ == 0) {
		ValadocParserCallback* _tmp9_;
		_tmp9_ = parser;
		valadoc_rule_do_start ((ValadocRule*) self, _tmp9_, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == VALADOC_PARSER_ERROR) {
				gboolean _tmp10_ = FALSE;
				g_propagate_error (error, _inner_error_);
				_g_object_unref0 (state);
				return _tmp10_;
			} else {
				gboolean _tmp11_ = FALSE;
				_g_object_unref0 (state);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return _tmp11_;
			}
		}
	} else {
		ValadocSequenceRuleState* _tmp12_;
		gint _tmp13_;
		GObject** _tmp14_;
		gint _tmp14__length1;
		_tmp12_ = state;
		_tmp13_ = _tmp12_->index;
		_tmp14_ = self->priv->_scheme;
		_tmp14__length1 = self->priv->_scheme_length1;
		if (_tmp13_ == _tmp14__length1) {
			ValadocParserCallback* _tmp15_;
			_tmp15_ = parser;
			valadoc_rule_do_reduce ((ValadocRule*) self, _tmp15_, &_inner_error_);
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				if (_inner_error_->domain == VALADOC_PARSER_ERROR) {
					gboolean _tmp16_ = FALSE;
					g_propagate_error (error, _inner_error_);
					_g_object_unref0 (state);
					return _tmp16_;
				} else {
					gboolean _tmp17_ = FALSE;
					_g_object_unref0 (state);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return _tmp17_;
				}
			}
			result = FALSE;
			_g_object_unref0 (state);
			return result;
		}
	}
	scheme_element = NULL;
	{
		gboolean _tmp18_ = FALSE;
		_tmp18_ = TRUE;
		while (TRUE) {
			GObject** _tmp22_;
			gint _tmp22__length1;
			ValadocSequenceRuleState* _tmp23_;
			gint _tmp24_;
			GObject* _tmp25_;
			GObject* _tmp26_;
			gboolean _tmp27_ = FALSE;
			GObject* _tmp28_;
			ValadocToken* _tmp29_;
			ValadocParserCallback* _tmp30_;
			gboolean _tmp31_ = FALSE;
			gboolean _tmp32_;
			GObject* _tmp37_;
			gboolean _tmp38_;
			ValadocSequenceRuleState* _tmp43_;
			gint _tmp44_;
			if (!_tmp18_) {
				ValadocSequenceRuleState* _tmp19_;
				gint _tmp20_;
				GObject** _tmp21_;
				gint _tmp21__length1;
				_tmp19_ = state;
				_tmp20_ = _tmp19_->index;
				_tmp21_ = self->priv->_scheme;
				_tmp21__length1 = self->priv->_scheme_length1;
				if (!(_tmp20_ < _tmp21__length1)) {
					break;
				}
			}
			_tmp18_ = FALSE;
			_tmp22_ = self->priv->_scheme;
			_tmp22__length1 = self->priv->_scheme_length1;
			_tmp23_ = state;
			_tmp24_ = _tmp23_->index;
			_tmp25_ = _tmp22_[_tmp24_];
			_tmp26_ = _g_object_ref0 (_tmp25_);
			_g_object_unref0 (scheme_element);
			scheme_element = _tmp26_;
			_tmp28_ = scheme_element;
			_tmp29_ = token;
			_tmp30_ = parser;
			_tmp32_ = valadoc_rule_try_to_apply ((ValadocRule*) self, _tmp28_, _tmp29_, _tmp30_, &_tmp31_, &_inner_error_);
			handled = _tmp31_;
			_tmp27_ = _tmp32_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				if (_inner_error_->domain == VALADOC_PARSER_ERROR) {
					gboolean _tmp33_ = FALSE;
					g_propagate_error (error, _inner_error_);
					_g_object_unref0 (scheme_element);
					_g_object_unref0 (state);
					return _tmp33_;
				} else {
					gboolean _tmp34_ = FALSE;
					_g_object_unref0 (scheme_element);
					_g_object_unref0 (state);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return _tmp34_;
				}
			}
			if (_tmp27_) {
				ValadocSequenceRuleState* _tmp35_;
				gint _tmp36_;
				_tmp35_ = state;
				_tmp36_ = _tmp35_->index;
				_tmp35_->index = _tmp36_ + 1;
				result = handled;
				_g_object_unref0 (scheme_element);
				_g_object_unref0 (state);
				return result;
			}
			_tmp37_ = scheme_element;
			_tmp38_ = valadoc_rule_is_optional_rule ((ValadocRule*) self, _tmp37_);
			if (!_tmp38_) {
				break;
			} else {
				GObject* _tmp39_;
				ValadocParserCallback* _tmp40_;
				_tmp39_ = scheme_element;
				_tmp40_ = parser;
				valadoc_rule_do_skip (G_TYPE_CHECK_INSTANCE_CAST (_tmp39_, VALADOC_TYPE_RULE, ValadocRule), _tmp40_, &_inner_error_);
				if (G_UNLIKELY (_inner_error_ != NULL)) {
					if (_inner_error_->domain == VALADOC_PARSER_ERROR) {
						gboolean _tmp41_ = FALSE;
						g_propagate_error (error, _inner_error_);
						_g_object_unref0 (scheme_element);
						_g_object_unref0 (state);
						return _tmp41_;
					} else {
						gboolean _tmp42_ = FALSE;
						_g_object_unref0 (scheme_element);
						_g_object_unref0 (state);
						g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
						g_clear_error (&_inner_error_);
						return _tmp42_;
					}
				}
			}
			_tmp43_ = state;
			_tmp44_ = _tmp43_->index;
			_tmp43_->index = _tmp44_ + 1;
		}
	}
	_tmp45_ = state;
	_tmp46_ = _tmp45_->index;
	_tmp47_ = self->priv->_scheme;
	_tmp47__length1 = self->priv->_scheme_length1;
	if (_tmp46_ == _tmp47__length1) {
		ValadocParserCallback* _tmp48_;
		_tmp48_ = parser;
		valadoc_rule_do_reduce ((ValadocRule*) self, _tmp48_, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == VALADOC_PARSER_ERROR) {
				gboolean _tmp49_ = FALSE;
				g_propagate_error (error, _inner_error_);
				_g_object_unref0 (scheme_element);
				_g_object_unref0 (state);
				return _tmp49_;
			} else {
				gboolean _tmp50_ = FALSE;
				_g_object_unref0 (scheme_element);
				_g_object_unref0 (state);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return _tmp50_;
			}
		}
		result = FALSE;
		_g_object_unref0 (scheme_element);
		_g_object_unref0 (state);
		return result;
	}
	_tmp51_ = scheme_element;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp51_, VALADOC_TYPE_TOKEN_TYPE)) {
		ValadocParserCallback* _tmp52_;
		ValadocToken* _tmp53_;
		GObject* _tmp54_;
		gchar* _tmp55_;
		gchar* _tmp56_;
		gchar* _tmp57_;
		gchar* _tmp58_;
		_tmp52_ = parser;
		_tmp53_ = token;
		_tmp54_ = scheme_element;
		_tmp55_ = valadoc_token_type_to_pretty_string (G_TYPE_CHECK_INSTANCE_CAST (_tmp54_, VALADOC_TYPE_TOKEN_TYPE, ValadocTokenType));
		_tmp56_ = _tmp55_;
		_tmp57_ = g_strdup_printf ("expected %s", _tmp56_);
		_tmp58_ = _tmp57_;
		valadoc_parser_callback_error (_tmp52_, _tmp53_, _tmp58_, &_inner_error_);
		_g_free0 (_tmp58_);
		_g_free0 (_tmp56_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == VALADOC_PARSER_ERROR) {
				gboolean _tmp59_ = FALSE;
				g_propagate_error (error, _inner_error_);
				_g_object_unref0 (scheme_element);
				_g_object_unref0 (state);
				return _tmp59_;
			} else {
				gboolean _tmp60_ = FALSE;
				_g_object_unref0 (scheme_element);
				_g_object_unref0 (state);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return _tmp60_;
			}
		}
	} else {
		ValadocParserCallback* _tmp61_;
		ValadocToken* _tmp62_;
		_tmp61_ = parser;
		_tmp62_ = token;
		valadoc_parser_callback_error (_tmp61_, _tmp62_, "unexpected token", &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == VALADOC_PARSER_ERROR) {
				gboolean _tmp63_ = FALSE;
				g_propagate_error (error, _inner_error_);
				_g_object_unref0 (scheme_element);
				_g_object_unref0 (state);
				return _tmp63_;
			} else {
				gboolean _tmp64_ = FALSE;
				_g_object_unref0 (scheme_element);
				_g_object_unref0 (state);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return _tmp64_;
			}
		}
	}
	g_assert_not_reached ();
	_g_object_unref0 (scheme_element);
	_g_object_unref0 (state);
}


static gboolean valadoc_sequence_rule_real_would_accept_token (ValadocRule* base, ValadocToken* token, GObject* rule_state) {
	ValadocSequenceRule * self;
	gboolean result = FALSE;
	ValadocSequenceRuleState* state = NULL;
	GObject* _tmp0_;
	ValadocSequenceRuleState* _tmp1_;
	gint _tmp2_;
	ValadocToken* _tmp3_;
	gboolean _tmp4_;
	self = (ValadocSequenceRule*) base;
	g_return_val_if_fail (token != NULL, FALSE);
	_tmp0_ = rule_state;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, VALADOC_SEQUENCE_RULE_TYPE_STATE) ? ((ValadocSequenceRuleState*) _tmp0_) : NULL);
	state = _tmp1_;
	_tmp2_ = state->index;
	_tmp3_ = token;
	_tmp4_ = valadoc_sequence_rule_test_token (self, _tmp2_, _tmp3_);
	result = _tmp4_;
	_g_object_unref0 (state);
	return result;
}


static gboolean valadoc_sequence_rule_real_would_reduce (ValadocRule* base, ValadocToken* token, GObject* rule_state) {
	ValadocSequenceRule * self;
	gboolean result = FALSE;
	ValadocSequenceRuleState* state = NULL;
	GObject* _tmp0_;
	ValadocSequenceRuleState* _tmp1_;
	gboolean _tmp2_ = FALSE;
	ValadocSequenceRuleState* _tmp3_;
	gint _tmp4_;
	GObject** _tmp5_;
	gint _tmp5__length1;
	self = (ValadocSequenceRule*) base;
	g_return_val_if_fail (token != NULL, FALSE);
	_tmp0_ = rule_state;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, VALADOC_SEQUENCE_RULE_TYPE_STATE) ? ((ValadocSequenceRuleState*) _tmp0_) : NULL);
	state = _tmp1_;
	_tmp3_ = state;
	_tmp4_ = _tmp3_->index;
	_tmp5_ = self->priv->_scheme;
	_tmp5__length1 = self->priv->_scheme_length1;
	if (_tmp4_ == _tmp5__length1) {
		_tmp2_ = TRUE;
	} else {
		ValadocSequenceRuleState* _tmp6_;
		gint _tmp7_;
		ValadocToken* _tmp8_;
		gboolean _tmp9_;
		_tmp6_ = state;
		_tmp7_ = _tmp6_->index;
		_tmp8_ = token;
		_tmp9_ = valadoc_sequence_rule_test_reduce (self, _tmp7_, _tmp8_);
		_tmp2_ = _tmp9_;
	}
	result = _tmp2_;
	_g_object_unref0 (state);
	return result;
}


static gchar* valadoc_sequence_rule_real_to_string (ValadocRule* base, GObject* rule_state) {
	ValadocSequenceRule * self;
	gchar* result = NULL;
	ValadocSequenceRuleState* state = NULL;
	GObject* _tmp0_;
	ValadocSequenceRuleState* _tmp1_;
	ValadocSequenceRuleState* _tmp2_;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	ValadocSequenceRuleState* _tmp9_;
	gint _tmp10_;
	GObject** _tmp11_;
	gint _tmp11__length1;
	gchar* _tmp12_;
	self = (ValadocSequenceRule*) base;
	_tmp0_ = rule_state;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, VALADOC_SEQUENCE_RULE_TYPE_STATE) ? ((ValadocSequenceRuleState*) _tmp0_) : NULL);
	state = _tmp1_;
	_tmp2_ = state;
	if (_tmp2_ == NULL) {
		ValadocSequenceRuleState* _tmp3_;
		_tmp3_ = valadoc_sequence_rule_state_new ();
		_g_object_unref0 (state);
		state = _tmp3_;
	}
	_tmp5_ = valadoc_rule_get_name ((ValadocRule*) self);
	_tmp6_ = _tmp5_;
	if (_tmp6_ != NULL) {
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp7_ = valadoc_rule_get_name ((ValadocRule*) self);
		_tmp8_ = _tmp7_;
		_tmp4_ = _tmp8_;
	} else {
		_tmp4_ = " ";
	}
	_tmp9_ = state;
	_tmp10_ = _tmp9_->index;
	_tmp11_ = self->priv->_scheme;
	_tmp11__length1 = self->priv->_scheme_length1;
	_tmp12_ = g_strdup_printf ("%-15s%-15s(index=%d/%d)", _tmp4_, "[seq]", _tmp10_, _tmp11__length1);
	result = _tmp12_;
	_g_object_unref0 (state);
	return result;
}


static ValadocSequenceRuleState* valadoc_sequence_rule_state_construct (GType object_type) {
	ValadocSequenceRuleState * self = NULL;
	self = (ValadocSequenceRuleState*) g_object_new (object_type, NULL);
	return self;
}


static ValadocSequenceRuleState* valadoc_sequence_rule_state_new (void) {
	return valadoc_sequence_rule_state_construct (VALADOC_SEQUENCE_RULE_TYPE_STATE);
}


static void valadoc_sequence_rule_state_class_init (ValadocSequenceRuleStateClass * klass) {
	valadoc_sequence_rule_state_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = valadoc_sequence_rule_state_finalize;
}


static void valadoc_sequence_rule_state_instance_init (ValadocSequenceRuleState * self) {
	self->index = 0;
}


static void valadoc_sequence_rule_state_finalize (GObject * obj) {
	ValadocSequenceRuleState * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_SEQUENCE_RULE_TYPE_STATE, ValadocSequenceRuleState);
	G_OBJECT_CLASS (valadoc_sequence_rule_state_parent_class)->finalize (obj);
}


static GType valadoc_sequence_rule_state_get_type (void) {
	static volatile gsize valadoc_sequence_rule_state_type_id__volatile = 0;
	if (g_once_init_enter (&valadoc_sequence_rule_state_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValadocSequenceRuleStateClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_sequence_rule_state_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocSequenceRuleState), 0, (GInstanceInitFunc) valadoc_sequence_rule_state_instance_init, NULL };
		GType valadoc_sequence_rule_state_type_id;
		valadoc_sequence_rule_state_type_id = g_type_register_static (G_TYPE_OBJECT, "ValadocSequenceRuleState", &g_define_type_info, 0);
		g_once_init_leave (&valadoc_sequence_rule_state_type_id__volatile, valadoc_sequence_rule_state_type_id);
	}
	return valadoc_sequence_rule_state_type_id__volatile;
}


static void valadoc_sequence_rule_class_init (ValadocSequenceRuleClass * klass) {
	valadoc_sequence_rule_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ValadocSequenceRulePrivate));
	((ValadocRuleClass *) klass)->is_optional = (gboolean (*) (ValadocRule *)) valadoc_sequence_rule_real_is_optional;
	((ValadocRuleClass *) klass)->starts_with_token = (gboolean (*) (ValadocRule *, ValadocToken*)) valadoc_sequence_rule_real_starts_with_token;
	((ValadocRuleClass *) klass)->accept_token = (gboolean (*) (ValadocRule *, ValadocToken*, ValadocParserCallback*, ValadocRuleForward, GError**)) valadoc_sequence_rule_real_accept_token;
	((ValadocRuleClass *) klass)->would_accept_token = (gboolean (*) (ValadocRule *, ValadocToken*, GObject*)) valadoc_sequence_rule_real_would_accept_token;
	((ValadocRuleClass *) klass)->would_reduce = (gboolean (*) (ValadocRule *, ValadocToken*, GObject*)) valadoc_sequence_rule_real_would_reduce;
	((ValadocRuleClass *) klass)->to_string = (gchar* (*) (ValadocRule *, GObject*)) valadoc_sequence_rule_real_to_string;
	G_OBJECT_CLASS (klass)->finalize = valadoc_sequence_rule_finalize;
}


static void valadoc_sequence_rule_instance_init (ValadocSequenceRule * self) {
	self->priv = VALADOC_SEQUENCE_RULE_GET_PRIVATE (self);
}


static void valadoc_sequence_rule_finalize (GObject * obj) {
	ValadocSequenceRule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_TYPE_SEQUENCE_RULE, ValadocSequenceRule);
	self->priv->_scheme = (_vala_array_free (self->priv->_scheme, self->priv->_scheme_length1, (GDestroyNotify) g_object_unref), NULL);
	G_OBJECT_CLASS (valadoc_sequence_rule_parent_class)->finalize (obj);
}


G_GNUC_INTERNAL GType valadoc_sequence_rule_get_type (void) {
	static volatile gsize valadoc_sequence_rule_type_id__volatile = 0;
	if (g_once_init_enter (&valadoc_sequence_rule_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValadocSequenceRuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_sequence_rule_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocSequenceRule), 0, (GInstanceInitFunc) valadoc_sequence_rule_instance_init, NULL };
		GType valadoc_sequence_rule_type_id;
		valadoc_sequence_rule_type_id = g_type_register_static (VALADOC_TYPE_RULE, "ValadocSequenceRule", &g_define_type_info, 0);
		g_once_init_leave (&valadoc_sequence_rule_type_id__volatile, valadoc_sequence_rule_type_id);
	}
	return valadoc_sequence_rule_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



