Support syntax error feedback in parser.

Now, parser correctly finishes parse procedure if syntax of source code is incorrect (syntax correctness is indicated using return value):
 - parser-internal memory management is performed using jsp_mm_alloc / jsp_mm_free;
 - upon detection of incorrect syntax, all parser-allocated memory regions are deallocated using jsp_mm_free_all and parse finishes with corresponding return value.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan
2015-06-19 00:11:31 +03:00
parent 85f12de139
commit a4e54e736e
46 changed files with 227 additions and 173 deletions
+29
View File
@@ -20,6 +20,15 @@
#include "jrt-libc-includes.h"
#include "ecma-helpers.h"
/**
* SyntaxError longjmp label, used to finish parse upon a SyntaxError is raised
*
* See also:
* syntax_get_syntax_error_longjmp_label
* syntax_raise_error
*/
static jmp_buf jsp_syntax_error_label;
typedef struct
{
prop_type type;
@@ -38,6 +47,26 @@ enum
};
STATIC_STACK (U8, uint8_t)
/**
* Get buffer for SyntaxError longjmp label
*
* @return pointer to jmp_buf
*/
jmp_buf *
syntax_get_syntax_error_longjmp_label (void)
{
return &jsp_syntax_error_label;
} /* syntax_get_syntax_error_longjmp_label */
/**
* Raise SyntaxError, i.e. perform longjmp to SyntaxError longjmp label
*/
void __attribute__((noreturn))
syntax_raise_error (void)
{
longjmp (jsp_syntax_error_label, 1);
} /* syntax_raise_error */
static prop_literal
create_prop_literal (literal_t lit, prop_type type)
{