Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions jscomp/runtime/caml_lexer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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];
}
}
/**
Expand Down
21 changes: 17 additions & 4 deletions lib/js/caml_lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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];
}
}
/**
Expand Down