summaryrefslogtreecommitdiffstats
path: root/ds9/library/lex.fcl
blob: fe661bed1fe5a367b81505f9018b0974db195e6b (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
%{
source $ds9(root)/library/parser.tab.tcl
%}

%option noyywrap
%option caseless
%option nodefault
%option nointeractive
%option stack
%option yylineno
%option debug

%x FOO
%s BAR

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

%%

<FOO>close	    {return $yy::CLOSE_}
<BAR>in	    {return $yy::IN_}
fit	    {return $yy::FIT_}
open	    {return $yy::OPEN_}
out	    {return $yy::OUT_}
to	    {return $yy::TO_}

# INT
[+-]?{D}+ {set yy::yylval $yytext; return $yy::INT_}

# REAL
[+-]?{D}+"."?({E})? |
[+-]?{D}*"."{D}+({E})? {set yy::yylval $yytext; return $yy::REAL_}

# Quoted STRING
\"[^\"]*\" {set yy::yylval [string range $yytext 1 end-1]; return $yy::STRING_}

# Quoted STRING
\'[^\']*\' {set yy::yylval [string range $yytext 1 end-1]; return $yy::STRING_}

# Quoted STRING
\{[^\}]*\} {set yy::yylval [string range $yytext 1 end-1]; return $yy::STRING_}

# STRING
\S+\S+ {set yy::yylval $yytext; return $yy::STRING_}

\s        # ignore whitespace

.	  {set yy::yylval $yytext; return $yy::yylval}

%%