Skip to content

Support of escape sequences #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions jerry-core/ecma/base/ecma-helpers-char.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* Copyright 2015 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.
*/

/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmahelpers Helpers for operations with ECMA characters
* @{
*/

#include "ecma-globals.h"
#include "ecma-helpers.h"

/**
* Check if specified character is the newline character
*
* @return true - if the character is "<LF>" character according to ECMA-262 v5, Table 3,
* false - otherwise.
*/
bool
ecma_char_is_new_line (ecma_char_t c) /**< character value */
{
return (c == '\x0D');
} /* ecma_char_is_new_line */

/**
* Check if specified character the carriage return character
*
* @return true - if the character is "<CR>" character according to ECMA-262 v5, Table 3,
* false - otherwise.
*/
bool
ecma_char_is_carriage_return (ecma_char_t c) /**< character value */
{
return (c == '\x0A');
} /* ecma_char_is_carriage_return */

/**
* Check if specified character is one of LineTerminator (ECMA-262 v5, Table 3) characters
*
* @return true - if the character is one of LineTerminator characters,
* false - otherwise.
*/
bool
ecma_char_is_line_terminator (ecma_char_t c) /**< character value */
{
/* FIXME: Handle <LS> and <PS> (ECMA-262 v5, 7.3, Table 3) when Unicode would be supported */

return (ecma_char_is_carriage_return (c)
|| ecma_char_is_new_line (c));
} /* ecma_char_is_line_terminator */

/**
* @}
* @}
*/
5 changes: 5 additions & 0 deletions jerry-core/ecma/base/ecma-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ extern ecma_number_t ecma_int32_to_number (int32_t value);
extern ecma_number_t ecma_uint32_to_number (uint32_t value);
extern ecma_length_t ecma_number_to_zt_string (ecma_number_t num, ecma_char_t *buffer_p, ssize_t buffer_size);

/* ecma-helpers-char.cpp */
extern bool ecma_char_is_new_line (ecma_char_t c);
extern bool ecma_char_is_carriage_return (ecma_char_t c);
extern bool ecma_char_is_line_terminator (ecma_char_t c);

#endif /* !JERRY_ECMA_HELPERS_H */

/**
Expand Down
Loading