####################################################################
#
#    This file was generated using Parse::Yapp version 1.05.
#
#        Don't edit this file, use source file instead.
#
#             ANY CHANGE MADE HERE WILL BE LOST !
#
####################################################################
package OpenResty::RestyScript::View;
use vars qw ( @ISA );
use strict;

@ISA= qw ( Parse::Yapp::Driver );
use Parse::Yapp::Driver;

#line 5 "grammar/restyscript-view.yp"


my (
    @Models, @Columns, @OutVars,
    $InVals, %Defaults, $Quote, $QuoteIdent,
    @Unbound,
);



sub new {
        my($class)=shift;
        ref($class)
    and $class=ref($class);

    my($self)=$class->SUPER::new( yyversion => '1.05',
                                  yystates =>
[
	{#State 0
		ACTIONS => {
			"(" => 2,
			"select" => 4
		},
		GOTOS => {
			'select_stmt' => 1,
			'statement' => 3,
			'miniSQL' => 6,
			'compound_select_stmt' => 5
		}
	},
	{#State 1
		DEFAULT => -6
	},
	{#State 2
		ACTIONS => {
			"select" => 4
		},
		GOTOS => {
			'select_stmt' => 7
		}
	},
	{#State 3
		DEFAULT => -1
	},
	{#State 4
		ACTIONS => {
			'NUM' => 13,
			"(" => 23,
			"*" => 15,
			'VAR' => 25,
			"distinct" => 20,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'pattern' => 24,
			'expr' => 14,
			'atom' => 16,
			'pattern_list' => 26,
			'column' => 17
		}
	},
	{#State 5
		ACTIONS => {
			";" => 27
		},
		DEFAULT => -3
	},
	{#State 6
		ACTIONS => {
			'' => 28
		}
	},
	{#State 7
		ACTIONS => {
			")" => 29
		}
	},
	{#State 8
		DEFAULT => -106
	},
	{#State 9
		DEFAULT => -105
	},
	{#State 10
		ACTIONS => {
			"(" => 30
		},
		DEFAULT => -70
	},
	{#State 11
		DEFAULT => -67
	},
	{#State 12
		DEFAULT => -65
	},
	{#State 13
		DEFAULT => -62
	},
	{#State 14
		ACTIONS => {
			"-" => 31,
			"::" => 32,
			"+" => 33,
			"%" => 34,
			"^" => 35,
			"*" => 36,
			"||" => 37,
			"/" => 38,
			"as" => 39
		},
		DEFAULT => -20
	},
	{#State 15
		DEFAULT => -21
	},
	{#State 16
		DEFAULT => -31
	},
	{#State 17
		DEFAULT => -34
	},
	{#State 18
		ACTIONS => {
			"." => 40
		},
		DEFAULT => -68
	},
	{#State 19
		DEFAULT => -35
	},
	{#State 20
		ACTIONS => {
			'NUM' => 13,
			"(" => 23,
			"*" => 15,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'pattern' => 24,
			'expr' => 14,
			'atom' => 16,
			'pattern_list' => 41,
			'column' => 17
		}
	},
	{#State 21
		DEFAULT => -33
	},
	{#State 22
		DEFAULT => -36
	},
	{#State 23
		ACTIONS => {
			'NUM' => 13,
			"(" => 23,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'expr' => 42,
			'atom' => 16,
			'column' => 17
		}
	},
	{#State 24
		ACTIONS => {
			"," => 43
		},
		DEFAULT => -18
	},
	{#State 25
		ACTIONS => {
			"|" => 44
		},
		DEFAULT => -72
	},
	{#State 26
		ACTIONS => {
			"where" => 56,
			"order by" => 48,
			"limit" => 47,
			"group by" => 51,
			"from" => 58,
			"offset" => 53
		},
		DEFAULT => -13,
		GOTOS => {
			'postfix_clause_list' => 57,
			'order_by_clause' => 46,
			'offset_clause' => 45,
			'where_clause' => 49,
			'group_by_clause' => 50,
			'from_clause' => 52,
			'limit_clause' => 54,
			'postfix_clause' => 55
		}
	},
	{#State 27
		DEFAULT => -2
	},
	{#State 28
		DEFAULT => 0
	},
	{#State 29
		ACTIONS => {
			"intersect" => 61,
			"union" => 59,
			"except" => 62,
			"union all" => 63
		},
		DEFAULT => -5,
		GOTOS => {
			'set_operator' => 60
		}
	},
	{#State 30
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			"*" => 68,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 64,
			'symbol' => 18,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'parameter' => 74,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69,
			'parameter_list' => 70
		}
	},
	{#State 31
		ACTIONS => {
			'NUM' => 13,
			"(" => 23,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'expr' => 78,
			'atom' => 16,
			'column' => 17
		}
	},
	{#State 32
		ACTIONS => {
			'VAR' => 81,
			'IDENT' => 79
		},
		GOTOS => {
			'symbol' => 80,
			'type' => 82
		}
	},
	{#State 33
		ACTIONS => {
			'NUM' => 13,
			"(" => 23,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'expr' => 83,
			'atom' => 16,
			'column' => 17
		}
	},
	{#State 34
		ACTIONS => {
			'NUM' => 13,
			"(" => 23,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'expr' => 84,
			'atom' => 16,
			'column' => 17
		}
	},
	{#State 35
		ACTIONS => {
			'NUM' => 13,
			"(" => 23,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'expr' => 85,
			'atom' => 16,
			'column' => 17
		}
	},
	{#State 36
		ACTIONS => {
			'NUM' => 13,
			"(" => 23,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'expr' => 86,
			'atom' => 16,
			'column' => 17
		}
	},
	{#State 37
		ACTIONS => {
			'NUM' => 13,
			"(" => 23,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'expr' => 87,
			'atom' => 16,
			'column' => 17
		}
	},
	{#State 38
		ACTIONS => {
			'NUM' => 13,
			"(" => 23,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'expr' => 88,
			'atom' => 16,
			'column' => 17
		}
	},
	{#State 39
		ACTIONS => {
			'VAR' => 81,
			'IDENT' => 79
		},
		GOTOS => {
			'symbol' => 89,
			'alias' => 90
		}
	},
	{#State 40
		ACTIONS => {
			'VAR' => 81,
			'IDENT' => 79
		},
		GOTOS => {
			'symbol' => 91
		}
	},
	{#State 41
		ACTIONS => {
			"where" => 56,
			"group by" => 51,
			"from" => 58,
			"order by" => 48,
			"limit" => 47,
			"offset" => 53
		},
		GOTOS => {
			'postfix_clause_list' => 92,
			'order_by_clause' => 46,
			'offset_clause' => 45,
			'where_clause' => 49,
			'group_by_clause' => 50,
			'from_clause' => 52,
			'limit_clause' => 54,
			'postfix_clause' => 55
		}
	},
	{#State 42
		ACTIONS => {
			"-" => 31,
			"::" => 32,
			"||" => 37,
			"+" => 33,
			"/" => 38,
			"%" => 34,
			"^" => 35,
			"*" => 36,
			")" => 93
		}
	},
	{#State 43
		ACTIONS => {
			'NUM' => 13,
			"(" => 23,
			"*" => 15,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'pattern' => 24,
			'expr' => 14,
			'atom' => 16,
			'pattern_list' => 94,
			'column' => 17
		}
	},
	{#State 44
		ACTIONS => {
			'NUM' => 97,
			'IDENT' => 95,
			'STRING' => 96
		}
	},
	{#State 45
		DEFAULT => -80
	},
	{#State 46
		DEFAULT => -78
	},
	{#State 47
		ACTIONS => {
			'NUM' => 98,
			'VAR' => 100,
			'STRING' => 12
		},
		GOTOS => {
			'literal' => 99,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'string' => 9
		}
	},
	{#State 48
		ACTIONS => {
			'VAR' => 81,
			'IDENT' => 79
		},
		GOTOS => {
			'symbol' => 18,
			'order_by_objects' => 102,
			'column' => 103,
			'qualified_symbol' => 11,
			'order_by_object' => 101
		}
	},
	{#State 49
		DEFAULT => -76
	},
	{#State 50
		DEFAULT => -77
	},
	{#State 51
		ACTIONS => {
			'VAR' => 81,
			'IDENT' => 79
		},
		GOTOS => {
			'symbol' => 18,
			'column_list' => 104,
			'column' => 105,
			'qualified_symbol' => 11
		}
	},
	{#State 52
		DEFAULT => -81
	},
	{#State 53
		ACTIONS => {
			'NUM' => 98,
			'VAR' => 100,
			'STRING' => 12
		},
		GOTOS => {
			'literal' => 106,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'string' => 9
		}
	},
	{#State 54
		DEFAULT => -79
	},
	{#State 55
		ACTIONS => {
			"where" => 56,
			"order by" => 48,
			"limit" => 47,
			"group by" => 51,
			"from" => 58,
			"offset" => 53
		},
		DEFAULT => -75,
		GOTOS => {
			'postfix_clause_list' => 107,
			'order_by_clause' => 46,
			'offset_clause' => 45,
			'where_clause' => 49,
			'group_by_clause' => 50,
			'from_clause' => 52,
			'limit_clause' => 54,
			'postfix_clause' => 55
		}
	},
	{#State 56
		ACTIONS => {
			'NUM' => 13,
			"(" => 113,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'comparison' => 108,
			'true_literal' => 19,
			'symbol' => 18,
			'conjunction' => 110,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'disjunction' => 111,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'lhs_atom' => 112,
			'expr' => 109,
			'atom' => 16,
			'condition' => 114,
			'column' => 17
		}
	},
	{#State 57
		DEFAULT => -12
	},
	{#State 58
		ACTIONS => {
			'VAR' => 81,
			'IDENT' => 10
		},
		GOTOS => {
			'models' => 116,
			'symbol' => 117,
			'model' => 115,
			'proc_call' => 118
		}
	},
	{#State 59
		DEFAULT => -8
	},
	{#State 60
		ACTIONS => {
			"(" => 2,
			"select" => 4
		},
		GOTOS => {
			'select_stmt' => 1,
			'compound_select_stmt' => 119
		}
	},
	{#State 61
		DEFAULT => -9
	},
	{#State 62
		DEFAULT => -10
	},
	{#State 63
		DEFAULT => -7
	},
	{#State 64
		ACTIONS => {
			"-" => 120,
			"::" => 121,
			"||" => 126,
			"+" => 122,
			"/" => 127,
			"%" => 123,
			"^" => 124,
			"*" => 125
		},
		DEFAULT => -41
	},
	{#State 65
		DEFAULT => -108
	},
	{#State 66
		ACTIONS => {
			"(" => 128
		},
		DEFAULT => -70
	},
	{#State 67
		DEFAULT => -54
	},
	{#State 68
		ACTIONS => {
			")" => 129
		}
	},
	{#State 69
		DEFAULT => -53
	},
	{#State 70
		ACTIONS => {
			")" => 130
		}
	},
	{#State 71
		DEFAULT => -107
	},
	{#State 72
		DEFAULT => -51
	},
	{#State 73
		DEFAULT => -55
	},
	{#State 74
		ACTIONS => {
			"," => 131
		},
		DEFAULT => -40
	},
	{#State 75
		DEFAULT => -52
	},
	{#State 76
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 132,
			'symbol' => 18,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69
		}
	},
	{#State 77
		ACTIONS => {
			"\@\@" => -72,
			"<" => -72,
			"like" => -72,
			">=" => -72,
			"<>" => -72,
			"!=" => -72,
			"=" => -72,
			"|" => 44,
			"<=" => -72,
			"." => -72,
			">" => -72
		},
		DEFAULT => -61
	},
	{#State 78
		ACTIONS => {
			"::" => 32,
			"%" => 34,
			"^" => 35,
			"*" => 36,
			"||" => 37,
			"/" => 38
		},
		DEFAULT => -27
	},
	{#State 79
		DEFAULT => -70
	},
	{#State 80
		DEFAULT => -32
	},
	{#State 81
		ACTIONS => {
			"|" => 133
		},
		DEFAULT => -72
	},
	{#State 82
		DEFAULT => -29
	},
	{#State 83
		ACTIONS => {
			"::" => 32,
			"%" => 34,
			"^" => 35,
			"*" => 36,
			"||" => 37,
			"/" => 38
		},
		DEFAULT => -26
	},
	{#State 84
		ACTIONS => {
			"::" => 32,
			"^" => 35,
			"||" => 37
		},
		DEFAULT => -25
	},
	{#State 85
		ACTIONS => {
			"::" => 32,
			"^" => 35,
			"||" => 37
		},
		DEFAULT => -28
	},
	{#State 86
		ACTIONS => {
			"::" => 32,
			"^" => 35,
			"||" => 37
		},
		DEFAULT => -23
	},
	{#State 87
		ACTIONS => {
			"::" => 32
		},
		DEFAULT => -22
	},
	{#State 88
		ACTIONS => {
			"::" => 32,
			"^" => 35,
			"||" => 37
		},
		DEFAULT => -24
	},
	{#State 89
		DEFAULT => -73
	},
	{#State 90
		DEFAULT => -19
	},
	{#State 91
		DEFAULT => -69
	},
	{#State 92
		DEFAULT => -11
	},
	{#State 93
		DEFAULT => -30
	},
	{#State 94
		DEFAULT => -17
	},
	{#State 95
		DEFAULT => -71
	},
	{#State 96
		DEFAULT => -66
	},
	{#State 97
		DEFAULT => -64
	},
	{#State 98
		DEFAULT => -63
	},
	{#State 99
		DEFAULT => -119
	},
	{#State 100
		ACTIONS => {
			"|" => 134
		},
		DEFAULT => -61
	},
	{#State 101
		ACTIONS => {
			"," => 135
		},
		DEFAULT => -114
	},
	{#State 102
		DEFAULT => -112
	},
	{#State 103
		ACTIONS => {
			"desc" => 136,
			"asc" => 137
		},
		DEFAULT => -116,
		GOTOS => {
			'order_by_modifier' => 138
		}
	},
	{#State 104
		DEFAULT => -109
	},
	{#State 105
		ACTIONS => {
			"," => 139
		},
		DEFAULT => -111
	},
	{#State 106
		DEFAULT => -120
	},
	{#State 107
		DEFAULT => -74
	},
	{#State 108
		DEFAULT => -89
	},
	{#State 109
		ACTIONS => {
			"-" => 31,
			"::" => 32,
			"+" => 33,
			"%" => 34,
			"^" => 35,
			"*" => 36,
			"||" => 37,
			"/" => 38
		},
		DEFAULT => -92
	},
	{#State 110
		ACTIONS => {
			"and" => 140
		},
		DEFAULT => -87
	},
	{#State 111
		ACTIONS => {
			"or" => 141
		},
		DEFAULT => -85
	},
	{#State 112
		ACTIONS => {
			"!=" => 148,
			"<" => 143,
			"\@\@" => 142,
			"like" => 144,
			"=" => 149,
			">=" => 145,
			"<=" => 150,
			"<>" => 147,
			">" => 151
		},
		GOTOS => {
			'operator' => 146
		}
	},
	{#State 113
		ACTIONS => {
			'NUM' => 13,
			"(" => 113,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'comparison' => 108,
			'true_literal' => 19,
			'symbol' => 18,
			'conjunction' => 110,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'disjunction' => 111,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'lhs_atom' => 112,
			'expr' => 152,
			'atom' => 16,
			'condition' => 153,
			'column' => 17
		}
	},
	{#State 114
		DEFAULT => -84
	},
	{#State 115
		ACTIONS => {
			"," => 154
		},
		DEFAULT => -15
	},
	{#State 116
		DEFAULT => -82
	},
	{#State 117
		DEFAULT => -16
	},
	{#State 118
		DEFAULT => -83
	},
	{#State 119
		DEFAULT => -4
	},
	{#State 120
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 155,
			'symbol' => 18,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69
		}
	},
	{#State 121
		ACTIONS => {
			'VAR' => 81,
			'IDENT' => 79
		},
		GOTOS => {
			'symbol' => 80,
			'type' => 156
		}
	},
	{#State 122
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 157,
			'symbol' => 18,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69
		}
	},
	{#State 123
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 158,
			'symbol' => 18,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69
		}
	},
	{#State 124
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 159,
			'symbol' => 18,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69
		}
	},
	{#State 125
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 160,
			'symbol' => 18,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69
		}
	},
	{#State 126
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 161,
			'symbol' => 18,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69
		}
	},
	{#State 127
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 162,
			'symbol' => 18,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69
		}
	},
	{#State 128
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			"*" => 165,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 163,
			'symbol' => 18,
			'true_literal' => 71,
			'parameter2' => 164,
			'number' => 8,
			'variable' => 65,
			'parameter_list2' => 166,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69
		}
	},
	{#State 129
		DEFAULT => -38
	},
	{#State 130
		DEFAULT => -37
	},
	{#State 131
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 64,
			'symbol' => 18,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'parameter' => 74,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69,
			'parameter_list' => 167
		}
	},
	{#State 132
		ACTIONS => {
			"-" => 120,
			"::" => 121,
			"||" => 126,
			"+" => 122,
			"/" => 127,
			"%" => 123,
			"^" => 124,
			"*" => 125,
			")" => 168
		}
	},
	{#State 133
		ACTIONS => {
			'IDENT' => 95
		}
	},
	{#State 134
		ACTIONS => {
			'NUM' => 97,
			'STRING' => 96
		}
	},
	{#State 135
		ACTIONS => {
			'VAR' => 81,
			'IDENT' => 79
		},
		GOTOS => {
			'symbol' => 18,
			'order_by_objects' => 169,
			'column' => 103,
			'qualified_symbol' => 11,
			'order_by_object' => 101
		}
	},
	{#State 136
		DEFAULT => -118
	},
	{#State 137
		DEFAULT => -117
	},
	{#State 138
		DEFAULT => -115
	},
	{#State 139
		ACTIONS => {
			'VAR' => 81,
			'IDENT' => 79
		},
		GOTOS => {
			'symbol' => 18,
			'column_list' => 170,
			'column' => 105,
			'qualified_symbol' => 11
		}
	},
	{#State 140
		ACTIONS => {
			'NUM' => 13,
			"(" => 113,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'comparison' => 108,
			'conjunction' => 171,
			'true_literal' => 19,
			'symbol' => 18,
			'number' => 8,
			'string' => 9,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'lhs_atom' => 112,
			'expr' => 109,
			'atom' => 16,
			'column' => 17
		}
	},
	{#State 141
		ACTIONS => {
			'NUM' => 13,
			"(" => 113,
			'VAR' => 25,
			'IDENT' => 10,
			'STRING' => 12
		},
		GOTOS => {
			'comparison' => 108,
			'true_literal' => 19,
			'symbol' => 18,
			'conjunction' => 110,
			'number' => 8,
			'string' => 9,
			'disjunction' => 172,
			'proc_call' => 21,
			'qualified_symbol' => 11,
			'true_number' => 22,
			'lhs_atom' => 112,
			'expr' => 109,
			'atom' => 16,
			'column' => 17
		}
	},
	{#State 142
		DEFAULT => -104
	},
	{#State 143
		DEFAULT => -99
	},
	{#State 144
		DEFAULT => -103
	},
	{#State 145
		DEFAULT => -97
	},
	{#State 146
		ACTIONS => {
			'NUM' => 13,
			"(" => 175,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 173,
			'symbol' => 18,
			'true_literal' => 71,
			'number' => 8,
			'variable' => 65,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'rhs_atom' => 174,
			'column' => 69
		}
	},
	{#State 147
		DEFAULT => -100
	},
	{#State 148
		DEFAULT => -101
	},
	{#State 149
		DEFAULT => -102
	},
	{#State 150
		DEFAULT => -98
	},
	{#State 151
		DEFAULT => -96
	},
	{#State 152
		ACTIONS => {
			"-" => 31,
			"::" => 32,
			"+" => 33,
			"%" => 34,
			"^" => 35,
			"*" => 36,
			")" => 93,
			"||" => 37,
			"/" => 38
		},
		DEFAULT => -92
	},
	{#State 153
		ACTIONS => {
			")" => 176
		}
	},
	{#State 154
		ACTIONS => {
			'VAR' => 81,
			'IDENT' => 79
		},
		GOTOS => {
			'models' => 177,
			'symbol' => 117,
			'model' => 115
		}
	},
	{#State 155
		ACTIONS => {
			"::" => 121,
			"%" => 123,
			"^" => 124,
			"*" => 125,
			"||" => 126,
			"/" => 127
		},
		DEFAULT => -47
	},
	{#State 156
		DEFAULT => -49
	},
	{#State 157
		ACTIONS => {
			"::" => 121,
			"%" => 123,
			"^" => 124,
			"*" => 125,
			"||" => 126,
			"/" => 127
		},
		DEFAULT => -46
	},
	{#State 158
		ACTIONS => {
			"::" => 121,
			"^" => 124,
			"||" => 126
		},
		DEFAULT => -45
	},
	{#State 159
		ACTIONS => {
			"::" => 121,
			"^" => 124,
			"||" => 126
		},
		DEFAULT => -48
	},
	{#State 160
		ACTIONS => {
			"::" => 121,
			"^" => 124,
			"||" => 126
		},
		DEFAULT => -43
	},
	{#State 161
		ACTIONS => {
			"::" => 121
		},
		DEFAULT => -42
	},
	{#State 162
		ACTIONS => {
			"::" => 121,
			"^" => 124,
			"||" => 126
		},
		DEFAULT => -44
	},
	{#State 163
		ACTIONS => {
			"-" => 120,
			"::" => 121,
			"||" => 126,
			"+" => 122,
			"/" => 127,
			"%" => 123,
			"^" => 124,
			"*" => 125
		},
		DEFAULT => -60
	},
	{#State 164
		ACTIONS => {
			"," => 178
		},
		DEFAULT => -59
	},
	{#State 165
		ACTIONS => {
			")" => 179
		}
	},
	{#State 166
		ACTIONS => {
			")" => 180
		}
	},
	{#State 167
		DEFAULT => -39
	},
	{#State 168
		DEFAULT => -50
	},
	{#State 169
		DEFAULT => -113
	},
	{#State 170
		DEFAULT => -110
	},
	{#State 171
		DEFAULT => -88
	},
	{#State 172
		DEFAULT => -86
	},
	{#State 173
		ACTIONS => {
			"-" => 120,
			"::" => 121,
			"+" => 122,
			"%" => 123,
			"^" => 124,
			"*" => 125,
			"||" => 126,
			"/" => 127
		},
		DEFAULT => -94
	},
	{#State 174
		DEFAULT => -90
	},
	{#State 175
		ACTIONS => {
			'NUM' => 13,
			"(" => 185,
			'VAR' => 77,
			'IDENT' => 181,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 132,
			'comparison' => 108,
			'number' => 8,
			'variable' => 65,
			'string' => 9,
			'qualified_symbol' => 11,
			'literal' => 67,
			'expr' => 109,
			'atom' => 16,
			'column' => 182,
			'conjunction' => 110,
			'symbol' => 18,
			'true_literal' => 183,
			'atom2' => 72,
			'disjunction' => 111,
			'proc_call' => 21,
			'true_number' => 184,
			'proc_call2' => 75,
			'lhs_atom' => 112,
			'condition' => 186
		}
	},
	{#State 176
		ACTIONS => {
			"\@\@" => -93,
			"<" => -93,
			"like" => -93,
			">=" => -93,
			"<>" => -93,
			"!=" => -93,
			"=" => -93,
			"<=" => -93,
			">" => -93
		},
		DEFAULT => -91
	},
	{#State 177
		DEFAULT => -14
	},
	{#State 178
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 163,
			'symbol' => 18,
			'true_literal' => 71,
			'parameter2' => 164,
			'number' => 8,
			'variable' => 65,
			'parameter_list2' => 187,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'column' => 69
		}
	},
	{#State 179
		DEFAULT => -57
	},
	{#State 180
		DEFAULT => -56
	},
	{#State 181
		ACTIONS => {
			"(" => 188
		},
		DEFAULT => -70
	},
	{#State 182
		DEFAULT => -34
	},
	{#State 183
		DEFAULT => -35
	},
	{#State 184
		DEFAULT => -36
	},
	{#State 185
		ACTIONS => {
			'NUM' => 13,
			"(" => 185,
			'VAR' => 77,
			'IDENT' => 181,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 132,
			'comparison' => 108,
			'number' => 8,
			'variable' => 65,
			'string' => 9,
			'qualified_symbol' => 11,
			'literal' => 67,
			'expr' => 152,
			'atom' => 16,
			'column' => 182,
			'conjunction' => 110,
			'symbol' => 18,
			'true_literal' => 183,
			'atom2' => 72,
			'disjunction' => 111,
			'proc_call' => 21,
			'true_number' => 184,
			'proc_call2' => 75,
			'lhs_atom' => 112,
			'condition' => 153
		}
	},
	{#State 186
		ACTIONS => {
			")" => 189
		}
	},
	{#State 187
		DEFAULT => -58
	},
	{#State 188
		ACTIONS => {
			'NUM' => 13,
			"(" => 76,
			"*" => 191,
			'VAR' => 77,
			'IDENT' => 66,
			'STRING' => 12
		},
		GOTOS => {
			'expr2' => 190,
			'symbol' => 18,
			'true_literal' => 71,
			'parameter2' => 164,
			'number' => 8,
			'variable' => 65,
			'parameter_list2' => 166,
			'atom2' => 72,
			'string' => 9,
			'qualified_symbol' => 11,
			'parameter' => 74,
			'true_number' => 73,
			'literal' => 67,
			'proc_call2' => 75,
			'parameter_list' => 70,
			'column' => 69
		}
	},
	{#State 189
		DEFAULT => -95
	},
	{#State 190
		ACTIONS => {
			"-" => 120,
			"::" => 121,
			"||" => 126,
			"+" => 122,
			"/" => 127,
			"%" => 123,
			"^" => 124,
			"*" => 125
		},
		DEFAULT => -41
	},
	{#State 191
		ACTIONS => {
			")" => 192
		}
	},
	{#State 192
		DEFAULT => -38
	}
],
                                  yyrules  =>
