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

    namespace export yylex
}

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

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

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

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

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

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

array set viewsend::table {
  37:307,target 54
  27:0 reduce
  48:0 reduce
  0:306,target 49
  0:296,target 39
  0:275,target 19
  6:0,target 6
  2:0 reduce
  24:0 reduce
  48:0,target 49
  41:0,target 34
  45:0 reduce
  33:0,target 39
  0:304,target 47
  25:0,target 25
  17:0,target 17
  10:0,target 10
  0:273,target 17
  21:0 reduce
  42:0 reduce
  0:292,target 36
  0:302,target 45
  0:271,target 15
  17:0 reduce
  38:0 reduce
  0:300,target 43
  0:290,target 34
  0:289,target 33
  3:0,target 3
  53:0,target 54
  0:268,target 12
  45:0,target 47
  14:0 reduce
  37:0,target 53
  29:0,target 29
  30:0,target 30
  22:0,target 22
  14:0,target 14
  35:0 reduce
  0:287,target 31
  0:257 shift
  0:258 shift
  0:259 shift
  0:260 shift
  0:261 shift
  0:266,target 10
  9:0 reduce
  0:262 shift
  11:0 reduce
  0:263 shift
  0:264 shift
  0:265 shift
  32:0 reduce
  0:266 shift
  0:267 shift
  53:0 reduce
  0:268 shift
  0:269 shift
  0:270 shift
  0:271 shift
  0:285,target 29
  0:272 shift
  0:273 shift
  0:274 shift
  0:275 shift
  6:0 reduce
  0:264,target 8
  0:276 shift
  0:277 shift
  0:278 shift
  0:279 shift
  0:280 shift
  7:0,target 7
  28:0 reduce
  0:0,target 32
  0:281 shift
  0:282 shift
  50:0 reduce
  49:0 reduce
  0:283 shift
  0:284 shift
  0:285 shift
  50:0,target 50
  49:0,target 43
  0:283,target 27
  0:286 shift
  42:0,target 33
  0:287 shift
  0:288 shift
  34:0,target 40
  0:300 shift
  0:290 shift
  0:289 shift
  3:0 reduce
  26:0,target 26
  0:291 shift
  0:301 shift
  18:0,target 18
  0:292 shift
  0:302 shift
  0:262,target 6
  11:0,target 11
  0:303 shift
  0:293 shift
  0:304 shift
  25:0 reduce
  0:305 shift
  0:295 shift
  0:306 shift
  0:296 shift
  46:0 reduce
  0:297 shift
  0:308 goto
  0:298 shift
  0:309 goto
  0:310 goto
  0:299 shift
  0:281,target 25
  0:0 reduce
  37:311,target 55
  0:259,target 3
  0:260,target 4
  22:0 reduce
  43:0 reduce
  0:309,target 51
  0:310,target 52
  0:299,target 42
  37:294 shift
  0:278,target 22
  37:307 shift
  4:0,target 4
  37:311 goto
  0:257,target 1
  18:0 reduce
  54:0,target 55
  39:0 reduce
  40:0 reduce
  46:0,target 45
  0:297,target 40
  38:0,target 42
  31:0,target 31
  23:0,target 23
  15:0,target 15
  0:276,target 20
  15:0 reduce
  36:0 reduce
  0:305,target 48
  0:295,target 38
  0:274,target 18
  12:0 reduce
  37:294,target 53
  33:0 reduce
  54:0 reduce
  0:303,target 46
  0:293,target 37
  8:0,target 8
  1:0,target 1
  0:272,target 16
  7:0 reduce
  51:0,target 51
  43:0,target 48
  29:0 reduce
  30:0 reduce
  35:0,target 44
  27:0,target 27
  19:0,target 19
  20:0,target 20
  51:0 reduce
  12:0,target 12
  0:291,target 35
  0:301,target 44
  0:269,target 13
  0:270,target 14
  4:0 reduce
  26:0 reduce
  47:0 reduce
  0:288,target 32
  1:0 reduce
  0:267,target 11
  23:0 reduce
  44:0 reduce
  5:0,target 5
  0:286,target 30
  55:0,target 41
  47:0,target 36
  40:0,target 46
  39:0,target 35
  0:265,target 9
  32:0,target 38
  24:0,target 24
  16:0,target 16
  19:0 reduce
  20:0 reduce
  41:0 reduce
  0:284,target 28
  0:263,target 7
  16:0 reduce
  37:0 reduce
  0:282,target 26
  0:261,target 5
  9:0,target 9
  13:0 reduce
  2:0,target 2
  34:0 reduce
  55:0 reduce
  52:0,target 0
  44:0,target 37
  36:0,target 52
  0:279,target 23
  0:280,target 24
  28:0,target 28
  21:0,target 21
  13:0,target 13
  8:0 reduce
  10:0 reduce
  0:258,target 2
  31:0 reduce
  0:308,target 50
  0:298,target 41
  52:0 accept
  0:277,target 21
  5:0 reduce
}

