blob: 2f87d6ffd4b1ba185d49ee30b82c19f11dfcc202 (
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
|
/* Copyright comment! */
%{
#include "type.h"
#include "y.tab.h"
#include "extern.h"
#define dbg(arg) if (debugging) fprintf(stderr, "DEBUG, %d: %s\n", yylineno, #arg);
%}
%option yylineno
%s C SQL
ccomment \/\*([^*]|\*[^/]|\*\*[^/])*\*\/
ws ([ \t\n][ \t\n]*|{ccomment})*
letter [A-Za-z_]
digit [0-9]
length {digit}+
symbol {letter}({letter}|{digit})*
string '[^']*'
exec [eE][xX][eE][cC]
execute [eE][xX][eE][cC][uU][tT][eE]
sql [sS][qQ][lL]
varchar [vV][aA][rR][cC][hH][aA][rR]
varchar2 [vV][aA][rR][cC][hH][aA][rR]2
into [iI][nN][tT][oO]
begin [bB][eE][gG][iI][nN]
end [eE][nN][dD]
declare [dD][eE][cC][lL][aA][rR][eE]
section [sS][eE][cC][tT][iI][oO][nN]
include [iI][nN][cC][lL][uU][dD][eE]
connect [cC][oO][nN][nN][eE][cC][tT]
open [oO][pP][eE][nN]
commit [cC][oO][mM][mM][iI][tT]
immediate [iI][mM][mM][eE][dD][iI][aA][tT][eE]
release [rR][eE][lL][eE][aA][sS][eE]
rollback [rR][oO][lL][lL][bB][aA][cC][kK]
work [wW][oO][rR][kK]
%%
<C>{exec}{ws}{sql} { BEGIN SQL; dbg(SQL_START); return SQL_START; }
<SQL>";" { BEGIN C; dbg(SQL_SEMI); return SQL_SEMI; }
<SQL>{begin} { dbg(SQL_BEGIN); return SQL_BEGIN; }
<SQL>{end} { dbg(SQL_END); return SQL_END; }
<SQL>{declare} { dbg(SQL_DECLARE); return SQL_DECLARE; }
<SQL>{execute} { dbg(SQL_EXECUTE); return SQL_EXECUTE; }
<SQL>{immediate} { dbg(SQL_IMMEDIATE); return SQL_IMMEDIATE; }
<SQL>{section} { dbg(SQL_SECTION); return SQL_SECTION; }
<SQL>{include} { dbg(SQL_INCLUDE); return SQL_INCLUDE; }
<SQL>{connect} { dbg(SQL_CONNECT); return SQL_CONNECT; }
<SQL>{open} { dbg(SQL_OPEN); return SQL_OPEN; }
<SQL>{commit} { dbg(SQL_COMMIT); return SQL_COMMIT; }
<SQL>{release} { dbg(SQL_RELEASE); return SQL_RELEASE; }
<SQL>{work} { dbg(SQL_WORK); return SQL_WORK; }
<SQL>{rollback} { dbg(SQL_ROLLBACK); return SQL_ROLLBACK; }
<SQL>{into} { dbg(SQL_INTO); return SQL_INTO; }
{length} { dbg(S_LENGTH); return S_LENGTH; }
{varchar} { dbg(S_VARCHAR); return S_VARCHAR; }
{varchar2} { dbg(S_VARCHAR2); return S_VARCHAR2; }
long { dbg(S_LONG); return S_LONG; }
short { dbg(S_SHORT); return S_SHORT; }
int { dbg(S_INT); return S_INT; }
char { dbg(S_CHAR); return S_CHAR; }
float { dbg(S_FLOAT); return S_FLOAT; }
double { dbg(S_DOUBLE); return S_DOUBLE; }
bool { dbg(S_BOOL); return S_BOOL; }
static { dbg(S_STATIC); return S_STATIC; }
extern { dbg(S_EXTERN); return S_EXTERN; }
auto { dbg(S_AUTO); return S_AUTO; }
const { dbg(S_CONST); return S_CONST; }
register { dbg(S_REGISTER); return S_REGISTER; }
struct { dbg(S_STRUCT); return S_STRUCT; }
{string} { dbg(SQL_STRING); return SQL_STRING; }
<SQL>{ws} ;
{symbol} { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"!<" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"!>" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"!^" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"!|" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"!~" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"!~*" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"#<" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"#<=" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"#<>" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"#=" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"#>" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"#>=" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"&&" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"&<" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"&>" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"<<" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"<=" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"<===>" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"<>" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"<?>" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"===>" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"===`" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"=|=" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>">=" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>">>" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"@@" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"|/" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"||/" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"~*" { dbg(S_SYMBOL); return S_SYMBOL; }
<SQL>"~=" { dbg(S_SYMBOL); return S_SYMBOL; }
"[" { dbg([); return '['; }
"]" { dbg(]); return ']'; }
";" { dbg(;); return ';'; }
"=" { dbg(=); return '='; }
"," { dbg(komma); return ','; }
\{ { dbg(blockstart); return '{'; }
\} { dbg(blockend); return'}'; }
\* { dbg(*); return('*'); }
<SQL>":" { dbg(:); return ':'; }
{ws} { ECHO; }
. { dbg(.); return S_ANYTHING; }
%%
void
lex_init(void)
{
braces_open = 0;
BEGIN C;
}
int yywrap(void)
{
return 1;
}
|