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

    namespace export yylex
}

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

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

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

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

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

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

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

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

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

array set smosaicwcs::rules {
  7,line 79
  4,line 76
  34,line 115
  1,line 73
  31,line 110
  27,line 99
  24,line 96
  21,line 93
  17,line 89
  14,line 86
  11,line 83
  9,line 81
  6,line 78
  3,line 75
  33,line 114
  29,line 106
  30,line 109
  26,line 98
  23,line 95
  19,line 91
  20,line 92
  16,line 88
  13,line 85
  10,line 82
  8,line 80
  5,line 77
  2,line 74
  32,line 113
  28,line 103
  25,line 97
  22,line 94
  18,line 90
  15,line 87
  12,line 84
}

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

array set smosaicwcs::token_id_table {
  286,t 0
  286 NEW_
  280,title WCSW
  279,title WCSV
  264,line 14
  292,line 116
  287 wcssys
  270,t 0
  269,t 0
  288 command
  290 sys
  289 smosaicwcs
  276,line 26
  265,title WCSH
  291,t 1
  291 opts
  284,title string
  292 start'
  274,t 0
  261,line 11
  288,line 102
  257,t 0
  270,title WCSM
  269,title WCSL
  288,title {}
  273,line 23
  278,t 0
  257,line 7
  262,t 0
  285,line 39
  274,title WCSQ
  283,t 0
  270,line 20
  269,line 19
  259,title WCSB
  260,title WCSC
  266,t 0
  278,title WCSU
  282,line 32
  287,t 1
  error error
  271,t 0
  264,title WCSG
  266,line 16
  283,title WCSZ
  292,t 1
  278,line 28
  error,line 71
  275,t 0
  268,title WCSK
  287,title {}
  258,t 0
  263,line 13
  291,line 112
  error,title {}
  280,t 0
  279,t 0
  275,line 25
  273,title WCSP
  292,title {}
  263,t 0
  259,line 9
  260,line 10
  287,line 72
  258,title WCSA
  284,t 0
  277,title WCST
  272,line 22
  267,t 0
  263,title WCSF
  288,t 1
  284,line 35
  282,title WCSY
  272,t 0
  268,line 18
  267,title WCSJ
  286,title NEW
  257 WCS_
  281,line 31
  276,t 0
  258 WCSA_
  259,t 0
  259 WCSB_
  260 WCSC_
  260,t 0
  272,title WCSO
  261 WCSD_
  265,line 15
  291,title {}
  262 WCSE_
  281,t 0
  263 WCSF_
  277,line 27
  257,title WCS
  264 WCSG_
  264,t 0
  276,title WCSS
  265 WCSH_
  262,line 12
  266 WCSI_
  290,line 108
  289,line 105
  285,t 0
  267 WCSJ_
  0,t 0
  0 {$}
  262,title WCSE
  268 WCSK_
  268,t 0
  281,title WCSX
  274,line 24
  270 WCSM_
  269 WCSL_
  error,t 0
  271 WCSN_
  290,t 1
  289,t 1
  272 WCSO_
  258,line 8
  286,line 40
  273,t 0
  273 WCSP_
  266,title WCSI
  285,title MASK
  274 WCSQ_
  275 WCSR_
  271,line 21
  276 WCSS_
  277,t 0
  277 WCST_
  271,title WCSN
  290,title {}
  289,title {}
  283,line 33
  278 WCSU_
  261,t 0
  280 WCSW_
  279 WCSV_
  281 WCSX_
  267,line 17
  282,t 0
  282 WCSY_
  275,title WCSR
  283 WCSZ_
  265,t 0
  284 STRING_
  280,line 30
  279,line 29
  285 MASK_
  261,title WCSD
}

proc smosaicwcs::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 _ wcs }
                    2 { set _ wcsa }
                    3 { set _ wcsb }
                    4 { set _ wcsc }
                    5 { set _ wcsd }
                    6 { set _ wcse }
                    7 { set _ wcsf }
                    8 { set _ wcsg }
                    9 { set _ wcsh }
                    10 { set _ wcsi }
                    11 { set _ wcsj }
                    12 { set _ wcsk }
                    13 { set _ wcsl }
                    14 { set _ wcsm }
                    15 { set _ wcsn }
                    16 { set _ wcso }
                    17 { set _ wcsp }
                    18 { set _ wcsq }
                    19 { set _ wcsr }
                    20 { set _ wcss }
                    21 { set _ wcst }
                    22 { set _ wcsu }
                    23 { set _ wcsv }
                    24 { set _ wcsw }
                    25 { set _ wcsx }
                    26 { set _ wcsy }
                    27 { set _ wcsz }
                    29 { LoadSMosaicWCSFile $3 $4 $2 $1 }
                    30 { set _ wcs }
                    31 { set _ $1 }
                    33 { CreateFrame; set _ {} }
                    34 { set _ mask }
                }
                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 smosaicwcs::yyerror {msg} {
     variable yycnt
     variable yy_current_buffer
     variable index_

     ParserError $msg $yycnt $yy_current_buffer $index_
}
