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 threed {
    variable yylval {}
    variable table
    variable rules
    variable token {}
    variable yycnt 0
    variable yyerr 0
    variable save_state 0

    namespace export yylex
}

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

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

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

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

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

proc threed::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 threed::unsetupvalues {numsyms} {
    for {set i 1} {$i <= $numsyms} {incr i} {
        upvar 1 $i y
        unset y
    }
}

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

array set threed::rules {
  9,l 284
  11,l 286
  32,l 290
  6,l 283
  28,l 288
  3,l 283
  25,l 287
  0,l 293
  22,l 287
  18,l 287
  15,l 287
  36,l 292
  12,l 285
  33,l 290
  7,l 283
  29,l 289
  30,l 289
  4,l 283
  26,l 287
  1,l 283
  23,l 287
  19,l 287
  20,l 287
  16,l 287
  37,l 292
  13,l 287
  34,l 291
  8,l 284
  10,l 285
  31,l 289
  5,l 283
  27,l 288
  2,l 283
  24,l 287
  21,l 287
  17,l 287
  14,l 287
  35,l 291
}

array set threed::rules {
  12,dc 3
  26,dc 2
  3,dc 1
  18,dc 3
  33,dc 1
  9,dc 1
  11,dc 0
  25,dc 1
  2,dc 1
  17,dc 2
  32,dc 2
  8,dc 1
  10,dc 1
  24,dc 2
  1,dc 0
  16,dc 2
  31,dc 1
  7,dc 1
  23,dc 2
  0,dc 1
  37,dc 1
  15,dc 1
  29,dc 1
  30,dc 1
  6,dc 1
  22,dc 2
  36,dc 2
  14,dc 1
  28,dc 1
  5,dc 1
  21,dc 2
  35,dc 1
  13,dc 0
  27,dc 1
  4,dc 1
  19,dc 2
  20,dc 2
  34,dc 2
}

array set threed::rules {
  7,line 59
  37,line 103
  4,line 56
  34,line 98
  1,line 53
  31,line 91
  27,line 85
  24,line 80
  21,line 77
  17,line 73
  14,line 70
  11,line 65
  9,line 62
  6,line 58
  36,line 102
  3,line 55
  33,line 95
  29,line 89
  30,line 90
  26,line 82
  23,line 79
  19,line 75
  20,line 76
  16,line 72
  13,line 69
  10,line 65
  8,line 61
  5,line 57
  35,line 99
  2,line 54
  32,line 94
  28,line 86
  25,line 81
  22,line 78
  18,line 74
  15,line 71
  12,line 66
  11,e 1
}

