Browse Source

Merge branch 'remove-end-line-tracking'

Remove end line tracking from lexer tokens.  The end line information is
not used at the moment, and there doesn't seem to be a reason to use it
in the near future either.
v1.0-maintenance
Sami Vaarala 10 years ago
parent
commit
b9f364ec55
  1. 6
      src/duk_js_compiler.c
  2. 6
      src/duk_lexer.c
  3. 1
      src/duk_lexer.h

6
src/duk_js_compiler.c

@ -442,19 +442,17 @@ static void duk__advance_helper(duk_compiler_ctx *comp_ctx, duk_small_int_t expe
comp_ctx->curr_func.is_strict,
regexp);
DUK_DDD(DUK_DDDPRINT("advance: curr: tok=%ld/%ld,%ld-%ld,term=%ld,%!T,%!T "
"prev: tok=%ld/%ld,%ld-%ld,term=%ld,%!T,%!T",
DUK_DDD(DUK_DDDPRINT("advance: curr: tok=%ld/%ld,%ld,term=%ld,%!T,%!T "
"prev: tok=%ld/%ld,%ld,term=%ld,%!T,%!T",
(long) comp_ctx->curr_token.t,
(long) comp_ctx->curr_token.t_nores,
(long) comp_ctx->curr_token.start_line,
(long) comp_ctx->curr_token.end_line,
(long) comp_ctx->curr_token.lineterm,
(duk_tval *) duk_get_tval(ctx, comp_ctx->tok11_idx),
(duk_tval *) duk_get_tval(ctx, comp_ctx->tok12_idx),
(long) comp_ctx->prev_token.t,
(long) comp_ctx->prev_token.t_nores,
(long) comp_ctx->prev_token.start_line,
(long) comp_ctx->prev_token.end_line,
(long) comp_ctx->prev_token.lineterm,
(duk_tval *) duk_get_tval(ctx, comp_ctx->tok21_idx),
(duk_tval *) duk_get_tval(ctx, comp_ctx->tok22_idx)));

6
src/duk_lexer.c

@ -536,7 +536,6 @@ static void duk__parse_input_element_raw(duk_lexer_ctx *lex_ctx,
out_token->num_escapes = 0;
out_token->start_line = lex_ctx->lines[0];
out_token->start_offset = lex_ctx->offsets[0];
/* out_token->end_line set at exit */
/* out_token->lineterm set by caller */
duk_to_undefined((duk_context *) lex_ctx->thr, lex_ctx->slot1_idx);
@ -1267,7 +1266,6 @@ static void duk__parse_input_element_raw(duk_lexer_ctx *lex_ctx,
if (out_token->t_nores < 0) {
out_token->t_nores = out_token->t;
}
out_token->end_line = lex_ctx->lines[0];
}
/*
@ -1295,8 +1293,8 @@ void duk_lexer_parse_js_input_element(duk_lexer_ctx *lex_ctx,
duk__parse_input_element_raw(lex_ctx, out_token, strict_mode, regexp_mode);
tok = out_token->t;
DUK_DDD(DUK_DDDPRINT("RAWTOKEN: %ld (line %ld-%ld)",
(long) tok, (long) out_token->start_line, (long) out_token->end_line));
DUK_DDD(DUK_DDDPRINT("RAWTOKEN: %ld (line %ld)",
(long) tok, (long) out_token->start_line));
if (tok == DUK_TOK_COMMENT) {
/* single-line comment or multi-line comment without an internal lineterm */

1
src/duk_lexer.h

@ -357,7 +357,6 @@ struct duk_token {
duk_hstring *str2; /* string 2 of token (borrowed, stored to ctx->slot1_idx) */
duk_size_t start_offset; /* start byte offset of token in lexer input */
duk_int_t start_line; /* start line of token (first char) */
duk_int_t end_line; /* end line of token (char after last token char) */
duk_int_t num_escapes; /* number of escapes and line continuations (for directive prologue) */
duk_bool_t lineterm; /* token was preceded by a lineterm */
duk_bool_t allow_auto_semi; /* token allows automatic semicolon insertion (eof or preceded by newline) */

Loading…
Cancel
Save