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
|
/* Copyright (C) 1999-2016
* Smithsonian Astrophysical Observatory, Cambridge, MA, USA
* For conditions of distribution and use, see copyright notice in "copyright"
*/
%option noyywrap
%option caseless
%option never-interactive
%option c++
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "util.h"
#include "ds9parser.H"
extern YYSTYPE* mklval;
extern mkFlexLexer* mklexx;
%}
%x DISCARD
D [0-9]
E [Ee][+-]?{D}+
H [0-9a-fA-F]
/* rules */
%%
<DISCARD>[\n] { // special case-- #\n
BEGIN INITIAL;
yyless(0); // put back the terminator
strcpy(mklval->str,""); // feed a blank string
return STRING;
}
<DISCARD>[^\n]* { // Discard reset of line
BEGIN INITIAL;
int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1);
strncpy(mklval->str,yytext,ll);
mklval->str[ll] = '\0';
return STRING;
}
amplifier {return AMPLIFIER_;}
ann[u][l][u][s] {return ANNULUS_;}
arcmin {return ARCMIN_;}
arcsec {return ARCSEC_;}
arrow {return ARROW_;}
b1950 {return B1950_;}
background {return BACKGROUND_;}
begin {return BEGIN_;}
box {return BOX_;}
boxcircle {return BOXCIRCLE_;}
bpanda {return BPANDA_;}
callback {return CALLBACK_;}
cir[c][l][e] {return CIRCLE_;}
circle3d {return CIRCLE3D_;}
color {return COLOR_;}
compass {return COMPASS_;}
composite {return COMPOSITE_;}
cpanda {return CPANDA_;}
cross {return CROSS_;}
dash {return DASH_;}
dashlist {return DASHLIST_;}
debug {return DEBUG_;}
degrees {return DEGREES_;}
delete {return DELETE_;}
detector {return DETECTOR_;}
diamond {return DIAMOND_;}
edit {return EDIT_;}
ell[i][p][s][e] {return ELLIPSE_;}
ecliptic {return ECLIPTIC_;}
epanda {return EPANDA_;}
end {return END_;}
false {return FALSE_;}
fie[l][d] {return FIELD_;}
fill {return FILL_;}
fixed {return FIXED_;}
fk4 {return FK4_;}
fk4-no-e {return FK4_NO_E_;}
fk5 {return FK5_;}
font {return FONT_;}
galactic {return GALACTIC_;}
global {return GLOBAL_;}
helioecliptic {return HELIOECLIPTIC_;}
highlite {return HIGHLITE_;}
icrs {return ICRS_;}
ignore {return IGNORE_;}
include {return INCLUDE_;}
image {return IMAGE_;}
key {return KEY_;}
j2000 {return J2000_;}
lin[e] {return LINE_;}
linear {return LINEAR_;}
move {return MOVE_;}
n {return N_;}
no {return NO_;}
off {return OFF_;}
on {return ON_;}
panda {return CPANDA_;}
physical {return PHYSICAL_;}
pie {return PIE_;}
pixels {return PIXELS_;}
poi[n][t] {return POINT_;}
pol[y][g][o][n] {return POLYGON_;}
projection {return PROJECTION_;}
property {return PROPERTY_;}
rotate {return ROTATE_;}
rotbox {return ROTBOX_;}
ruler {return RULER_;}
select {return SELECT_;}
segment {return SEGMENT_;}
source {return SOURCE_;}
supergalactic {return SUPERGALACTIC_;}
tag {return TAG_;}
text {return TEXT_;}
textangle {return TEXTANGLE_;}
textrotate {return TEXTROTATE_;}
tile {return TILE_;}
true {return TRUE_;}
vector {return VECTOR_;}
version {return VERSION_;}
update {return UPDATE_;}
unhighlite {return UNHIGHLITE_;}
unselect {return UNSELECT_;}
wcs {return WCS_;}
wcsa {return WCSA_;}
wcsb {return WCSB_;}
wcsc {return WCSC_;}
wcsd {return WCSD_;}
wcse {return WCSE_;}
wcsf {return WCSF_;}
wcsg {return WCSG_;}
wcsh {return WCSH_;}
wcsi {return WCSI_;}
wcsj {return WCSJ_;}
wcsk {return WCSK_;}
wcsl {return WCSL_;}
wcsm {return WCSM_;}
wcsn {return WCSN_;}
wcso {return WCSO_;}
wcsp {return WCSP_;}
wcsq {return WCSQ_;}
wcsr {return WCSR_;}
wcss {return WCSS_;}
wcst {return WCST_;}
wcsu {return WCSU_;}
wcsv {return WCSV_;}
wcsw {return WCSW_;}
wcsx {return WCSX_;}
wcsy {return WCSY_;}
wcsz {return WCSZ_;}
wcs0 {return WCS0_;}
width {return WIDTH_;}
x {return X_;}
y {return Y_;}
yes {return YES_;}
[+-]?{D}+ { // Integer
mklval->integer = atoi(yytext);
return INT;
}
[+-]?{D}+"."?({E})? |
[+-]?{D}*"."{D}+({E})? { // Real Number
mklval->real = atof(yytext);
return REAL;
}
[+-]?{D}+"."?d |
[+-]?{D}*"."{D}+d { // degrees
yytext[yyleng-1] = '\0';
mklval->real = atof(yytext);
return ANGDEGREE;
}
[+-]?{D}+"."?r |
[+-]?{D}*"."{D}+r { // radians
yytext[yyleng-1] = '\0';
mklval->real = atof(yytext);
return ANGRADIAN;
}
[+-]?{D}+"."?p |
[+-]?{D}*"."{D}+p { // physical coords
yytext[yyleng-1] = '\0';
mklval->real = atof(yytext);
return PHYCOORD;
}
[+-]?{D}+"."?i |
[+-]?{D}*"."{D}+i { // image coords
yytext[yyleng-1] = '\0';
mklval->real = atof(yytext);
return IMGCOORD;
}
{D}+"."?' |
{D}*"."{D}+' |
[+-]?{D}+"."?({E})?' |
[+-]?{D}*"."{D}+({E})?' { // minutes of arc
yytext[yyleng-1] = '\0';
mklval->real = atof(yytext);
return ARCMINUTE;
}
{D}+"."?\" |
{D}*"."{D}+\" |
[+-]?{D}+"."?({E})?\" |
[+-]?{D}*"."{D}+({E})?\" { // seconds of arc
yytext[yyleng-1] = '\0';
mklval->real = atof(yytext);
return ARCSECOND;
}
[+-]?{D}+:{D}+:{D}+"."? |
[+-]?{D}+:{D}+:{D}*"."{D}+ { // Sexagesimal
int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1);
strncpy(mklval->str,yytext,ll);
mklval->str[ll] = '\0';
return SEXSTR;
}
[+-]?{D}+h{D}+m{D}+"."?s |
[+-]?{D}+h{D}+m{D}*"."{D}+s { // HMS
int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1);
strncpy(mklval->str,yytext,ll);
mklval->str[ll] = '\0';
return HMSSTR;
}
[+-]?{D}+d{D}+m{D}+"."?s |
[+-]?{D}+d{D}+m{D}*"."{D}+s { // DMS
int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1);
strncpy(mklval->str,yytext,ll);
mklval->str[ll] = '\0';
return DMSSTR;
}
#({H}){3} { // 8 bit Hex Color
int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1);
strncpy(mklval->str,yytext,ll);
mklval->str[ll] = '\0';
return STRING;
}
#({H}){6} { // 16 bit Hex Color
int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1);
strncpy(mklval->str,yytext,ll);
mklval->str[ll] = '\0';
return STRING;
}
#({H}){12} { // 32 bit Hex Color
int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1);
strncpy(mklval->str,yytext,ll);
mklval->str[ll] = '\0';
return STRING;
}
\"[^\"\n]*\" |
\'[^\'\n]*\' { // Quoted String
int ll = (yyleng-2)<(MKBUFSIZE-1) ? (yyleng-2):(MKBUFSIZE-1);
strncpy(mklval->str,yytext+1,ll); // skip the " "
mklval->str[ll] = '\0'; // Remove the '"'
return STRING;
}
\{[^\}\n]*\} { // Quoted String
int ll = (yyleng-2)<(MKBUFSIZE-1) ? (yyleng-2):(MKBUFSIZE-1);
strncpy(mklval->str,yytext+1,ll); // skip the '{'
mklval->str[ll] = '\0'; // Remove the '}'
return STRING;
}
[0-9A-Za-z]+ { // General String
int ll = yyleng <(MKBUFSIZE-1) ? yyleng:(MKBUFSIZE-1);
strncpy(mklval->str,yytext,ll);
mklval->str[ll] = '\0';
return STRING;
}
[ \t]+ { // White Spaces
}
\r\n { // windows line feed
return '\n';
}
\\n { // fake line feed
return '\n';
}
\n { // linefeed
return '\n';
}
<<EOF>> { // eof
return EOF_;
}
. { // Else, return the char
return yytext[0];
}
%%
void mkDiscard(int doit)
{
if (mklexx)
mklexx->begin(DISCARD, doit);
}
void mkFlexLexer::begin(int which, int doit)
{
BEGIN which;
if (doit)
yyless(0);
}
|