summaryrefslogtreecommitdiffstats
path: root/tksao/frame/parser.Y
blob: 8618f6cd909a1b22de42dd8d84b9efc0664715e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
// Copyright (C) 1999-2018
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"

%pure-parser
%parse-param {Base* fr}
%lex-param {frFlexLexer* ll}
%parse-param {frFlexLexer* ll}

%{
#define YYDEBUG 1

#include <math.h>
#include <string.h>
#include <iostream>

#include "base.h"
#include "frame3d.h"
#include "fitsimage.h"
#include "fitsmask.h"
#include "marker.h"

#undef yyFlexLexer
#define yyFlexLexer frFlexLexer
#include <FlexLexer.h>

extern int frlex(void*, frFlexLexer*);
extern void frerror(Base*, frFlexLexer*, const char*);

static Coord::CoordSystem currentCoord = Coord::IMAGE;
static Coord::SkyFrame currentSky = Coord::FK5;

static unsigned short defaultProps = Marker::SELECT | Marker::HIGHLITE |
		Marker::EDIT | Marker::MOVE | Marker::ROTATE | 
		Marker::DELETE | Marker::INCLUDE | Marker::SOURCE;
static unsigned short currentProps;
static char currentColor[16];
static int currentWidth;
static int currentDash[2];
static char currentFont[32];
static char currentText[80];

static List<Tag> taglist;
static List<CallBack> cblist;

static unsigned short propQMask;
static unsigned short propQValue;

static void setProps(unsigned short* props, unsigned short prop, int value);
%}

%union {
#define FRBUFSIZE 4096
  char chr;
  char str[FRBUFSIZE];
  void* ptr;
  int integer;
  double real;
  double vector[3];
  int dash[2];
}

%type <real> numeric
%type <integer> yesno

%type <real> angle
%type <real> optangle
%type <real> sexagesimal
%type <real> hms
%type <real> dms
%type <vector> coord
%type <integer> coordSystem
%type <integer> wcsSystem
%type <integer> internalSystem
%type <integer> skyFrame
%type <integer> skyFormat
%type <integer> skyDist

%type <integer> markerProperty
%type <integer> markerCallBack
%type <integer> markerFormat
%type <integer> markerLayer
%type <dash> markerDash
%type <integer> maskType
%type <integer> pscolorspace
%type <integer> scaleType
%type <integer> minmaxMode
%type <integer> contourClipMode
%type <integer> contourClipScope
%type <integer> shmType
%type <integer> contourMethod
%type <integer> layerType
%type <integer> gridType
%type <integer> fileNameType
%type <integer> smoothFunction
%type <integer> pointShape
%type <integer> pointSize
%type <integer> endian
%type <integer> renderMethod
%type <integer> renderBackground
%type <integer> analysisMethod
%type <integer> analysisParam
%type <integer> cutMethod

%token <real> REAL
%token <integer> INT
%token <str> STRING
%token <ptr> POINTER

%token <real> ANGDEGREE
%token <real> ANGRADIAN

%token <str> SEXSTR
%token <str> HMSSTR
%token <str> DMSSTR

%token ABOUT_
%token AIP_
%token ALLOC_
%token ALLOCGZ_
%token ALIGN_
%token ALL_
%token ALT_
%token AMPLIFIER_
%token ANALYSIS_
%token ANGLE_
%token ANNULUS_
%token APPEND_
%token ARCMIN_
%token ARCSEC_
%token ARRAY_
%token ARROW_
%token ASINH_
%token AST_
%token AUTO_
%token AUX_
%token AVERAGE_
%token AXES_
%token AZIMUTH_
%token B1950_
%token BACK_
%token BACKGROUND_
%token BASE_
%token BBOX_
%token BEGIN_
%token BG_
%token BIG_
%token BIGENDIAN_
%token BIN_
%token BITPIX_
%token BLOCK_
%token BORDER_
%token BOX_
%token BOXANNULUS_
%token BOXCAR_
%token BOXCIRCLE_
%token BPANDA_
%token BUFFER_
%token BW_
%token CALLBACK_
%token CANVAS_
%token CATALOG_
%token CELESTIAL_
%token CENTER_
%token CENTROID_
%token CHANNEL_
%token CIRCLE_
%token CIAO_
%token CLEAR_
%token CLIP_
%token COLOR_
%token COLORBAR_
%token COLORMAP_
%token COLORSCALE_
%token COLORSPACE_
%token COLS_
%token COLUMN_
%token COMMAND_
%token COMPASS_
%token COMPOSITE_
%token COMPRESS_
%token CONTOUR_
%token CONTRAST_
%token COORDINATES_
%token COPY_
%token COUNT_
%token CPANDA_
%token CREATE_
%token CROP_
%token CROSS_
%token CROSSHAIR_
%token CUBE_
%token CURSOR_
%token CUT_
%token CMYK_
%token DASH_
%token DASHLIST_
%token DATA_
%token DATAMIN_
%token DATASEC_
%token DEBUG_
%token DEGREES_
%token DEFAULT_
%token DELETE_
%token DEPTH_
%token DETECTOR_
%token DIAMOND_
%token DIM_
%token DS9_
%token EDIT_
%token ECLIPTIC_
%token ELEVATION_
%token ELLIPTIC_
%token ELLIPSE_
%token ELLIPSEANNULUS_
%token END_
%token ENVI_
%token EPANDA_
%token EPSILON_
%token EQUATORIAL_
%token ERASE_
%token EXT_
%token FACTOR_
%token FALSE_
%token FILE_
%token FILL_
%token FILTER_
%token FIT_
%token FITS_
%token FITSY_
%token FIXED_
%token FK4_
%token FK5_
%token FONT_
%token FORMAT_
%token FROM_
%token FRONT_
%token FULL_
%token FUNCTION_
%token GALACTIC_
%token GAUSSIAN_
%token GET_
%token GLOBAL_
%token GRAPHICS_
%token GRAY_
%token GRID_
%token GZ_
%token HANDLE_
%token HAS_
%token HEAD_
%token HEADER_
%token HEIGHT_
%token HIDE_
%token HIGHLITE_
%token HISTEQU_
%token HISTOGRAM_
%token HORIZONTAL_
%token ICRS_
%token ID_
%token IIS_
%token IMAGE_
%token INCLUDE_
%token INCR_
%token INFO_
%token ITERATION_
%token IRAF_
%token IRAFMIN_
%token J2000_
%token KEY_
%token KEYWORD_
%token LABEL_
%token LENGTH_
%token LEVEL_
%token LITTLE_
%token LITTLEENDIAN_
%token LINE_
%token LINEAR_
%token LIST_
%token LOAD_
%token LOCAL_
%token LOG_
%token MACOSX_
%token MAGNIFIER_
%token MATCH_
%token MAP_
%token MARK_
%token MARKER_
%token MASK_
%token MESSAGE_
%token METHOD_
%token MINMAX_
%token MINOR_
%token MIP_
%token MMAP_
%token MMAPINCR_
%token MOSAIC_
%token MODE_
%token MOTION_
%token MOVE_
%token NAME_
%token NAN_
%token NATIVE_
%token NAXES_
%token NEW_
%token NEXT_
%token NO_
%token NONE_
%token NONNAN_
%token NONZERO_
%token NOW_
%token NRRD_
%token NUMBER_
%token OBJECT_
%token OFF_
%token ON_
%token ONLY_
%token OPTION_
%token ORIENT_
%token PAN_
%token PANNER_
%token PARSER_
%token PASTE_
%token PERF_
%token PHOTO_
%token PHYSICAL_
%token PIXEL_
%token PLOT2D_
%token PLOT3D_
%token POINT_
%token POINTER_
%token POLYGON_
%token POSTSCRIPT_
%token POW_
%token PRECISION_
%token PRINT_
%token PRESERVE_
%token PROJECTION_
%token PROPERTY_
%token PUBLICATION_
%token PROS_
%token QUERY_
%token RADIAL_
%token RADIUS_
%token RANGE_
%token REGION_
%token REPLACE_
%token RESAMPLE_
%token RESET_
%token RESOLUTION_
%token RGB_
%token ROOT_
%token ROTATE_
%token RULER_
%token SAMPLE_
%token SAOIMAGE_
%token SAOTNG_
%token SAVE_
%token SCALE_
%token SCAN_
%token SCIENTIFIC_
%token SCOPE_
%token SEGMENT_
%token SELECT_
%token SET_
%token SEXAGESIMAL_
%token SHAPE_
%token SHARED_
%token SHIFT_
%token SHMID_
%token SHOW_
%token SIGMA_
%token SINH_
%token SIZE_
%token SLICE_
%token SMMAP_
%token SMOOTH_
%token SOCKET_
%token SOCKETGZ_
%token SOURCE_
%token SQRT_
%token SQUARED_
%token SSHARED_
%token STATS_
%token STATUS_
%token SUM_
%token SYSTEM_
%token TABLE_
%token TAG_
%token TEMPLATE_
%token TEXT_
%token THREADS_
%token THREED_
%token THRESHOLD_
%token THICK_
%token TRANSPARENCY_
%token TO_
%token TOGGLE_
%token TOPHAT_
%token TRUE_
%token TYPE_
%token UNDO_
%token UNHIGHLITE_
%token UNLOAD_
%token UNSELECT_
%token UPDATE_
%token USER_
%token VALUE_
%token VAR_
%token VIEW_
%token VECTOR_
%token VERSION_
%token VERTEX_
%token VERTICAL_
%token WARP_
%token WCS_
%token WCSA_
%token WCSB_
%token WCSC_
%token WCSD_
%token WCSE_
%token WCSF_
%token WCSG_
%token WCSH_
%token WCSI_
%token WCSJ_
%token WCSK_
%token WCSL_
%token WCSM_
%token WCSN_
%token WCSO_
%token WCSP_
%token WCSQ_
%token WCSR_
%token WCSS_
%token WCST_
%token WCSU_
%token WCSV_
%token WCSW_
%token WCSX_
%token WCSY_
%token WCSZ_
%token WCS0_
%token WFPC2_
%token WIDTH_
%token WIN32_
%token XML_
%token XY_
%token YES_
%token ZERO_
%token ZMAX_
%token ZSCALE_
%token ZOOM_

%%

command : DEBUG_ debug
	| BIN_ bin
	| BG_ COLOR_ STRING {fr->bgColorCmd($3);}
        | BLOCK_ block
	| CENTER_ {fr->centerCmd();}
	| CLEAR_ {fr->clearCmd();}
	| CLIP_ clip
	| COLORBAR_ TAG_ STRING {fr->colorbarTagCmd($3);}
	| COLORMAP_ colormap
	| COLORSCALE_ colorscale
	| CONTOUR_ contour
	| CROP_ crop
	| CROSSHAIR_ crosshair
        | CUBE_ cube
	| DATASEC_ yesno {fr->DATASECCmd($2);}
	| FITSY_ fitsy
	| GET_ get
	| GRID_ grid
	| HAS_ has
	| HIDE_ {fr->hideCmd();}
	| HIGHLITE_ yesno {fr->highliteCmd($2);}
	| IIS_ iis
	| IRAF_ ALIGN_ INT {fr->irafAlignCmd($3);}
	| LOAD_ load
	| MACOSX_ macosx
	| MAGNIFIER_ magnifier
	| MATCH_ match
	| MARKER_ markerLayer marker
	| MASK_ mask
	| NAN_ COLOR_ STRING {fr->nanColorCmd($3);}
	| ORIENT_ orient
	| PAN_ pan
	| PANNER_ panner
	| QUERY_ CURSOR_ {fr->queryCursorCmd();}
        | PRECISION_ precision
	| POSTSCRIPT_ postscript
	| RESET_ {fr->resetCmd();}
	| REGION_ markerLayer region
	| RGB_ rgb
	| ROTATE_ rotate
	| SAVE_ save
	| SHOW_ {fr->showCmd();}
	| SMOOTH_ smooth
	| THREADS_ INT {fr->threadsCmd($2);}
	| THREED_ threed
	| UNLOAD_ {fr->unloadFitsCmd();}
	| UPDATE_ update
	| VERSION_ {fr->msg("Frame 1.0");}
	| WARP_ warp
	| WCS_ wcs
	| WIN32_ win32
	| ZOOM_ zoom
	;

numeric	: REAL {$$=$1;}
	| INT {$$=$1;}
	;

debug	: ON_ {yydebug=1;}
        | OFF_ {yydebug=0;}
	| MOSAIC_ yesno {DebugMosaic=$2;}
	| PARSER_ yesno {yydebug=$2;}
	| PERF_ yesno {DebugPerf=$2;}
	| WCS_ yesno {DebugWCS=$2;}
	| BIN_ yesno {DebugBin=$2;}
        | BLOCK_ yesno {DebugBlock=$2;}
        | COMPRESS_ yesno {DebugCompress=$2;}
        | CROP_ yesno {DebugCrop=$2;}
	| GZ_ yesno {DebugGZ=$2;}
	| RGB_ yesno {DebugRGB=$2;}
	;

yesno	: INT {$$=($1 ? 1 : 0);}

	| YES_ {$$=1;}
	| 'Y' {$$=1;}
	| ON_ {$$=1;}
	| TRUE_ {$$=1;}

	| NO_ {$$=0;}
	| 'N' {$$=0;}
	| OFF_ {$$=0;}
	| FALSE_ {$$=0;}
	;

fileNameType : /* empty */ {$$ = Base::ROOTBASE;}
	| ROOT_ BASE_ {$$ = Base::ROOTBASE;}
	| FULL_ BASE_ {$$ = Base::FULLBASE;}
	| ROOT_ {$$ = Base::ROOT;}
	| FULL_ {$$ = Base::FULL;}
	;

optangle : /* empty */ {$$ = 0;}
	| angle {$$ = $1;}
	;

angle	: numeric {$$ = zeroTWOPI(degToRad($1));} /* assume degree */
        | ANGDEGREE {$$ = zeroTWOPI(degToRad($1));}
	| ANGRADIAN {$$=$1;}
	;

sexagesimal: SEXSTR {$$ = parseSEXStr($1);}
	;

hms	: HMSSTR {$$ = parseHMSStr($1);}
	;

dms	: DMSSTR {$$ = parseDMSStr($1);}
	;

coord	: sexagesimal sexagesimal
	{
	  Vector r;
	  if (currentSky == Coord::GALACTIC || currentSky == Coord::ECLIPTIC) 
	    r = Vector($1,$2);
	  else
	    r = Vector($1*360./24.,$2);

	  $$[0] = r[0];
	  $$[1] = r[1];
	  $$[2] = r[2];
	}
	| hms dms
        {
	  Vector r = Vector($1,$2);
	  $$[0] = r[0];
	  $$[1] = r[1];
	  $$[2] = r[2];
	}
	| dms dms
        {
	  Vector r = Vector($1,$2);
	  $$[0] = r[0];
	  $$[1] = r[1];
	  $$[2] = r[2];
	}
	| numeric numeric 
	{
	  $$[0] = $1;
	  $$[1] = $2;
	  $$[2] = 1;
	}
	;

coordSystem :IMAGE_ {$$ = currentCoord = Coord::IMAGE;}
	| PHYSICAL_ {$$ = currentCoord = Coord::PHYSICAL;}
	| DETECTOR_ {$$ = currentCoord = Coord::DETECTOR;}
	| AMPLIFIER_ {$$ = currentCoord = Coord::AMPLIFIER;}
	| wcsSystem {$$ = (Coord::CoordSystem)$1;}
	;

wcsSystem : WCS_ {$$ = currentCoord = Coord::WCS;}
	| WCSA_ {$$ = currentCoord = Coord::WCSA;}
	| WCSB_ {$$ = currentCoord = Coord::WCSB;}
	| WCSC_ {$$ = currentCoord = Coord::WCSC;}
	| WCSD_ {$$ = currentCoord = Coord::WCSD;}
	| WCSE_ {$$ = currentCoord = Coord::WCSE;}
	| WCSF_ {$$ = currentCoord = Coord::WCSF;}
	| WCSG_ {$$ = currentCoord = Coord::WCSG;}
	| WCSH_ {$$ = currentCoord = Coord::WCSH;}
	| WCSI_ {$$ = currentCoord = Coord::WCSI;}
	| WCSJ_ {$$ = currentCoord = Coord::WCSJ;}
	| WCSK_ {$$ = currentCoord = Coord::WCSK;}
	| WCSL_ {$$ = currentCoord = Coord::WCSL;}
	| WCSM_ {$$ = currentCoord = Coord::WCSM;}
	| WCSN_ {$$ = currentCoord = Coord::WCSN;}
	| WCSO_ {$$ = currentCoord = Coord::WCSO;}
	| WCSP_ {$$ = currentCoord = Coord::WCSP;}
	| WCSQ_ {$$ = currentCoord = Coord::WCSQ;}
	| WCSR_ {$$ = currentCoord = Coord::WCSR;}
	| WCSS_ {$$ = currentCoord = Coord::WCSS;}
	| WCST_ {$$ = currentCoord = Coord::WCST;}
	| WCSU_ {$$ = currentCoord = Coord::WCSU;}
	| WCSV_ {$$ = currentCoord = Coord::WCSV;}
	| WCSW_ {$$ = currentCoord = Coord::WCSW;}
	| WCSX_ {$$ = currentCoord = Coord::WCSX;}
	| WCSY_ {$$ = currentCoord = Coord::WCSY;}
	| WCSZ_ {$$ = currentCoord = Coord::WCSZ;}
	| WCS0_ {$$ = currentCoord = Coord::WCS0;}
	;