array set viewsend::rules {
  9,l 309
  11,l 309
  32,l 310
  53,l 311
  6,l 309
  28,l 309
  50,l 310
  49,l 310
  3,l 308
  25,l 309
  46,l 310
  0,l 312
  22,l 309
  43,l 310
  18,l 309
  40,l 310
  39,l 310
  15,l 309
  36,l 310
  12,l 309
  33,l 310
  54,l 311
  7,l 309
  29,l 309
  30,l 309
  51,l 310
  4,l 308
  26,l 309
  47,l 310
  1,l 308
  23,l 309
  44,l 310
  19,l 309
  20,l 309
  41,l 310
  16,l 309
  37,l 310
  13,l 309
  34,l 310
  55,l 311
  8,l 309
  10,l 309
  31,l 309
  52,l 310
  5,l 309
  27,l 309
  48,l 310
  2,l 308
  24,l 309
  45,l 310
  21,l 309
  42,l 310
  17,l 309
  38,l 310
  14,l 309
  35,l 310
}

array set viewsend::rules {
  12,dc 1
  26,dc 1
  3,dc 1
  41,dc 2
  55,dc 1
  18,dc 1
  33,dc 1
  9,dc 1
  47,dc 1
  11,dc 1
  25,dc 1
  2,dc 1
  40,dc 1
  39,dc 1
  54,dc 1
  17,dc 1
  32,dc 0
  8,dc 1
  46,dc 1
  10,dc 1
  24,dc 1
  1,dc 1
  38,dc 1
  53,dc 0
  16,dc 1
  31,dc 1
  7,dc 1
  45,dc 1
  23,dc 1
  0,dc 1
  37,dc 1
  52,dc 1
  15,dc 1
  29,dc 1
  30,dc 1
  6,dc 1
  44,dc 1
  22,dc 1
  36,dc 1
  51,dc 1
  14,dc 1
  28,dc 1
  5,dc 1
  43,dc 1
  21,dc 1
  35,dc 1
  50,dc 1
  49,dc 1
  13,dc 1
  27,dc 1
  4,dc 1
  42,dc 1
  19,dc 1
  20,dc 1
  34,dc 1
  48,dc 1
}

array set viewsend::rules {
  41,line 144
  7,line 106
  37,line 138
  4,line 102
  34,line 135
  1,line 99
  31,line 130
  27,line 126
  24,line 123
  21,line 120
  17,line 116
  14,line 113
  11,line 110
  53,line 162
  50,line 156
  49,line 155
  46,line 151
  43,line 148
  9,line 108
  40,line 142
  39,line 141
  6,line 105
  36,line 137
  3,line 101
  33,line 134
  29,line 128
  30,line 129
  26,line 125
  23,line 122
  19,line 118
  20,line 119
  16,line 115
  13,line 112
  10,line 109
  55,line 164
  52,line 159
  48,line 153
  45,line 150
  42,line 146
  8,line 107
  38,line 139
  5,line 104
  35,line 136
  2,line 100
  32,line 133
  28,line 127
  25,line 124
  22,line 121
  18,line 117
  15,line 114
  12,line 111
  54,line 163
  51,line 158
  47,line 152
  44,line 149
}

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

