mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Merge the js-parser and parser files
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit is contained in:
parent
41f2f910e8
commit
b0bdf0ebf4
@ -22,7 +22,7 @@
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "lit-magic-strings.h"
|
||||
#include "parser.h"
|
||||
#include "js-parser.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "parser.h"
|
||||
#include "js-parser.h"
|
||||
#include "vm.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
#include "lit-literal.h"
|
||||
#include "lit-magic-strings.h"
|
||||
#include "lit-snapshot.h"
|
||||
#include "parser.h"
|
||||
#include "js-parser.h"
|
||||
#include "re-compiler.h"
|
||||
|
||||
#define JERRY_INTERNAL
|
||||
|
||||
@ -1815,10 +1815,12 @@ parser_free_literals (parser_list_t *literal_pool_p) /**< literals */
|
||||
/**
|
||||
* Parse and compile EcmaScript source code
|
||||
*
|
||||
* Note: source must be a valid UTF-8 string
|
||||
*
|
||||
* @return compiled code
|
||||
*/
|
||||
ecma_compiled_code_t *
|
||||
parser_parse_script (const uint8_t *source_p, /**< valid UTF-8 source code */
|
||||
static ecma_compiled_code_t *
|
||||
parser_parse_source (const uint8_t *source_p, /**< valid UTF-8 source code */
|
||||
size_t size, /**< size of the source code */
|
||||
int strict_mode, /**< strict mode */
|
||||
parser_error_location *error_location) /**< error location */
|
||||
@ -1947,7 +1949,7 @@ parser_parse_script (const uint8_t *source_p, /**< valid UTF-8 source code */
|
||||
parser_stack_free (&context);
|
||||
|
||||
return compiled_code;
|
||||
} /* parser_parse_script */
|
||||
} /* parser_parse_source */
|
||||
|
||||
/**
|
||||
* Parse function code
|
||||
@ -2219,7 +2221,7 @@ parser_raise_error (parser_context_t *context_p, /**< context */
|
||||
/* First the current literal pool is freed, and then it is replaced
|
||||
* by the literal pool coming from the saved context. Since literals
|
||||
* are not used anymore, this is a valid replacement. The last pool
|
||||
* is freed by parser_parse_script. */
|
||||
* is freed by parser_parse_source. */
|
||||
|
||||
parser_free_literals (&context_p->literal_pool);
|
||||
context_p->literal_pool.data = saved_context_p->literal_pool_data;
|
||||
@ -2251,6 +2253,45 @@ parser_set_show_instrs (int show_instrs) /**< flag indicating whether to dump by
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
} /* parser_set_show_instrs */
|
||||
|
||||
|
||||
/**
|
||||
* Parse EcamScript source code
|
||||
*/
|
||||
jsp_status_t
|
||||
parser_parse_script (const jerry_api_char_t *source_p, /**< source code */
|
||||
size_t size, /**< size of the source code */
|
||||
ecma_compiled_code_t **bytecode_data_p) /**< result */
|
||||
{
|
||||
*bytecode_data_p = parser_parse_source (source_p, size, false, NULL);
|
||||
|
||||
if (!*bytecode_data_p)
|
||||
{
|
||||
return JSP_STATUS_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
return JSP_STATUS_OK;
|
||||
} /* parser_parse_script */
|
||||
|
||||
/**
|
||||
* Parse EcamScript eval source code
|
||||
*/
|
||||
jsp_status_t
|
||||
parser_parse_eval (const jerry_api_char_t *source_p, /**< source code */
|
||||
size_t size, /**< size of the source code */
|
||||
bool is_strict, /**< strict mode */
|
||||
ecma_compiled_code_t **bytecode_data_p) /**< result */
|
||||
{
|
||||
*bytecode_data_p = parser_parse_source (source_p, size, is_strict, NULL);
|
||||
|
||||
if (!*bytecode_data_p)
|
||||
{
|
||||
return JSP_STATUS_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
return JSP_STATUS_OK;
|
||||
} /* parser_parse_eval */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
@ -128,8 +128,24 @@ typedef struct
|
||||
parser_line_counter_t column; /**< column where the error occured */
|
||||
} parser_error_location;
|
||||
|
||||
/* Note: source must be a valid UTF-8 string. */
|
||||
ecma_compiled_code_t * parser_parse_script (const uint8_t *, size_t, int, parser_error_location *);
|
||||
/**
|
||||
* Parser completion status
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JSP_STATUS_OK, /**< parse finished successfully, no early errors occured */
|
||||
JSP_STATUS_SYNTAX_ERROR, /**< SyntaxError early error occured */
|
||||
JSP_STATUS_REFERENCE_ERROR /**< ReferenceError early error occured */
|
||||
} jsp_status_t;
|
||||
|
||||
extern void parser_set_show_instrs (int);
|
||||
|
||||
/* Note: source must be a valid UTF-8 string */
|
||||
extern jsp_status_t parser_parse_script (const jerry_api_char_t *, size_t,
|
||||
ecma_compiled_code_t **);
|
||||
extern jsp_status_t parser_parse_eval (const jerry_api_char_t *, size_t, bool,
|
||||
ecma_compiled_code_t **);
|
||||
|
||||
const char *parser_error_to_string (parser_error_t);
|
||||
|
||||
extern void parser_set_show_instrs (int);
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2015-2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "js-parser-internal.h"
|
||||
#include "parser.h"
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
*
|
||||
* \addtogroup jsparser JavaScript
|
||||
* @{
|
||||
*
|
||||
* \addtogroup jsparser_parser Parser
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parse EcamScript source code
|
||||
*/
|
||||
jsp_status_t
|
||||
parser_parse_script (const jerry_api_char_t *source_p, /**< source code */
|
||||
size_t size, /**< size of the source code */
|
||||
ecma_compiled_code_t **bytecode_data_p) /**< result */
|
||||
{
|
||||
*bytecode_data_p = parser_parse_script (source_p, size, false, NULL);
|
||||
|
||||
if (!*bytecode_data_p)
|
||||
{
|
||||
return JSP_STATUS_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
return JSP_STATUS_OK;
|
||||
} /* parser_parse_script */
|
||||
|
||||
/**
|
||||
* Parse EcamScript eval source code
|
||||
*/
|
||||
jsp_status_t
|
||||
parser_parse_eval (const jerry_api_char_t *source_p, /**< source code */
|
||||
size_t size, /**< size of the source code */
|
||||
bool is_strict, /**< strict mode */
|
||||
ecma_compiled_code_t **bytecode_data_p) /**< result */
|
||||
{
|
||||
*bytecode_data_p = parser_parse_script (source_p, size, is_strict, NULL);
|
||||
|
||||
if (!*bytecode_data_p)
|
||||
{
|
||||
return JSP_STATUS_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
return JSP_STATUS_OK;
|
||||
} /* parser_parse_eval */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@ -1,55 +0,0 @@
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
#include "jerry-api.h"
|
||||
#include "byte-code.h"
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
*
|
||||
* \addtogroup jsparser ECMAScript
|
||||
* @{
|
||||
*
|
||||
* \addtogroup jsparser_parser Parser
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parser completion status
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JSP_STATUS_OK, /**< parse finished successfully, no early errors occured */
|
||||
JSP_STATUS_SYNTAX_ERROR, /**< SyntaxError early error occured */
|
||||
JSP_STATUS_REFERENCE_ERROR /**< ReferenceError early error occured */
|
||||
} jsp_status_t;
|
||||
|
||||
extern void parser_set_show_instrs (int);
|
||||
|
||||
extern jsp_status_t parser_parse_script (const jerry_api_char_t *, size_t,
|
||||
ecma_compiled_code_t **);
|
||||
extern jsp_status_t parser_parse_eval (const jerry_api_char_t *, size_t, bool,
|
||||
ecma_compiled_code_t **);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !PARSER_H */
|
||||
Loading…
x
Reference in New Issue
Block a user