-
Notifications
You must be signed in to change notification settings - Fork 16
/
sscan.l
55 lines (49 loc) · 1.13 KB
/
sscan.l
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
%{
#include <stdio.h>
#include "string.h"
#include "sparse.h"
#include "sbuffer.h"
#define YY_DECL int sphere_yylex(void)
YY_DECL;
#define yylval sphere_yylval
#undef YY_INPUT
#define YY_NO_INPUT
#define YY_INPUT(buf, result, max_size) \
{ \
result = get_buffer(buf, max_size); \
result = (result > 0) ? (result) : (YY_NULL); \
}
void sphere_flush_scanner_buffer(void)
{
YY_FLUSH_BUFFER;
}
%}
%option 8bit
%option never-interactive
%option nounput
%option noyywrap
int [0-9]+
sign [+-]
real ({int})?\.({int})
float ({int}|{real})([eE]{sign}{int})?
%%
{sign} sphere_yylval.i = (strcmp("-", yytext)) ? (1) : (-1); return SIGN;
{int} sphere_yylval.i = atoi(yytext); return INT;
{float} sphere_yylval.d = atof(yytext); return FLOAT;
[x-zX-Z]{3} memcpy(&sphere_yylval.c[0], yytext, 3); return EULERAXIS;
h return HOUR;
d return DEG;
' return MIN;
m return MIN;
\" return SEC;
s return SEC;
, return COMMA;
\< return OPENCIRC;
\> return CLOSECIRC;
\( return OPENPOINT;
\) return CLOSEPOINT;
\{ return OPENARR;
\} return CLOSEARR;
[ \n\t]+ /* discard spaces */
. /* alert parser of the garbage */
%%