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

View File

@ -2662,7 +2662,14 @@ preparse_scope (bool is_global)
skip_newlines ();
}
lexer_seek (start_loc);
if (start_loc != tok.loc)
{
lexer_seek (start_loc);
}
else
{
lexer_save_token (tok);
}
}
/* source_element_list

View File

@ -63,7 +63,7 @@ syntax_add_prop_name (operand op, prop_type pt)
}
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)
{
@ -144,7 +144,7 @@ void syntax_add_varg (operand op)
}
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)
{
@ -169,7 +169,7 @@ syntax_check_for_eval_and_arguments_in_strict_mode (operand op, bool is_strict,
/* 13.1, 15.3.2 */
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)
{
@ -199,7 +199,7 @@ syntax_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc)
}
void
syntax_check_delete (bool is_strict, locus loc)
syntax_check_delete (bool is_strict, locus loc __unused)
{
if (is_strict)
{

View File

@ -20,6 +20,7 @@
#include "opcodes-dumper.h"
#include "lexer.h"
#ifndef JERRY_NDEBUG
#define PARSE_ERROR(MESSAGE, LOCUS) do { \
size_t 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); \
__exit (-1); \
} 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
{