2323#include " lit-strings.h"
2424#include " jsp-early-error.h"
2525
26- static token saved_token, prev_token, sent_token, empty_token;
26+ static token saved_token, prev_token, sent_token, empty_token, prev_non_lf_token ;
2727
2828static bool allow_dump_lines = false , strict_mode;
2929static size_t buffer_size = 0 ;
@@ -1092,18 +1092,15 @@ lexer_parse_regexp (void)
10921092
10931093 /* Eat up '/' */
10941094 JERRY_ASSERT (LA (0 ) == LIT_CHAR_SLASH);
1095- consume_char ();
10961095 new_token ();
10971096
1097+ consume_char ();
1098+
10981099 while (true )
10991100 {
11001101 ecma_char_t c = (ecma_char_t ) LA (0 );
11011102
1102- if (c == LIT_CHAR_NULL)
1103- {
1104- PARSE_ERROR (JSP_EARLY_ERROR_SYNTAX, " Unclosed string" , token_start_pos);
1105- }
1106- else if (lit_char_is_line_terminator (c))
1103+ if (lit_char_is_line_terminator (c))
11071104 {
11081105 PARSE_ERROR (JSP_EARLY_ERROR_SYNTAX, " RegExp literal shall not contain newline character" , token_start_pos);
11091106 }
@@ -1140,16 +1137,15 @@ lexer_parse_regexp (void)
11401137 {
11411138 ecma_char_t c = (ecma_char_t ) LA (0 );
11421139
1143- if (c == LIT_CHAR_NULL
1144- || !lit_char_is_word_char (c)
1145- || lit_char_is_line_terminator (c))
1140+ if (!lit_char_is_word_char (c) || lit_char_is_line_terminator (c))
11461141 {
11471142 break ;
11481143 }
1144+
11491145 consume_char ();
11501146 }
11511147
1152- result = lexer_create_token_for_charset (TOK_REGEXP, TOK_START (), TOK_SIZE ());
1148+ result = lexer_create_token_for_charset (TOK_REGEXP, TOK_START () + 1 , TOK_SIZE () - 1 );
11531149
11541150 is_token_parse_in_progress = false ;
11551151 return result;
@@ -1294,16 +1290,16 @@ lexer_parse_token (void)
12941290 }
12951291
12961292 if (c == LIT_CHAR_SLASH
1297- && !(sent_token .type == TOK_NAME
1298- || sent_token .type == TOK_NULL
1299- || sent_token .type == TOK_BOOL
1300- || sent_token .type == TOK_CLOSE_BRACE
1301- || sent_token .type == TOK_CLOSE_SQUARE
1302- || sent_token .type == TOK_CLOSE_PAREN
1303- || sent_token .type == TOK_SMALL_INT
1304- || sent_token .type == TOK_NUMBER
1305- || sent_token .type == TOK_STRING
1306- || sent_token .type == TOK_REGEXP))
1293+ && !(prev_non_lf_token .type == TOK_NAME
1294+ || prev_non_lf_token .type == TOK_NULL
1295+ || prev_non_lf_token .type == TOK_BOOL
1296+ || prev_non_lf_token .type == TOK_CLOSE_BRACE
1297+ || prev_non_lf_token .type == TOK_CLOSE_SQUARE
1298+ || prev_non_lf_token .type == TOK_CLOSE_PAREN
1299+ || prev_non_lf_token .type == TOK_SMALL_INT
1300+ || prev_non_lf_token .type == TOK_NUMBER
1301+ || prev_non_lf_token .type == TOK_STRING
1302+ || prev_non_lf_token .type == TOK_REGEXP))
13071303 {
13081304 return lexer_parse_regexp ();
13091305 }
@@ -1482,6 +1478,7 @@ lexer_next_token (void)
14821478 if (!is_empty (saved_token))
14831479 {
14841480 sent_token = saved_token;
1481+ prev_non_lf_token = sent_token;
14851482 saved_token = empty_token;
14861483 goto end;
14871484 }
@@ -1499,6 +1496,11 @@ lexer_next_token (void)
14991496 PARSE_ERROR (JSP_EARLY_ERROR_SYNTAX, " Unexpected EOF" , lit_utf8_iterator_get_pos (&src_iter));
15001497 }
15011498
1499+ if (sent_token.type != TOK_NEWLINE)
1500+ {
1501+ prev_non_lf_token = sent_token;
1502+ }
1503+
15021504 prev_token = sent_token;
15031505 sent_token = lexer_parse_token ();
15041506
0 commit comments