summaryrefslogtreecommitdiffstats
path: root/tksao/frame/xylex.L
blob: 2217783b0a3041d2d5b965644b2dfcc77b3b4894 (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
/* 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 "xyparser.H"

  extern YYSTYPE* xylval;
%}

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

/* rules */

%%

amplifier	{return AMPLIFIER_;}
b1950		{return B1950_;}
ccd		{return CCD_;}
debug		{return DEBUG_;}
detector	{return DETECTOR_;}
ecliptic	{return ECLIPTIC_;}
fk4		{return FK4_;}
fk5		{return FK5_;}
galactic	{return GALACTIC_;}
icrs		{return ICRS_;}
image		{return IMAGE_;}
j2000		{return J2000_;}
logical		{return LOGICAL_;}
off		{return OFF_;}
on		{return ON_;}
physical	{return PHYSICAL_;}
version		{return VERSION_;}
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_;}

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

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

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

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

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

#.*		{ // comment, eat it
		}

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

[\n;,]		{ // special chars
		  return yytext[0];
		}

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

.		{ // Else, eat it
		}

%%