internalSystem : CANVAS_ {$$ = Coord::CANVAS;}
	| PANNER_ {$$ = Coord::PANNER;}
	;

maskType : /* empty */ {$$ = FitsMask::NONZERO;}
	| ZERO_ {$$ = FitsMask::ZERO;}
	| NONZERO_ {$$ = FitsMask::NONZERO;}
	| NAN_ {$$ = FitsMask::NaN;}
	| NONNAN_ {$$ = FitsMask::NONNaN;}
	| RANGE_ {$$ = FitsMask::RANGE;}
	;

scaleType: LINEAR_ {$$ = FrScale::LINEARSCALE;}
	| LOG_ {$$ = FrScale::LOGSCALE;}
	| POW_ {$$ = FrScale::POWSCALE;}
	| SQRT_ {$$ = FrScale::SQRTSCALE;}
	| SQUARED_ {$$ = FrScale::SQUAREDSCALE;}
	| ASINH_ {$$ = FrScale::ASINHSCALE;}
	| SINH_ {$$ = FrScale::SINHSCALE;}
	| HISTEQU_ {$$ = FrScale::HISTEQUSCALE;}
	;	

minmaxMode : AUTO_ {$$=FrScale::SCAN;}
	| SCAN_ {$$=FrScale::SCAN;}
	| SAMPLE_ {$$=FrScale::SAMPLE;}
	| DATAMIN_ {$$=FrScale::DATAMIN;}
	| IRAFMIN_ {$$=FrScale::IRAFMIN;}
        ;

skyFrame : /* empty */ {$$ = currentSky = Coord::FK5;}
	| FK4_ {$$ = currentSky = Coord::FK4;}
	| B1950_ {$$ = currentSky = Coord::FK4;}
	| FK5_ {$$ = currentSky = Coord::FK5;}
	| J2000_ {$$ = currentSky = Coord::FK5;}
	| ICRS_ {$$ = currentSky = Coord::ICRS;}
	| GALACTIC_ {$$ = currentSky = Coord::GALACTIC;}
	| ECLIPTIC_ {$$ = currentSky = Coord::ECLIPTIC;}
	;

skyFormat : /* empty */ {$$=Coord::DEGREES;}
	| DEGREES_ {$$=Coord::DEGREES;}
	| SEXAGESIMAL_ {$$=Coord::SEXAGESIMAL;}
	;

skyDist : /* empty */ {$$=Coord::DEGREE;}
	| DEGREES_ {$$=Coord::DEGREE;}
	| ARCMIN_ {$$=Coord::ARCMIN;}
	| ARCSEC_ {$$=Coord::ARCSEC;}
	;

shmType	: /* empty */ {$$ = Base::SHMID;}
	| SHMID_ {$$ = Base::SHMID;}
	| KEY_ {$$ = Base::KEY;}
	;

incrLoad: /*backward compatibility*/ {}
        | ALL_ {}
        | INCR_ {}
	;

layerType : /* empty */ {$$ = Base::IMG;}
	| IMAGE_ {$$ = Base::IMG;}
	| MASK_ {$$ = Base::MASK;}
	;

pointShape: /* empty */ {$$ = Point::CIRCLE;}
	| CIRCLE_  {$$ = Point::CIRCLE;}
	| BOX_ {$$ = Point::BOX;}
	| DIAMOND_ {$$ = Point::DIAMOND;}
	| CROSS_ {$$ = Point::CROSS;}
	| 'X' {$$ = Point::EX;}
	| ARROW_ {$$ = Point::ARROW;}
	| BOXCIRCLE_ {$$ = Point::BOXCIRCLE;}
	;

pointSize: /* empty */ {$$ = POINTSIZE;}
	| INT {$$ = $1;}
	;

analysisMethod: CPANDA_ {$$ = Marker::PANDA;}
        | HISTOGRAM_ {$$ = Marker::HISTOGRAM;}
	| PLOT2D_ {$$ = Marker::PLOT2D;}
	| PLOT3D_ {$$ = Marker::PLOT3D;}
	| RADIAL_ {$$ = Marker::RADIAL;}
	| STATS_ {$$ = Marker::STATS;}
	;

analysisParam : /* emtpy */ {$$ = Marker::AVERAGE;}
	| AVERAGE_  {$$ = Marker::AVERAGE;}
	| SUM_  {$$ = Marker::SUM;}
	;

endian	: /* empty */ {$$ = FitsFile::NATIVE;}
	| NATIVE_ {$$ = FitsFile::NATIVE;}
	| BIG_ {$$ = FitsFile::BIG;}
	| BIGENDIAN_ {$$ = FitsFile::BIG;}
	| LITTLE_ {$$ = FitsFile::LITTLE;}
	| LITTLEENDIAN_ {$$ = FitsFile::LITTLE;}
	;

threed	: VIEW_ threedView
	| BORDER_ threedBorder
	| COMPASS_ threedCompass
	| HIGHLITE_ threedHighlite
	| METHOD_ renderMethod {fr->set3dRenderMethodCmd($2);}
	| BACKGROUND_ renderBackground {fr->set3dRenderBackgroundCmd($2);}
	| SCALE_ numeric {fr->set3dScaleCmd($2);}
        | PRESERVE_ {fr->set3dPreserveCmd();}
	| THRESHOLD_ numeric 
	  {/* needed for compatibility with old version of backup */}
	;

threedBorder : yesno {fr->set3dBorderCmd($1);}
	| COLOR_ STRING {fr->set3dBorderColorCmd($2);}
	;

threedCompass : yesno {fr->set3dCompassCmd($1);}
	| COLOR_ STRING {fr->set3dCompassColorCmd($2);}
	;

threedHighlite : yesno {fr->set3dHighliteCmd($1);}
	| COLOR_ STRING {fr->set3dHighliteColorCmd($2);}
	;

threedView : numeric numeric {fr->set3dViewCmd($1,$2);}
	| POINT_ numeric numeric numeric numeric numeric
	  {fr->set3dViewPointCmd(Vector3d($2,$3,$4),Vector($5,$6));}
	;

bin	: ABOUT_ binAbout
	| COLS_ STRING STRING STRING {fr->binColsCmd($2,$3,$4);}
	| DEPTH_ INT {fr->binDepthCmd($2);}
	| FACTOR_ binFactor
	| FUNCTION_ binFunction
	| BUFFER_ SIZE_ INT {fr->binBufferSizeCmd($3);}
	| TO_ binTo
	| FILTER_ STRING {fr->binFilterCmd($2);}
	;

binAbout : CENTER_ {fr->binAboutCmd();}
	| numeric numeric {fr->binAboutCmd(Vector($1,$2));}
	;

binFactor : numeric {fr->binFactorCmd(Vector($1,$1));}
	| numeric numeric {fr->binFactorCmd(Vector($1,$2));}
	| numeric ABOUT_ numeric numeric
	{fr->binFactorAboutCmd(Vector($1,$1), Vector($3,$4));}
	| numeric numeric ABOUT_ numeric numeric
	{fr->binFactorAboutCmd(Vector($1,$2), Vector($4,$5));}
	| TO_ numeric {fr->binFactorToCmd(Vector($2,$2));}
	| TO_ numeric numeric {fr->binFactorToCmd(Vector($2,$3));}
	| TO_ numeric ABOUT_ numeric numeric
	{fr->binFactorToAboutCmd(Vector($2,$2), Vector($4,$5));}
	| TO_ numeric numeric ABOUT_ numeric numeric
	{fr->binFactorToAboutCmd(Vector($2,$3), Vector($5,$6));}
	;

binFunction : AVERAGE_ {fr->binFunctionCmd(FitsHist::AVERAGE);}
	| SUM_ {fr->binFunctionCmd(FitsHist::SUM);}
	;

binTo	: FIT_ {fr->binToFitCmd();}
	| numeric numeric ABOUT_ CENTER_ STRING STRING STRING 
	{fr->binCmd(Vector($1,$2), $5, $6, $7);}
	| numeric numeric INT numeric numeric ABOUT_ CENTER_ 
	    STRING STRING STRING STRING
	{fr->binCmd(Vector($1,$2), $3, Vector($4,$5), $8, $9, $10, $11);}
	| numeric numeric ABOUT_ numeric numeric STRING STRING STRING 
	{fr->binCmd(Vector($1,$2), Vector($4,$5), $6, $7, $8);}
	| numeric numeric INT numeric numeric ABOUT_ numeric numeric 
	    STRING STRING STRING STRING
	{fr->binCmd(Vector($1,$2), $3, Vector($4,$5), Vector($7,$8), 
	    $9, $10, $11, $12);}
	;

block	: numeric {fr->blockCmd(Vector($1,$1));}
        | numeric numeric {fr->blockCmd(Vector($1,$2));}
        | TO_ blockTo
	;

blockTo : FIT_ {fr->blockToFitCmd();}
        | numeric {fr->blockToCmd(Vector($1,$1));}
        | numeric numeric {fr->blockToCmd(Vector($1,$2));}
        ;

clip	: SCOPE_ clipScope
	| MODE_ clipMode
	| MINMAX_ clipMinMax
	| USER_ numeric numeric {fr->clipUserCmd($2,$3);}
	| USER_ NAN_ NAN_ {fr->clipUserCmd(NAN,NAN);}
        | ZSCALE_ clipZScale
 	| PRESERVE_ yesno
        {
	  // backward compatibility with backup
	}
	;

clipScope: GLOBAL_ {fr->clipScopeCmd(FrScale::GLOBAL);}
	| LOCAL_ {fr->clipScopeCmd(FrScale::LOCAL);}
	;

clipMode: numeric {fr->clipModeCmd($1);}
	| MINMAX_ {fr->clipModeCmd(FrScale::MINMAX);}
	| ZSCALE_ {fr->clipModeCmd(FrScale::ZSCALE);}
	| ZMAX_ {fr->clipModeCmd(FrScale::ZMAX);}
	| USER_ {fr->clipModeCmd(FrScale::USERCLIP);}
	;

clipMinMax : INT minmaxMode {fr->clipMinMaxCmd((FrScale::MinMaxMode)$2,$1);}
        | MODE_ minmaxMode {fr->clipMinMaxModeCmd((FrScale::MinMaxMode)$2);}
	| SAMPLE_ INT {fr->clipMinMaxSampleCmd($2);}
	;

clipZScale: numeric INT INT {fr->clipZScaleCmd($1,$2,$3);}
        | CONTRAST_ numeric
	{
	  // backward compatibility with backup
	  fr->clipZScaleContrastCmd($2);
        }
        | SAMPLE_ INT
	{
	  // backward compatibility with backup
	  fr->clipZScaleSampleCmd($2);
        }
        | LINE_ INT
	{
	  // backward compatibility with backup
	  fr->clipZScaleLineCmd($2);
        }
	;

colormap : INT numeric numeric INT POINTER INT 
        {fr->colormapCmd($1, $2, $3, $4, (unsigned char*)$5, $6);}
	| RGB_ numeric numeric numeric numeric numeric numeric INT POINTER INT
	{fr->colormapCmd($2,$3,$4,$5,$6,$7,$8,(unsigned char*)$9,$10);}
	| BEGIN_ {fr->colormapBeginCmd();}
	| MOTION_ colormapMotion
	| END_ {fr->colormapEndCmd();}
	;

colormapMotion: INT numeric numeric INT POINTER INT
	{fr->colormapMotionCmd($1, $2, $3, $4, (unsigned char*)$5, $6);}
	| RGB_ numeric numeric numeric numeric numeric numeric INT POINTER INT
	{fr->colormapMotionCmd($2,$3,$4,$5,$6,$7,$8,(unsigned char*)$9,$10);}

colorscale : scaleType {fr->colorScaleCmd((FrScale::ColorScaleType)$1);}
	| LOG_ numeric {fr->colorScaleLogCmd($2);}
	;

contour	: CREATE_ contourCreate
	| DELETE_ contourDelete
        | LOAD_ contourLoad
        | PASTE_ contourPaste
	| SAVE_ contourSave
	;

contourCreate : STRING INT INT contourMethod INT INT scaleType numeric contourClipMode contourClipScope numeric numeric STRING
{fr->contourCreateCmd($1,$2,$3,(FVContour::Method)$4,$5,$6,(FrScale::ColorScaleType)$7,$8,(FrScale::ClipMode)$9,100,(FrScale::ClipScope)$10,$11,$12,$13);}
        | STRING INT INT contourMethod INT INT scaleType numeric numeric contourClipScope numeric numeric STRING
	{fr->contourCreateCmd($1,$2,$3,(FVContour::Method)$4,$5,$6,(FrScale::ColorScaleType)$7,$8,FrScale::AUTOCUT,$9,(FrScale::ClipScope)$10,$11,$12,$13);}
        | STRING INT INT contourMethod INT INT scaleType numeric contourClipMode numeric numeric STRING
        {
	  // backward compatibility with backup
	  fr->contourCreateCmd($1,$2,$3,(FVContour::Method)$4,$5,$6,(FrScale::ColorScaleType)$7,$8,(FrScale::ClipMode)$9,100,FrScale::LOCAL,$10,$11,$12);
	}
        | STRING INT INT contourMethod INT INT scaleType numeric numeric numeric numeric STRING
	{
	  // backward compatibility with backup
	  fr->contourCreateCmd($1,$2,$3,(FVContour::Method)$4,$5,$6,(FrScale::ColorScaleType)$7,$8,FrScale::AUTOCUT,$9,FrScale::LOCAL,$10,$11,$12);
	}
	| POLYGON_ {fr->contourCreatePolygonCmd();}
	;

contourDelete : /*empty */ {fr->contourDeleteCmd();}
        | AUX_ {fr->contourDeleteAuxCmd();}
        ;

contourLoad : STRING {fr->contourLoadCmd($1);}
        | STRING STRING INT yesno {fr->contourLoadCmd($1,$2,$3,$4);}
        | STRING INT yesno STRING coordSystem skyFrame 
	{
	  // backward compatibility with backup
	  fr->contourLoadCmd($4,(Coord::CoordSystem)$5,(Coord::SkyFrame)$6,$1,$2,$3);
	}
        ;

contourClipMode: MINMAX_ {$$ = FrScale::MINMAX;}
	| ZSCALE_ {$$ = FrScale::ZSCALE;}
	| ZMAX_ {$$ = FrScale::ZMAX;}
	| USER_ {$$ = FrScale::USERCLIP;}
	;

contourClipScope: GLOBAL_ {$$ = FrScale::GLOBAL;}
	| LOCAL_ {$$ = FrScale::LOCAL;}
	;

contourMethod : SMOOTH_ {$$ = FVContour::SMOOTH;}
	| BLOCK_ {$$ = FVContour::BLOCK;}
	;

contourPaste : STRING {fr->contourPasteCmd($1);}
        | STRING STRING INT yesno {fr->contourPasteCmd($1,$2,$3,$4);}
        ;

contourSave : STRING coordSystem skyFrame
	{fr->contourSaveCmd($1, (Coord::CoordSystem)$2, (Coord::SkyFrame)$3);}
        | AUX_ STRING coordSystem skyFrame
	{fr->contourSaveAuxCmd($2,(Coord::CoordSystem)$3,(Coord::SkyFrame)$4);}
        ;

crop	: /* empty */ {fr->cropCmd();}
	| numeric numeric numeric numeric coordSystem skyFrame
	{fr->cropCmd(Vector($1,$2), Vector($3,$4),
	    (Coord::CoordSystem)$5, (Coord::SkyFrame)$6);}
	| CENTER_ coord coordSystem skyFrame numeric numeric coordSystem skyDist
	{fr->cropCenterCmd(Vector($2), (Coord::CoordSystem)$3, (Coord::SkyFrame)$4, Vector($5,$6), (Coord::CoordSystem)$7, (Coord::DistFormat)$8);}
	| THREED_ crop3d
	| BEGIN_ numeric numeric {fr->cropBeginCmd(Vector($2,$3));}
	| MOTION_ numeric numeric {fr->cropMotionCmd(Vector($2,$3));}
	| END_ numeric numeric {fr->cropEndCmd(Vector($2,$3));}
	;

crop3d	: /* empty */ {fr->crop3dCmd();}
	| numeric numeric coordSystem skyFrame
	{fr->crop3dCmd($1, $2, (Coord::CoordSystem)$3, (Coord::SkyFrame)$4);}
	| BEGIN_ numeric numeric INT {fr->crop3dBeginCmd(Vector($2,$3),$4);}
	| MOTION_ numeric numeric INT {fr->crop3dMotionCmd(Vector($2,$3),$4);}
	| END_ numeric numeric INT {fr->crop3dEndCmd(Vector($2,$3),$4);}
	;

