Skip to content

Commit 8b28cac

Browse files
Implementing escape sequences support with the exception of "\0" ("<NUL>") character and cases that depend on Unicode support.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected]
1 parent 7025f97 commit 8b28cac

File tree

9 files changed

+639
-337
lines changed

9 files changed

+639
-337
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* Copyright 2015 Samsung Electronics Co., Ltd.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
/** \addtogroup ecma ECMA
17+
* @{
18+
*
19+
* \addtogroup ecmahelpers Helpers for operations with ECMA characters
20+
* @{
21+
*/
22+
23+
#include "ecma-globals.h"
24+
#include "ecma-helpers.h"
25+
26+
/**
27+
* Check if specified character is the newline character
28+
*
29+
* @return true - if the character is "<LF>" character according to ECMA-262 v5, Table 3,
30+
* false - otherwise.
31+
*/
32+
bool
33+
ecma_char_is_new_line (ecma_char_t c) /**< character value */
34+
{
35+
return (c == '\x0D');
36+
} /* ecma_char_is_new_line */
37+
38+
/**
39+
* Check if specified character the carriage return character
40+
*
41+
* @return true - if the character is "<CR>" character according to ECMA-262 v5, Table 3,
42+
* false - otherwise.
43+
*/
44+
bool
45+
ecma_char_is_carriage_return (ecma_char_t c) /**< character value */
46+
{
47+
return (c == '\x0A');
48+
} /* ecma_char_is_carriage_return */
49+
50+
/**
51+
* Check if specified character is one of LineTerminator (ECMA-262 v5, Table 3) characters
52+
*
53+
* @return true - if the character is one of LineTerminator characters,
54+
* false - otherwise.
55+
*/
56+
bool
57+
ecma_char_is_line_terminator (ecma_char_t c) /**< character value */
58+
{
59+
/* FIXME: Handle <LS> and <PS> (ECMA-262 v5, 7.3, Table 3) when Unicode would be supported */
60+
61+
return (ecma_char_is_carriage_return (c)
62+
|| ecma_char_is_new_line (c));
63+
} /* ecma_char_is_line_terminator */
64+
65+
/**
66+
* @}
67+
* @}
68+
*/

jerry-core/ecma/base/ecma-helpers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ extern ecma_number_t ecma_int32_to_number (int32_t value);
313313
extern ecma_number_t ecma_uint32_to_number (uint32_t value);
314314
extern ecma_length_t ecma_number_to_zt_string (ecma_number_t num, ecma_char_t *buffer_p, ssize_t buffer_size);
315315

316+
/* ecma-helpers-char.cpp */
317+
extern bool ecma_char_is_new_line (ecma_char_t c);
318+
extern bool ecma_char_is_carriage_return (ecma_char_t c);
319+
extern bool ecma_char_is_line_terminator (ecma_char_t c);
320+
316321
#endif /* !JERRY_ECMA_HELPERS_H */
317322

318323
/**

0 commit comments

Comments
 (0)