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
|
%{
%}
#include yesno.tin
#include coordsys.tin
#include wcssys.tin
#include skyframe.tin
#include skyformat.tin
#include numeric.tin
#include string.tin
%start command
%token ALL_
%token AT_
%token AUTO_
%token AUTOCENTROID_
%token BACK_
%token BACKGROUND_
%token CENTROID_
%token CLOSE_
%token COLOR_
%token COMMAND_
%token COMPOSITE_
%token COPY_
%token CUT_
%token DELETE_
%token DELETEALL_
%token DELIM_
%token DISSOLVE_
%token EDIT_
%token EPSILON_
%token EXCLUDE_
%token FILE_
%token FIXED_
%token FONT_
%token FORMAT_
%token FRONT_
%token GETINFO_
%token GROUP_
%token GROUPS_
%token INCLUDE_
%token INVERT_
%token ITERATION_
%token LIST_
%token LOAD_
%token MOVE_
%token MOVEBACK_
%token MOVEFRONT_
%token NEW_
%token NL_
%token NONE_
%token PASTE_
%token PROPERTY_
%token RADIUS_
%token ROTATE_
%token SAVE_
%token SAVETEMPLATE_
%token SELECT_
%token SELECTALL_
%token SELECTNONE_
%token SHAPE_
%token SHOW_
%token SHOWTEXT_
%token SKY_
%token SKYFORMAT_
%token SOURCE_
%token STRIP_
%token SYSTEM_
%token TEMPLATE_
%token UNDO_
%token UPDATE_
%token WIDTH_
%token DS9_
%token XML_
%token CIAO_
%token SAOTNG_
%token PROS_
%token SAOIMAGE_
%token XY_
%token CIRCLE_
%token ELLIPSE_
%token BOX_
%token POLYGON_
%token POINT_
%token LINE_
%token VECTOR_
%token TEXT_
%token RULER_
%token COMPASS_
%token PROJECTION_
%token ANNULUS_
%token PANDA_
%token EPANDA_
%token BPANDA_
%token COMPOSITE_
%token DIAMOND_
%token CROSS_
%token ARROW_
%token BOXCIRCLE_
%token MFORMAT_
%token MSYSTEM_
%token MSKY_
%%
#include yesno.trl
#include coordsys.trl
#include wcssys.trl
#include skyframe.trl
#include skyformat.trl
#include numeric.trl
command : region
| region {yyclearin; YYACCEPT} STRING_
;
region : {RegionCmdLoad}
| props {RegionCmdLoad}
| STRING_ {RegionCmdLoadFn $1}
| STRING_ props {RegionCmdLoadFn $1}
| LOAD_ loadall STRING_ {RegionCmdLoadFn $3 $2}
# backward compatibility
| FILE_ loadall STRING_ {RegionCmdLoadFn $3 $2}
| SAVE_ STRING_ {RegionCmdSave $2}
| LIST_ list
| EPSILON_ INT_ {ProcessCmdSet pmarker epsilon $2 MarkerEpsilon}
| SHOW_ yesno {ProcessCmdSet marker show $2 MarkerShow}
| SHOWTEXT_ yesno {ProcessCmdSet marker show,text $2 MarkerShowText}
| CENTROID_ centroid
# backward compatibility
| AUTOCENTROID_ yesno {ProcessCmdSet marker centroid,auto $2 MarkerCentroidAuto}
| GETINFO_ {MarkerInfo}
| MOVE_ move
# backward compatibility
| MOVEFRONT_ {MarkerFront}
# backward compatibility
| MOVEBACK_ {MarkerBack}
| SELECT_ select
# backward compatibility
| SELECTALL_ {MarkerSelectAll}
# backward compatibility
| SELECTNONE_ {MarkerUnSelectAll}
| DELETE_ delete
# backward compatibility
| DELETEALL_ {MarkerDeleteAll}
| FORMAT_ format {ProcessCmdSet marker format $2}
| SYSTEM_ coordsys {ProcessCmdSet marker system $2}
| SYSTEM_ wcssys {ProcessCmdSet marker system $2}
# backward compatibility
| SYSTEM_ skyframe {ProcessCmdSet marker system wcs; ProcessCmdSet marker sky $2}
| SKY_ skyframe {ProcessCmdSet marker sky $2}
| SKYFORMAT_ skyformat {ProcessCmdSet marker skyformat $2}
| STRIP_ yesno {ProcessCmdSet marker strip $2}
# backward compatibility
| DELIM_ delim {ProcessCmdSet marker strip $2}
| SHAPE_ shape {ProcessCmdSet marker shape $2}
| COLOR_ STRING_ {ProcessCmdSet marker color $2 MarkerColor}
| WIDTH_ INT_ {ProcessCmdSet marker width $2 MarkerWidth}
| FIXED_ yesno {ProcessCmdSet marker fixed $2 [list MarkerProp fixed]}
| EDIT_ yesno {ProcessCmdSet marker edit $2 [list MarkerProp edit]}
| ROTATE_ yesno {ProcessCmdSet marker rotate $2 [list MarkerProp rotate]}
| DELETE_ yesno {ProcessCmdSet marker delete $2 [list MarkerProp delete]}
| INCLUDE_ {ProcessCmdSet marker include 1 [list MarkerProp include]}
| EXCLUDE_ {ProcessCmdSet marker include 0 [list MarkerProp include]}
| SOURCE_ {ProcessCmdSet marker source 1 [list MarkerProp source]}
| BACKGROUND_ {ProcessCmdSet marker source 0 [list MarkerProp source]}
| GROUPS_ group
| GROUP_ group
| COPY_ {MarkerCopy}
| CUT_ {MarkerCut}
| PASTE_ {ProcessCmdSet marker paste,system wcs MarkerPaste}
| PASTE_ coordsys {ProcessCmdSet marker paste,system $2 MarkerPaste}
| PASTE_ wcssys {ProcessCmdSet marker paste,system $2 MarkerPaste}
# backward compatibility
| PASTE_ skyframe {ProcessCmdSet marker paste,system wcs MarkerPaste}
| UNDO_ {MarkerUndo}
| COMPOSITE_ {CompositeCreate}
| DISSOLVE_ {CompositeDelete}
| TEMPLATE_ template
| SAVETEMPLATE_ STRING_ {RegionCmdTemplateSave $2}
| COMMAND_ STRING_ {RegionCmdCommand $2}
;
props : props prop
| prop
;
prop : MFORMAT_ format {ProcessCmdSet marker load,format $2}
| MSYSTEM_ coordsys {ProcessCmdSet marker load,system $2}
| MSYSTEM_ wcssys {ProcessCmdSet marker load,system $2}
# backward compatibility
| MSYSTEM_ skyframe {ProcessCmdSet marker load,system wcs; ProcessCmdSet marker load,sky $2}
| MSKY_ skyframe {ProcessCmdSet marker load,sky $2}
;
loadall : {set _ 0}
| ALL_ {set _ 1}
;
list : {RegionCmdList}
| CLOSE_ {SimpleTextDestroy markertxt}
;
centroid : {MarkerCentroid}
| AUTO_ yesno {ProcessCmdSet marker centroid,auto $2 MarkerCentroidAuto}
| RADIUS_ numeric {ProcessCmdSet marker centroid,radius $2 MarkerCentroidRadius}
| ITERATION_ INT_ {ProcessCmdSet marker centroid,iteration $2 MarkerCentroidIteration}
;
move : FRONT_ {MarkerFront}
| BACK_ {MarkerBack}
;
select : ALL_ {MarkerSelectAll}
| NONE_ {MarkerUnselectAll}
| INVERT_ {MarkerSelectInvert}
# backward compatibility
| GROUP_ STRING_ {ProcessCmdSet marker tag $2; RegionCmdGroup select}
;
delete : ALL_ {MarkerDeleteAll}
| SELECT_ {MarkerDeleteSelect}
;
format : DS9_ {set _ ds9}
| XML_ {set _ xml}
| CIAO_ {set _ ciao}
| SAOTNG_ {set _ saotng}
| PROS_ {set _ pros}
| SAOIMAGE_ {set _ saoimage}
| XY_ {set _ xy}
;
shape : CIRCLE_
| ELLIPSE_
| BOX_
| POLYGON_
| point POINT_
| LINE_
| VECTOR_
| TEXT_
| RULER_
| COMPASS_
| PROJECTION_
| ANNULUS_
| ELLIPSE_ ANNULUS_
| BOX_ ANNULUS_
| PANDA_
| EPANDA_
| BPANDA_
| COMPOSITE_
;
point :
| CIRCLE_
| BOX_
| DIAMOND_
| CROSS_
| 'X'
| 'x'
| ARROW_
| BOXCIRCLE_
;
delim : NL_ {set _ 0}
| STRING_ {set _ 1}
;
template : STRING_ {RegionCmdTemplate $1}
| STRING_ AT_ numeric numeric {RegionCmdTemplateAt $1 $3 $4 wcs fk5}
| STRING_ AT_ numeric numeric wcssys {RegionCmdTemplateAt $1 $3 $4 $5 fk5}
| STRING_ AT_ numeric numeric skyframe {RegionCmdTemplateAt $1 $3 $4 wcs $5}
| STRING_ AT_ numeric numeric wcssys skyframe {RegionCmdTemplateAt $1 $3 $4 $5 $6}
;
group : NEW_ {RegionCmdGroupNew}
| STRING_ {ProcessCmdSet marker tag $1} groupTag
;
groupTag : NEW_ {RegionCmdGroupNew}
| UPDATE_ {RegionCmdGroupUpdate}
| DELETE_ {RegionCmdGroup delete}
| SELECT_ {RegionCmdGroup select}
| COLOR_ STRING_ {RegionCmdGroup color $2}
| COPY_ {RegionCmdGroup copy}
| CUT_ {RegionCmdGroup cut}
| FONT_ STRING_ {RegionCmdGroupFont $2}
| MOVE_ INT_ INT_ {RegionCmdGroup move $2 $3}
| MOVEFRONT_ {RegionCmdGroup {move front}}
| MOVEBACK_ {RegionCmdGroup {move back}}
| PROPERTY_ property yesno {RegionCmdGroup property $2 $3}
;
property : SELECT_ {set _ select}
| EDIT_ {set _ edit}
| MOVE_ {set _ move}
| ROTATE_ {set _ rotate}
| DELETE_ {set _ delete}
| FIXED_ {set _ fixed}
| INCLUDE_ {set _ include}
| SOURCE_ {set _ source}
;
%%
proc region::yyerror {msg} {
variable yycnt
variable yy_current_buffer
variable index_
ParserError $msg $yycnt $yy_current_buffer $index_
}
|