package provide DS9 1.0

######
# Begin autogenerated taccle (version 1.3) routines.
# Although taccle itself is protected by the GNU Public License (GPL)
# all user-supplied functions are protected by their respective
# author's license.  See http://mini.net/tcl/taccle for other details.
######

namespace eval prefsfirst {
    variable yylval {}
    variable table
    variable rules
    variable token {}
    variable yycnt 0
    variable yyerr 0
    variable save_state 0

    namespace export yylex
}

proc prefsfirst::YYABORT {} {
    return -code return 1
}

proc prefsfirst::YYACCEPT {} {
    return -code return 0
}

proc prefsfirst::YYERROR {} {
    variable yyerr
    set yyerr 1
}

proc prefsfirst::yyclearin {} {
    variable token
    variable yycnt
    set token {}
    incr yycnt -1
}

proc prefsfirst::yyerror {s} {
    puts stderr $s
}

proc prefsfirst::setupvalues {stack pointer numsyms} {
    upvar 1 1 y
    set y {}
    for {set i 1} {$i <= $numsyms} {incr i} {
        upvar 1 $i y
        set y [lindex $stack $pointer]
        incr pointer
    }
}

proc prefsfirst::unsetupvalues {numsyms} {
    for {set i 1} {$i <= $numsyms} {incr i} {
        upvar 1 $i y
        unset y
    }
}

