summaryrefslogtreecommitdiffstats
path: root/tksao/frame/ciaolex.L
blob: 7f454cb635d15ff0e30511bba3e2c94a3ad749f1 (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
/* Copyright (C) 1999-2018
 * 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 "ciaoparser.H"

  extern YYSTYPE* ciaolval;
%}

D   [0-9]
E   [Ee][+-]?{D}+

/* rules */

%%

annulus			{return ANNULUS_;}
box			{return BOX_;}
cir			{return CIRCLE_;}
circle			{return CIRCLE_;}
debug			{return DEBUG_;}
ell			{return ELLIPSE_;}
ellipse			{return ELLIPSE_;}
field                   {return FIELD_;}
off			{return OFF_;}
on			{return ON_;}
pie			{return PIE_;}
poi			{return POINT_;}
point			{return POINT_;}
poly			{return POLYGON_;}
polygon			{return POLYGON_;}
rect                    {return RECTANGLE_;}
rectangle               {return RECTANGLE_;}
region                  {return REGION_;}
rotbox			{return ROTBOX_;}
sector                  {return SECTOR_;}
version			{return VERSION_;}

[+-]?{D}+	{ // Integer
		  ciaolval->integer = atoi(yytext);
		  return INT;
		}

[+-]?{D}+"."?({E})? |
[+-]?{D}*"."{D}+({E})? { // Real Number
		  ciaolval->real = atof(yytext);
		  return REAL;
		}

[+-]?{D}+"."?d |
[+-]?{D}*"."{D}+d { // degrees
		  yytext[yyleng-1] = '\0';
		  ciaolval->real = atof(yytext);
		  return ANGDEGREE;
		}	

{D}+"."?' |
{D}*"."{D}+' |
[+-]?{D}+"."?({E})?' |
[+-]?{D}*"."{D}+({E})?' { // minutes of arc
		  yytext[yyleng-1] = '\0';
		  ciaolval->real = atof(yytext);
		  return ARCMINUTE;
		}	

{D}+"."?\" |
{D}*"."{D}+\" |
[+-]?{D}+"."?({E})?\" |
[+-]?{D}*"."{D}+({E})?\" { // seconds of arc
		  yytext[yyleng-1] = '\0';
		  ciaolval->real = atof(yytext);
		  return ARCSECOND;
		}

{D}+"."?\'\' |
{D}*"."{D}+\'\'	|
[+-]?{D}+"."?({E})?\'\' |
[+-]?{D}*"."{D}+({E})?\'\' { // seconds of arc
		  yytext[yyleng-1] = '\0';
		  ciaolval->real = atof(yytext);
		  return ARCSECOND;
		}

[+-]?{D}+:{D}+:{D}+"."? |
[+-]?{D}+:{D}+:{D}*"."{D}+ { // Sexagesimal
		  int ll = yyleng <(CIAOBUFSIZE-1) ? yyleng:(CIAOBUFSIZE-1);
		  strncpy(ciaolval->str,yytext,ll);
	          ciaolval->str[ll] = '\0';
		  return SEXSTR;
		}	

[+-]?{D}+h{D}+m{D}+"."?s |
[+-]?{D}+h{D}+m{D}*"."{D}+s { // HMS
		  int ll = yyleng <(CIAOBUFSIZE-1) ? yyleng:(CIAOBUFSIZE-1);
		  strncpy(ciaolval->str,yytext,ll);
	          ciaolval->str[ll] = '\0';
		  return HMSSTR;
		}	

[+-]?{D}+d{D}+m{D}+"."?s |
[+-]?{D}+d{D}+m{D}*"."{D}+s { // DMS
		  int ll = yyleng <(CIAOBUFSIZE-1) ? yyleng:(CIAOBUFSIZE-1);
		  strncpy(ciaolval->str,yytext,ll);
	          ciaolval->str[ll] = '\0';
		  return DMSSTR;
		}	

#.*		{ // comment, eat it
		}

[ \t]+		{ // White Spaces
		} 

\\n		{ // fake line feed
		  return '\n';
		}

\r\n		{ // windows line feed
		  return '\n';
		}

\n		{ // linefeed
		  return '\n';
		}

<<EOF>>		{ // eof
		  return EOF_;
		}

.		{ // Else, return the char
		  return yytext[0];
		}

%%