crosshair: internalSystem numeric numeric
	{fr->crosshairCmd(Vector($2,$3), (Coord::InternalSystem)$1);}
	| coordSystem skyFrame coord
	{fr->crosshairCmd(Vector($3), (Coord::CoordSystem)$1, (Coord::SkyFrame)$2);}
	| yesno {fr->crosshairCmd($1);}
	| WARP_ numeric numeric {fr->crosshairWarpCmd(Vector($2,$3));}

	| BEGIN_ MOTION_ internalSystem numeric numeric
	{fr->crosshairCmd(Vector($4,$5), (Coord::InternalSystem)$3);}
	| MOTION_ internalSystem numeric numeric
	{fr->crosshairCmd(Vector($3,$4), (Coord::InternalSystem)$2);}
	| BEGIN_ MOTION_ coordSystem coord
	{fr->crosshairCmd(Vector($4), (Coord::CoordSystem)$3);}
	| MOTION_ coordSystem coord
	{fr->crosshairCmd(Vector($3), (Coord::CoordSystem)$2);}
	;

cube    : AXES_ INT {fr->axesOrderCmd($2);}
        ;

cutMethod : /* emtpy */ {$$ = Base::AVERAGE;}
	| AVERAGE_  {$$ = Base::AVERAGE;}
	| SUM_  {$$ = Base::SUM;}
	;

fitsy	: HAS_ EXT_ STRING {fr->fitsyHasExtCmd($3);}
	;

get	: BG_ COLOR_ {fr->getBgColorCmd();}
	| BIN_ getBin
        | BLOCK_ getBlock
	| CLIP_ getClip
	| COLORMAP_ getColorMap
	| COLORBAR_ getColorbar
	| COLORSCALE_ getColorScale
	| CONTOUR_ getContour
	| COORDINATES_ getCoord
	| CROP_ getCrop
	| CROSSHAIR_ getCrosshair
	| CURSOR_ getCursor
	| CUBE_ getCube
	| DATA_ getData
	| DATASEC_ {fr->getDATASECCmd();}
	| FITS_ getFits
	| GRID_ getGrid
	| HISTOGRAM_ STRING STRING INT {fr->getHistogramCmd($2,$3,$4);}
	| HORIZONTAL_ CUT_ STRING STRING numeric numeric internalSystem INT cutMethod
	{fr->getHorzCutCmd($3,$4,Vector($5,$6),(Coord::InternalSystem)$7,$8,(Base::CutMethod)$9);}
	| IIS_ getiis
	| INFO_ getInfo
	| IRAF_ ALIGN_ {fr->getIRAFAlignCmd();}
	| MINMAX_ {fr->getMinMaxCmd();}
	| MARKER_ markerLayer markerGet
	| MASK_ getMask
	| NAN_ COLOR_ {fr->getNANColorCmd();}
	| ORIENT_ {fr->getOrientCmd();}
	| PAN_ getPan
	| PIXEL_ TABLE_ internalSystem numeric numeric INT INT STRING
	{fr->getPixelTableCmd(Vector($4,$5), (Coord::InternalSystem)$3, $6, $7, $8);}
	| RGB_ getRGB
	| ROTATE_ {fr->getRotateCmd();}
	| SMOOTH_ getSmooth
	| THREADS_ {fr->getThreadsCmd();}
	| THREED_ getThreed
	| TYPE_ {fr->getTypeCmd();}
	| VALUE_ internalSystem numeric numeric
	{fr->getValueCmd(Vector($3,$4),(Coord::InternalSystem)$2);}
	| VERTICAL_ CUT_ STRING STRING numeric numeric internalSystem INT cutMethod
	{fr->getVertCutCmd($3,$4,Vector($5,$6),(Coord::InternalSystem)$7,$8,(Base::CutMethod)$9);}
	| WCS_ getWCS
	| ZOOM_ {fr->getZoomCmd();}
	;

getBin	: DEPTH_ {fr->getBinDepthCmd();}
	| FACTOR_ {fr->getBinFactorCmd();}
	| FUNCTION_ {fr->getBinFunctionCmd();}
	| BUFFER_ SIZE_ {fr->getBinBufferSizeCmd();}
	| CURSOR_ {fr->getBinCursorCmd();}
	| FILTER_ {fr->getBinFilterCmd();}
	| COLS_ getBinCols
	| LIST_ {fr->getBinListCmd();}
	;

getBinCols : /* empty */ {fr->getBinColsCmd();}
	| MINMAX_ STRING {fr->getBinColsMinMaxCmd($2);}
	| DIM_ STRING {fr->getBinColsDimCmd($2);}
	;

getBlock : FACTOR_  {fr->getBlockCmd();}
	;

getClip	: {fr->getClipCmd();}
        | contourClipMode contourClipScope 
	{fr->getClipCmd((FrScale::ClipMode)$1, (FrScale::ClipScope)$2);}
        | numeric contourClipScope 
	{fr->getClipCmd($1, (FrScale::ClipScope)$2);}
	| SCOPE_ {fr->getClipScopeCmd();}
	| MODE_ {fr->getClipModeCmd();}
	| MINMAX_ getClipMinMax
	| USER_ LEVEL_ {fr->getClipUserCmd();}
	| ZSCALE_ getClipZScale
 	| PRESERVE_ 
	{
	  // backward compatibility with backup
	  fr->getClipPreserveCmd();
	}
	;

getClipMinMax : MODE_ {fr->getClipMinMaxModeCmd();}
	| SAMPLE_ {fr->getClipMinMaxSampleCmd();}
	;

getClipZScale: CONTRAST_ {fr->getClipZScaleContrastCmd();}
	| SAMPLE_ {fr->getClipZScaleSampleCmd();}
	| LINE_ {fr->getClipZScaleLineCmd();}
	;

getColorbar: /* empty */ {fr->getColorbarCmd();}
	| TAG_ {fr->getColorbarTagCmd();}
	;

getColorMap : LEVEL_ getColorMapLevel
	;

getColorMapLevel: INT {fr->getColorMapLevelCmd($1);}
	| INT internalSystem numeric numeric
	{fr->getColorMapLevelCmd($1,Vector($3,$4),(Coord::InternalSystem)$2);}
	| INT numeric numeric scaleType numeric
	{fr->getColorMapLevelCmd($1,$2,$3,(FrScale::ColorScaleType)$4,$5);}
	;

getColorScale : /* empty */ {fr->getColorScaleCmd();}
	| LEVEL_ getColorScaleLevel
	| LOG_ {fr->getColorScaleLogCmd();}
	;

getColorScaleLevel: INT numeric numeric scaleType numeric
        {fr->getColorScaleLevelCmd($1,$2,$3,(FrScale::ColorScaleType)$4,$5);}
	;

getContour: coordSystem skyFrame 
	{fr->getContourCmd((Coord::CoordSystem)$1,(Coord::SkyFrame)$2);}
	| CLIP_ getContourClip
	| COLOR_ {fr->getContourColorNameCmd();}
	| DASH_ {fr->getContourDashCmd();}
	| LEVEL_ {fr->getContourLevelCmd();}
	| NUMBER_ LEVEL_ {fr->getContourNumLevelCmd();}
	| METHOD_ {fr->getContourMethodCmd();}
	| COLORSCALE_ getContourColorScale
	| SMOOTH_ {fr->getContourSmoothCmd();}
	| WIDTH_ {fr->getContourLineWidthCmd();}
	;

getContourClip : /* empty */ {fr->getContourClipCmd();}
	| MODE_ {fr->getContourClipModeCmd();}
	| SCOPE_ {fr->getContourClipScopeCmd();}
	;

getContourColorScale : /* empty */ {fr->getContourScaleCmd();}
	| LOG_ {fr->getContourScaleLogCmd();}
	;

getCoord : numeric numeric coordSystem skyFrame skyFormat
	{fr->getCoordCmd(Vector($1,$2), (Coord::CoordSystem)$3, (Coord::SkyFrame)$4, (Coord::SkyFormat)$5);}
	| internalSystem numeric numeric coordSystem skyFrame skyFormat
	{
	  // backward compatibility
	  fr->getCoordCmd(Vector($2,$3), (Coord::CoordSystem)$4, (Coord::SkyFrame)$5,
	    (Coord::SkyFormat)$6);
	}
	;

getCrop	: coordSystem skyFrame skyFormat
        {fr->getCropCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, (Coord::SkyFormat)$3);}
	| CENTER_ coordSystem skyFrame skyFormat coordSystem skyDist
	{fr->getCropCenterCmd((Coord::CoordSystem)$2, (Coord::SkyFrame)$3, (Coord::SkyFormat)$4, (Coord::CoordSystem)$5, (Coord::DistFormat)$6);}
	| THREED_ coordSystem skyFrame
	{fr->getCrop3dCmd((Coord::CoordSystem)$2, (Coord::SkyFrame)$3);}
	;

getCrosshair: internalSystem {fr->getCrosshairCmd((Coord::InternalSystem)$1);}
	| coordSystem skyFrame skyFormat
	{fr->getCrosshairCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, (Coord::SkyFormat)$3);}
	| STATUS_ {fr->getCrosshairStatusCmd();}
	;

getCube : AXES_ {fr->getAxesOrderCmd();}
        ;

getCursor : internalSystem {fr->getCursorCmd((Coord::InternalSystem)$1);}
	| coordSystem skyFrame skyFormat
	{fr->getCursorCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, (Coord::SkyFormat)$3);}
	;

getData	: coordSystem skyFrame coord numeric numeric STRING
	{fr->getDataValuesCmd(1, Vector($3), (Coord::CoordSystem)$1, (Coord::SkyFrame)$2, Vector($4,$5), $6);}
	| INT coordSystem skyFrame coord numeric numeric STRING
	{fr->getDataValuesCmd($1, Vector($4), 
	    (Coord::CoordSystem)$2, (Coord::SkyFrame)$3, Vector($5,$6), $7);}
	| internalSystem numeric numeric INT INT
	{fr->getDataValuesCmd(Vector($2,$3),(Coord::InternalSystem)$1,
	    Vector($4,$5));}
	;

getInfo	: STRING {fr->getInfoCmd($1);}
	| CLIP_ {fr->getInfoClipCmd();}
 	| internalSystem numeric numeric STRING
	{fr->getInfoCmd(Vector($2,$3), (Coord::InternalSystem)$1, $4);}
	;

getiis	: POINTER INT INT INT INT {fr->iisGetCmd((char*)$1,$2,$3,$4,$5);}
	| CURSOR_ {fr->iisGetCursorCmd();}
	| FILE_ NAME_ getIISFileName
	;

getIISFileName : /* empty */ {fr->iisGetFileNameCmd();}
	| INT {fr->iisGetFileNameCmd($1);}
	| numeric numeric {fr->iisGetFileNameCmd(Vector($1,$2));}
	;

getFits	: NAXES_ /* empty */ {fr->getFitsNAxesCmd();}
	| CENTER_ coordSystem skyFrame skyFormat
	{fr->getFitsCenterCmd((Coord::CoordSystem)$2,(Coord::SkyFrame)$3,(Coord::SkyFormat)$4);}
	| COUNT_ {fr->getFitsCountCmd();}
	| DEPTH_ getFitsDepth
	| BITPIX_ {fr->getBitpixCmd();}
	| EXT_ getFitsExt
	| FILE_ NAME_ getFitsFileName
	| HEADER_ getFitsHeader
	| HEIGHT_ {fr->getFitsHeightCmd();}
	| OBJECT_ NAME_ {fr->getFitsObjectNameCmd();}
	| SIZE_ {fr->getFitsSizeCmd();}
	| SIZE_ coordSystem skyFrame skyDist
	{fr->getFitsSizeCmd((Coord::CoordSystem)$2,(Coord::SkyFrame)$3,(Coord::DistFormat)$4);}
	| SLICE_ getFitsSlice
	| WIDTH_ {fr->getFitsWidthCmd();}
	;

getFitsExt : INT {fr->getFitsExtCmd($1);}
	| internalSystem numeric numeric
	{fr->getFitsExtCmd(Vector($2,$3),(Coord::InternalSystem)$1);}

getFitsHeader : INT {fr->getFitsHeaderCmd($1);}
	| KEYWORD_ STRING {fr->getFitsHeaderKeywordCmd(1,$2);}
	| INT KEYWORD_ STRING {fr->getFitsHeaderKeywordCmd($1,$3);}
	| WCS_ INT {fr->getFitsHeaderWCSCmd($2);}
	;

getFitsDepth : /* empty */ {fr->getFitsDepthCmd(2);}
	;

getFitsFileName: fileNameType 
	{fr->getFitsFileNameCmd((Base::FileNameType)$1);}
	| fileNameType internalSystem numeric numeric
	{fr->getFitsFileNameCmd(Vector($3,$4), (Coord::InternalSystem)$2,
	    (Base::FileNameType)$1);}
	| fileNameType INT 
	{fr->getFitsFileNameCmd($2, (Base::FileNameType)$1);}
	;

getFitsSlice : /* empty */ {fr->getFitsSliceCmd();}
        | FROM_ IMAGE_ coordSystem skyFrame
	{fr->getFitsSliceFromImageCmd((Coord::CoordSystem)$3, (Coord::SkyFrame)$4);}
        | FROM_ IMAGE_ INT coordSystem skyFrame
	{fr->getFitsSliceFromImageCmd($3, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);}
        | TO_ IMAGE_ numeric coordSystem skyFrame
	{fr->getFitsSliceToImageCmd($3, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);}
	;

getGrid : /* empty */ {fr->getGridCmd();}
	| OPTION_ {fr->getGridOptionCmd();}
	| VAR_ {fr->getGridVarsCmd();}
	;

getMask	: COLOR_ {fr->getMaskColorCmd();}
	| MARK_ {fr->getMaskMarkCmd();}
	| RANGE_ {fr->getMaskRangeCmd();}
        | SYSTEM_ {fr->getMaskSystemCmd();}
	| TRANSPARENCY_ {fr->getMaskTransparencyCmd();}
	| COUNT_ {fr->getMaskCountCmd();}
	;

getPan : PRESERVE_ {fr->getPanPreserveCmd();}
	;

getRGB	: CHANNEL_ {fr->getRGBChannelCmd();}
	| SYSTEM_ {fr->getRGBSystemCmd();}
	| VIEW_ {fr->getRGBViewCmd();}
	;

getSmooth : FUNCTION_  {fr->getSmoothFunctionCmd();}
	| RADIUS_ {fr->getSmoothRadiusCmd();}
	| RADIUS_ MINOR_ {fr->getSmoothRadiusMinorCmd();}
	| SIGMA_ {fr->getSmoothSigmaCmd();}
	| SIGMA_ MINOR_ {fr->getSmoothSigmaMinorCmd();}
	| ANGLE_ {fr->getSmoothAngleCmd();}
	;

getThreed : VIEW_ getThreedView
	| BORDER_ getThreedBorder
	| COMPASS_ getThreedCompass
	| HIGHLITE_ getThreedHighlite
	| METHOD_ {fr->get3dRenderMethodCmd();}
        | BACKGROUND_ {fr->get3dRenderBackgroundCmd();}
	| SCALE_ {fr->get3dScaleCmd();}
	;

getThreedBorder : {fr->get3dBorderCmd();}
	| COLOR_ {fr->get3dBorderColorCmd();}
	;

getThreedCompass : {fr->get3dCompassCmd();}
	| COLOR_ {fr->get3dCompassColorCmd();}
	;

getThreedHighlite : {fr->get3dHighliteCmd();}
	| COLOR_ {fr->get3dHighliteColorCmd();}
	;

getThreedView : {fr->get3dViewCmd();}
	| POINT_ {fr->get3dViewPointCmd();}
	;

getWCS	: /* empty */ {fr->getWCSCmd();}
	| ALIGN_ getWCSAlign
	| NAME_ wcsSystem {fr->getWCSNameCmd((Coord::CoordSystem)$2);}
	;

getWCSAlign : /* empty */ {fr->getWCSAlignCmd();}
	| POINTER_ {fr->getWCSAlignPointerCmd();}
	;

grid	: CREATE_ gridCreate
	| DELETE_ {fr->gridDeleteCmd();}
	;

gridCreate: coordSystem skyFrame skyFormat gridType STRING STRING
        {fr->gridCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, 
	    (Coord::SkyFormat)$3, (Grid2d::GridType)$4, $5, $6);}
        | coordSystem skyFrame skyFormat gridType STRING
	{
	  // backward compatibility with backup
	  fr->gridCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, 
		      (Coord::SkyFormat)$3, (Grid2d::GridType)$4, $5, "");
	}
        ;

gridType : ANALYSIS_ {$$=Grid2d::ANALYSIS;}
	| PUBLICATION_ {$$=Grid2d::PUBLICATION;}
	;

has	: AMPLIFIER_ {fr->hasAmplifierCmd();}
	| BIN_ hasBin
	| CONTOUR_ hasContour
	| CROP_ {fr->hasCropCmd();}
	| DATAMIN_ {fr->hasDATAMINCmd();}
	| DATASEC_ {fr->hasDATASECCmd();}
	| DETECTOR_ {fr->hasDetectorCmd();}
	| FITS_ hasFits
	| GRID_ {fr->hasGridCmd();}
	| IIS_ {fr->hasIISCmd();}
	| IRAFMIN_ {fr->hasIRAFMINCmd();}
	| MARKER_ hasMarker
	| PHYSICAL_ {fr->hasPhysicalCmd();}
	| IMAGE_ {fr->hasImageCmd();}
	| SMOOTH_ {fr->hasSmoothCmd();}
	| SYSTEM_ coordSystem {fr->hasSystemCmd((Coord::CoordSystem)$2);}
	| WCS_ hasWCS
	;

