diff --git a/jscomp/runtime/caml_lexer.ml b/jscomp/runtime/caml_lexer.ml index cb56e7d511..3394eafd35 100644 --- a/jscomp/runtime/caml_lexer.ml +++ b/jscomp/runtime/caml_lexer.ml @@ -186,6 +186,12 @@ function $$caml_lex_engine(tbl, start_state, lexbuf) { /***********************************************/ /* New lexer engine, with memory of positions */ /***********************************************/ + +/** + * s -> Lexing.lex_tables.lex_code + * mem -> Lexing.lexbuf.lex_mem (* int array *) + */ + function caml_lex_run_mem(s, i, mem, curr_pos) { for (;;) { var dst = s.charCodeAt(i); @@ -195,11 +201,18 @@ function caml_lex_run_mem(s, i, mem, curr_pos) { var src = s.charCodeAt(i); i++; if (src == 0xff) - mem[dst + 1] = curr_pos; + mem[dst] = curr_pos; else - mem[dst + 1] = mem[src + 1]; + mem[dst] = mem[src]; } } + + +/** + * s -> Lexing.lex_tables.lex_code + * mem -> Lexing.lexbuf.lex_mem (* int array *) + */ + function caml_lex_run_tag(s, i, mem) { for (;;) { var dst = s.charCodeAt(i); @@ -209,9 +222,9 @@ function caml_lex_run_tag(s, i, mem) { var src = s.charCodeAt(i); i++; if (src == 0xff) - mem[dst + 1] = -1; + mem[dst] = -1; else - mem[dst + 1] = mem[src + 1]; + mem[dst] = mem[src]; } } /** diff --git a/lib/js/caml_lexer.js b/lib/js/caml_lexer.js index 9a3b3a696d..b039802f76 100644 --- a/lib/js/caml_lexer.js +++ b/lib/js/caml_lexer.js @@ -161,6 +161,12 @@ function $$caml_lex_engine(tbl, start_state, lexbuf) { /***********************************************/ /* New lexer engine, with memory of positions */ /***********************************************/ + +/** + * s -> Lexing.lex_tables.lex_code + * mem -> Lexing.lexbuf.lex_mem (* int array *) + */ + function caml_lex_run_mem(s, i, mem, curr_pos) { for (;;) { var dst = s.charCodeAt(i); @@ -170,11 +176,18 @@ function caml_lex_run_mem(s, i, mem, curr_pos) { var src = s.charCodeAt(i); i++; if (src == 0xff) - mem[dst + 1] = curr_pos; + mem[dst] = curr_pos; else - mem[dst + 1] = mem[src + 1]; + mem[dst] = mem[src]; } } + + +/** + * s -> Lexing.lex_tables.lex_code + * mem -> Lexing.lexbuf.lex_mem (* int array *) + */ + function caml_lex_run_tag(s, i, mem) { for (;;) { var dst = s.charCodeAt(i); @@ -184,9 +197,9 @@ function caml_lex_run_tag(s, i, mem) { var src = s.charCodeAt(i); i++; if (src == 0xff) - mem[dst + 1] = -1; + mem[dst] = -1; else - mem[dst + 1] = mem[src + 1]; + mem[dst] = mem[src]; } } /**