array set threed::lr1_table {
  35 {{17 {0 265} 2}}
  14,trans {}
  36 {{32 {0 265} 1}}
  33,trans {}
  37 {{33 {0 265} 1}}
  52,trans {}
  38 {{22 {0 265} 2}}
  40 {{27 {0 265} 1}}
  39 {{26 {0 265} 2}}
  18,trans {}
  41 {{28 {0 265} 1}}
  1,trans {{263 16} {264 17} {284 18}}
  37,trans {}
  42 {{20 {0 265} 2}}
  43 {{19 {0 265} 2}}
  44 {{8 {263 264} 1}}
  23,trans {}
  45 {{9 {263 264} 1}}
  5,trans {{257 23} {258 24} {259 25} {260 26} {261 27} {262 28} {271 32} {283 33} {292 34}}
  42,trans {}
  46 {{18 {0 265} 2} {8 {0 265} 0} {9 {0 265} 0}}
  47 {{12 0 2}}
  48 {{34 {0 265} 2}}
  50 {{32 {0 265} 2}}
  49 {{36 {0 265} 2}}
  27,trans {}
  9,trans {}
  46,trans {{263 16} {264 17} {284 51}}
  51 {{18 {0 265} 3}}
  52 {{12 0 3}}
  13,trans {{263 44} {264 45} {284 46}}
  32,trans {{265 49}}
  51,trans {}
  17,trans {}
  0,trans {{267 1} {268 2} {269 3} {270 4} {272 5} {273 6} {274 7} {275 8} {276 9} {277 10} {280 11} {281 12} {282 13} {285 14} {287 15}}
  36,trans {{265 50}}
  22,trans {}
  4,trans {}
  41,trans {}
  26,trans {}
  8,trans {{257 23} {258 24} {259 25} {260 26} {261 27} {262 28} {283 39}}
  45,trans {}
  12,trans {{263 16} {264 17} {284 43}}
  31,trans {}
  50,trans {}
  49,trans {}
  16,trans {}
  35,trans {}
  21,trans {}
  3,trans {{257 23} {258 24} {259 25} {260 26} {261 27} {262 28} {271 29} {283 30} {291 31}}
  40,trans {}
  39,trans {}
  10 {{20 {0 265} 1} {27 {0 265} 0} {28 {0 265} 0}}
  11 {{14 {0 265} 1}}
  25,trans {}
  12 {{19 {0 265} 1} {8 {0 265} 0} {9 {0 265} 0}}
  7,trans {{257 23} {258 24} {259 25} {260 26} {261 27} {262 28} {271 36} {283 37} {290 38}}
  44,trans {}
  13 {{18 {0 265} 1} {8 {263 264} 0} {9 {263 264} 0}}
  14 {{0 0 1}}
  11,trans {}
  15 {{10 0 1} {12 0 1} {11 265 0}}
  30,trans {}
  29,trans {{265 48}}
  16 {{8 {0 265} 1}}
  48,trans {}
  0 {{0 0 0} {10 0 0} {12 0 0} {13 {0 265} 0} {14 {0 265} 0} {15 {0 265} 0} {16 {0 265} 0} {17 {0 265} 0} {18 {0 265} 0} {19 {0 265} 0} {20 {0 265} 0} {21 {0 265} 0} {22 {0 265} 0} {23 {0 265} 0} {24 {0 265} 0} {25 {0 265} 0} {26 {0 265} 0}}
  17 {{9 {0 265} 1}}
  1 {{16 {0 265} 1} {8 {0 265} 0} {9 {0 265} 0}}
  18 {{16 {0 265} 2}}
  15,trans {{286 47}}
  2 {{21 {0 265} 1} {29 {0 265} 0} {30 {0 265} 0} {31 {0 265} 0}}
  19 {{30 {0 265} 1}}
  20 {{31 {0 265} 1}}
  34,trans {}
  3 {{23 {0 265} 1} {34 {0 265} 0} {35 {0 265} 0} {1 {0 265} 0} {2 {0 265} 0} {3 {0 265} 0} {4 {0 265} 0} {5 {0 265} 0} {6 {0 265} 0} {7 {0 265} 0}}
  21 {{29 {0 265} 1}}
  4 {{15 {0 265} 1}}
  22 {{21 {0 265} 2}}
  5 {{24 {0 265} 1} {36 {0 265} 0} {37 {0 265} 0} {1 {0 265} 0} {2 {0 265} 0} {3 {0 265} 0} {4 {0 265} 0} {5 {0 265} 0} {6 {0 265} 0} {7 {0 265} 0}}
  23 {{2 {0 265} 1}}
  20,trans {}
  19,trans {}
  6 {{17 {0 265} 1} {8 {0 265} 0} {9 {0 265} 0}}
  2,trans {{267 19} {273 20} {279 21} {289 22}}
  24 {{5 {0 265} 1}}
  38,trans {}
  7 {{22 {0 265} 1} {32 {0 265} 0} {33 {0 265} 0} {1 {0 265} 0} {2 {0 265} 0} {3 {0 265} 0} {4 {0 265} 0} {5 {0 265} 0} {6 {0 265} 0} {7 {0 265} 0}}
  25 {{3 {0 265} 1}}
  8 {{26 {0 265} 1} {1 {0 265} 0} {2 {0 265} 0} {3 {0 265} 0} {4 {0 265} 0} {5 {0 265} 0} {6 {0 265} 0} {7 {0 265} 0}}
  26 {{6 {0 265} 1}}
  9 {{25 {0 265} 1}}
  27 {{4 {0 265} 1}}
  24,trans {}
  28 {{7 {0 265} 1}}
  6,trans {{263 16} {264 17} {284 35}}
  43,trans {}
  29 {{34 {0 265} 1}}
  30 {{35 {0 265} 1}}
  31 {{23 {0 265} 2}}
  10,trans {{266 40} {278 41} {288 42}}
  32 {{36 {0 265} 1}}
  28,trans {}
  33 {{37 {0 265} 1}}
  47,trans {{265 52}}
  34 {{24 {0 265} 2}}
}

