Skip to content

Commit 04b3ac7

Browse files
author
Hongbo Zhang
committed
done
1 parent ae2dc2d commit 04b3ac7

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

jscomp/runtime/caml_lexer.ml

+17-4
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ function $$caml_lex_engine(tbl, start_state, lexbuf) {
186186
/***********************************************/
187187
/* New lexer engine, with memory of positions */
188188
/***********************************************/
189+
190+
/**
191+
* s -> Lexing.lex_tables.lex_code
192+
* mem -> Lexing.lexbuf.lex_mem (* int array *)
193+
*/
194+
189195
function caml_lex_run_mem(s, i, mem, curr_pos) {
190196
for (;;) {
191197
var dst = s.charCodeAt(i);
@@ -195,11 +201,18 @@ function caml_lex_run_mem(s, i, mem, curr_pos) {
195201
var src = s.charCodeAt(i);
196202
i++;
197203
if (src == 0xff)
198-
mem[dst + 1] = curr_pos;
204+
mem[dst] = curr_pos;
199205
else
200-
mem[dst + 1] = mem[src + 1];
206+
mem[dst] = mem[src];
201207
}
202208
}
209+
210+
211+
/**
212+
* s -> Lexing.lex_tables.lex_code
213+
* mem -> Lexing.lexbuf.lex_mem (* int array *)
214+
*/
215+
203216
function caml_lex_run_tag(s, i, mem) {
204217
for (;;) {
205218
var dst = s.charCodeAt(i);
@@ -209,9 +222,9 @@ function caml_lex_run_tag(s, i, mem) {
209222
var src = s.charCodeAt(i);
210223
i++;
211224
if (src == 0xff)
212-
mem[dst + 1] = -1;
225+
mem[dst] = -1;
213226
else
214-
mem[dst + 1] = mem[src + 1];
227+
mem[dst] = mem[src];
215228
}
216229
}
217230
/**

lib/js/caml_lexer.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ function $$caml_lex_engine(tbl, start_state, lexbuf) {
161161
/***********************************************/
162162
/* New lexer engine, with memory of positions */
163163
/***********************************************/
164+
165+
/**
166+
* s -> Lexing.lex_tables.lex_code
167+
* mem -> Lexing.lexbuf.lex_mem (* int array *)
168+
*/
169+
164170
function caml_lex_run_mem(s, i, mem, curr_pos) {
165171
for (;;) {
166172
var dst = s.charCodeAt(i);
@@ -170,11 +176,18 @@ function caml_lex_run_mem(s, i, mem, curr_pos) {
170176
var src = s.charCodeAt(i);
171177
i++;
172178
if (src == 0xff)
173-
mem[dst + 1] = curr_pos;
179+
mem[dst] = curr_pos;
174180
else
175-
mem[dst + 1] = mem[src + 1];
181+
mem[dst] = mem[src];
176182
}
177183
}
184+
185+
186+
/**
187+
* s -> Lexing.lex_tables.lex_code
188+
* mem -> Lexing.lexbuf.lex_mem (* int array *)
189+
*/
190+
178191
function caml_lex_run_tag(s, i, mem) {
179192
for (;;) {
180193
var dst = s.charCodeAt(i);
@@ -184,9 +197,9 @@ function caml_lex_run_tag(s, i, mem) {
184197
var src = s.charCodeAt(i);
185198
i++;
186199
if (src == 0xff)
187-
mem[dst + 1] = -1;
200+
mem[dst] = -1;
188201
else
189-
mem[dst + 1] = mem[src + 1];
202+
mem[dst] = mem[src];
190203
}
191204
}
192205
/**

0 commit comments

Comments
 (0)