array set prefsfirst::table {
  7:264,target 22
  9:283 goto
  27:0 reduce
  17:264 shift
  28:264,target 27
  0:275,target 16
  6:0,target 7
  2:0 reduce
  6:264 reduce
  26:264 reduce
  7:262,target 6
  24:0 reduce
  17:264,target 33
  33:0,target 23
  28:283,target 37
  25:0,target 16
  35:264 shift
  0:273,target 14
  8:264,target 22
  7:259,target 3
  7:260,target 4
  21:0 reduce
  23:282,target 36
  23:261,target 5
  14:264 reduce
  30:264,target 21
  29:264,target 19
  7:278,target 24
  23:257 shift
  23:258 shift
  23:260 shift
  0:271,target 12
  8:262,target 6
  23:259 shift
  23:261 shift
  23:262 shift
  3:264 reduce
  7:257,target 1
  23:264 shift
  3:0,target 3
  23:258,target 2
  32:263 shift
  9:264,target 27
  0:268,target 9
  8:259,target 3
  8:260,target 4
  37:0,target 20
  14:0 reduce
  30:0,target 21
  29:0,target 19
  23:278 goto
  22:0,target 27
  41:263 shift
  14:0,target 12
  9:283,target 29
  23:282 goto
  31:264,target 25
  8:278,target 24
  0:257 shift
  11:264 reduce
  0:258 shift
  0:260 shift
  0:259 shift
  13:261,target 5
  0:261 shift
  0:266,target 8
  8:257,target 1
  19:264,target 11
  0:262 shift
  11:0 reduce
  0:264 reduce
  0:265 shift
  0:266 shift
  8:257 shift
  19:264 reduce
  8:258 shift
  0:268 shift
  8:259 shift
  8:260 shift
  0:269 shift
  0:270 shift
  8:261 shift
  0:271 shift
  8:262 shift
  0:272 shift
  0:273 shift
  8:264 shift
  0:274 shift
  43:264,target 22
  28:264 shift
  0:275 shift
  6:0 reduce
  13:258,target 2
  0:264,target 1
  0:276 shift
  0:277 shift
  0:278 goto
  0:279 goto
  7:0,target 1
  0:0,target 1
  0:281 goto
  37:264 reduce
  8:278 goto
  34:0,target 24
  21:264,target 9
  26:0,target 18
  3:0 reduce
  8:282 goto
  0:262,target 6
  11:0,target 13
  28:283 goto
  25:0 reduce
  10:264,target 27
  16:264 reduce
  15:263,target 32
  0:281,target 21
  0:0 reduce
  1:264,target 2
  5:264 reduce
  7:267,target 23
  10:283,target 30
  25:264 reduce
  0:260,target 4
  0:259,target 3
  22:0 reduce
  33:264,target 23
  43:0 reduce
  38:263,target 40
  34:264 reduce
  22:264,target 27
  0:278,target 19
  4:0,target 6
  0:257,target 1
  11:264,target 13
  13:257 shift
  43:264 reduce
  13:258 shift
  39:0 reduce
  13:259 shift
  13:260 shift
  13:261 shift
  13:262 shift
  31:0,target 25
  13:264 reduce
  23:0,target 1
  2:264,target 5
  0:276,target 17
  34:264,target 24
  2:264 reduce
  22:264 reduce
  36:0 reduce
  40:263,target 41
  23:264,target 22
  13:278 goto
  7:282,target 25
  31:264 reduce
  0:274,target 15
  12:264,target 14
  7:261,target 5
  12:0 reduce
  33:0 reduce
  40:263 shift
  23:262,target 6
  3:264,target 3
  8:0,target 1
  9:267,target 28
  1:0,target 2
  10:264 shift
  0:272,target 13
  35:264,target 39
  7:0 reduce
  7:258,target 2
  43:0,target 22
  41:263,target 42
  30:0 reduce
  29:0 reduce
  27:0,target 28
  18:263 shift
  24:264,target 26
  7:257 shift
  19:0,target 11
  20:0,target 0
  7:258 shift
  12:0,target 14
  7:259 shift
  7:260 shift
  8:282,target 26
  23:260,target 4
  7:261 shift
  23:259,target 3
  7:262 shift
  7:264 shift
  13:264,target 1
  0:269,target 10
  0:270,target 11
  4:0 reduce
  8:261,target 5
  27:264 reduce
  7:267 shift
  10:283 goto
  18:263,target 34
  26:0 reduce
  23:278,target 24
  4:264,target 6
  36:264 reduce
  23:257,target 1
  36:264,target 17
  7:278 goto
  1:0 reduce
  13:262,target 6
  8:258,target 2
  7:282 goto
  42:263,target 43
  23:0 reduce
  25:264,target 16
  5:0,target 4
  15:263 shift
  14:264,target 12
  39:0,target 10
  13:259,target 3
  13:260,target 4
  0:265,target 7
  4:264 reduce
  24:0,target 26
  24:264 reduce
  16:0,target 15
  19:0 reduce
  20:0 accept
  5:264,target 4
  13:278,target 31
  37:264,target 20
  33:264 reduce
  13:257,target 1
  26:264,target 18
  16:0 reduce
  42:263 shift
  37:0 reduce
  32:263,target 38
  12:264 reduce
  0:261,target 5
  13:0 reduce
  1:264 reduce
  2:0,target 5
  6:264,target 7
  34:0 reduce
  21:264 reduce
  36:0,target 17
  0:279,target 20
  9:264 shift
  21:0,target 8
  30:264 reduce
  29:264 reduce
  13:0,target 1
  27:264,target 28
  8:0 reduce
  9:267 shift
  0:258,target 2
  31:0 reduce
  21:280 goto
  38:263 shift
  16:264,target 15
  21:280,target 35
  0:277,target 18
  5:0 reduce
}

array set prefsfirst::rules {
  27,l 282
  9,l 280
  11,l 281
  15,l 281
  20,l 281
  19,l 281
  2,l 278
  24,l 281
  6,l 278
  28,l 283
  12,l 281
  16,l 281
  21,l 281
  3,l 278
  25,l 281
  7,l 278
  13,l 281
  0,l 284
  17,l 281
  22,l 281
  4,l 278
  26,l 282
  8,l 279
  10,l 279
  14,l 281
  18,l 281
  1,l 278
  23,l 281
  5,l 278
}

array set prefsfirst::rules {
  23,dc 2
  5,dc 1
  0,dc 1
  17,dc 3
  12,dc 1
  26,dc 1
  8,dc 1
  21,dc 2
  3,dc 1
  15,dc 1
  10,dc 3
  24,dc 2
  6,dc 1
  18,dc 2
  1,dc 0
  13,dc 1
  27,dc 1
  9,dc 0
  22,dc 7
  4,dc 1
  16,dc 2
  11,dc 1
  25,dc 2
  7,dc 1
  20,dc 3
  19,dc 2
  2,dc 1
  14,dc 1
  28,dc 1
}