array set threed::token_id_table {
  286,t 1
  286 @PSEUDO1
  280,title OPEN
  279,title NONE
  264,line 15
  292,line 101
  287 3d
  270,t 0
  269,t 0
  288 method
  290 highlite
  289 bg
  276,line 31
  265,title string
  291,t 1
  291 border
  284,title {}
  292 compass
  274,t 0
  261,line 11
  293 start'
  288,line 84
  257,t 0
  270,title CLOSE
  269,title BORDER
  288,title {}
  273,line 28
  278,t 0
  257,line 7
  262,t 0
  285,line 64
  274,title HIGHLITE
  293,title {}
  283,t 1
  270,line 25
  269,line 24
  259,title ON
  260,title OFF
  266,t 0
  278,title MIP
  282,line 37
  287,t 1
  error error
  271,t 0
  264,title float
  266,line 21
  283,title {}
  292,t 1
  278,line 33
  error,line 51
  275,t 0
  268,title BG
  287,title {}
  258,t 0
  263,line 14
  291,line 97
  error,title {}
  280,t 0
  279,t 0
  275,line 30
  273,title EL
  292,title {}
  263,t 0
  259,line 9
  260,line 10
  287,line 68
  258,title NO
  284,t 1
  277,title METHOD
  272,line 27
  267,t 0
  263,title integer
  288,t 1
  284,line 60
  282,title VIEW
  272,t 0
  268,line 23
  267,title AZ
  293,t 1
  286,title {}
  257 YES_
  281,line 36
  276,t 0
  258 NO_
  259,t 0
  259 ON_
  260 OFF_
  260,t 0
  272,title COMPASS
  261 TRUE_
  265,line 17
  293,line 104
  291,title {}
  262 FALSE_
  281,t 0
  263 INT_
  277,line 32
  257,title YES
  264 REAL_
  264,t 0
  276,title MATCH
  265 STRING_
  262,line 12
  266 AIP_
  290,line 93
  289,line 88
  285,t 1
  267 AZ_
  0,t 0
  0 {$}
  262,title FALSE
  268 BG_
  268,t 0
  281,title SCALE
  274,line 29
  270 CLOSE_
  269 BORDER_
  error,t 0
  271 COLOR_
  290,t 1
  289,t 1
  272 COMPASS_
  258,line 8
  286,line 65
  273,t 0
  273 EL_
  266,title AIP
  285,title {}
  274 HIGHLITE_
  275 LOCK_
  271,line 26
  276 MATCH_
  277,t 0
  277 METHOD_
  271,title COLOR
  290,title {}
  289,title {}
  283,line 52
  278 MIP_
  261,t 0
  280 OPEN_
  279 NONE_
  281 SCALE_
  267,line 22
  282,t 0
  282 VIEW_
  275,title LOCK
  283 yesno
  265,t 0
  284 numeric
  280,line 35
  279,line 34
  285 command
  261,title TRUE
}

proc threed::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 }
                    8 { set _ $1 }
                    9 { set _ $1 }
                    11 { global ds9; if {!$ds9(init)} {YYERROR} else {yyclearin; YYACCEPT} }
                    13 { Create3DFrame }
                    15 { 3DDestroyDialog }
                    16 { ProcessCmdSet threed az $2 3DViewPoint }
                    17 { ProcessCmdSet threed el $2 3DViewPoint }
                    18 { ProcessCmdSet threed az $2; ProcessCmdSet threed el $3 3DViewPoint }
                    19 { ProcessCmdSet threed scale $2 3DScale }
                    20 { ProcessCmdSet threed method $2 3DRenderMethod }
                    21 { ProcessCmdSet threed background $2 3DBackground }
                    25 { Match3DCurrent }
                    26 { ProcessCmdSet threed lock $2 Lock3DCurrent }
                    27 { set _ aip }
                    28 { set _ mip }
                    29 { set _ none }
                    30 { set _ azimuth }
                    31 { set _ elevation }
                    32 { ProcessCmdSet threed highlite,color $2 3DHighliteColor }
                    33 { ProcessCmdSet threed highlite $1 3DHighlite }
                    34 { ProcessCmdSet threed border,color $2 3DBorderColor }
                    35 { ProcessCmdSet threed border $1 3DBorder }
                    36 { ProcessCmdSet threed compass,color $2 3DCompassColor }
                    37 { ProcessCmdSet threed compass $1 3DCompass }
                }
                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 threed::yyerror {msg} {
     variable yycnt
     variable yy_current_buffer
     variable index_

     ParserError $msg $yycnt $yy_current_buffer $index_
}
