@@ -103,36 +103,23 @@ function caml_lex_array(s) {
103
103
* @returns {any}
104
104
*)
105
105
let caml_lex_engine_aux : lex_tables -> int -> lexbuf -> exn -> int = [% raw{| function (tbl, start_state, lexbuf, exn ){
106
- // Lexing. lexbuf
107
- var lex_buffer = 'lex_buffer';
108
- var lex_buffer_len = 'lex_buffer_len';
109
- var lex_start_pos = 'lex_start_pos';
110
- var lex_curr_pos = 'lex_curr_pos';
111
- var lex_last_pos = 'lex_last_pos';
112
- var lex_last_action = 'lex_last_action';
113
- var lex_eof_reached = 'lex_eof_reached';
114
- // Lexing. lex_tables
115
- var lex_base = 'lex_base';
116
- var lex_backtrk = 'lex_backtrk';
117
- var lex_default = 'lex_default';
118
- var lex_trans = 'lex_trans';
119
- var lex_check = 'lex_check';
106
+
120
107
if (! tbl.processed) {
121
- tbl.lex_base = caml_lex_array(tbl[ lex_base] );
122
- tbl.lex_backtrk = caml_lex_array(tbl[ lex_backtrk] );
123
- tbl.lex_check = caml_lex_array(tbl[ lex_check] );
124
- tbl.lex_trans = caml_lex_array(tbl[ lex_trans] );
125
- tbl.lex_default = caml_lex_array(tbl[ lex_default] );
108
+ tbl.lex_base = caml_lex_array(tbl. lex_base);
109
+ tbl.lex_backtrk = caml_lex_array(tbl. lex_backtrk);
110
+ tbl.lex_check = caml_lex_array(tbl. lex_check);
111
+ tbl.lex_trans = caml_lex_array(tbl. lex_trans);
112
+ tbl.lex_default = caml_lex_array(tbl. lex_default);
126
113
tbl.processed = true ;
127
114
}
128
115
var c;
129
116
var state = start_state;
130
- // var buffer = bytes_of_string(lexbuf[ lex_buffer] );
131
- var buffer = lexbuf[ lex_buffer] ;
117
+ // var buffer = bytes_of_string(lexbuf. lex_buffer);
118
+ var buffer = lexbuf. lex_buffer;
132
119
if (state > = 0 ) {
133
120
/* First entry */
134
- lexbuf[ lex_last_pos] = lexbuf[ lex_start_pos] = lexbuf[ lex_curr_pos] ;
135
- lexbuf[ lex_last_action] = - 1 ;
121
+ lexbuf. lex_last_pos = lexbuf. lex_start_pos = lexbuf. lex_curr_pos;
122
+ lexbuf. lex_last_action = - 1 ;
136
123
}
137
124
else {
138
125
/* Reentry after refill */
@@ -146,20 +133,20 @@ let caml_lex_engine_aux : lex_tables -> int -> lexbuf -> exn -> int = [%raw{|fun
146
133
/* See if it's a backtrack point */
147
134
var backtrk = tbl.lex_backtrk[state];
148
135
if (backtrk > = 0 ) {
149
- lexbuf[ lex_last_pos] = lexbuf[ lex_curr_pos] ;
150
- lexbuf[ lex_last_action] = backtrk;
136
+ lexbuf. lex_last_pos = lexbuf. lex_curr_pos;
137
+ lexbuf. lex_last_action = backtrk;
151
138
}
152
139
/* See if we need a refill */
153
- if (lexbuf[ lex_curr_pos] > = lexbuf[ lex_buffer_len] ) {
154
- if (lexbuf[ lex_eof_reached] === 0 )
140
+ if (lexbuf. lex_curr_pos > = lexbuf. lex_buffer_len) {
141
+ if (lexbuf. lex_eof_reached === 0 )
155
142
return - state - 1 ;
156
143
else
157
144
c = 256 ;
158
145
}
159
146
else {
160
147
/* Read next input char */
161
- c = buffer[lexbuf[ lex_curr_pos] ];
162
- lexbuf[ lex_curr_pos] ++ ;
148
+ c = buffer[lexbuf. lex_curr_pos];
149
+ lexbuf. lex_curr_pos++ ;
163
150
}
164
151
/* Determine next state */
165
152
if (tbl.lex_check[base + c] === state) {
@@ -170,18 +157,18 @@ let caml_lex_engine_aux : lex_tables -> int -> lexbuf -> exn -> int = [%raw{|fun
170
157
}
171
158
/* If no transition on this char , return to last backtrack point */
172
159
if (state < 0 ) {
173
- lexbuf[ lex_curr_pos] = lexbuf[ lex_last_pos] ;
174
- if (lexbuf[ lex_last_action] == - 1 )
160
+ lexbuf. lex_curr_pos = lexbuf. lex_last_pos;
161
+ if (lexbuf. lex_last_action == - 1 )
175
162
throw exn
176
163
else
177
- return lexbuf[ lex_last_action] ;
164
+ return lexbuf. lex_last_action;
178
165
}
179
166
else {
180
167
/* Erase the EOF condition only if the EOF pseudo- character was
181
168
consumed by the automaton (i.e. there was no backtrack above)
182
169
*/
183
170
if (c == 256 )
184
- lexbuf[ lex_eof_reached] = 0 ;
171
+ lexbuf. lex_eof_reached = 0 ;
185
172
}
186
173
}
187
174
}
@@ -252,47 +239,27 @@ function caml_lex_run_tag(s, i, mem) {
252
239
253
240
254
241
let caml_new_lex_engine_aux : lex_tables -> int -> lexbuf -> exn -> int = [% raw{| function (tbl, start_state, lexbuf, exn ) {
255
- // Lexing. lexbuf
256
- var lex_buffer = 'lex_buffer';
257
- var lex_buffer_len = 'lex_buffer_len';
258
- var lex_start_pos = 'lex_start_pos';
259
- var lex_curr_pos = 'lex_curr_pos';
260
- var lex_last_pos = 'lex_last_pos';
261
- var lex_last_action = 'lex_last_action';
262
- var lex_eof_reached = 'lex_eof_reached';
263
- var lex_mem = 'lex_mem';
264
- // Lexing. lex_tables
265
- var lex_base = 'lex_base';
266
- var lex_backtrk = 'lex_backtrk';
267
- var lex_default = 'lex_default';
268
- var lex_trans = 'lex_trans';
269
- var lex_check = 'lex_check';
270
- var lex_base_code = 'lex_base_code';
271
- var lex_backtrk_code = 'lex_backtrk_code';
272
- var lex_default_code = 'lex_default_code';
273
- var lex_trans_code = 'lex_trans_code';
274
- var lex_check_code = 'lex_check_code';
275
- var lex_code = 'lex_code';
242
+
276
243
if (! tbl.processed) {
277
- tbl.lex_base = caml_lex_array(tbl[ lex_base] );
278
- tbl.lex_backtrk = caml_lex_array(tbl[ lex_backtrk] );
279
- tbl.lex_check = caml_lex_array(tbl[ lex_check] );
280
- tbl.lex_trans = caml_lex_array(tbl[ lex_trans] );
281
- tbl.lex_default = caml_lex_array(tbl[ lex_default] );
282
- tbl.lex_base_code = caml_lex_array(tbl[ lex_base_code] );
283
- tbl.lex_backtrk_code = caml_lex_array(tbl[ lex_backtrk_code] );
284
- tbl.lex_check_code = caml_lex_array(tbl[ lex_check_code] );
285
- tbl.lex_trans_code = caml_lex_array(tbl[ lex_trans_code] );
286
- tbl.lex_default_code = caml_lex_array(tbl[ lex_default_code] );
244
+ tbl.lex_base = caml_lex_array(tbl. lex_base);
245
+ tbl.lex_backtrk = caml_lex_array(tbl. lex_backtrk);
246
+ tbl.lex_check = caml_lex_array(tbl. lex_check);
247
+ tbl.lex_trans = caml_lex_array(tbl. lex_trans);
248
+ tbl.lex_default = caml_lex_array(tbl. lex_default);
249
+ tbl.lex_base_code = caml_lex_array(tbl. lex_base_code);
250
+ tbl.lex_backtrk_code = caml_lex_array(tbl. lex_backtrk_code);
251
+ tbl.lex_check_code = caml_lex_array(tbl. lex_check_code);
252
+ tbl.lex_trans_code = caml_lex_array(tbl. lex_trans_code);
253
+ tbl.lex_default_code = caml_lex_array(tbl. lex_default_code);
287
254
tbl.processed = true ;
288
255
}
289
256
var c, state = start_state;
290
- // var buffer = caml_bytes_of_string(lexbuf[ lex_buffer] );
291
- var buffer = lexbuf[ lex_buffer] ;
257
+ // var buffer = caml_bytes_of_string(lexbuf. lex_buffer);
258
+ var buffer = lexbuf. lex_buffer;
292
259
if (state > = 0 ) {
293
260
/* First entry */
294
- lexbuf[ lex_last_pos] = lexbuf[ lex_start_pos] = lexbuf[ lex_curr_pos] ;
295
- lexbuf[ lex_last_action] = - 1 ;
261
+ lexbuf. lex_last_pos = lexbuf. lex_start_pos = lexbuf. lex_curr_pos;
262
+ lexbuf. lex_last_action = - 1 ;
296
263
}
297
264
else {
298
265
/* Reentry after refill */
@@ -303,28 +270,28 @@ let caml_new_lex_engine_aux : lex_tables -> int -> lexbuf -> exn -> int= [%raw{|
303
270
var base = tbl.lex_base[state];
304
271
if (base < 0 ) {
305
272
var pc_off = tbl.lex_base_code[state];
306
- caml_lex_run_tag(tbl.lex_code, pc_off, lexbuf[ lex_mem] );
273
+ caml_lex_run_tag(tbl.lex_code, pc_off, lexbuf. lex_mem);
307
274
return - base - 1 ;
308
275
}
309
276
/* See if it's a backtrack point */
310
277
var backtrk = tbl.lex_backtrk[state];
311
278
if (backtrk > = 0 ) {
312
279
var pc_off = tbl.lex_backtrk_code[state];
313
- caml_lex_run_tag(tbl.lex_code, pc_off, lexbuf[ lex_mem] );
314
- lexbuf[ lex_last_pos] = lexbuf[ lex_curr_pos] ;
315
- lexbuf[ lex_last_action] = backtrk;
280
+ caml_lex_run_tag(tbl.lex_code, pc_off, lexbuf. lex_mem);
281
+ lexbuf. lex_last_pos = lexbuf. lex_curr_pos;
282
+ lexbuf. lex_last_action = backtrk;
316
283
}
317
284
/* See if we need a refill */
318
- if (lexbuf[ lex_curr_pos] > = lexbuf[ lex_buffer_len] ) {
319
- if (lexbuf[ lex_eof_reached] == 0 )
285
+ if (lexbuf. lex_curr_pos > = lexbuf. lex_buffer_len) {
286
+ if (lexbuf. lex_eof_reached == 0 )
320
287
return - state - 1 ;
321
288
else
322
289
c = 256 ;
323
290
}
324
291
else {
325
292
/* Read next input char */
326
- c = buffer[lexbuf[ lex_curr_pos] ];
327
- lexbuf[ lex_curr_pos] ++ ;
293
+ c = buffer[lexbuf. lex_curr_pos];
294
+ lexbuf. lex_curr_pos++ ;
328
295
}
329
296
/* Determine next state */
330
297
var pstate = state;
@@ -334,11 +301,11 @@ let caml_new_lex_engine_aux : lex_tables -> int -> lexbuf -> exn -> int= [%raw{|
334
301
state = tbl.lex_default[state];
335
302
/* If no transition on this char , return to last backtrack point */
336
303
if (state < 0 ) {
337
- lexbuf[ lex_curr_pos] = lexbuf[ lex_last_pos] ;
338
- if (lexbuf[ lex_last_action] == - 1 )
304
+ lexbuf. lex_curr_pos = lexbuf. lex_last_pos;
305
+ if (lexbuf. lex_last_action == - 1 )
339
306
throw exn ;
340
307
else
341
- return lexbuf[ lex_last_action] ;
308
+ return lexbuf. lex_last_action;
342
309
}
343
310
else {
344
311
/* If some transition, get and perform memory moves */
@@ -348,12 +315,12 @@ let caml_new_lex_engine_aux : lex_tables -> int -> lexbuf -> exn -> int= [%raw{|
348
315
else
349
316
pc_off = tbl.lex_default_code[pstate];
350
317
if (pc_off > 0 )
351
- caml_lex_run_mem(tbl.lex_code, pc_off, lexbuf[ lex_mem] , lexbuf[ lex_curr_pos] );
318
+ caml_lex_run_mem(tbl.lex_code, pc_off, lexbuf. lex_mem, lexbuf. lex_curr_pos);
352
319
/* Erase the EOF condition only if the EOF pseudo- character was
353
320
consumed by the automaton (i.e. there was no backtrack above)
354
321
*/
355
322
if (c == 256 )
356
- lexbuf[ lex_eof_reached] = 0 ;
323
+ lexbuf. lex_eof_reached = 0 ;
357
324
}
358
325
}
359
326
}
0 commit comments