array set prefsfirst::rules {
  13,line 62
  25,line 76
  7,line 52
  10,line 56
  22,line 73
  4,line 49
  18,line 68
  1,line 46
  15,line 65
  27,line 80
  9,line 55
  12,line 61
  24,line 75
  6,line 51
  21,line 72
  3,line 48
  17,line 67
  14,line 63
  26,line 79
  8,line 55
  11,line 60
  23,line 74
  5,line 50
  20,line 70
  19,line 69
  2,line 47
  9,e 1
  16,line 66
  28,line 83
}

array set prefsfirst::lr1_table {
  35 {{10 0 2}}
  36 {{17 {0 264} 3}}
  14,trans {}
  33,trans {}
  37 {{20 {0 264} 3}}
  38 {{22 {0 264} 3}}
  40 {{22 {0 264} 4}}
  39 {{10 0 3}}
  41 {{22 {0 264} 5}}
  18,trans {{263 34}}
  1,trans {}
  42 {{22 {0 264} 6}}
  37,trans {}
  43 {{22 {0 264} 7}}
  23,trans {{257 1} {258 2} {259 3} {260 4} {261 5} {262 6} {264 22} {278 24} {282 36}}
  5,trans {}
  42,trans {{263 43}}
  27,trans {}
  9,trans {{264 27} {267 28} {283 29}}
  13,trans {{257 1} {258 2} {259 3} {260 4} {261 5} {262 6} {278 31}}
  32,trans {{263 38}}
  17,trans {{264 33}}
  0,trans {{257 1} {258 2} {259 3} {260 4} {261 5} {262 6} {265 7} {266 8} {268 9} {269 10} {270 11} {271 12} {272 13} {273 14} {274 15} {275 16} {276 17} {277 18} {278 19} {279 20} {281 21}}
  36,trans {}
  22,trans {}
  4,trans {}
  41,trans {{263 42}}
  26,trans {}
  8,trans {{257 1} {258 2} {259 3} {260 4} {261 5} {262 6} {264 22} {278 24} {282 26}}
  12,trans {}
  31,trans {}
  16,trans {}
  35,trans {{264 39}}
  21,trans {{280 35}}
  3,trans {}
  40,trans {{263 41}}
  39,trans {}
  10 {{21 {0 264} 1} {28 {0 264} 0}}
  11 {{13 {0 264} 1}}
  25,trans {}
  12 {{14 {0 264} 1}}
  7,trans {{257 1} {258 2} {259 3} {260 4} {261 5} {262 6} {264 22} {267 23} {278 24} {282 25}}
  13 {{25 {0 264} 1} {1 {0 264} 0} {2 {0 264} 0} {3 {0 264} 0} {4 {0 264} 0} {5 {0 264} 0} {6 {0 264} 0} {7 {0 264} 0}}
  14 {{12 {0 264} 1}}
  15 {{22 {0 264} 1}}
  11,trans {}
  30,trans {}
  29,trans {}
  16 {{15 {0 264} 1}}
  0 {{0 0 0} {8 0 0} {10 0 0} {11 {0 264} 0} {12 {0 264} 0} {13 {0 264} 0} {14 {0 264} 0} {15 {0 264} 0} {16 {0 264} 0} {17 {0 264} 0} {18 {0 264} 0} {19 {0 264} 0} {20 {0 264} 0} {21 {0 264} 0} {22 {0 264} 0} {23 {0 264} 0} {24 {0 264} 0} {25 {0 264} 0} {1 {0 264} 0} {2 {0 264} 0} {3 {0 264} 0} {4 {0 264} 0} {5 {0 264} 0} {6 {0 264} 0} {7 {0 264} 0}}
  17 {{23 {0 264} 1}}
  1 {{2 {0 264} 1}}
  18 {{24 {0 264} 1}}
  15,trans {{263 32}}
  2 {{5 {0 264} 1}}
  19 {{11 {0 264} 1}}
  20 {{0 0 1}}
  34,trans {}
  3 {{3 {0 264} 1}}
  21 {{8 0 1} {10 0 1} {9 264 0}}
  4 {{6 {0 264} 1}}
  22 {{27 {0 264} 1}}
  5 {{4 {0 264} 1}}
  23 {{17 {0 264} 2} {26 {0 264} 0} {27 {0 264} 0} {1 {0 264} 0} {2 {0 264} 0} {3 {0 264} 0} {4 {0 264} 0} {5 {0 264} 0} {6 {0 264} 0} {7 {0 264} 0}}
  20,trans {}
  19,trans {}
  6 {{7 {0 264} 1}}
  2,trans {}
  24 {{26 {0 264} 1}}
  38,trans {{263 40}}
  7 {{16 {0 264} 1} {17 {0 264} 1} {26 {0 264} 0} {27 {0 264} 0} {1 {0 264} 0} {2 {0 264} 0} {3 {0 264} 0} {4 {0 264} 0} {5 {0 264} 0} {6 {0 264} 0} {7 {0 264} 0}}
  25 {{16 {0 264} 2}}
  8 {{18 {0 264} 1} {26 {0 264} 0} {27 {0 264} 0} {1 {0 264} 0} {2 {0 264} 0} {3 {0 264} 0} {4 {0 264} 0} {5 {0 264} 0} {6 {0 264} 0} {7 {0 264} 0}}
  26 {{18 {0 264} 2}}
  9 {{19 {0 264} 1} {20 {0 264} 1} {28 {0 264} 0}}
  27 {{28 {0 264} 1}}
  24,trans {}
  6,trans {}
  28 {{20 {0 264} 2} {28 {0 264} 0}}
  43,trans {}
  29 {{19 {0 264} 2}}
  30 {{21 {0 264} 2}}
  31 {{25 {0 264} 2}}
  10,trans {{264 27} {283 30}}
  32 {{22 {0 264} 2}}
  28,trans {{264 27} {283 37}}
  33 {{23 {0 264} 2}}
  34 {{24 {0 264} 2}}
}