[
	[#Rule 0
		 '$start', 2, undef
	],
	[#Rule 1
		 'miniSQL', 1, undef
	],
	[#Rule 2
		 'statement', 2, undef
	],
	[#Rule 3
		 'statement', 1, undef
	],
	[#Rule 4
		 'compound_select_stmt', 5,
sub
#line 33 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 5
		 'compound_select_stmt', 3,
sub
#line 35 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 6
		 'compound_select_stmt', 1, undef
	],
	[#Rule 7
		 'set_operator', 1, undef
	],
	[#Rule 8
		 'set_operator', 1, undef
	],
	[#Rule 9
		 'set_operator', 1, undef
	],
	[#Rule 10
		 'set_operator', 1, undef
	],
	[#Rule 11
		 'select_stmt', 4,
sub
#line 43 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 12
		 'select_stmt', 3,
sub
#line 45 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 13
		 'select_stmt', 2,
sub
#line 47 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 14
		 'models', 3,
sub
#line 51 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 15
		 'models', 1, undef
	],
	[#Rule 16
		 'model', 1,
sub
#line 55 "grammar/restyscript-view.yp"
{ push @Models, $_[1]; $QuoteIdent->($_[1]) }
	],
	[#Rule 17
		 'pattern_list', 3,
sub
#line 59 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 18
		 'pattern_list', 1, undef
	],
	[#Rule 19
		 'pattern', 3,
sub
#line 64 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 20
		 'pattern', 1, undef
	],
	[#Rule 21
		 'pattern', 1, undef
	],
	[#Rule 22
		 'expr', 3,
sub
#line 70 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 23
		 'expr', 3,
sub
#line 72 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 24
		 'expr', 3,
sub
#line 74 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 25
		 'expr', 3,
sub
#line 76 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 26
		 'expr', 3,
sub
#line 78 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 27
		 'expr', 3,
sub
#line 80 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 28
		 'expr', 3,
sub
#line 82 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 29
		 'expr', 3,
sub
#line 84 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 30
		 'expr', 3,
sub
#line 86 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 31
		 'expr', 1, undef
	],
	[#Rule 32
		 'type', 1, undef
	],
	[#Rule 33
		 'atom', 1, undef
	],
	[#Rule 34
		 'atom', 1, undef
	],
	[#Rule 35
		 'atom', 1, undef
	],
	[#Rule 36
		 'atom', 1, undef
	],
	[#Rule 37
		 'proc_call', 4,
sub
#line 100 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 38
		 'proc_call', 4,
sub
#line 102 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 39
		 'parameter_list', 3,
sub
#line 106 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 40
		 'parameter_list', 1, undef
	],
	[#Rule 41
		 'parameter', 1, undef
	],
	[#Rule 42
		 'expr2', 3,
sub
#line 114 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 43
		 'expr2', 3,
sub
#line 116 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 44
		 'expr2', 3,
sub
#line 118 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 45
		 'expr2', 3,
sub
#line 120 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 46
		 'expr2', 3,
sub
#line 122 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 47
		 'expr2', 3,
sub
#line 124 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 48
		 'expr2', 3,
sub
#line 126 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 49
		 'expr2', 3,
sub
#line 128 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 50
		 'expr2', 3,
sub
#line 130 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 51
		 'expr2', 1, undef
	],
	[#Rule 52
		 'atom2', 1, undef
	],
	[#Rule 53
		 'atom2', 1, undef
	],
	[#Rule 54
		 'atom2', 1, undef
	],
	[#Rule 55
		 'atom2', 1, undef
	],
	[#Rule 56
		 'proc_call2', 4,
sub
#line 141 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 57
		 'proc_call2', 4,
sub
#line 143 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 58
		 'parameter_list2', 3,
sub
#line 147 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 59
		 'parameter_list2', 1, undef
	],
	[#Rule 60
		 'parameter2', 1, undef
	],
	[#Rule 61
		 'variable', 1,
sub
#line 156 "grammar/restyscript-view.yp"
{
                push @OutVars, $_[1];
                my $val = $InVals->{$_[1]};
                if (!defined $val) {
                    push @Unbound, $_[1];
                    return $Quote->("");
                }
                $Quote->($val);
            }
	],
	[#Rule 62
		 'true_number', 1, undef
	],
	[#Rule 63
		 'number', 1, undef
	],
	[#Rule 64
		 'number', 3,
sub
#line 172 "grammar/restyscript-view.yp"
{
                push @OutVars, $_[1];
                my $val = $InVals->{$_[1]};
                if (!defined $val) {
                    my $default;
                    $Defaults{$_[1]} = $default = $_[3];
                    return $default;
                }
                $Quote->($val);
            }
	],
	[#Rule 65
		 'string', 1,
sub
#line 184 "grammar/restyscript-view.yp"
{ $Quote->(parse_string($_[1])) }
	],
	[#Rule 66
		 'string', 3,
sub
#line 186 "grammar/restyscript-view.yp"
{ push @OutVars, $_[1];
            my $val = $InVals->{$_[1]};
            if (!defined $val) {
                my $default;
                $Defaults{$_[1]} = $default = parse_string($_[3]);
                return $Quote->($default);
            }
            $Quote->($val);
          }
	],
	[#Rule 67
		 'column', 1, undef
	],
	[#Rule 68
		 'column', 1,
sub
#line 198 "grammar/restyscript-view.yp"
{ push @Columns, $_[1]; $QuoteIdent->($_[1]) }
	],
	[#Rule 69
		 'qualified_symbol', 3,
sub
#line 202 "grammar/restyscript-view.yp"
{
                      push @Models, $_[1];
                      push @Columns, $_[3];
                      $QuoteIdent->($_[1]).'.'.$QuoteIdent->($_[3]);
                    }
	],
	[#Rule 70
		 'symbol', 1, undef
	],
	[#Rule 71
		 'symbol', 3,
sub
#line 211 "grammar/restyscript-view.yp"
{ push @OutVars, $_[1];
            my $val = $InVals->{$_[1]};
            if (!defined $val) {
                my $default;
                $Defaults{$_[1]} = $default = $_[3];
                _IDENT($default) or die "Bad symbol: $default\n";
                return $default;
            }
            _IDENT($val) or die "Bad symbol: $val\n";
            $val;
          }
	],
	[#Rule 72
		 'symbol', 1,
sub
#line 223 "grammar/restyscript-view.yp"
{ push @OutVars, $_[1];
            my $val = $InVals->{$_[1]};
            if (!defined $val) {
                push @Unbound, $_[1];
                return '';
            }
            #warn _IDENT($val);
            _IDENT($val) or die "Bad symbol: $val\n";
            $val;
          }
	],
	[#Rule 73
		 'alias', 1, undef
	],
	[#Rule 74
		 'postfix_clause_list', 2,
sub
#line 239 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 75
		 'postfix_clause_list', 1, undef
	],
	[#Rule 76
		 'postfix_clause', 1, undef
	],
	[#Rule 77
		 'postfix_clause', 1, undef
	],
	[#Rule 78
		 'postfix_clause', 1, undef
	],
	[#Rule 79
		 'postfix_clause', 1, undef
	],
	[#Rule 80
		 'postfix_clause', 1, undef
	],
	[#Rule 81
		 'postfix_clause', 1, undef
	],
	[#Rule 82
		 'from_clause', 2,
sub
#line 252 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 83
		 'from_clause', 2,
sub
#line 254 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 84
		 'where_clause', 2,
sub
#line 258 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 85
		 'condition', 1, undef
	],
	[#Rule 86
		 'disjunction', 3,
sub
#line 265 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 87
		 'disjunction', 1, undef
	],
	[#Rule 88
		 'conjunction', 3,
sub
#line 270 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 89
		 'conjunction', 1, undef
	],
	[#Rule 90
		 'comparison', 3,
sub
#line 275 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 91
		 'comparison', 3,
sub
#line 277 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 92
		 'lhs_atom', 1, undef
	],
	[#Rule 93
		 'lhs_atom', 3, undef
	],
	[#Rule 94
		 'rhs_atom', 1, undef
	],
	[#Rule 95
		 'rhs_atom', 3, undef
	],
	[#Rule 96
		 'operator', 1, undef
	],
	[#Rule 97
		 'operator', 1, undef
	],
	[#Rule 98
		 'operator', 1, undef
	],
	[#Rule 99
		 'operator', 1, undef
	],
	[#Rule 100
		 'operator', 1, undef
	],
	[#Rule 101
		 'operator', 1, undef
	],
	[#Rule 102
		 'operator', 1, undef
	],
	[#Rule 103
		 'operator', 1, undef
	],
	[#Rule 104
		 'operator', 1, undef
	],
	[#Rule 105
		 'true_literal', 1, undef
	],
	[#Rule 106
		 'true_literal', 1, undef
	],
	[#Rule 107
		 'literal', 1, undef
	],
	[#Rule 108
		 'literal', 1, undef
	],
	[#Rule 109
		 'group_by_clause', 2,
sub
#line 309 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 110
		 'column_list', 3,
sub
#line 313 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 111
		 'column_list', 1, undef
	],
	[#Rule 112
		 'order_by_clause', 2,
sub
#line 318 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 113
		 'order_by_objects', 3,
sub
#line 322 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 114
		 'order_by_objects', 1, undef
	],
	[#Rule 115
		 'order_by_object', 2,
sub
#line 327 "grammar/restyscript-view.yp"
{ join(' ', @_[1..$#_]) }
	],
	[#Rule 116
		 'order_by_object', 1, undef
	],
	[#Rule 117
		 'order_by_modifier', 1, undef
	],
	[#Rule 118
		 'order_by_modifier', 1, undef
	],
	[#Rule 119
		 'limit_clause', 2,
sub
#line 335 "grammar/restyscript-view.yp"
{ delete $_[0]->YYData->{limit}; join(' ', @_[1..$#_]) }
	],
	[#Rule 120
		 'offset_clause', 2,
sub
#line 339 "grammar/restyscript-view.yp"
{ delete $_[0]->YYData->{offset}; join(' ', @_[1..$#_]) }
	]
],
                                  @_);
    bless($self,$class);
}

#line 342 "grammar/restyscript-view.yp"


#use Smart::Comments '####';

sub _Error {
    my ($value) = $_[0]->YYCurval;

    my $token = 1;
    ## $value
    my @expect = $_[0]->YYExpect;
    #### expect: @expect
    my ($what) = $value ? "input: \"$value\"" : "end of input";

    map { $_ = "'$_'" if $_ ne '' and !/^\w+$/ } @expect;
    my $expected = join " or ", @expect;
    my $yydata = $_[0]->YYData;
    #print substr($yydata->{input}, 0, 50);
    _SyntaxError(1, "Unexpected $what".($expected?" ($expected expected)":''), $.);
}

sub _SyntaxError {
    my ($level, $message, $lineno) = @_;

    $message= "line $lineno: error: $message";
    die $message, ".\n";
}

sub _Lexer {
    my ($parser) = shift;

    my $yydata = $parser->YYData;
    my $source = $yydata->{source};
    #local $" = "\n";
    defined $yydata->{input} && $yydata->{input} =~ s/^\s+//s;

    if (!defined $yydata->{input} || $yydata->{input} eq '') {
        ### HERE!!!
        $yydata->{input} = <$source>;
    }
    if (!defined $yydata->{input}) {
        return ('', undef);
    }

    ## other data: <$source>
    ### data: $yydata->{input}
    ### lineno: $.

    for ($yydata->{input}) {
        s/^\s*('(?:\\.|''|[^'])*')//s
                and return ('STRING', $1);
        s/^\s*[-+]?(\.\d+|\d+\.\d*|\d+)//s
                and return ('NUM', $1);
        s/^\s*"(\w*)"//s
                and return ('IDENT', $1);
        s/^\s*(\$(\w*)\$.*?\$\2\$)//s
                and return ('STRING', $1);
        if (s/^\s*(\*|as|select|distinct|and|or|from|where|delete|update|set|order\s+by|asc|desc|group\s+by|limit|offset|union\s+all|union|intersect|except)\b//is) {
            my $s = $1;
            (my $token = $s) =~ s/\s+/ /gs;
            return (lc($token), lc($s));
        }
        s/^\s*(<=|>=|<>|!=|\|\||::|like\b|\@\@)//s
                and return (lc($1), lc($1));
        s/^\s*([A-Za-z][A-Za-z0-9_]*)\b//s
                and return ('IDENT', $1);
        s/^\$(\w+)//s
                and return ('VAR', $1);
        s/^\s*(\S)//s
                and return ($1, $1);
    }
}

sub parse_string {
    my $s = $_[0];
    if ($s =~ /^'(.*)'$/) {
        $s = $1;
        $s =~ s/''/'/g;
        $s =~ s/\\n/\n/g;
        $s =~ s/\\t/\t/g;
        $s =~ s/\\r/\r/g;
        $s =~ s/\\(.)/$1/g;
        return $s;
    } elsif ($s =~ /^\$(\w*)\$(.*)\$\1\$$/) {
        $s = $2;
        return $s;
    } elsif ($s =~ /^[\d\.]*$/) {
        return $s;
    } else {
        die "Unknown string literal: $s";
    }
}

sub parse {
    my ($self, $sql, $params) = @_;
    open my $source, '<', \$sql;
    my $yydata = $self->YYData;
    $yydata->{source} = $source;
    $yydata->{limit} = $params->{limit};
    $yydata->{offset} = $params->{offset};

    $Quote = $params->{quote} || sub { "''" };
    $QuoteIdent = $params->{quote_ident} || sub { '""' };
    $InVals = $params->{vars} || {};
    #$QuoteIdent = $params->{quote_ident};

    #$self->YYData->{INPUT} = ;
    ### $sql
    @Unbound = ();
    @Models = ();
    @Columns = ();
    @OutVars = ();
    %Defaults = ();
    $sql = $self->YYParse( yydebug => 0 & 0x1F, yylex => \&_Lexer, yyerror => \&_Error );
    close $source;
    return {
        limit   => $yydata->{limit},
        offset  => $yydata->{offset},
        models  => [@Models],
        columns => [@Columns],
        sql => $sql,
        vars => [@OutVars],
        defaults => {%Defaults},
        unbound => [@Unbound],
    };
}

sub _IDENT {
    (defined $_[0] && $_[0] =~ /^[A-Za-z]\w*$/) ? $_[0] : undef;
}

#my ($select) =new Select;
#my $var = $select->Run;

1;


1;
