Source file CCSexp_lex.ml
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# 1 "src/core/CCSexp_lex.mll"
type token =
| ATOM of string
| LIST_OPEN
| LIST_CLOSE
| EOI
exception Error of int * int * string
let error lexbuf msg =
let start = Lexing.lexeme_start_p lexbuf in
let line = start.Lexing.pos_lnum in
let col = start.Lexing.pos_cnum - start.Lexing.pos_bol in
raise (Error (line,col,msg))
type unescape_state =
| Not_escaped
| Escaped
| Escaped_int_1 of int
| Escaped_int_2 of int
let char_equal (a : char) b = Stdlib.(=) a b
let remove_quotes lexbuf s =
assert (char_equal s.[0] '"' && char_equal s.[String.length s - 1] '"');
let buf = Buffer.create (String.length s) in
let st = ref Not_escaped in
for i = 1 to String.length s-2 do
match !st, s.[i] with
| Escaped, '\\' -> Buffer.add_char buf '\\'; st := Not_escaped
| Not_escaped, '\\' -> st := Escaped
| Escaped, 'n' -> Buffer.add_char buf '\n'; st := Not_escaped
| Escaped, 'r' -> Buffer.add_char buf '\r'; st := Not_escaped
| Escaped, 't' -> Buffer.add_char buf '\t'; st := Not_escaped
| Escaped, 'b' -> Buffer.add_char buf '\b'; st := Not_escaped
| Escaped, '"' -> Buffer.add_char buf '"'; st := Not_escaped
| Escaped, ('0'..'9' as c) ->
st := Escaped_int_1 (Char.code c - Char.code '0')
| Escaped_int_1 i, ('0'..'9' as c) ->
st := Escaped_int_2 (10*i+Char.code c - Char.code '0')
| Escaped_int_2 i, ('0'..'9' as c) ->
let n = 10*i+Char.code c - Char.code '0' in
if n < 256 then (
Buffer.add_char buf (Char.chr n);
) else (
let c =
try Uchar.of_int n
with _ ->
failwith (Printf.sprintf "CCSexp: invalid unicode codepont '%d'" n)
in
CCUtf8_string.uchar_to_bytes c (Buffer.add_char buf)
);
st := Not_escaped
| (Escaped | Escaped_int_1 _ | Escaped_int_2 _), c ->
error lexbuf (Printf.sprintf "wrong escape `%c`" c)
| Not_escaped, c -> Buffer.add_char buf c;
done;
Buffer.contents buf
# 67 "src/core/CCSexp_lex.ml"
let __ocaml_lex_tables = {
Lexing.lex_base =
"\000\000\002\000\005\000\249\255\250\255\251\255\252\255\001\000\
\253\255\010\000\015\000\020\000\006\000\247\255\014\000\004\000\
\027\000\065\000";
Lexing.lex_backtrk =
"\255\255\009\000\007\000\255\255\255\255\255\255\255\255\003\000\
\255\255\001\000\007\000\000\000\001\000\255\255\255\255\255\255\
\255\255\255\255";
Lexing.lex_default =
"\002\000\015\000\002\000\000\000\000\000\000\000\000\000\255\255\
\000\000\009\000\002\000\002\000\012\000\000\000\255\255\015\000\
\255\255\255\255";
Lexing.lex_trans =
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\006\000\008\000\008\000\000\000\007\000\255\255\255\255\
\255\255\000\000\255\255\012\000\255\255\000\000\000\000\012\000\
\255\255\255\255\000\000\000\000\255\255\255\255\255\255\000\000\
\006\000\255\255\001\000\010\000\013\000\255\255\013\000\255\255\
\004\000\003\000\012\000\000\000\012\000\255\255\255\255\255\255\
\015\000\255\255\012\000\012\000\255\255\000\000\255\255\255\255\
\255\255\000\000\000\000\009\000\255\255\255\255\016\000\016\000\
\016\000\016\000\016\000\016\000\016\000\016\000\016\000\016\000\
\000\000\000\000\011\000\017\000\017\000\017\000\017\000\017\000\
\017\000\017\000\017\000\017\000\017\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\014\000\000\000\
\014\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\015\000\000\000\000\000\000\000\000\000\000\000\
\015\000\015\000\015\000\015\000\015\000\015\000\015\000\015\000\
\015\000\015\000\015\000\000\000\015\000\000\000\000\000\000\000\
\015\000\000\000\015\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\005\000\000\000\255\255\000\000\255\255\255\255\255\255\000\000\
\000\000\000\000\255\255\000\000\000\000\000\000\000\000\255\255\
\000\000\000\000\000\000\000\000\255\255\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
\000\000\000\000";
Lexing.lex_check =
"\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\000\000\000\000\007\000\255\255\000\000\002\000\002\000\
\012\000\255\255\002\000\009\000\009\000\255\255\255\255\009\000\
\010\000\010\000\255\255\255\255\010\000\011\000\011\000\255\255\
\000\000\011\000\000\000\000\000\001\000\002\000\015\000\002\000\
\000\000\000\000\009\000\255\255\009\000\002\000\002\000\010\000\
\014\000\010\000\009\000\009\000\011\000\255\255\011\000\010\000\
\010\000\255\255\255\255\000\000\011\000\011\000\014\000\014\000\
\014\000\014\000\014\000\014\000\014\000\014\000\014\000\014\000\
\255\255\255\255\010\000\016\000\016\000\016\000\016\000\016\000\
\016\000\016\000\016\000\016\000\016\000\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\001\000\255\255\
\015\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\014\000\255\255\255\255\255\255\255\255\255\255\
\014\000\017\000\017\000\017\000\017\000\017\000\017\000\017\000\
\017\000\017\000\017\000\255\255\014\000\255\255\255\255\255\255\
\014\000\255\255\014\000\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\000\000\255\255\001\000\255\255\015\000\002\000\012\000\255\255\
\255\255\255\255\009\000\255\255\255\255\255\255\255\255\010\000\
\255\255\255\255\255\255\255\255\011\000\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
\255\255\255\255";
Lexing.lex_base_code =
"";
Lexing.lex_backtrk_code =
"";
Lexing.lex_default_code =
"";
Lexing.lex_trans_code =
"";
Lexing.lex_check_code =
"";
Lexing.lex_code =
"";
}
let rec token lexbuf =
__ocaml_lex_token_rec lexbuf 0
and __ocaml_lex_token_rec lexbuf __ocaml_lex_state =
match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with
| 0 ->
# 79 "src/core/CCSexp_lex.mll"
( SEXP_COMMENT )
# 186 "src/core/CCSexp_lex.ml"
| 1 ->
# 80 "src/core/CCSexp_lex.mll"
( token lexbuf )
# 191 "src/core/CCSexp_lex.ml"
| 2 ->
# 81 "src/core/CCSexp_lex.mll"
( Lexing.new_line lexbuf; token lexbuf )
# 196 "src/core/CCSexp_lex.ml"
| 3 ->
# 82 "src/core/CCSexp_lex.mll"
( token lexbuf )
# 201 "src/core/CCSexp_lex.ml"
| 4 ->
# 83 "src/core/CCSexp_lex.mll"
( EOI )
# 206 "src/core/CCSexp_lex.ml"
| 5 ->
# 84 "src/core/CCSexp_lex.mll"
( LIST_OPEN )
# 211 "src/core/CCSexp_lex.ml"
| 6 ->
# 85 "src/core/CCSexp_lex.mll"
( LIST_CLOSE )
# 216 "src/core/CCSexp_lex.ml"
| 7 ->
# 86 "src/core/CCSexp_lex.mll"
( ATOM (Lexing.lexeme lexbuf) )
# 221 "src/core/CCSexp_lex.ml"
| 8 ->
# 87 "src/core/CCSexp_lex.mll"
( ATOM (remove_quotes lexbuf (Lexing.lexeme lexbuf)) )
# 226 "src/core/CCSexp_lex.ml"
| 9 ->
let
# 88 "src/core/CCSexp_lex.mll"
c
# 232 "src/core/CCSexp_lex.ml"
= Lexing.sub_lexeme_char lexbuf lexbuf.Lexing.lex_start_pos in
# 89 "src/core/CCSexp_lex.mll"
( error lexbuf (Printf.sprintf "lexing failed on char `%c`" c) )
# 236 "src/core/CCSexp_lex.ml"
| __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf;
__ocaml_lex_token_rec lexbuf __ocaml_lex_state
;;