hasBin	: COLUMN_ STRING {fr->hasBinColCmd($2);}
	;

hasContour : /* empty */ {fr->hasContourCmd();}
	| AUX_ {fr->hasContourAuxCmd();}
	;

hasFits	: /* empty */ {fr->hasFitsCmd();}
	| BIN_ {fr->hasFitsBinCmd();}
	| CUBE_ {fr->hasFitsCubeCmd();}
	| MOSAIC_ {fr->hasFitsMosaicCmd();}
	;

hasMarker : HIGHLITE_ {fr->hasMarkerHighlitedCmd();}
	| SELECT_ {fr->hasMarkerSelectedCmd();}
	| PASTE_ {fr->hasMarkerPasteCmd();}
	| UNDO_ {fr->hasMarkerUndoCmd();}
	;

hasWCS	: coordSystem {fr->hasWCSCmd((Coord::CoordSystem)$1);}
	| CELESTIAL_ coordSystem {fr->hasWCSCelCmd((Coord::CoordSystem)$2);}
	| EQUATORIAL_ coordSystem {fr->hasWCSEquCmd((Coord::CoordSystem)$2);}
        | LINEAR_ coordSystem {fr->hasWCSLinearCmd((Coord::CoordSystem)$2);}
	| ALT_ {fr->hasWCSAltCmd();}
	| THREED_ coordSystem {fr->hasWCS3DCmd((Coord::CoordSystem)$2);}
	;

iis	: NEW_ INT INT {fr->iisCmd($2,$3);}
	| ERASE_ {fr->iisEraseCmd();}
	| MESSAGE_ STRING {fr->iisMessageCmd($2);}
	| CURSOR_ iiscursor
	| SET_ FILE_ NAME_ iisSetFileName
	| SET_ POINTER INT INT INT INT
	{fr->iisSetCmd((const char*)$2,$3,$4,$5,$6);}
	| UPDATE_ {fr->iisUpdateCmd();}
	| WCS_ numeric numeric numeric numeric 
	  numeric numeric numeric numeric INT
	{fr->iisWCSCmd(Matrix($2,$3,$4,$5,$6,$7),Vector($8,$9),$10);}
	;

iisSetFileName : STRING {fr->iisSetFileNameCmd($1);}
	| STRING INT {fr->iisSetFileNameCmd($1,$2);}
	;

iiscursor: INT INT CANVAS_
	{fr->iisSetCursorCmd(Vector($1,$2),Coord::CANVAS);}
	| INT INT coordSystem
	{fr->iisSetCursorCmd(Vector($1,$2),(Coord::CoordSystem)$3);}
	| MODE_ yesno {fr->iisCursorModeCmd($2);}
	;

load	: ARRAY_ loadArr
        | ENVI_ loadENVI
	| FITS_ loadFits
	| INCR_ loadIncr
        | NRRD_ loadNRRD
	| PHOTO_ loadPhoto
	;

loadArr : STRING ALLOC_ STRING layerType 
	{fr->loadArrAllocCmd($3, $1, (Base::LayerType)$4);}
	| STRING ALLOCGZ_ STRING layerType 
	{fr->loadArrAllocGZCmd($3, $1, (Base::LayerType)$4);}
	| STRING CHANNEL_ STRING layerType 
	{fr->loadArrChannelCmd($3, $1, (Base::LayerType)$4);}
	| STRING MMAP_ layerType {fr->loadArrMMapCmd($1, (Base::LayerType)$3);}
	| STRING MMAPINCR_ layerType 
	{fr->loadArrMMapIncrCmd($1, (Base::LayerType)$3);}
	| STRING SHARED_ shmType INT layerType
	{fr->loadArrShareCmd((Base::ShmType)$3, $4, $1, (Base::LayerType)$5);}
	| STRING SOCKET_ INT layerType 
	{fr->loadArrSocketCmd($3, $1, (Base::LayerType)$4);}
	| STRING SOCKETGZ_ INT layerType 
	{fr->loadArrSocketGZCmd($3, $1, (Base::LayerType)$4);}
	| STRING VAR_ STRING layerType 
	{fr->loadArrVarCmd($3, $1, (Base::LayerType)$4);}
	| RGB_ CUBE_ loadArrayRGBCube
	;

loadArrayRGBCube : STRING ALLOC_ STRING {fr->loadArrayRGBCubeAllocCmd($3, $1);}
	| STRING ALLOCGZ_ STRING {fr->loadArrayRGBCubeAllocGZCmd($3, $1);}
	| STRING CHANNEL_ STRING {fr->loadArrayRGBCubeChannelCmd($3, $1);}
	| STRING MMAP_ {fr->loadArrayRGBCubeMMapCmd($1);}
	| STRING MMAPINCR_  {fr->loadArrayRGBCubeMMapIncrCmd($1);}
	| STRING SHARED_ shmType INT
	{fr->loadArrayRGBCubeShareCmd((Base::ShmType)$3, $4, $1);}
	| STRING SOCKET_ INT {fr->loadArrayRGBCubeSocketCmd($3, $1);}
	| STRING SOCKETGZ_ INT {fr->loadArrayRGBCubeSocketGZCmd($3, $1);}
	| STRING VAR_ STRING {fr->loadArrayRGBCubeVarCmd($3, $1);}
	;

loadENVI : STRING STRING SMMAP_ {fr->loadENVISMMapCmd($1,$2);}
	;

loadFits: STRING ALLOC_ STRING layerType 
	{fr->loadFitsAllocCmd($3, $1, (Base::LayerType)$4);}
	| STRING ALLOCGZ_ STRING layerType 
	{fr->loadFitsAllocGZCmd($3, $1, (Base::LayerType)$4);}
	| STRING CHANNEL_ STRING layerType 
	{fr->loadFitsChannelCmd($3, $1, (Base::LayerType)$4);}
	| STRING MMAP_ incrLoad layerType
	{fr->loadFitsMMapCmd($1, (Base::LayerType)$4);}
	| STRING STRING SMMAP_ incrLoad layerType
	{fr->loadFitsSMMapCmd($1, $2, (Base::LayerType)$5);}
	| STRING MMAPINCR_ incrLoad layerType
	{fr->loadFitsMMapIncrCmd($1, (Base::LayerType)$4);}
	| STRING SHARED_ shmType INT incrLoad layerType
	{fr->loadFitsShareCmd((Base::ShmType)$3, $4, $1, (Base::LayerType)$6);}
	| STRING SSHARED_ shmType INT INT incrLoad layerType
	{fr->loadFitsSShareCmd((Base::ShmType)$3, $4, $5, $1, 
	  (Base::LayerType)$7);}
	| STRING SOCKET_ INT  layerType
	{fr->loadFitsSocketCmd($3, $1, (Base::LayerType)$4);}
	| STRING SOCKETGZ_ INT  layerType
	{fr->loadFitsSocketGZCmd($3, $1, (Base::LayerType)$4);}
	| STRING VAR_ STRING incrLoad layerType
	{fr->loadFitsVarCmd($3, $1, (Base::LayerType)$5);}
	| SLICE_ loadFitsSlice
	| EXT_ CUBE_ loadFitsExtCube
	| RGB_ IMAGE_ loadFitsRGBImage
	| RGB_ CUBE_ loadFitsRGBCube
	| MOSAIC_ loadFitsMosaic
	;

loadFitsSlice:STRING ALLOC_ STRING {fr->loadSliceAllocCmd($3, $1);}
	| STRING ALLOCGZ_ STRING {fr->loadSliceAllocGZCmd($3, $1);}
	| STRING CHANNEL_ STRING {fr->loadSliceChannelCmd($3, $1);}
	| STRING MMAP_ incrLoad {fr->loadSliceMMapCmd($1);}
	| STRING STRING SMMAP_ incrLoad {fr->loadSliceSMMapCmd($1, $2);}
	| STRING MMAPINCR_ incrLoad {fr->loadSliceMMapIncrCmd($1);}
	| STRING SHARED_ shmType INT incrLoad
	{fr->loadSliceShareCmd((Base::ShmType)$3, $4, $1);}
	| STRING SSHARED_ shmType INT INT incrLoad
	{fr->loadSliceSShareCmd((Base::ShmType)$3, $4, $5, $1);}
	| STRING SOCKET_ INT {fr->loadSliceSocketCmd($3, $1);}
	| STRING SOCKETGZ_ INT {fr->loadSliceSocketGZCmd($3, $1);}
	| STRING VAR_ STRING incrLoad {fr->loadSliceVarCmd($3, $1);}
	;

loadFitsExtCube: STRING ALLOC_ STRING {fr->loadExtCubeAllocCmd($3, $1);}
	| STRING ALLOCGZ_ STRING {fr->loadExtCubeAllocGZCmd($3, $1);}
	| STRING CHANNEL_ STRING {fr->loadExtCubeChannelCmd($3, $1);}
	| STRING MMAP_ incrLoad {fr->loadExtCubeMMapCmd($1);}
	| STRING MMAPINCR_ incrLoad {fr->loadExtCubeMMapIncrCmd($1);}
	| STRING SHARED_ shmType INT incrLoad
	{fr->loadExtCubeShareCmd((Base::ShmType)$3, $4, $1);}
	| STRING SOCKET_ INT {fr->loadExtCubeSocketCmd($3, $1);}
	| STRING SOCKETGZ_ INT {fr->loadExtCubeSocketGZCmd($3, $1);}
	| STRING VAR_ STRING incrLoad {fr->loadExtCubeVarCmd($3, $1);}
	;

loadFitsMosaic : IMAGE_ IRAF_ loadFitsMosaicImageIRAF
	| IRAF_ loadFitsMosaicIRAF
	| IMAGE_ loadFitsMosaicImageWCS
	| loadFitsMosaicWCS
	| IMAGE_ WFPC2_ loadFitsMosaicImageWFPC2
	;

loadFitsMosaicImageIRAF : STRING ALLOC_ STRING layerType
	{fr->loadMosaicImageAllocCmd(Base::IRAF, Coord::WCS, 
	    $3, $1, (Base::LayerType)$4);}
	| STRING ALLOCGZ_ STRING layerType
	{fr->loadMosaicImageAllocGZCmd(Base::IRAF, Coord::WCS,
	    $3, $1,(Base::LayerType)$4);}
	| STRING CHANNEL_ STRING layerType
	{fr->loadMosaicImageChannelCmd(Base::IRAF, Coord::WCS,
	    $3, $1,(Base::LayerType)$4);}
	| STRING MMAP_ incrLoad layerType
	{fr->loadMosaicImageMMapCmd(Base::IRAF, Coord::WCS,
	    $1, (Base::LayerType)$4);}
	| STRING MMAPINCR_ incrLoad layerType
	{fr->loadMosaicImageMMapIncrCmd(Base::IRAF, Coord::WCS,
	    $1, (Base::LayerType)$4);}
	| STRING SHARED_ shmType INT incrLoad layerType
	{fr->loadMosaicImageShareCmd(Base::IRAF, Coord::WCS,
	    (Base::ShmType)$3, $4, $1, (Base::LayerType)$6);}
	| STRING SOCKET_ INT layerType
	{fr->loadMosaicImageSocketCmd(Base::IRAF, Coord::WCS,
	    $3, $1, (Base::LayerType)$4);}
	| STRING SOCKETGZ_ INT layerType
	{fr->loadMosaicImageSocketGZCmd(Base::IRAF, Coord::WCS,
	    $3, $1, (Base::LayerType)$4);}
	| STRING VAR_ STRING incrLoad layerType
	{fr->loadMosaicImageVarCmd(Base::IRAF, Coord::WCS,
	    $3, $1, (Base::LayerType)$5);}
	;

loadFitsMosaicIRAF : STRING ALLOC_ STRING layerType
        {fr->loadMosaicAllocCmd(Base::IRAF, Coord::WCS,
	    $3, $1, (Base::LayerType)$4);}
	| STRING ALLOCGZ_ STRING layerType
	{fr->loadMosaicAllocGZCmd(Base::IRAF, Coord::WCS,
	    $3, $1, (Base::LayerType)$4);}
	| STRING CHANNEL_ STRING layerType
	{fr->loadMosaicChannelCmd(Base::IRAF, Coord::WCS,
	    $3, $1, (Base::LayerType)$4);}
	| STRING MMAP_ incrLoad layerType
	{fr->loadMosaicMMapCmd(Base::IRAF, Coord::WCS,
	    $1, (Base::LayerType)$4);}
	| STRING STRING SMMAP_ incrLoad layerType
	{fr->loadMosaicSMMapCmd(Base::IRAF, Coord::WCS,
	    $1, $2, (Base::LayerType)$5);}
	| STRING MMAPINCR_ incrLoad layerType
	{fr->loadMosaicMMapIncrCmd(Base::IRAF, Coord::WCS,
	    $1, (Base::LayerType)$4);}
	| STRING SHARED_ shmType INT incrLoad layerType
	{fr->loadMosaicShareCmd(Base::IRAF, Coord::WCS,
	    (Base::ShmType)$3, $4, $1, (Base::LayerType)$6);}
	| STRING SSHARED_ shmType INT INT incrLoad layerType
	{fr->loadMosaicSShareCmd(Base::IRAF, Coord::WCS,
	    (Base::ShmType)$3, $4, $5, $1, (Base::LayerType)$7);}
	| STRING SOCKET_ INT layerType
	{fr->loadMosaicSocketCmd(Base::IRAF, Coord::WCS,
	    $3, $1, (Base::LayerType)$4);}
	| STRING SOCKETGZ_ INT layerType
	{fr->loadMosaicSocketGZCmd(Base::IRAF, Coord::WCS,
	    $3, $1, (Base::LayerType)$4);}
	| STRING VAR_ STRING incrLoad layerType
	{fr->loadMosaicVarCmd(Base::IRAF, Coord::WCS,
	    $3, $1, (Base::LayerType)$5);}
	;

loadFitsMosaicImageWCS : wcsSystem STRING ALLOC_ STRING layerType
	{fr->loadMosaicImageAllocCmd(Base::WCSMOSAIC, (Coord::CoordSystem)$1,
	    $4, $2, (Base::LayerType)$5);}
	| wcsSystem STRING ALLOCGZ_ STRING layerType
	{fr->loadMosaicImageAllocGZCmd(Base::WCSMOSAIC, 
	    (Coord::CoordSystem)$1, $4, $2, (Base::LayerType)$5);}
	| wcsSystem STRING CHANNEL_ STRING layerType
	{fr->loadMosaicImageChannelCmd(Base::WCSMOSAIC,
	    (Coord::CoordSystem)$1, $4, $2, (Base::LayerType)$5);}
	| wcsSystem STRING MMAP_ incrLoad layerType
	{fr->loadMosaicImageMMapCmd(Base::WCSMOSAIC, (Coord::CoordSystem)$1,
	    $2, (Base::LayerType)$5);}
	| wcsSystem STRING MMAPINCR_ incrLoad layerType
	{fr->loadMosaicImageMMapIncrCmd(Base::WCSMOSAIC,
	    (Coord::CoordSystem)$1, $2, (Base::LayerType)$5);}
	| wcsSystem STRING SHARED_ shmType INT incrLoad layerType
	{fr->loadMosaicImageShareCmd(Base::WCSMOSAIC, (Coord::CoordSystem)$1, 
	    (Base::ShmType)$4, $5, $2, (Base::LayerType)$7);}
	| wcsSystem STRING SOCKET_ INT layerType
	{fr->loadMosaicImageSocketCmd(Base::WCSMOSAIC, (Coord::CoordSystem)$1,
	    $4, $2, (Base::LayerType)$5);}
	| wcsSystem STRING SOCKETGZ_ INT layerType
	{fr->loadMosaicImageSocketGZCmd(Base::WCSMOSAIC, 
	    (Coord::CoordSystem)$1, $4, $2, (Base::LayerType)$5);}
	| wcsSystem STRING VAR_ STRING incrLoad layerType
	{fr->loadMosaicImageVarCmd(Base::WCSMOSAIC, (Coord::CoordSystem)$1,
	    $4, $2, (Base::LayerType)$6);}
	;

loadFitsMosaicImageWFPC2 : STRING ALLOC_ STRING layerType
        {fr->loadMosaicImageWFPC2AllocCmd($3, $1, (Base::LayerType)$4);}
        | STRING ALLOCGZ_ STRING layerType
	{fr->loadMosaicImageWFPC2AllocGZCmd($3, $1, (Base::LayerType)$4);}
	| STRING CHANNEL_ STRING layerType
	{fr->loadMosaicImageWFPC2ChannelCmd($3, $1, (Base::LayerType)$4);}
	| STRING MMAP_ incrLoad layerType
	{fr->loadMosaicImageWFPC2MMapCmd($1, (Base::LayerType)$4);}
	| STRING MMAPINCR_ incrLoad layerType
	{fr->loadMosaicImageWFPC2MMapIncrCmd($1, (Base::LayerType)$4);}
	| STRING SHARED_ shmType INT incrLoad layerType
	{
	  fr->loadMosaicImageWFPC2ShareCmd((Base::ShmType)$3, $4, $1,
					   (Base::LayerType)$6);
        }
	| STRING SOCKET_ INT layerType
	{fr->loadMosaicImageWFPC2SocketCmd($3, $1, (Base::LayerType)$4);}
	| STRING SOCKETGZ_ INT layerType
	{fr->loadMosaicImageWFPC2SocketGZCmd($3, $1, (Base::LayerType)$4);}
	| STRING VAR_ STRING incrLoad layerType
	{fr->loadMosaicImageWFPC2VarCmd($3, $1, (Base::LayerType)$5);}
	;