array set viewsend::token_id_table {
  286 WCSY_
  286,t 0
  287 WCSZ_
  292,line 46
  302,line 56
  288 BUTTONS_
  265,title WCSD
  289 COLORBAR_
  290 COLORBARNUMERICS_
  300 LOWHIGH_
  284,title WCSW
  291 FILENAME_
  301 MAGNIFIER_
  292 FRAME_
  302 MINMAX_
  288,line 42
  293 GRAPH_
  303 OBJECT_
  294 HORIZONTAL_
  304 PANNER_
  305 UNITS_
  295 HORZGRAPH_
  306 VERTGRAPH_
  296 INFO_
  307 VERTICAL_
  262,t 0
  297 KEYWORD_
  308 coordsys
  285,line 36
  298 KEYVALUE_
  310 viewsend
  309 wcssys
  299 LAYOUT_
  311 graph
  283,t 0
  312 start'
  282,line 33
  264,title WCSC
  283,title WCSV
  312,title {}
  278,line 29
  error,line 97
  258,t 0
  275,line 26
  279,t 0
  280,t 0
  311,t 1
  272,line 23
  263,title WCSB
  282,title WCSU
  311,title {}
  268,line 19
  276,t 0
  265,line 16
  307,t 0
  297,t 0
  262,line 13
  0,t 0
  0 {$}
  262,title WCSA
  281,title WCST
  310,title {}
  309,title {}
  error,t 0
  299,title LAYOUT
  258,line 8
  273,t 0
  294,t 0
  304,t 0
  261,title WCS
  279,title WCSR
  280,title WCSS
  308,title {}
  269,t 0
  270,t 0
  298,title KEYVALUE
  291,t 0
  301,t 0
  311,line 161
  307,line 61
  266,t 0
  260,title DETECTOR
  259,title AMPLIFIER
  297,line 51
  278,title WCSQ
  307,title VERTICAL
  297,title KEYWORD
  287,t 0
  294,line 48
  304,line 58
  error,title {}
  291,line 45
  301,line 55
  263,t 0
  258,title PHYSICAL
  287,line 38
  277,title WCSP
  284,t 0
  306,title VERTGRAPH
  296,title INFO
  284,line 35
  281,line 32
  260,t 0
  259,t 0
  281,t 0
  257,title IMAGE
  277,line 28
  276,title WCSO
  312,t 1
  305,title UNITS
  295,title HORZGRAPH
  274,line 25
  271,line 22
  277,t 0
  308,t 1
  267,line 18
  298,t 0
  275,title WCSN
  294,title HORIZONTAL
  304,title PANNER
  264,line 15
  261,line 12
  274,t 0
  305,t 0
  295,t 0
  257,line 7
  274,title WCSM
  293,title GRAPH
  303,title OBJECT
  error error
  271,t 0
  292,t 0
  302,t 0
  273,title WCSL
  292,title FRAME
  302,title MINMAX
  267,t 0
  310,line 132
  309,line 103
  299,line 53
  288,t 0
  306,line 60
  296,line 50
  272,title WCSK
  291,title FILENAME
  293,line 47
  301,title MAGNIFIER
  303,line 57
  264,t 0
  285,t 0
  289,line 43
  290,line 44
  300,line 54
  286,line 37
  271,title WCSJ
  261,t 0
  283,line 34
  289,title COLORBAR
  290,title COLORBARNUMERICS
  300,title LOWHIGH
  282,t 0
  279,line 30
  280,line 31
  276,line 27
  257,t 0
  269,title WCSH
  270,title WCSI
  273,line 24
  288,title BUTTONS
  278,t 0
  310,t 1
  309,t 1
  299,t 0
  269,line 20
  270,line 21
  266,line 17
  268,title WCSG
  275,t 0
  263,line 14
  287,title WCSZ
  306,t 0
  296,t 0
  260,line 10
  259,line 9
  272,t 0
  267,title WCSF
  257 IMAGE_
  286,title WCSY
  293,t 0
  303,t 0
  258 PHYSICAL_
  260 DETECTOR_
  259 AMPLIFIER_
  261 WCS_
  262 WCSA_
  263 WCSB_
  264 WCSC_
  265 WCSD_
  266 WCSE_
  267 WCSF_
  268,t 0
  268 WCSG_
  269 WCSH_
  270 WCSI_
  312,line 165
  271 WCSJ_
  272 WCSK_
  289,t 0
  290,t 0
  300,t 0
  266,title WCSE
  273 WCSL_
  274 WCSM_
  285,title WCSX
  275 WCSN_
  308,line 98
  276 WCSO_
  298,line 52
  277 WCSP_
  278 WCSQ_
  279 WCSR_
  280 WCSS_
  281 WCST_
  305,line 59
  282 WCSU_
  295,line 49
  265,t 0
  283 WCSV_
  284 WCSW_
  285 WCSX_
}

