aboutsummaryrefslogtreecommitdiff
path: root/jerry-core
diff options
context:
space:
mode:
authorRobert Sipka <rsipka.uszeged@partner.samsung.com>2016-02-09 14:00:04 +0100
committerLászló Langó <llango.u-szeged@partner.samsung.com>2016-02-10 12:35:55 +0100
commitb0bdf0ebf4ee89181a55e1c8dbfb49d5b314a633 (patch)
tree37a022572cd4a40e1ed5f0f4efc4b48850b05cd8 /jerry-core
parent41f2f910e8e7366db3ddad4bc4e19ea4354844f2 (diff)
Merge the js-parser and parser files
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
Diffstat (limited to 'jerry-core')
-rw-r--r--jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp2
-rw-r--r--jerry-core/ecma/operations/ecma-eval.cpp2
-rw-r--r--jerry-core/jerry.cpp2
-rw-r--r--jerry-core/parser/js/js-parser.cpp49
-rw-r--r--jerry-core/parser/js/js-parser.h20
-rw-r--r--jerry-core/parser/js/parser.cpp71
-rw-r--r--jerry-core/parser/js/parser.h55
7 files changed, 66 insertions, 135 deletions
diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp
index aeb6a6de..91d8700b 100644
--- a/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp
+++ b/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp
@@ -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"
diff --git a/jerry-core/ecma/operations/ecma-eval.cpp b/jerry-core/ecma/operations/ecma-eval.cpp
index f0da249c..90bda1e2 100644
--- a/jerry-core/ecma/operations/ecma-eval.cpp
+++ b/jerry-core/ecma/operations/ecma-eval.cpp
@@ -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
diff --git a/jerry-core/jerry.cpp b/jerry-core/jerry.cpp
index 6f521e53..55c7fc6c 100644
--- a/jerry-core/jerry.cpp
+++ b/jerry-core/jerry.cpp
@@ -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
diff --git a/jerry-core/parser/js/js-parser.cpp b/jerry-core/parser/js/js-parser.cpp
index 84d2e363..894eda96 100644
--- a/jerry-core/parser/js/js-parser.cpp
+++ b/jerry-core/parser/js/js-parser.cpp
@@ -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 */
+
+
/**
* @}
* @}
diff --git a/jerry-core/parser/js/js-parser.h b/jerry-core/parser/js/js-parser.h
index f7d74694..e71db227 100644
--- a/jerry-core/parser/js/js-parser.h
+++ b/jerry-core/parser/js/js-parser.h
@@ -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);
diff --git a/jerry-core/parser/js/parser.cpp b/jerry-core/parser/js/parser.cpp
deleted file mode 100644
index d9cb443e..00000000
--- a/jerry-core/parser/js/parser.cpp
+++ /dev/null
@@ -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 */
-
-/**
- * @}
- * @}
- * @}
- */
diff --git a/jerry-core/parser/js/parser.h b/jerry-core/parser/js/parser.h
deleted file mode 100644
index cbb06bbd..00000000
--- a/jerry-core/parser/js/parser.h
+++ /dev/null
@@ -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 */