loadFitsMosaicWCS : wcsSystem STRING ALLOC_ STRING layerType
	{fr->loadMosaicAllocCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1,
	    $4, $2, (Base::LayerType)$5);}
	| wcsSystem STRING ALLOCGZ_ STRING layerType
	{fr->loadMosaicAllocGZCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1,
	    $4, $2, (Base::LayerType)$5);}
	| wcsSystem STRING CHANNEL_ STRING  layerType
	{fr->loadMosaicChannelCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1,
	    $4, $2, (Base::LayerType)$5);}
	| wcsSystem STRING MMAP_ incrLoad  layerType
	{fr->loadMosaicMMapCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1,
	    $2, (Base::LayerType)$5);}
	| wcsSystem STRING STRING SMMAP_ incrLoad  layerType
	{fr->loadMosaicSMMapCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1,
	    $2, $3, (Base::LayerType)$6);}
	| wcsSystem STRING MMAPINCR_ incrLoad  layerType
	{fr->loadMosaicMMapIncrCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1,
	    $2, (Base::LayerType)$5);}
	| wcsSystem STRING SHARED_ shmType INT incrLoad layerType
	{fr->loadMosaicShareCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, 
	    (Base::ShmType)$4, $5, $2, (Base::LayerType)$7);}
	| wcsSystem STRING SSHARED_ shmType INT INT incrLoad layerType
	{fr->loadMosaicSShareCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1, 
	    (Base::ShmType)$4, $5, $6, $2, (Base::LayerType)$8);}
	| wcsSystem STRING SOCKET_ INT  layerType
	{fr->loadMosaicSocketCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1,
	    $4, $2, (Base::LayerType)$5);}
	| wcsSystem STRING SOCKETGZ_ INT  layerType
	{fr->loadMosaicSocketGZCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1,
	    $4, $2, (Base::LayerType)$5);}
	| wcsSystem STRING VAR_ STRING incrLoad layerType
	{fr->loadMosaicVarCmd((Base::WCSMOSAIC), (Coord::CoordSystem)$1,
	    $4, $2, (Base::LayerType)$6);}
	;

loadFitsRGBCube: STRING ALLOC_ STRING {fr->loadRGBCubeAllocCmd($3, $1);}
	| STRING ALLOCGZ_ STRING {fr->loadRGBCubeAllocGZCmd($3, $1);}
	| STRING CHANNEL_ STRING {fr->loadRGBCubeChannelCmd($3, $1);}
	| STRING MMAP_ incrLoad {fr->loadRGBCubeMMapCmd($1);}
	| STRING STRING SMMAP_ incrLoad {fr->loadRGBCubeSMMapCmd($1, $2);}
	| STRING MMAPINCR_ incrLoad {fr->loadRGBCubeMMapIncrCmd($1);}
	| STRING SHARED_ shmType INT incrLoad
	{fr->loadRGBCubeShareCmd((Base::ShmType)$3, $4, $1);}
	| STRING SSHARED_ shmType INT INT incrLoad
	{fr->loadRGBCubeSShareCmd((Base::ShmType)$3, $4, $5, $1);}
	| STRING SOCKET_ INT {fr->loadRGBCubeSocketCmd($3, $1);}
	| STRING SOCKETGZ_ INT {fr->loadRGBCubeSocketGZCmd($3, $1);}
	| STRING VAR_ STRING incrLoad {fr->loadRGBCubeVarCmd($3, $1);}
	;

loadFitsRGBImage: STRING ALLOC_ STRING {fr->loadRGBImageAllocCmd($3, $1);}
	| STRING ALLOCGZ_ STRING {fr->loadRGBImageAllocGZCmd($3, $1);}
	| STRING CHANNEL_ STRING {fr->loadRGBImageChannelCmd($3, $1);}
	| STRING MMAP_ incrLoad {fr->loadRGBImageMMapCmd($1);}
	| STRING MMAPINCR_ incrLoad {fr->loadRGBImageMMapIncrCmd($1);}
	| STRING SHARED_ shmType INT incrLoad
	{fr->loadRGBImageShareCmd((Base::ShmType)$3, $4, $1);}
	| STRING SOCKET_ INT {fr->loadRGBImageSocketCmd($3, $1);}
	| STRING SOCKETGZ_ INT {fr->loadRGBImageSocketGZCmd($3, $1);}
	| STRING VAR_ STRING incrLoad {fr->loadRGBImageVarCmd($3, $1);}
	;

loadNRRD : STRING ALLOC_ STRING layerType 
	{fr->loadNRRDAllocCmd($3, $1, (Base::LayerType)$4);}
	| STRING CHANNEL_ STRING layerType 
	{fr->loadNRRDChannelCmd($3, $1, (Base::LayerType)$4);}
	| STRING MMAP_ layerType {fr->loadNRRDMMapCmd($1, (Base::LayerType)$3);}
	| STRING SHARED_ shmType INT layerType
	{fr->loadNRRDShareCmd((Base::ShmType)$3, $4, $1, (Base::LayerType)$5);}
	| STRING SOCKET_ INT layerType 
	{fr->loadNRRDSocketCmd($3, $1, (Base::LayerType)$4);}
	| STRING VAR_ STRING layerType 
	{fr->loadNRRDVarCmd($3, $1, (Base::LayerType)$4);}
	;

loadPhoto: /* empty */ STRING STRING {fr->loadPhotoCmd($1,$2);}
	| SLICE_ STRING STRING {fr->loadSlicePhotoCmd($2,$3);}
	;

loadIncr: DATA_ INT INT INT INT INT {fr->loadIncrDataCmd($2,$3,$4,$5,$6);}
	| MINMAX_ INT INT INT INT INT {fr->loadIncrMinMaxCmd($2,$3,$4,$5,$6);}
	| END_ {fr->loadIncrEndCmd();}
	;

macosx	: PRINT_ {
#ifdef MAC_OSX_TK
	  fr->macosxPrintCmd();
#endif
	}
	;

magnifier: yesno {fr->magnifierCmd($1);}
	| GRAPHICS_ yesno {fr->magnifierGraphicsCmd($2);}
	| CURSOR_ yesno {fr->magnifierCursorCmd($2);}
	| COLOR_ STRING {fr->magnifierColorCmd($2);}
	| STRING INT INT {fr->magnifierCmd($1, $2, $3);}
	| UPDATE_ numeric numeric {fr->updateMagnifierCmd(Vector($2, $3));}
	| ZOOM_ numeric {fr->magnifierZoomCmd($2);}
	;

match	: STRING STRING wcsSystem skyFrame STRING STRING wcsSystem skyFrame numeric wcsSystem skyDist STRING
	{
	  fr->matchCmd($1,$2,(Coord::CoordSystem)$3,(Coord::SkyFrame)$4,
		       $5,$6,(Coord::CoordSystem)$7,(Coord::SkyFrame)$8,
		       $9,(Coord::CoordSystem)$10,(Coord::DistFormat)$11,
		       $12);
	}