array set prefsfirst::token_id_table {
  280,title {}
  279,title {}
  264,line 16
  270,t 0
  269,t 0
  276,line 32
  265,title BACKGROUND
  284,title {}
  274,t 0
  261,line 11
  257,t 0
  270,title CLEAR
  269,title NANCOLOR
  273,line 29
  278,t 1
  257,line 7
  262,t 0
  274,title PRECISION
  283,t 1
  270,line 26
  269,line 24
  259,title ON
  260,title OFF
  266,t 0
  278,title {}
  282,line 78
  error error
  271,t 0
  264,title string
  266,line 21
  283,title {}
  278,line 45
  error,line 44
  275,t 0
  268,title NAN
  258,t 0
  263,line 14
  error,title {}
  280,t 1
  279,t 1
  275,line 31
  273,title OPEN
  263,t 0
  259,line 9
  260,line 10
  258,title NO
  284,t 1
  277,title THREADS
  272,line 28
  267,t 0
  263,title integer
  284,line 84
  282,title {}
  272,t 0
  268,line 23
  267,title COLOR
  257 YES_
  281,line 58
  276,t 0
  258 NO_
  259,t 0
  259 ON_
  260 OFF_
  260,t 0
  272,title IRAFALIGN
  261 TRUE_
  265,line 20
  262 FALSE_
  281,t 1
  263 INT_
  277,line 33
  257,title YES
  264 STRING_
  264,t 0
  276,title THEME
  265 BACKGROUND_
  262,line 12
  266 BGCOLOR_
  267 COLOR_
  0,t 0
  0 {$}
  262,title FALSE
  268 NAN_
  268,t 0
  281,title {}
  274,line 30
  270 CLEAR_
  269 NANCOLOR_
  error,t 0
  271 CLOSE_
  272 IRAFALIGN_
  258,line 8
  273,t 0
  273 OPEN_
  266,title BGCOLOR
  274 PRECISION_
  275 SAVE_
  271,line 27
  276 THEME_
  277,t 0
  277 THREADS_
  271,title CLOSE
  283,line 82
  278 yesno
  261,t 0
  280 @PSEUDO1
  279 command
  281 prefs
  267,line 22
  282,t 1
  282 bg
  275,title SAVE
  283 nan
  265,t 0
  284 start'
  280,line 55
  279,line 54
  261,title TRUE
}

