Fix parsing of empty file

This commit is contained in:
Ilmir Usmanov
2014-12-15 17:10:04 +03:00
parent c1ebb8db50
commit ddac13f944
3 changed files with 26 additions and 5 deletions
+8 -1
View File
@@ -2662,7 +2662,14 @@ preparse_scope (bool is_global)
skip_newlines (); skip_newlines ();
} }
lexer_seek (start_loc); if (start_loc != tok.loc)
{
lexer_seek (start_loc);
}
else
{
lexer_save_token (tok);
}
} }
/* source_element_list /* source_element_list
+4 -4
View File
@@ -63,7 +63,7 @@ syntax_add_prop_name (operand op, prop_type pt)
} }
void void
syntax_check_for_duplication_of_prop_names (bool is_strict, locus loc) syntax_check_for_duplication_of_prop_names (bool is_strict, locus loc __unused)
{ {
if (STACK_SIZE (props) - STACK_TOP (U8) < 2) if (STACK_SIZE (props) - STACK_TOP (U8) < 2)
{ {
@@ -144,7 +144,7 @@ void syntax_add_varg (operand op)
} }
static void static void
emit_error_on_eval_and_arguments (operand op, locus loc) emit_error_on_eval_and_arguments (operand op, locus loc __unused)
{ {
if (op.type == OPERAND_LITERAL) if (op.type == OPERAND_LITERAL)
{ {
@@ -169,7 +169,7 @@ syntax_check_for_eval_and_arguments_in_strict_mode (operand op, bool is_strict,
/* 13.1, 15.3.2 */ /* 13.1, 15.3.2 */
void void
syntax_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc) syntax_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc __unused)
{ {
if (STACK_SIZE (props) - STACK_TOP (U8) < 2 || !is_strict) if (STACK_SIZE (props) - STACK_TOP (U8) < 2 || !is_strict)
{ {
@@ -199,7 +199,7 @@ syntax_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc)
} }
void void
syntax_check_delete (bool is_strict, locus loc) syntax_check_delete (bool is_strict, locus loc __unused)
{ {
if (is_strict) if (is_strict)
{ {
+14
View File
@@ -20,6 +20,7 @@
#include "opcodes-dumper.h" #include "opcodes-dumper.h"
#include "lexer.h" #include "lexer.h"
#ifndef JERRY_NDEBUG
#define PARSE_ERROR(MESSAGE, LOCUS) do { \ #define PARSE_ERROR(MESSAGE, LOCUS) do { \
size_t line, column; \ size_t line, column; \
lexer_locus_to_line_and_column ((locus) (LOCUS), &line, &column); \ lexer_locus_to_line_and_column ((locus) (LOCUS), &line, &column); \
@@ -63,6 +64,19 @@
__printf ("SORRY, Unimplemented: Ln %d, Col %d: %s\n", line + 1, column + 1, MESSAGE); \ __printf ("SORRY, Unimplemented: Ln %d, Col %d: %s\n", line + 1, column + 1, MESSAGE); \
__exit (-1); \ __exit (-1); \
} while (0) } while (0)
#else /* JERRY_NDEBUG */
#define PARSE_ERROR(MESSAGE, LOCUS) do { \
__exit (-1); \
} while (0)
#define PARSE_WARN(MESSAGE, LOCUS) do { \
} while (0)
#define PARSE_ERROR_VARG(MESSAGE, LOCUS, ...) do { \
__exit (-1); \
} while (0)
#define PARSE_SORRY(MESSAGE, LOCUS) do { \
__exit (-1); \
} while (0)
#endif /* JERRY_NDEBUG */
typedef enum typedef enum
{ {