marker	: CENTROID_ markerCentroid
	| COLOR_ STRING {fr->markerColorCmd($2);}
	| COPY_ {fr->markerCopyCmd();}
	| COMMAND_ markerFormat STRING
	{fr->markerCommandCmd((Base::MarkerFormat)$2,$3);}
	| COMMAND_ markerFormat VAR_ STRING
	{fr->markerCommandVarCmd((Base::MarkerFormat)$2,$4);}
	| COMPOSITE_ DELETE_ {fr->markerCompositeDeleteCmd();}
	| CREATE_ {maperr =0;} markerCreate
	| CUT_ {fr->markerCutCmd();}
	| DELETE_ {fr->markerDeleteCmd();}
	| DELETE_ ALL_ {fr->markerDeleteAllCmd();}
	| EDIT_ markerEdit
        | EPSILON_ INT {fr->markerEpsilonCmd($2);}
	| FONT_ STRING {fr->markerFontCmd($2);}

	| HIGHLITE_ ALL_ {fr->markerHighliteAllCmd();}
	| HIGHLITE_ ONLY_ numeric numeric 
	{fr->markerHighliteOnlyCmd(Vector($3,$4));}
	| HIGHLITE_ TOGGLE_ numeric numeric
	{fr->markerHighliteToggleCmd(Vector($3,$4));}

	| INT ANALYSIS_ analysisMethod yesno
	{fr->markerAnalysisCmd($1, (Marker::AnalysisTask)$3, $4);}

	| INT ANGLE_ angle {fr->markerAngleCmd($1,$3);}
	| INT ANGLE_ angle internalSystem {fr->markerAngleCmd($1,$3);}
	| INT ANGLE_ angle coordSystem skyFrame
	{fr->markerAngleCmd($1,$3,(Coord::CoordSystem)$4, (Coord::SkyFrame)$5);}

	| INT ANNULUS_ RADIUS_ numeric numeric INT coordSystem skyDist
	{fr->markerAnnulusRadiusCmd($1, $4, $5, $6,
	    (Coord::CoordSystem)$7, (Coord::DistFormat)$8);}
	| INT ANNULUS_ RADIUS_ STRING coordSystem skyDist
	{fr->markerAnnulusRadiusCmd($1, $4,(Coord::CoordSystem)$5,(Coord::DistFormat)$6);}

	| INT BOX_ FILL_ yesno {fr->markerBoxFillCmd($1,$4);}
	| INT BOXANNULUS_ RADIUS_ numeric numeric numeric INT 
	    coordSystem skyDist
	{fr->markerBoxAnnulusRadiusCmd($1, Vector($4, $5), 
	    Vector($6, $6*$5/$4), $7, (Coord::CoordSystem)$8, (Coord::DistFormat)$9);}
	| INT BOXANNULUS_ RADIUS_ STRING coordSystem skyDist
	{fr->markerBoxAnnulusRadiusCmd($1,$4,(Coord::CoordSystem)$5,(Coord::DistFormat)$6);}

	| INT BOX_ RADIUS_ numeric numeric coordSystem skyDist
	{fr->markerBoxRadiusCmd($1, Vector($4,$5), 
	    (Coord::CoordSystem)$6, (Coord::DistFormat)$7);}
	| INT BPANDA_ EDIT_ angle angle INT numeric numeric numeric INT 
	{fr->markerBpandaEditCmd($1, $4, $5, $6,
	    Vector($7,$8), Vector($9,$9*$8/$7), $10);}
	| INT BPANDA_ EDIT_ angle angle INT numeric numeric numeric INT 
	    internalSystem
	{fr->markerBpandaEditCmd($1, $4, $5, $6,
	    Vector($7,$8), Vector($9,$9*$8/$7), $10);}
	| INT BPANDA_ EDIT_ angle angle INT numeric numeric numeric INT 
	    coordSystem skyFrame
	{fr->markerBpandaEditCmd($1, $4, $5, $6,
	    Vector($7,$8), Vector($9,$9*$8/$7), $10,
	    (Coord::CoordSystem)$11, (Coord::SkyFrame)$12);}
	| INT BPANDA_ EDIT_ STRING STRING coordSystem skyFrame 
	    coordSystem skyDist
	{fr->markerBpandaEditCmd($1, $4, $5, 
	    (Coord::CoordSystem)$6, (Coord::SkyFrame)$7, (Coord::CoordSystem)$8, (Coord::DistFormat)$9);}

	| INT CALLBACK_ markerCallBack STRING STRING
	{fr->markerCallBackCmd($1,(CallBack::Type)$3,$4,$5);}
	| INT CIRCLE_ FILL_ yesno {fr->markerCircleFillCmd($1,$4);}
	| INT CIRCLE_ RADIUS_ numeric coordSystem skyDist
	{fr->markerCircleRadiusCmd($1, $4, (Coord::CoordSystem)$5, (Coord::DistFormat)$6);}
	| INT COLOR_ STRING {fr->markerColorCmd($1,$3);}
	| INT COMPASS_ ARROW_ yesno yesno 
	{fr->markerCompassArrowCmd($1,$4,$5);}
	| INT COMPASS_ LABEL_ STRING STRING
	{fr->markerCompassLabelCmd($1,$4,$5);}
	| INT COMPASS_ RADIUS_ numeric coordSystem skyDist
	  {fr->markerCompassRadiusCmd($1,$4,(Coord::CoordSystem)$5,(Coord::DistFormat)$6);}
	| INT COMPASS_ SYSTEM_ coordSystem skyFrame
	{fr->markerCompassSystemCmd($1, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);}
	| INT COMPOSITE_ GLOBAL_ yesno {fr->markerCompositeCmd($1,$4);}
	| INT CPANDA_ EDIT_ angle angle INT numeric numeric INT 
	{fr->markerCpandaEditCmd($1, $4, $5, $6, $7, $8, $9);}
	| INT CPANDA_ EDIT_ angle angle INT numeric numeric INT internalSystem
	{fr->markerCpandaEditCmd($1, $4, $5, $6, $7, $8, $9);}
	| INT CPANDA_ EDIT_ angle angle INT numeric numeric INT 
	    coordSystem skyFrame
	{fr->markerCpandaEditCmd($1, $4, $5, $6, $7, $8, $9,
	    (Coord::CoordSystem)$10, (Coord::SkyFrame)$11);}
	| INT CPANDA_ EDIT_ STRING STRING coordSystem skyFrame 
	    coordSystem skyDist
	{fr->markerCpandaEditCmd($1, $4, $5, (Coord::CoordSystem)$6, (Coord::SkyFrame)$7,
	    (Coord::CoordSystem)$8, (Coord::DistFormat)$9);}

	| INT CREATE_ ANNULUS_ RADIUS_ numeric numeric
	{fr->markerAnnulusCreateRadiusCmd($1,Vector($5,$6));}
	| INT CREATE_ BOXANNULUS_ RADIUS_ numeric numeric
	{fr->markerBoxAnnulusCreateRadiusCmd($1,Vector($5,$6));}
	| INT CREATE_ BPANDA_ ANGLE_ numeric numeric
	{fr->markerBpandaCreateAnglesCmd($1,Vector($5,$6));}
	| INT CREATE_ BPANDA_ RADIUS_ numeric numeric
	{fr->markerBpandaCreateRadiusCmd($1,Vector($5,$6));}
	| INT CREATE_ ELLIPSEANNULUS_ RADIUS_ numeric numeric
	{fr->markerEllipseAnnulusCreateRadiusCmd($1,Vector($5,$6));}
	| INT CREATE_ EPANDA_ ANGLE_ numeric numeric
	{fr->markerEpandaCreateAnglesCmd($1,Vector($5,$6));}
	| INT CREATE_ EPANDA_ RADIUS_ numeric numeric
	{fr->markerEpandaCreateRadiusCmd($1,Vector($5,$6));}
	| INT CREATE_ CPANDA_ ANGLE_ numeric numeric
	{fr->markerCpandaCreateAnglesCmd($1,Vector($5,$6));}
	| INT CREATE_ CPANDA_ RADIUS_ numeric numeric
	{fr->markerCpandaCreateRadiusCmd($1,Vector($5,$6));}
	| INT CREATE_ POLYGON_ VERTEX_ INT numeric numeric
	{fr->markerPolygonCreateVertexCmd($1,$5,Vector($6,$7));}
	| INT CREATE_ SEGMENT_ VERTEX_ INT numeric numeric
	{fr->markerSegmentCreateVertexCmd($1,$5,Vector($6,$7));}

	| INT DELETE_ {fr->markerDeleteCmd($1);}
	| INT DELETE_ ANNULUS_ INT 
	{fr->markerAnnulusDeleteRadiusCmd($1,$4);}
	| INT DELETE_ BOXANNULUS_ INT 
	{fr->markerBoxAnnulusDeleteRadiusCmd($1,$4);}
	| INT DELETE_ BPANDA_ INT {fr->markerBpandaDeleteCmd($1,$4);}
	| INT DELETE_ ELLIPSEANNULUS_ INT 
	{fr->markerEllipseAnnulusDeleteRadiusCmd($1,$4);}
	| INT DELETE_ CALLBACK_ markerCallBack STRING
	{fr->markerDeleteCallBackCmd($1,(CallBack::Type)$4,$5);}
	| INT DELETE_ EPANDA_ INT {fr->markerEpandaDeleteCmd($1,$4);}
	| INT DELETE_ CPANDA_ INT {fr->markerCpandaDeleteCmd($1,$4);}
	| INT DELETE_ POLYGON_ VERTEX_ INT 
	{fr->markerPolygonDeleteVertexCmd($1,$5);}
	| INT DELETE_ SEGMENT_ VERTEX_ INT 
	{fr->markerSegmentDeleteVertexCmd($1,$5);}
	| INT DELETE_ TAG_ {fr->markerDeleteTagCmd($1);}
	| INT DELETE_ TAG_ STRING {fr->markerDeleteTagCmd($1,$4);}
	| INT DELETE_ TAG_ INT {fr->markerDeleteTagCmd($1,$4);}

	| INT EDIT_ BEGIN_ INT {fr->markerEditBeginCmd($1,$4);}
	| INT ELLIPSE_ FILL_ yesno {fr->markerEllipseFillCmd($1,$4);}
	| INT ELLIPSE_ RADIUS_ numeric numeric coordSystem skyDist
	{fr->markerEllipseRadiusCmd($1, Vector($4, $5),
	    (Coord::CoordSystem)$6, (Coord::DistFormat)$7);}
	| INT ELLIPSEANNULUS_ RADIUS_ numeric numeric numeric INT
	    coordSystem skyDist
	{fr->markerEllipseAnnulusRadiusCmd($1, Vector($4,$5), 
	    Vector($6,$6*$5/$4), $7, (Coord::CoordSystem)$8, (Coord::DistFormat)$9);}
	| INT ELLIPSEANNULUS_ RADIUS_ STRING coordSystem skyDist
	{fr->markerEllipseAnnulusRadiusCmd($1, $4,
	    (Coord::CoordSystem)$5, (Coord::DistFormat)$6);}
	| INT EPANDA_ EDIT_ angle angle INT numeric numeric numeric INT 
	{fr->markerEpandaEditCmd($1, $4, $5, $6,
	    Vector($7,$8), Vector($9,$9*$8/$7), $10);}
	| INT EPANDA_ EDIT_ angle angle INT numeric numeric numeric INT 
	    internalSystem
	{fr->markerEpandaEditCmd($1, $4, $5, $6,
	    Vector($7,$8), Vector($9,$9*$8/$7), $10);}
	| INT EPANDA_ EDIT_ angle angle INT numeric numeric numeric INT 
	    coordSystem skyFrame
	{fr->markerEpandaEditCmd($1, $4, $5, $6,
	    Vector($7,$8), Vector($9,$9*$8/$7), $10,
	    (Coord::CoordSystem)$11, (Coord::SkyFrame)$12);}
	| INT EPANDA_ EDIT_ STRING STRING coordSystem skyFrame 
	    coordSystem skyDist
	{fr->markerEpandaEditCmd($1, $4, $5, 
	    (Coord::CoordSystem)$6, (Coord::SkyFrame)$7,
	    (Coord::CoordSystem)$8, (Coord::DistFormat)$9);}

	| INT FONT_ STRING {fr->markerFontCmd($1,$3);}
	| INT HIGHLITE_ {fr->markerHighliteCmd($1);}
	| INT HIGHLITE_ ONLY_{fr->markerHighliteOnlyCmd($1);}

	| INT LINE_ ARROW_ yesno yesno {fr->markerLineArrowCmd($1,$4,$5);}
	| INT LINE_ POINT_ coordSystem skyFrame coord coord
	{fr->markerLineCmd($1, Vector($6), Vector($7), 
	    (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);}

	| INT MOVE_ numeric numeric 
	{fr->markerMoveCmd($1, Vector($3,$4));}
	| INT MOVE_ FRONT_ {fr->markerFrontCmd($1);}
	| INT MOVE_ BACK_ {fr->markerBackCmd($1);}
	| INT MOVE_ TO_ coordSystem skyFrame coord 
	{fr->markerMoveToCmd($1,Vector($6),(Coord::CoordSystem)$4,(Coord::SkyFrame)$5);}

	| INT POLYGON_ RESET_ numeric numeric coordSystem skyDist
	{fr->markerPolygonResetCmd($1, Vector($4,$5),
	    (Coord::CoordSystem)$6, (Coord::DistFormat)$7);}
	| INT SEGMENT_ RESET_ numeric numeric coordSystem skyDist
	{fr->markerSegmentResetCmd($1, Vector($4,$5),
	    (Coord::CoordSystem)$6, (Coord::DistFormat)$7);}
	| INT POINT_ SHAPE_ pointShape 
	{fr->markerPointShapeCmd($1,(Point::PointShape)$4);}
	| INT POINT_ SIZE_ INT {fr->markerPointSizeCmd($1,$4);}

	| INT POLYGON_ FILL_ yesno {fr->markerPolygonFillCmd($1,$4);}
	| INT PROJECTION_ coordSystem skyFrame coord coord numeric
	    coordSystem skyDist
	{fr->markerProjectionCmd($1, Vector($5), Vector($6),
	    (Coord::CoordSystem)$3, (Coord::SkyFrame)$4, $7,
	    (Coord::CoordSystem)$8, (Coord::DistFormat)$9);}
	| INT PROPERTY_ markerProperty yesno 
	{fr->markerPropertyCmd($1,$3,$4);}

	| INT ROTATE_ BEGIN_ {fr->markerRotateBeginCmd($1);}
        | INT RULER_ FORMAT_ STRING {fr->markerRulerDistSpecCmd($1, $4);}
	| INT RULER_ POINT_ coordSystem skyFrame coord coord
	{fr->markerRulerPointCmd($1, Vector($6), Vector($7),
	    (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);}
	| INT RULER_ SYSTEM_ coordSystem skyFrame coordSystem skyDist
	{fr->markerRulerSystemCmd($1, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5,
	    (Coord::CoordSystem)$6, (Coord::DistFormat)$7);}

	| INT SELECT_ {fr->markerSelectCmd($1);}
	| INT SELECT_ ONLY_ {fr->markerSelectOnlyCmd($1);}

	| INT TAG_ STRING {fr->markerTagCmd($1,$3);}
	| INT TEXT_ STRING {fr->markerTextCmd($1,$3);}
	| INT TEXT_ ROTATE_ yesno {fr->markerTextRotateCmd($1,$4);}

	| INT UNHIGHLITE_ {fr->markerUnhighliteCmd($1);}
	| INT UNSELECT_ {fr->markerUnselectCmd($1);}

	| INT VECTOR_ ARROW_ yesno {fr->markerVectorArrowCmd($1,$4);}
	| INT VECTOR_ POINT_ coordSystem skyFrame coord 
	    coordSystem skyDist numeric angle
	{fr->markerVectorCmd($1, Vector($6), (Coord::CoordSystem)$4, (Coord::SkyFrame)$5,
	    $9, (Coord::CoordSystem)$7, (Coord::DistFormat)$8, $10);}

	| INT WIDTH_ INT {fr->markerLineWidthCmd($1,$3);}

	| KEY_ {fr->markerKeyCmd();}
	| KEY_ numeric numeric {fr->markerKeyCmd(Vector($2,$3));}

	| LIST_ markerList
	| LOAD_ markerLoad
	| MOVE_ markerMoveSelected
	| PRESERVE_ yesno {fr->markerPreserveCmd($2);}
	| PROPERTY_ markerProperty yesno {fr->markerPropertyCmd($2,$3);}
	| PROPERTY_ markerProperty yesno numeric numeric
	{fr->markerPropertyCmd($2,$3,Vector($4,$5));}
	| ROTATE_ BEGIN_ numeric numeric 
	{fr->markerRotateBeginCmd(Vector($3,$4));}
	| ROTATE_ MOTION_ numeric numeric INT
	{fr->markerRotateMotionCmd(Vector($3,$4),$5);}
	| ROTATE_ END_ {fr->markerRotateEndCmd();}
	| SAVE_ STRING markerFormat coordSystem skyFrame skyFormat yesno
	{fr->markerSaveCmd($2, (Base::MarkerFormat)$3, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5, (Coord::SkyFormat)$6, $7);}
	| SAVE_ TEMPLATE_ STRING {fr->markerSaveTemplateCmd($3);}
	| SELECT_ markerSelect

	| SHOW_ markerShow

	| STRING COLOR_ STRING {fr->markerColorCmd($1,$3);}
	| STRING COPY_ {fr->markerCopyCmd($1);}
	| STRING DELETE_ {fr->markerDeleteCmd($1);}
	| STRING CUT_ {fr->markerCutCmd($1);}
	| STRING FONT_ STRING {fr->markerFontCmd($1,$3);}
	| STRING HIGHLITE_ {fr->markerHighliteCmd($1);}
	| STRING HIGHLITE_ ONLY_ {fr->markerHighliteOnlyCmd($1);}
	| STRING MOVE_ numeric numeric {fr->markerMoveCmd($1,Vector($3,$4));}
	| STRING MOVE_ FRONT_ {fr->markerFrontCmd($1);}
	| STRING MOVE_ BACK_ {fr->markerBackCmd($1);}
	| STRING MOVE_ TO_ coordSystem skyFrame coord 
	{fr->markerMoveToCmd($1,Vector($6),(Coord::CoordSystem)$4,(Coord::SkyFrame)$5);}
	| STRING PROPERTY_ markerProperty yesno 
	{fr->markerPropertyCmd($1,$3,$4);}
	| STRING SELECT_ {fr->markerSelectCmd($1);}
	| STRING SELECT_ ONLY_ {fr->markerSelectOnlyCmd($1);}
	| STRING UNHIGHLITE_ {fr->markerUnhighliteCmd($1);}
	| STRING UNSELECT_ {fr->markerUnselectCmd($1);}

	| TAG_ EDIT_ STRING STRING {fr->markerTagEditCmd($3,$4);}
	| TAG_ DELETE_ STRING {fr->markerTagDeleteCmd($3);}
	| TAG_ DELETE_ ALL_ {fr->markerTagDeleteAllCmd();}
	| TAG_ STRING {fr->markerTagCmd($2);}
	| TAG_ UPDATE_ STRING {fr->markerTagUpdateCmd($3);}

	| PASTE_ {fr->markerPasteCmd();}
	| PASTE_ coordSystem {fr->markerPasteCmd((Coord::CoordSystem)$2);}
	| UNDO_ {fr->markerUndoCmd();}
	| UNHIGHLITE_ ALL_ {fr->markerUnhighliteAllCmd();}
	| UNSELECT_ ALL_ {fr->markerUnselectAllCmd();}
	| WIDTH_ INT {fr->markerLineWidthCmd($2);}
	;

markerCallBack : SELECT_ {$$ = CallBack::SELECTCB;}
	| UNSELECT_ {$$ = CallBack::UNSELECTCB;}
	| HIGHLITE_ {$$ = CallBack::HIGHLITECB;}
	| UNHIGHLITE_ {$$ = CallBack::UNHIGHLITECB;}
	| BEGIN_ MOVE_  {$$ = CallBack::MOVEBEGINCB;}
	| MOVE_  {$$ = CallBack::MOVECB;}
	| END_ MOVE_  {$$ = CallBack::MOVEENDCB;}
	| BEGIN_ EDIT_ {$$ = CallBack::EDITBEGINCB;}
	| EDIT_ {$$ = CallBack::EDITCB;}
	| END_ EDIT_ {$$ = CallBack::EDITENDCB;}
	| BEGIN_ ROTATE_ {$$ = CallBack::ROTATEBEGINCB;}
	| ROTATE_ {$$ = CallBack::ROTATECB;}
	| END_ ROTATE_ {$$ = CallBack::ROTATEENDCB;}
	| DELETE_ {$$ = CallBack::DELETECB;}
	| TEXT_ {$$ = CallBack::TEXTCB;}
	| COLOR_ {$$ = CallBack::COLORCB;}
	| WIDTH_ {$$ = CallBack::LINEWIDTHCB;}
	| PROPERTY_ {$$ = CallBack::PROPERTYCB;}
	| FONT_ {$$ = CallBack::FONTCB;}
	| KEY_ {$$ = CallBack::KEYCB;}
	| UPDATE_ {$$ = CallBack::UPDATECB;}
	;

markerCentroid : /* empty */ {fr->markerCentroidCmd();}
	| INT {fr->markerCentroidCmd($1);}
	| AUTO_ yesno {fr->markerCentroidAutoCmd($2);}
	| RADIUS_ numeric {fr->markerCentroidRadiusCmd($2);}
	| ITERATION_ INT {fr->markerCentroidIterationCmd($2);}
	| OPTION_ INT numeric
	{
	  fr->markerCentroidIterationCmd($2);
	  fr->markerCentroidRadiusCmd($3);
	}
	;

markerCreate : 
	  CIRCLE_ numeric numeric 
	    numeric 
	    markerProperties
	{fr->createCircleCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    $4, 0,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| ELLIPSE_ numeric numeric 
	    numeric numeric 
	    optangle
	    markerProperties
	{fr->createEllipseCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    Vector($4,$5),
            $6, 0,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| BOX_ numeric numeric 
	    numeric numeric 
	    optangle 
	    markerProperties
	{fr->createBoxCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    Vector($4,$5),
            $6, 0,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| POLYGON_ numeric numeric 
	    numeric numeric 
	    markerProperties
	{fr->createPolygonCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
            Vector($4,$5), 0,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| SEGMENT_ numeric numeric 
	    numeric numeric 
	    markerProperties
	{fr->createSegmentCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    Vector($4,$5),
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| LINE_ numeric numeric 
	    numeric numeric 
	    markerProperties
	{fr->createLineCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    fr->mapToRef(Vector($4,$5),Coord::CANVAS),
	    0, 0,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| VECTOR_ numeric numeric 
	    numeric numeric 
	    markerProperties
	{fr->createVectCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    fr->mapToRef(Vector($4,$5),Coord::CANVAS),
	    1,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| TEXT_ numeric numeric 
	    optangle 
	    markerProperties
	{fr->createTextCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    $4, 1,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| CIRCLE_ POINT_ numeric numeric pointSize markerProperties
	{fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS),
	    Point::CIRCLE, $5,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| BOX_ POINT_ numeric numeric pointSize markerProperties
	{fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS),
	    Point::BOX, $5,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| DIAMOND_ POINT_ numeric numeric pointSize markerProperties
	{fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS),
	    Point::DIAMOND, $5,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| CROSS_ POINT_ numeric numeric pointSize markerProperties
	{fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS),
	    Point::CROSS, $5,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| 'X' POINT_ numeric numeric pointSize markerProperties
	{fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS),
	    Point::EX, $5,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| ARROW_ POINT_ numeric numeric pointSize markerProperties
	{fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS),
	    Point::ARROW, $5,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| BOXCIRCLE_ POINT_ numeric numeric pointSize markerProperties
	{fr->createPointCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS),
	    Point::BOXCIRCLE, $5,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}

	| RULER_ numeric numeric 
	    numeric numeric 
	    coordSystem skyFrame coordSystem skyDist STRING
	    markerProperties
	{fr->createRulerCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    fr->mapToRef(Vector($4,$5),Coord::CANVAS),
            (Coord::CoordSystem)$6, (Coord::SkyFrame)$7, 
            (Coord::CoordSystem)$8, (Coord::DistFormat)$9, $10,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| COMPASS_ numeric numeric 
	    numeric 
	    coordSystem skyFrame
	    markerProperties
	{fr->createCompassCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), 
	    $4,
	    "N", "E", 1, 1,
	    (Coord::CoordSystem)$5, (Coord::SkyFrame)$6,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| PROJECTION_ numeric numeric 
	    numeric numeric 
	    numeric 
	    markerProperties
	{fr->createProjectionCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    fr->mapToRef(Vector($4,$5),Coord::CANVAS),
	    $6,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}

	| ANNULUS_ numeric numeric 
	    numeric numeric INT 
	    markerProperties
	{fr->createAnnulusCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    $4,$5,$6,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| ELLIPSEANNULUS_ numeric numeric 
	    numeric numeric numeric INT 
	    optangle 
	    markerProperties
	{fr->createEllipseAnnulusCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    Vector($4,$5), 
	    Vector($6,$6*$4/$5),$7,
	    $8,
	    currentColor,currentDash,currentWidth,currentFont, 
	    currentText,currentProps,NULL,taglist,cblist);}
	| BOXANNULUS_ numeric numeric 
	    numeric numeric numeric INT 
	    optangle 
	    markerProperties
	{fr->createBoxAnnulusCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    Vector($4,$5),Vector($6,$6*$4/$5),$7,
	    $8,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}

	| CPANDA_ numeric numeric 
	    angle angle INT
	    numeric numeric INT 
	    markerProperties
	{fr->createCpandaCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    $4,$5,$6,
	    $7,$8,$9,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| EPANDA_ numeric numeric 
	    angle angle INT
	    numeric numeric numeric INT 
	    optangle 
	    markerProperties
	{fr->createEpandaCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    $4,$5,$6,
	    Vector($7,$8),
	    Vector($9,$9*$7/$8),$10,
	    $11,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}
	| BPANDA_ numeric numeric 
	    angle angle INT
	    numeric numeric numeric INT 
	    optangle 
	    markerProperties
	{fr->createBpandaCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS),
	    $4,$5,$6,
	    Vector($7,$8),
	    Vector($9,$9*$7/$8),$10,
	    $11,
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}

	| COMPOSITE_ markerProperties
	{fr->createCompositeCmd(
	    currentColor,currentDash,currentWidth,currentFont,
	    currentText,currentProps,NULL,taglist,cblist);}

	| TEMPLATE_ markerCreateTemplate
	;

markerCreateTemplate : STRING numeric numeric
	{fr->createTemplateCmd(fr->mapToRef(Vector($2,$3),Coord::CANVAS), $1);}
	| VAR_ STRING numeric numeric
	{fr->createTemplateVarCmd(fr->mapToRef(Vector($3,$4),Coord::CANVAS), $2);}
	| numeric numeric VAR_ STRING 
	  { 
	    // backward compatibility
	    fr->createTemplateVarCmd(fr->mapToRef(Vector($1,$2),Coord::CANVAS), $4);
	  }
	| STRING coordSystem skyFrame coord
	{fr->createTemplateCmd(Vector($4),(Coord::CoordSystem)$2,(Coord::SkyFrame)$3, $1);}
	;

markerDash : INT INT {$$[0] = $1; $$[1] = $2;}
	;

markerEdit : BEGIN_ numeric numeric INT 
	{fr->markerEditBeginCmd(Vector($2,$3),$4);}
	| MOTION_ numeric numeric INT 
	{fr->markerEditMotionCmd(Vector($2,$3),$4);}
	| END_ {fr->markerEditEndCmd();}
	;

markerFormat : DS9_ {$$ = Base::DS9;}
	| XML_ {$$ = Base::XML;}
	| CIAO_ {$$ = Base::CIAO;}
	| SAOTNG_ {$$ = Base::SAOTNG;}
	| SAOIMAGE_ {$$ = Base::SAOIMAGE;}
	| PROS_ {$$ = Base::PROS;}
	| XY_ {$$ = Base::RAWXY;}
	;

markerGet : CENTROID_ markerGetCentroid
	| COLOR_ {fr->getMarkerColorCmd();}
	| FONT_ {fr->getMarkerFontCmd();}
        | EPSILON_ {fr->getMarkerEpsilonCmd();}
	| HANDLE_ numeric numeric {fr->getMarkerHandleCmd(Vector($2,$3));}
	| ID_ numeric numeric {fr->getMarkerIdCmd(Vector($2,$3));}

	| INT ANALYSIS_ CPANDA_ coordSystem
	{fr->getMarkerAnalysisPandaCmd($1,(Coord::CoordSystem)$4);}
        | INT ANALYSIS_ HISTOGRAM_ STRING STRING INT
	{fr->getMarkerAnalysisHistogramCmd($1,$4,$5,$6);}
	| INT ANALYSIS_ PLOT2D_ STRING STRING STRING STRING coordSystem skyFrame analysisParam
	{fr->getMarkerAnalysisPlot2dCmd($1,$4,$5,$6,$7,(Coord::CoordSystem)$8, (Coord::SkyFrame)$9, (Marker::AnalysisMethod)$10);}
	| INT ANALYSIS_ PLOT3D_ STRING STRING coordSystem skyFrame analysisParam
	{fr->getMarkerAnalysisPlot3dCmd($1,$4,$5,(Coord::CoordSystem)$6,(Coord::SkyFrame)$7, (Marker::AnalysisMethod)$8);}
	| INT ANALYSIS_ RADIAL_ STRING STRING STRING coordSystem
	{fr->getMarkerAnalysisRadialCmd($1,$4,$5,$6,(Coord::CoordSystem)$7);}
	| INT ANALYSIS_ STATS_ coordSystem skyFrame
	{fr->getMarkerAnalysisStatsCmd($1,(Coord::CoordSystem)$4, (Coord::SkyFrame)$5);}

	| ID_ ALL_ {fr->getMarkerIdAllCmd();}
	| INT ANGLE_ {fr->getMarkerAngleCmd($1);}
	| INT ANGLE_ internalSystem  {fr->getMarkerAngleCmd($1);}
	| INT ANGLE_ coordSystem skyFrame
	{fr->getMarkerAngleCmd($1,(Coord::CoordSystem)$3, (Coord::SkyFrame)$4);}
	| INT ANNULUS_ RADIUS_ coordSystem skyDist
	{fr->getMarkerAnnulusRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::DistFormat)$5);}

	| INT BOX_ FILL_ {fr->getMarkerBoxFillCmd($1);}
	| INT BOXANNULUS_ RADIUS_ coordSystem skyDist
	{fr->getMarkerBoxAnnulusRadiusCmd($1,(Coord::CoordSystem)$4,(Coord::DistFormat)$5);}
	| INT BOX_ RADIUS_ coordSystem skyDist
	{fr->getMarkerBoxRadiusCmd($1,(Coord::CoordSystem)$4, (Coord::DistFormat)$5);}
	| INT BPANDA_ ANGLE_ {fr->getMarkerBpandaAnglesCmd($1);}
	| INT BPANDA_ ANGLE_ internalSystem {fr->getMarkerBpandaAnglesCmd($1);}
	| INT BPANDA_ ANGLE_ coordSystem skyFrame
	{fr->getMarkerBpandaAnglesCmd($1, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);}
	| INT BPANDA_ RADIUS_ coordSystem skyDist
	{fr->getMarkerBpandaRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::DistFormat)$5);}

	| INT CENTER_ coordSystem skyFrame skyFormat 
	{fr->getMarkerCenterCmd($1, (Coord::CoordSystem)$3, (Coord::SkyFrame)$4, 
	    (Coord::SkyFormat)$5);}
	| INT CIRCLE_ FILL_ {fr->getMarkerCircleFillCmd($1);}
	| INT CIRCLE_ RADIUS_ coordSystem skyDist
	{fr->getMarkerCircleRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::DistFormat)$5);}
	| INT COLOR_ {fr->getMarkerColorCmd($1);}
	| INT COMPASS_ ARROW_ {fr->getMarkerCompassArrowCmd($1);}
	| INT COMPASS_ LABEL_ {fr->getMarkerCompassLabelCmd($1);}
	| INT COMPASS_ RADIUS_ coordSystem skyDist
	{fr->getMarkerCompassRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::DistFormat)$5);}
	| INT COMPASS_ SYSTEM_ {fr->getMarkerCompassSystemCmd($1);}
	| INT COMPOSITE_ GLOBAL_ {fr->getMarkerCompositeCmd($1);}
	| INT CPANDA_ ANGLE_ {fr->getMarkerCpandaAnglesCmd($1);}
	| INT CPANDA_ ANGLE_ internalSystem {fr->getMarkerCpandaAnglesCmd($1);}
	| INT CPANDA_ ANGLE_ coordSystem skyFrame
	{fr->getMarkerCpandaAnglesCmd($1, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);}
	| INT CPANDA_ RADIUS_ coordSystem skyDist
	{fr->getMarkerCpandaRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::DistFormat)$5);}
	| INT ELLIPSE_ FILL_ {fr->getMarkerEllipseFillCmd($1);}
	| INT ELLIPSE_ RADIUS_ coordSystem skyDist
	{fr->getMarkerEllipseRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::DistFormat)$5);}
	| INT ELLIPSEANNULUS_ RADIUS_ coordSystem skyDist
	{fr->getMarkerEllipseAnnulusRadiusCmd($1, (Coord::CoordSystem)$4, 
	    (Coord::DistFormat)$5);}
	| INT EPANDA_ ANGLE_ {fr->getMarkerEpandaAnglesCmd($1);}
	| INT EPANDA_ ANGLE_ internalSystem {fr->getMarkerEpandaAnglesCmd($1);}
	| INT EPANDA_ ANGLE_ coordSystem skyFrame
	{fr->getMarkerEpandaAnglesCmd($1, (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);}
	| INT EPANDA_ RADIUS_ coordSystem skyDist
	{fr->getMarkerEpandaRadiusCmd($1, (Coord::CoordSystem)$4, (Coord::DistFormat)$5);}
	| INT FONT_ {fr->getMarkerFontCmd($1);}
	| INT HIGHLITE_ {fr->getMarkerHighlitedCmd($1);}
	| INT LINE_ ARROW_ {fr->getMarkerLineArrowCmd($1);}
	| INT LINE_ LENGTH_ coordSystem skyDist
	{fr->getMarkerLineLengthCmd($1, (Coord::CoordSystem)$4, (Coord::DistFormat)$5);}
	| INT LINE_ POINT_ coordSystem skyFrame skyFormat
	{fr->getMarkerLineCmd($1, (Coord::CoordSystem)$4,
	    (Coord::SkyFrame)$5, (Coord::SkyFormat)$6);}
	| INT MAP_ LENGTH_ numeric coordSystem skyDist
	{fr->getMarkerMapLenFromRefCmd($1, $4,
	    (Coord::CoordSystem)$5,(Coord::DistFormat)$6);}

	| INT POLYGON_ FILL_ {fr->getMarkerPolygonFillCmd($1);}
	| INT POINT_ SHAPE_ {fr->getMarkerPointShapeCmd($1);}
	| INT POINT_ SIZE_ {fr->getMarkerPointSizeCmd($1);}
	| INT PROJECTION_ POINT_ coordSystem skyFrame skyFormat
	{fr->getMarkerProjectionPointsCmd($1, (Coord::CoordSystem)$4,
	    (Coord::SkyFrame)$5, (Coord::SkyFormat)$6);}
	| INT PROJECTION_ LENGTH_ coordSystem skyDist
	{fr->getMarkerProjectionLengthCmd($1, (Coord::CoordSystem)$4, 
	    (Coord::DistFormat)$5);}
	| INT PROJECTION_ THICK_ coordSystem skyDist
	{fr->getMarkerProjectionWidthCmd($1,(Coord::CoordSystem)$4,(Coord::DistFormat)$5);}
	| INT PROPERTY_ {fr->getMarkerPropertyCmd($1);}
	| INT PROPERTY_ markerProperty {fr->getMarkerPropertyCmd($1,$3);}
        | INT RULER_ FORMAT_ {fr->getMarkerRulerDistSpecCmd($1);}
	| INT RULER_ LENGTH_ coordSystem skyDist
	{fr->getMarkerRulerLengthCmd($1,(Coord::CoordSystem)$4,(Coord::DistFormat)$5);}
	| INT RULER_ POINT_ coordSystem skyFrame skyFormat
	{fr->getMarkerRulerPointCmd($1, (Coord::CoordSystem)$4,
	    (Coord::SkyFrame)$5, (Coord::SkyFormat)$6);}
	| INT RULER_ SYSTEM_ {fr->getMarkerRulerSystemCmd($1);}
	| INT SELECT_ {fr->getMarkerSelectedCmd($1);}

	| INT TAG_ {fr->getMarkerTagCmd($1);}
	| INT TAG_ INT {fr->getMarkerTagCmd($1,$3);}
	| INT TEXT_ {fr->getMarkerTextCmd($1);}
	| INT TEXT_ ROTATE_ {fr->getMarkerTextRotateCmd($1);}
	| INT TYPE_ {fr->getMarkerTypeCmd($1);}

	| INT VECTOR_ ARROW_ {fr->getMarkerVectorArrowCmd($1);}
	| INT VECTOR_ LENGTH_ coordSystem skyDist
	{fr->getMarkerVectorLengthCmd($1, (Coord::CoordSystem)$4, (Coord::DistFormat)$5);}
	| INT VECTOR_ POINT_ coordSystem skyFrame skyFormat
	{fr->getMarkerVectorCmd($1, (Coord::CoordSystem)$4,
	    (Coord::SkyFrame)$5, (Coord::SkyFormat)$6);}
	| INT WIDTH_ {fr->getMarkerLineWidthCmd($1);}
	| HIGHLITE_ markerGetHighlite
	| HIGHLITE_ NUMBER_ {fr->getMarkerHighlitedNumberCmd();}
	| NUMBER_ {fr->getMarkerNumberCmd();}
	| POLYGON_ SEGMENT_ numeric numeric
	{fr->getMarkerPolygonSegmentCmd(Vector($3,$4));}
	| SEGMENT_ SEGMENT_ numeric numeric
	{fr->getMarkerSegmentSegmentCmd(Vector($3,$4));}
	| PRESERVE_ {fr->getMarkerPreserveCmd();}
	| PROPERTY_ markerProperty {fr->getMarkerPropertyCmd($2);}
	| SELECT_ markerGetSelect
	| SELECT_ NUMBER_ {fr->getMarkerSelectedNumberCmd();}

	| SHOW_ markerGetShow

	| STRING COLOR_ {fr->getMarkerColorCmd($1);}
	| STRING FONT_ {fr->getMarkerFontCmd($1);}
	| STRING ID_ {fr->getMarkerIdCmd($1);}
	| STRING PROPERTY_ markerProperty {fr->getMarkerPropertyCmd($1,$3);}
	| STRING TAG_ {fr->getMarkerTagCmd($1);}
	| STRING TAG_ NUMBER_ {fr->getMarkerTagNumberCmd($1);}

	| TAG_ ALL_ {fr->getMarkerTagsCmd();}
	| TAG_ DEFAULT_ NAME_ {fr->getMarkerTagDefaultNameCmd();}

	| WIDTH_ {fr->getMarkerLineWidthCmd();}
	;

markerGetCentroid : AUTO_ {fr->getMarkerCentroidAutoCmd();}
        | RADIUS_ {fr->getMarkerCentroidRadiusCmd();}
        | ITERATION_ {fr->getMarkerCentroidIterationCmd();}
	| OPTION_ {fr->getMarkerCentroidOptionCmd();}
	;

markerGetHighlite : /* empty */ {fr->getMarkerHighlitedCmd();}
	| numeric numeric {fr->getMarkerHighlitedCmd(Vector($1,$2));}
	;

markerGetSelect : /* empty */ {fr->getMarkerSelectedCmd();}
	| numeric numeric {fr->getMarkerSelectedCmd(Vector($1,$2));}
	;

markerGetShow : /* empty */ {fr->getMarkerShowCmd();}
	| TEXT_ {fr->getMarkerShowTextCmd();}
	;

markerInitProp : {
	  strncpy(currentFont, "helvetica 10 normal roman", 32);
	  strncpy(currentColor, "green", 16);
	  currentDash[0] = 8;
	  currentDash[1] = 3;
	  currentWidth = 1;
	  strncpy(currentText, "", 80);
	  currentProps = defaultProps;
	  taglist.deleteAll();
	  cblist.deleteAll();
	}
	;

markerLayer : /* empty */ {fr->markerLayerCmd(Base::USER);}
	| POINTER_ {
	  // backward compatibility
	  fr->markerLayerCmd(Base::USER);
	  }
	| REGION_ {fr->markerLayerCmd(Base::USER);}
	| USER_ {
	  // backward compatibility
	  fr->markerLayerCmd(Base::USER);
	  }
	| CATALOG_  {fr->markerLayerCmd(Base::CATALOG);}
	;

markerList : markerFormat coordSystem skyFrame skyFormat 
	    yesno markerQuery markerTags
	{fr->markerListCmd((Base::MarkerFormat)$1,
	    (Coord::CoordSystem)$2, (Coord::SkyFrame)$3, (Coord::SkyFormat)$4, $5,
	    0, propQMask, propQValue, taglist);}
	| SELECT_ markerFormat coordSystem skyFrame skyFormat 
	    yesno markerQuery markerTags
	{fr->markerListCmd((Base::MarkerFormat)$2, 
	    (Coord::CoordSystem)$3, (Coord::SkyFrame)$4, (Coord::SkyFormat)$5, $6,
	    1, propQMask, propQValue, taglist);}
	;

markerLoad : markerFormat STRING
	{fr->markerLoadCmd((Base::MarkerFormat)$1,$2);}
	| markerFormat STRING coordSystem skyFrame
	{fr->markerLoadCmd((Base::MarkerFormat)$1,$2,
	    (Coord::CoordSystem)$3,(Coord::SkyFrame)$4);}
	| markerFormat INT
	{fr->markerLoadCmd((Base::MarkerFormat)$1,$2);}
	| markerFormat INT coordSystem skyFrame
	{fr->markerLoadCmd((Base::MarkerFormat)$1,$2,
	    (Coord::CoordSystem)$3,(Coord::SkyFrame)$4);}
	| FITS_ STRING STRING markerDash INT STRING 
	{fr->markerLoadFitsCmd($2, $3, $4, $5, $6);}
	;

markerMoveSelected : numeric numeric {fr->markerMoveCmd(Vector($1,$2));}
	| FRONT_ {fr->markerFrontCmd();}
	| BACK_ {fr->markerBackCmd();}
	| BEGIN_ numeric numeric {fr->markerMoveBeginCmd(Vector($2,$3));}
	| MOTION_ numeric numeric {fr->markerMoveMotionCmd(Vector($2,$3));}
	| END_ {fr->markerMoveEndCmd();}
	| TO_ coordSystem skyFrame coord 
	{fr->markerMoveToCmd(Vector($4), (Coord::CoordSystem)$2, (Coord::SkyFrame)$3);}
	;

markerProps : markerProps markerProp
	| markerProp
	;

markerProp : markerProperty '=' yesno {setProps(&currentProps,$1,$3);}
	| COLOR_ '=' STRING {strncpy(currentColor,$3,16);}
	| DASHLIST_ '=' INT INT {currentDash[0]=$3;currentDash[1]=$4;}
	| WIDTH_ '=' INT {currentWidth = $3;}
	| FONT_ '=' STRING {strncpy(currentFont,$3,32);}
	| TEXT_ '=' STRING {strncpy(currentText,$3,80);}
	| tag
	| callback
	;

markerProperty : NONE_ {$$ = Marker::NONE;}
	| SELECT_ {$$ = Marker::SELECT;}
	| HIGHLITE_ {$$ = Marker::HIGHLITE;}
	| DASH_ {$$ = Marker::DASH;}
	| FIXED_ {$$ = Marker::FIXED;}
	| EDIT_ {$$ = Marker::EDIT;}
	| MOVE_  {$$ = Marker::MOVE;}
	| ROTATE_ {$$ = Marker::ROTATE;}
	| DELETE_ {$$ = Marker::DELETE;}
	| INCLUDE_ {$$ = Marker::INCLUDE;}
	| SOURCE_ {$$ = Marker::SOURCE;}
	;

markerProperties : /* empty */ markerInitProp
	| markerInitProp markerProps
	;

markerQuery: /* empty */ {propQMask=0;propQValue=0;}
	| {propQMask=0;propQValue=0;} queries
	;

markerSelect : ALL_ {fr->markerSelectAllCmd();}
	| ONLY_ numeric numeric {fr->markerSelectOnlyCmd(Vector($2,$3));}
	| TOGGLE_ {fr->markerSelectToggleCmd();}
	| TOGGLE_ numeric numeric {fr->markerSelectToggleCmd(Vector($2,$3));}
	;

markerShow : yesno {fr->markerShowCmd($1);}
	| TEXT_ yesno {fr->markerShowTextCmd($2);}
	;

queries : queries query
	| query
	;

query	: markerProperty '=' yesno 
	  {propQMask |= $1; setProps(&propQValue,$1,$3);}
	;

markerTags: /* empty */ {taglist.deleteAll();}
        | {taglist.deleteAll();} tags
	;

tags	: tags tag
	| tag
	;

tag	: TAG_ '=' STRING {taglist.append(new Tag($3));}
	;

callback : CALLBACK_ '=' markerCallBack STRING STRING {cblist.append(
	new CallBack(fr->getInterp(),(CallBack::Type)$3,$4,$5));}
	;

mask	: CLEAR_ {fr->maskClearCmd();}
	| COLOR_ STRING {fr->maskColorCmd($2);}
        | MARK_ maskType {fr->maskMarkCmd((FitsMask::MaskType)$2);}
	| RANGE_ numeric numeric {fr->maskRangeCmd($2,$3);}
        | SYSTEM_ coordSystem {fr->maskSystemCmd((Coord::CoordSystem)$2);}
	| TRANSPARENCY_ numeric {fr->maskTransparencyCmd($2);}
        | MARK_ INT {
	  // backward compatibility
	  fr->maskMarkCmd((FitsMask::MaskType)$2);
	}
	;

orient	: 'X' {fr->orientCmd(Coord::XX);}
	| 'Y' {fr->orientCmd(Coord::YY);}
	| XY_ {fr->orientCmd(Coord::XY);}
	| NONE_ {fr->orientCmd(Coord::NORMAL);}
	;

pan	: numeric numeric numeric numeric 
	  {fr->panCmd(Vector($1,$2),Vector($3,$4));}
	| numeric numeric {fr->panCmd(Vector($1,$2));}
	| internalSystem numeric numeric 
	{
	  // backward compatibility
	  fr->panCmd(Vector($2,$3));
	}
	| coordSystem skyFrame coord
	{fr->panCmd(Vector($3), (Coord::CoordSystem)$1, (Coord::SkyFrame)$2);}
	| TO_ panTo
	| BBOX_ numeric numeric {fr->panBBoxCmd(Vector($2,$3));}
	| MOTION_ panMotion
	| PRESERVE_ yesno {fr->panPreserveCmd($2);}
	;

panTo	: numeric numeric {fr->panToCmd(Vector($1,$2));}
	| internalSystem numeric numeric 
	{
	  // backward compatibility
	  fr->panToCmd(Vector($2,$3));
	}
	| coordSystem skyFrame coord
	{fr->panToCmd(Vector($3), (Coord::CoordSystem)$1, (Coord::SkyFrame)$2);}
	;

panMotion : BEGIN_ numeric numeric {fr->panBeginCmd(Vector($2,$3));}
	| numeric numeric {fr->panMotionCmd(Vector($1,$2));}
	| END_ numeric numeric {fr->panEndCmd(Vector($2,$3));}
	;

panner	: yesno {fr->pannerCmd($1);}
	| WCS_ wcsSystem skyFrame 
	{
	  // backward compatibility
	  fr->pannerCmd((Coord::CoordSystem)$2,(Coord::SkyFrame)$3);
	}
	| STRING INT INT {fr->pannerCmd($1, $2, $3);}
	| UPDATE_ {fr->updatePannerCmd();}
	;

postscript : COLORSPACE_ pscolorspace 
	{fr->psColorSpaceCmd((Widget::PSColorSpace)$2);}
	| LEVEL_ INT {fr->psLevelCmd($2);}
	| RESOLUTION_ INT {fr->psResolutionCmd($2);}
	| SCALE_ numeric {
	  // backward compatibility with backup
	}
	;

precision : INT INT INT INT INT INT INT INT INT
        {fr->precCmd($1,$2,$3,$4,$5,$6,$7,$8,$9);}
        | INT INT INT INT INT INT {
	  // backward compatibility with backup
	  fr->precCmd($1,$2,$3,$4,$5,$6);
	}
        ;

pscolorspace : BW_ {$$ = Widget::BW;}
	| GRAY_ {$$ = Widget::GRAY;}
	| RGB_ {$$ = Widget::RGB;}
	| CMYK_ {$$ = Widget::CMYK;}
	;

region	: HIGHLITE_ regionHighlite
	| SELECT_ regionSelect
	;

regionHighlite : BEGIN_ numeric numeric 
	{fr->regionHighliteBeginCmd(Vector($2,$3));}
	| MOTION_ numeric numeric 
	{fr->regionHighliteMotionCmd(Vector($2,$3));}
	| END_ {fr->regionHighliteEndCmd();}
	| SHIFT_ END_ {fr->regionHighliteShiftEndCmd();}
	;

regionSelect : BEGIN_ numeric numeric 
	{fr->regionSelectBeginCmd(Vector($2,$3));}
	| MOTION_ numeric numeric {fr->regionSelectMotionCmd(Vector($2,$3));}
	| END_ {fr->regionSelectEndCmd();}
	| SHIFT_ END_ {fr->regionSelectShiftEndCmd();}
	;

renderMethod: MIP_ {$$ = Frame3dBase::MIP;}
	| AIP_ {$$ = Frame3dBase::AIP;}
	;

renderBackground: NONE_ {$$ = Frame3dBase::NONE;}
	| AZIMUTH_ {$$ = Frame3dBase::AZIMUTH;}
	| ELEVATION_ {$$ = Frame3dBase::ELEVATION;}
	;

rgb	: CHANNEL_ STRING {fr->setRGBChannelCmd($2);}
	| SYSTEM_ coordSystem {fr->setRGBSystemCmd((Coord::CoordSystem)$2);}
	| VIEW_ INT INT INT {fr->setRGBViewCmd($2,$3,$4);}
	;

rotate	: numeric {fr->rotateCmd(zeroTWOPI(degToRad($1)));}
        | numeric DEGREES_ {fr->rotateCmd(zeroTWOPI(degToRad($1)));}
	| MOTION_ rotateMotion
	| TO_ numeric {fr->rotateToCmd(zeroTWOPI(degToRad($2)));}
        | TO_ numeric DEGREES_ {fr->rotateToCmd(zeroTWOPI(degToRad($2)));}
	;

rotateMotion : BEGIN_ {fr->rotateBeginCmd();}
        | numeric {fr->rotateMotionCmd(zeroTWOPI(degToRad($1)));}
	| END_ {fr->rotateEndCmd();}
	;

save	: ARRAY_ saveArray
	| FITS_ saveFits
        | NRRD_ saveNRRD
        | ENVI_ saveENVI
	| PHOTO_ STRING {fr->savePhotoCmd($2);}
	;

saveArray : FILE_ STRING endian 
	{fr->saveArrayFileCmd($2, (FitsFile::ArchType)$3);}
	| CHANNEL_ STRING endian 
	{fr->saveArrayChannelCmd($2, (FitsFile::ArchType)$3);}
	| SOCKET_ INT endian 
	{fr->saveArraySocketCmd($2, (FitsFile::ArchType)$3);}
        | RGB_ CUBE_ saveArrayRGBCube
	;

saveArrayRGBCube : FILE_ STRING endian 
	{fr->saveArrayRGBCubeFileCmd($2, (FitsFile::ArchType)$3);}
	| CHANNEL_ STRING endian 
	{fr->saveArrayRGBCubeChannelCmd($2, (FitsFile::ArchType)$3);}
	| SOCKET_ INT endian 
	{fr->saveArrayRGBCubeSocketCmd($2, (FitsFile::ArchType)$3);}

saveFits: /* empty */ saveFitsImage
        | IMAGE_ saveFitsImage
	| TABLE_ saveFitsTable
        | SLICE_ saveFitsSlice
        | EXT_ CUBE_ saveFitsExtCube
        | MOSAIC_ saveFitsMosaic
        | RGB_ IMAGE_ saveFitsRGBImage
        | RGB_ CUBE_ saveFitsRGBCube
	| RESAMPLE_ saveFitsResample
	;

saveFitsImage : FILE_ STRING {fr->saveFitsFileCmd($2);}
	| CHANNEL_ STRING {fr->saveFitsChannelCmd($2);}
	| SOCKET_ INT {fr->saveFitsSocketCmd($2);}
	;

saveFitsTable : FILE_ STRING {fr->saveFitsTableFileCmd($2);}
        | CHANNEL_ STRING {fr->saveFitsTableChannelCmd($2);}
	| SOCKET_ INT {fr->saveFitsTableSocketCmd($2);}
	;

saveFitsSlice : FILE_ STRING {fr->saveFitsSliceFileCmd($2);}
	| CHANNEL_ STRING {fr->saveFitsSliceChannelCmd($2);}
	| SOCKET_ INT {fr->saveFitsSliceSocketCmd($2);}
	;

saveFitsExtCube : FILE_ STRING {fr->saveFitsExtCubeFileCmd($2);}
	| CHANNEL_ STRING {fr->saveFitsExtCubeChannelCmd($2);}
	| SOCKET_ INT {fr->saveFitsExtCubeSocketCmd($2);}
	;

saveFitsMosaic : IMAGE_ saveFitsMosaicImage 
        | FILE_ STRING INT {fr->saveFitsMosaicFileCmd($2,$3);}
        | CHANNEL_ STRING INT {fr->saveFitsMosaicChannelCmd($2,$3);}
        | SOCKET_ INT INT {fr->saveFitsMosaicSocketCmd($2,$3);}
        ;

saveFitsMosaicImage : FILE_ STRING {fr->saveFitsMosaicImageFileCmd($2);}
        | CHANNEL_ STRING {fr->saveFitsMosaicImageChannelCmd($2);}
        | SOCKET_ INT {fr->saveFitsMosaicImageSocketCmd($2);}
        ;

saveFitsRGBImage : FILE_ STRING {fr->saveFitsRGBImageFileCmd($2);}
	| CHANNEL_ STRING {fr->saveFitsRGBImageChannelCmd($2);}
	| SOCKET_ INT {fr->saveFitsRGBImageSocketCmd($2);}
	;

saveFitsRGBCube : FILE_ STRING {fr->saveFitsRGBCubeFileCmd($2);}
	| CHANNEL_ STRING {fr->saveFitsRGBCubeChannelCmd($2);}
	| SOCKET_ INT {fr->saveFitsRGBCubeSocketCmd($2);}
	;

saveFitsResample : FILE_ STRING {fr->saveFitsResampleFileCmd($2);}
	| CHANNEL_ STRING {fr->saveFitsResampleChannelCmd($2);}
	| SOCKET_ INT {fr->saveFitsResampleSocketCmd($2);}
	;

saveNRRD : FILE_ STRING endian 
	  {fr->saveNRRDFileCmd($2, (FitsFile::ArchType)$3);}
	| CHANNEL_ STRING endian 
	  {fr->saveNRRDChannelCmd($2, (FitsFile::ArchType)$3);}
	| SOCKET_ INT endian 
	  {fr->saveNRRDSocketCmd($2, (FitsFile::ArchType)$3);}
	;

saveENVI : FILE_ STRING STRING endian 
        {fr->saveENVIFileCmd($2, $3, (FitsFile::ArchType)$4);}
        ;

smooth	: smoothFunction INT INT numeric numeric angle
        {fr->smoothCmd((Context::SmoothFunction)$1,$2,$3,$4,$5,$6);}
	| smoothFunction INT
        {
	  // backward compatibility with backup
	  fr->smoothCmd((Context::SmoothFunction)$1,$2);
	}
	| DELETE_ {fr->smoothDeleteCmd();}
	;

smoothFunction : BOXCAR_ {$$ = Context::BOXCAR;}
	| TOPHAT_ {$$ = Context::TOPHAT;}
	| GAUSSIAN_ {$$ = Context::GAUSSIAN;}
	| ELLIPTIC_ {$$ = Context::ELLIPTIC;}
	;

update	: /* empty */ {fr->updateFitsCmd(0);}
	| INT numeric numeric numeric numeric
	{fr->updateFitsCmd($1,BBox($2,$3,$4,$5),0);}
	| NOW_ {fr->updateFitsCmd(1);}
	| NOW_ INT numeric numeric numeric numeric
	{fr->updateFitsCmd($2,BBox($3,$4,$5,$6),1);}
	| FITS_ SLICE_ updateFitsSlice
	;

updateFitsSlice : INT {fr->sliceCmd($1);}
        | numeric coordSystem skyFrame
	{fr->sliceCmd($1, (Coord::CoordSystem)$2, (Coord::SkyFrame $3));}
        | INT INT {
	  // backward compatibility with backup
	  fr->sliceCmd($2);
	}
	;

warp	: numeric numeric {fr->warpCmd(Vector($1,$2));}
	| TO_ numeric numeric {fr->warpToCmd(Vector($2,$3));}
	;

wcs	: wcsSystem skyFrame skyFormat 
	{fr->wcsCmd((Coord::CoordSystem)$1, (Coord::SkyFrame)$2, (Coord::SkyFormat)$3);}
	| ALIGN_ wcsAlign
	| RESET_ INT {fr->wcsResetCmd($2);}
	| REPLACE_ wcsReplace
	| APPEND_ wcsAppend
	;

wcsAppend : INT INT {fr->wcsAppendCmd($1,$2);}
	| INT STRING {fr->wcsAppendCmd($1,$2);}
	| TEXT_ INT STRING {fr->wcsAppendTxtCmd($2,$3);}
	;

wcsReplace : INT INT {fr->wcsReplaceCmd($1,$2);}
	| INT STRING {fr->wcsReplaceCmd($1,$2);}
	| TEXT_ INT STRING {fr->wcsReplaceTxtCmd($2,$3);}
	;

wcsAlign : INT {fr->wcsAlignCmd($1);}
	|  INT wcsSystem skyFrame 
	{
	  // used by backup
	  fr->wcsAlignCmd($1, (Coord::CoordSystem)$2, (Coord::SkyFrame)$3);
	}
	| INT POINTER wcsSystem skyFrame
	{fr->wcsAlignCmd($1, (FitsImage*)$2, (Coord::CoordSystem)$3, (Coord::SkyFrame)$4);}
	;

win32	: PRINT_ {
#ifdef __WIN32
	  fr->win32PrintCmd();
#endif
	}
	;

zoom	: numeric numeric {fr->zoomCmd(Vector($1,$2));}
	| numeric numeric ABOUT_ numeric numeric
	  {fr->zoomAboutCmd(Vector($1,$2),Vector($4,$5));}
	| numeric numeric ABOUT_ internalSystem numeric numeric
	{
	  // backward compatibility
	  fr->zoomAboutCmd(Vector($1,$2),Vector($5,$6));
	}
	| numeric numeric ABOUT_ coordSystem skyFrame coord
	{fr->zoomAboutCmd(Vector($1,$2),Vector($6), (Coord::CoordSystem)$4,(Coord::SkyFrame)$5);}
	| TO_ zoomTo
	;

zoomTo	: FIT_	{fr->zoomToFitCmd(1);}
	| FIT_	numeric {fr->zoomToFitCmd($2);}
	| numeric numeric {fr->zoomToCmd(Vector($1,$2));}
	| numeric numeric ABOUT_ numeric numeric
	{fr->zoomToAboutCmd(Vector($1,$2),Vector($4,$5));}
	| numeric numeric ABOUT_ internalSystem numeric numeric
	{
	  // backward compatibility
	  fr->zoomToAboutCmd(Vector($1,$2),Vector($5,$6));
	}
	| numeric numeric ABOUT_ coordSystem skyFrame coord
	  {fr->zoomToAboutCmd(Vector($1,$2), Vector($6),
	    (Coord::CoordSystem)$4, (Coord::SkyFrame)$5);}
	;

%%

static void setProps(unsigned short* props, unsigned short prop, int value)
{
  if (value)
    *props |= prop;
  else
    *props &= ~prop;
}