proc viewsend::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 _ image }
                    2 { set _ physical }
                    3 { set _ amplifier }
                    4 { set _ detector }
                    5 { set _ wcs }
                    6 { set _ wcsa }
                    7 { set _ wcsb }
                    8 { set _ wcsc }
                    9 { set _ wcsd }
                    10 { set _ wcse }
                    11 { set _ wcsf }
                    12 { set _ wcsg }
                    13 { set _ wcsh }
                    14 { set _ wcsi }
                    15 { set _ wcsj }
                    16 { set _ wcsk }
                    17 { set _ wcsl }
                    18 { set _ wcsm }
                    19 { set _ wcsn }
                    20 { set _ wcso }
                    21 { set _ wcsp }
                    22 { set _ wcsq }
                    23 { set _ wcsr }
                    24 { set _ wcss }
                    25 { set _ wcst }
                    26 { set _ wcsu }
                    27 { set _ wcsv }
                    28 { set _ wcsw }
                    29 { set _ wcsx }
                    30 { set _ wcsy }
                    31 { set _ wcsz }
                    33 { ProcessSendCmdGet view layout }
                    34 { ProcessSendCmdGet view info,keyvalue }
                    35 { ProcessSendCmdYesNo view info }
                    36 { ProcessSendCmdYesNo view panner }
                    37 { ProcessSendCmdYesNo view magnifier }
                    38 { ProcessSendCmdYesNo view buttons }
                    39 { ProcessSendCmdYesNo view colorbar }
                    40 { ProcessSendCmdYesNo colorbar numerics }
                    42 { ProcessSendCmdYesNo view graph,horz }
                    43 { ProcessSendCmdYesNo view graph,graph }
                    44 { ProcessSendCmdYesNo view info,filename }
                    45 { ProcessSendCmdYesNo view info,object }
                    46 { ProcessSendCmdYesNo view info,keyword }
                    47 { ProcessSendCmdYesNo view info,minmax }
                    48 { ProcessSendCmdYesNo view info,lowhigh }
                    49 { ProcessSendCmdYesNo view info,bunit }
                    50 { ProcessSendCmdYesNo view info,$1 }
                    51 { ProcessSendCmdYesNo view info,$1 }
                    52 { ProcessSendCmdYesNo view info,frame }
                    54 { ProcessSendCmdYesNo view graph,horz }
                    55 { ProcessSendCmdYesNo view graph,vert }
                }
                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 viewsend::yyerror {msg} {
     variable yycnt
     variable yy_current_buffer
     variable index_

     ParserError $msg $yycnt $yy_current_buffer $index_
}