proc prefsfirst::yyparse {} {
    variable yylval
    variable table
    variable rules
    variable token
    variable yycnt
    variable lr1_table
    variable token_id_table
    variable yyerr
    variable save_state

    set yycnt 0
    set state_stack {0}
    set value_stack {{}}
    set token ""
    set accepted 0
    set yyerr 0
    set save_state 0

    while {$accepted == 0} {
        set state [lindex $state_stack end]
        if {$token == ""} {
            set yylval ""
            set token [yylex]
            set buflval $yylval
	    if {$token>0} {
	        incr yycnt
            }
        }
        if {![info exists table($state:$token)] || $yyerr} {
	    if {!$yyerr} {
	        set save_state $state
	    }
            # pop off states until error token accepted
            while {[llength $state_stack] > 0 && \
                       ![info exists table($state:error)]} {
                set state_stack [lrange $state_stack 0 end-1]
                set value_stack [lrange $value_stack 0 \
                                       [expr {[llength $state_stack] - 1}]]
                set state [lindex $state_stack end]
            }
            if {[llength $state_stack] == 0} {
 
	        set rr { }
                if {[info exists lr1_table($save_state,trans)] && [llength $lr1_table($save_state,trans)] >= 1} {
                    foreach trans $lr1_table($save_state,trans) {
                        foreach {tok_id nextstate} $trans {
			    set ss $token_id_table($tok_id,title)
			    if {$ss != {}} {
			        append rr "$ss, "
                            }
                        }
                    }
                }
		set rr [string trimleft $rr { }]
		set rr [string trimright $rr {, }]
                yyerror "parse error, expecting: $rr"


                return 1
            }
            lappend state_stack [set state $table($state:error,target)]
            lappend value_stack {}
            # consume tokens until it finds an acceptable one
            while {![info exists table($state:$token)]} {
                if {$token == 0} {
                    yyerror "end of file while recovering from error"
                    return 1
                }
                set yylval {}
                set token [yylex]
                set buflval $yylval
            }
            continue
        }
        switch -- $table($state:$token) {
            shift {
                lappend state_stack $table($state:$token,target)
                lappend value_stack $buflval
                set token ""
            }
            reduce {
                set rule $table($state:$token,target)
                set ll $rules($rule,l)
                if {[info exists rules($rule,e)]} {
                    set dc $rules($rule,e)
                } else {
                    set dc $rules($rule,dc)
                }
                set stackpointer [expr {[llength $state_stack]-$dc}]
                setupvalues $value_stack $stackpointer $dc
                set _ $1
                set yylval [lindex $value_stack end]
                switch -- $rule {
                    1 { set _ 1 }
                    2 { set _ 1 }
                    3 { set _ 1 }
                    4 { set _ 1 }
                    5 { set _ 0 }
                    6 { set _ 0 }
                    7 { set _ 0 }
                    9 { global ds9; if {!$ds9(init)} {YYERROR} else {yyclearin; YYACCEPT} }
                    11 { ProcessCmdSet ds9 prefs $1 }
                }
                unsetupvalues $dc
                # pop off tokens from the stack if normal rule
                if {![info exists rules($rule,e)]} {
                    incr stackpointer -1
                    set state_stack [lrange $state_stack 0 $stackpointer]
                    set value_stack [lrange $value_stack 0 $stackpointer]
                }
                # now do the goto transition
                lappend state_stack $table([lindex $state_stack end]:$ll,target)
                lappend value_stack $_
            }
            accept {
                set accepted 1
            }
            goto -
            default {
                puts stderr "Internal parser error: illegal command $table($state:$token)"
                return 2
            }
        }
    }
    return 0
}

######
# end autogenerated taccle functions
######

proc prefsfirst::yyerror {msg} {
     variable yycnt
     variable yy_current_buffer
     variable index_

     ParserError $msg $yycnt $yy_current_buffer $index_
}
