Replace vera++ with clang-format (#4518)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
@@ -13,10 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "re-bytecode.h"
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-regexp-object.h"
|
||||
|
||||
#include "lit-strings.h"
|
||||
#include "re-bytecode.h"
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
|
||||
@@ -155,7 +157,7 @@ re_encode_u16 (uint8_t *dest_p, /**< destination */
|
||||
*/
|
||||
static void
|
||||
re_encode_u32 (uint8_t *dest_p, /**< destination */
|
||||
const uint32_t value) /**< value */
|
||||
const uint32_t value) /**< value */
|
||||
{
|
||||
*dest_p++ = (uint8_t) ((value >> 24) & 0xFF);
|
||||
*dest_p++ = (uint8_t) ((value >> 16) & 0xFF);
|
||||
@@ -368,7 +370,7 @@ re_get_bytecode_offset (const uint8_t *start_p, /**< bytecode start pointer */
|
||||
void
|
||||
re_dump_bytecode (re_compiler_ctx_t *re_ctx_p) /**< RegExp bytecode context */
|
||||
{
|
||||
static const char escape_chars[] = {'d', 'D', 'w', 'W', 's', 'S'};
|
||||
static const char escape_chars[] = { 'd', 'D', 'w', 'W', 's', 'S' };
|
||||
|
||||
re_compiled_code_t *compiled_code_p = (re_compiled_code_t *) re_ctx_p->bytecode_start_p;
|
||||
JERRY_DEBUG_MSG ("Flags: 0x%x ", compiled_code_p->header.status_flags);
|
||||
|
||||
@@ -16,11 +16,12 @@
|
||||
#ifndef RE_BYTECODE_H
|
||||
#define RE_BYTECODE_H
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "re-compiler-context.h"
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
*
|
||||
@@ -32,8 +33,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Size of the RegExp bytecode cache
|
||||
*/
|
||||
* Size of the RegExp bytecode cache
|
||||
*/
|
||||
#define RE_CACHE_SIZE 8u
|
||||
|
||||
/**
|
||||
@@ -51,42 +52,42 @@
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RE_OP_EOF, /**< end of pattern */
|
||||
RE_OP_EOF, /**< end of pattern */
|
||||
|
||||
RE_OP_ALTERNATIVE_START, /**< start of alternatives */
|
||||
RE_OP_ALTERNATIVE_NEXT, /**< next alternative */
|
||||
RE_OP_NO_ALTERNATIVE, /**< no alternative */
|
||||
RE_OP_ALTERNATIVE_START, /**< start of alternatives */
|
||||
RE_OP_ALTERNATIVE_NEXT, /**< next alternative */
|
||||
RE_OP_NO_ALTERNATIVE, /**< no alternative */
|
||||
|
||||
RE_OP_CAPTURING_GROUP_START, /**< start of a capturing group */
|
||||
RE_OP_NON_CAPTURING_GROUP_START, /**< start of a non-capturing group */
|
||||
RE_OP_CAPTURING_GROUP_START, /**< start of a capturing group */
|
||||
RE_OP_NON_CAPTURING_GROUP_START, /**< start of a non-capturing group */
|
||||
|
||||
RE_OP_GREEDY_CAPTURING_GROUP_END, /**< end of a greedy capturing group */
|
||||
RE_OP_GREEDY_NON_CAPTURING_GROUP_END, /**< end of a greedy non-capturing group */
|
||||
RE_OP_LAZY_CAPTURING_GROUP_END, /**< end of a lazy capturing group */
|
||||
RE_OP_LAZY_NON_CAPTURING_GROUP_END, /**< end of a lazy non-capturing group */
|
||||
RE_OP_GREEDY_CAPTURING_GROUP_END, /**< end of a greedy capturing group */
|
||||
RE_OP_GREEDY_NON_CAPTURING_GROUP_END, /**< end of a greedy non-capturing group */
|
||||
RE_OP_LAZY_CAPTURING_GROUP_END, /**< end of a lazy capturing group */
|
||||
RE_OP_LAZY_NON_CAPTURING_GROUP_END, /**< end of a lazy non-capturing group */
|
||||
|
||||
RE_OP_GREEDY_ITERATOR, /**< greedy iterator */
|
||||
RE_OP_LAZY_ITERATOR, /**< lazy iterator */
|
||||
RE_OP_ITERATOR_END, /*** end of an iterator */
|
||||
RE_OP_GREEDY_ITERATOR, /**< greedy iterator */
|
||||
RE_OP_LAZY_ITERATOR, /**< lazy iterator */
|
||||
RE_OP_ITERATOR_END, /*** end of an iterator */
|
||||
|
||||
RE_OP_BACKREFERENCE, /**< backreference */
|
||||
RE_OP_BACKREFERENCE, /**< backreference */
|
||||
|
||||
RE_OP_ASSERT_LINE_START, /**< line start assertion */
|
||||
RE_OP_ASSERT_LINE_END, /**< line end assertion */
|
||||
RE_OP_ASSERT_WORD_BOUNDARY, /**< word boundary assertion */
|
||||
RE_OP_ASSERT_NOT_WORD_BOUNDARY, /**< not word boundary assertion */
|
||||
RE_OP_ASSERT_LOOKAHEAD_POS, /**< positive lookahead assertion */
|
||||
RE_OP_ASSERT_LOOKAHEAD_NEG, /**< negative lookahead assertion */
|
||||
RE_OP_ASSERT_END, /**< end of an assertion */
|
||||
RE_OP_ASSERT_LINE_START, /**< line start assertion */
|
||||
RE_OP_ASSERT_LINE_END, /**< line end assertion */
|
||||
RE_OP_ASSERT_WORD_BOUNDARY, /**< word boundary assertion */
|
||||
RE_OP_ASSERT_NOT_WORD_BOUNDARY, /**< not word boundary assertion */
|
||||
RE_OP_ASSERT_LOOKAHEAD_POS, /**< positive lookahead assertion */
|
||||
RE_OP_ASSERT_LOOKAHEAD_NEG, /**< negative lookahead assertion */
|
||||
RE_OP_ASSERT_END, /**< end of an assertion */
|
||||
|
||||
RE_OP_CLASS_ESCAPE, /**< class escape */
|
||||
RE_OP_CHAR_CLASS, /**< character class */
|
||||
RE_OP_CLASS_ESCAPE, /**< class escape */
|
||||
RE_OP_CHAR_CLASS, /**< character class */
|
||||
#if JERRY_ESNEXT
|
||||
RE_OP_UNICODE_PERIOD, /**< period in full unicode mode */
|
||||
RE_OP_UNICODE_PERIOD, /**< period in full unicode mode */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
RE_OP_PERIOD, /**< period in non-unicode mode */
|
||||
RE_OP_CHAR, /**< any code point */
|
||||
RE_OP_BYTE, /**< 1-byte utf8 character */
|
||||
RE_OP_PERIOD, /**< period in non-unicode mode */
|
||||
RE_OP_CHAR, /**< any code point */
|
||||
RE_OP_BYTE, /**< 1-byte utf8 character */
|
||||
} re_opcode_t;
|
||||
|
||||
/**
|
||||
@@ -94,10 +95,10 @@ typedef enum
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ecma_compiled_code_t header; /**< compiled code header */
|
||||
uint32_t captures_count; /**< number of capturing groups */
|
||||
uint32_t non_captures_count; /**< number of non-capturing groups */
|
||||
ecma_value_t source; /**< original RegExp pattern */
|
||||
ecma_compiled_code_t header; /**< compiled code header */
|
||||
uint32_t captures_count; /**< number of capturing groups */
|
||||
uint32_t non_captures_count; /**< number of non-capturing groups */
|
||||
ecma_value_t source; /**< original RegExp pattern */
|
||||
} re_compiled_code_t;
|
||||
|
||||
void re_initialize_regexp_bytecode (re_compiler_ctx_t *re_ctx_p);
|
||||
@@ -110,7 +111,7 @@ void re_append_value (re_compiler_ctx_t *re_ctx_p, const uint32_t value);
|
||||
|
||||
void re_insert_opcode (re_compiler_ctx_t *re_ctx_p, const uint32_t offset, const re_opcode_t opcode);
|
||||
void re_insert_byte (re_compiler_ctx_t *re_ctx_p, const uint32_t offset, const uint8_t byte);
|
||||
void re_insert_char (re_compiler_ctx_t *re_ctx_p, const uint32_t offset, const lit_code_point_t cp);
|
||||
void re_insert_char (re_compiler_ctx_t *re_ctx_p, const uint32_t offset, const lit_code_point_t cp);
|
||||
void re_insert_value (re_compiler_ctx_t *re_ctx_p, const uint32_t offset, const uint32_t value);
|
||||
|
||||
re_opcode_t re_get_opcode (const uint8_t **bc_p);
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
#ifndef RE_COMPILER_CONTEXT_H
|
||||
#define RE_COMPILER_CONTEXT_H
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
|
||||
#include "re-token.h"
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
*
|
||||
@@ -36,18 +36,18 @@
|
||||
typedef struct
|
||||
{
|
||||
const lit_utf8_byte_t *input_start_p; /**< start of input pattern */
|
||||
const lit_utf8_byte_t *input_curr_p; /**< current position in input pattern */
|
||||
const lit_utf8_byte_t *input_end_p; /**< end of input pattern */
|
||||
const lit_utf8_byte_t *input_curr_p; /**< current position in input pattern */
|
||||
const lit_utf8_byte_t *input_end_p; /**< end of input pattern */
|
||||
|
||||
uint8_t *bytecode_start_p; /**< start of bytecode block */
|
||||
size_t bytecode_size; /**< size of bytecode */
|
||||
uint8_t *bytecode_start_p; /**< start of bytecode block */
|
||||
size_t bytecode_size; /**< size of bytecode */
|
||||
|
||||
uint32_t captures_count; /**< number of capture groups */
|
||||
uint32_t non_captures_count; /**< number of non-capture groups */
|
||||
uint32_t captures_count; /**< number of capture groups */
|
||||
uint32_t non_captures_count; /**< number of non-capture groups */
|
||||
|
||||
int groups_count; /**< number of groups */
|
||||
uint16_t flags; /**< RegExp flags */
|
||||
re_token_t token; /**< current token */
|
||||
int groups_count; /**< number of groups */
|
||||
uint16_t flags; /**< RegExp flags */
|
||||
re_token_t token; /**< current token */
|
||||
} re_compiler_ctx_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,15 +13,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "re-compiler.h"
|
||||
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-regexp-object.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jmem.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "re-bytecode.h"
|
||||
#include "re-compiler.h"
|
||||
#include "re-compiler-context.h"
|
||||
#include "re-parser.h"
|
||||
|
||||
@@ -140,9 +142,8 @@ re_compile_bytecode (ecma_string_t *pattern_str_p, /**< pattern */
|
||||
|
||||
/* Align bytecode size to JMEM_ALIGNMENT so that it can be stored in the bytecode header. */
|
||||
const uint32_t final_size = JERRY_ALIGNUP (re_ctx.bytecode_size, JMEM_ALIGNMENT);
|
||||
re_compiled_code_t *re_compiled_code_p = (re_compiled_code_t *) jmem_heap_realloc_block (re_ctx.bytecode_start_p,
|
||||
re_ctx.bytecode_size,
|
||||
final_size);
|
||||
re_compiled_code_t *re_compiled_code_p =
|
||||
(re_compiled_code_t *) jmem_heap_realloc_block (re_ctx.bytecode_start_p, re_ctx.bytecode_size, final_size);
|
||||
|
||||
/* Bytecoded will be inserted into the cache and returned to the caller, so refcount is implicitly set to 2. */
|
||||
re_compiled_code_p->header.refs = 2;
|
||||
|
||||
@@ -16,11 +16,12 @@
|
||||
#ifndef RE_COMPILER_H
|
||||
#define RE_COMPILER_H
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "re-bytecode.h"
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
*
|
||||
@@ -31,8 +32,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
re_compiled_code_t *
|
||||
re_compile_bytecode (ecma_string_t *pattern_str_p, uint16_t flags);
|
||||
re_compiled_code_t *re_compile_bytecode (ecma_string_t *pattern_str_p, uint16_t flags);
|
||||
|
||||
void re_cache_gc (void);
|
||||
|
||||
|
||||
@@ -13,13 +13,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "re-parser.h"
|
||||
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "re-compiler.h"
|
||||
#include "re-parser.h"
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
|
||||
@@ -42,7 +44,7 @@ static re_opcode_t
|
||||
re_get_group_start_opcode (bool is_capturing) /**< is capturing group */
|
||||
{
|
||||
return (is_capturing) ? RE_OP_CAPTURING_GROUP_START : RE_OP_NON_CAPTURING_GROUP_START;
|
||||
} /* re_get_group_start_opcode*/
|
||||
} /* re_get_group_start_opcode */
|
||||
|
||||
/**
|
||||
* Get the end opcode for the current group.
|
||||
@@ -91,9 +93,7 @@ re_insert_into_group (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
|
||||
|
||||
if (qmin == 0)
|
||||
{
|
||||
re_insert_value (re_ctx_p,
|
||||
group_start_offset,
|
||||
re_bytecode_size (re_ctx_p) - group_start_offset);
|
||||
re_insert_value (re_ctx_p, group_start_offset, re_bytecode_size (re_ctx_p) - group_start_offset);
|
||||
}
|
||||
|
||||
re_insert_value (re_ctx_p, group_start_offset, qmin);
|
||||
@@ -174,8 +174,7 @@ re_insert_assertion_lookahead (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler
|
||||
static void
|
||||
re_parse_lazy_char (re_compiler_ctx_t *re_ctx_p) /**< RegExp parser context */
|
||||
{
|
||||
if (re_ctx_p->input_curr_p < re_ctx_p->input_end_p
|
||||
&& *re_ctx_p->input_curr_p == LIT_CHAR_QUESTION)
|
||||
if (re_ctx_p->input_curr_p < re_ctx_p->input_end_p && *re_ctx_p->input_curr_p == LIT_CHAR_QUESTION)
|
||||
{
|
||||
re_ctx_p->input_curr_p++;
|
||||
re_ctx_p->token.greedy = false;
|
||||
@@ -198,14 +197,12 @@ re_parse_octal (re_compiler_ctx_t *re_ctx_p) /**< RegExp parser context */
|
||||
|
||||
uint32_t value = (uint32_t) (*re_ctx_p->input_curr_p++) - LIT_CHAR_0;
|
||||
|
||||
if (re_ctx_p->input_curr_p < re_ctx_p->input_end_p
|
||||
&& lit_char_is_octal_digit (*re_ctx_p->input_curr_p))
|
||||
if (re_ctx_p->input_curr_p < re_ctx_p->input_end_p && lit_char_is_octal_digit (*re_ctx_p->input_curr_p))
|
||||
{
|
||||
value = value * 8 + (*re_ctx_p->input_curr_p++) - LIT_CHAR_0;
|
||||
}
|
||||
|
||||
if (re_ctx_p->input_curr_p < re_ctx_p->input_end_p
|
||||
&& lit_char_is_octal_digit (*re_ctx_p->input_curr_p))
|
||||
if (re_ctx_p->input_curr_p < re_ctx_p->input_end_p && lit_char_is_octal_digit (*re_ctx_p->input_curr_p))
|
||||
{
|
||||
const uint32_t new_value = value * 8 + (*re_ctx_p->input_curr_p) - LIT_CHAR_0;
|
||||
|
||||
@@ -381,9 +378,7 @@ re_count_groups (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context */
|
||||
}
|
||||
case LIT_CHAR_LEFT_PAREN:
|
||||
{
|
||||
if (curr_p < re_ctx_p->input_end_p
|
||||
&& *curr_p != LIT_CHAR_QUESTION
|
||||
&& !is_char_class)
|
||||
if (curr_p < re_ctx_p->input_end_p && *curr_p != LIT_CHAR_QUESTION && !is_char_class)
|
||||
{
|
||||
re_ctx_p->groups_count++;
|
||||
}
|
||||
@@ -403,20 +398,10 @@ re_count_groups (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context */
|
||||
static bool
|
||||
re_is_syntax_char (lit_code_point_t cp) /**< code point */
|
||||
{
|
||||
return (cp == LIT_CHAR_CIRCUMFLEX
|
||||
|| cp == LIT_CHAR_DOLLAR_SIGN
|
||||
|| cp == LIT_CHAR_BACKSLASH
|
||||
|| cp == LIT_CHAR_DOT
|
||||
|| cp == LIT_CHAR_ASTERISK
|
||||
|| cp == LIT_CHAR_PLUS
|
||||
|| cp == LIT_CHAR_QUESTION
|
||||
|| cp == LIT_CHAR_LEFT_PAREN
|
||||
|| cp == LIT_CHAR_RIGHT_PAREN
|
||||
|| cp == LIT_CHAR_LEFT_SQUARE
|
||||
|| cp == LIT_CHAR_RIGHT_SQUARE
|
||||
|| cp == LIT_CHAR_LEFT_BRACE
|
||||
|| cp == LIT_CHAR_RIGHT_BRACE
|
||||
|| cp == LIT_CHAR_VLINE);
|
||||
return (cp == LIT_CHAR_CIRCUMFLEX || cp == LIT_CHAR_DOLLAR_SIGN || cp == LIT_CHAR_BACKSLASH || cp == LIT_CHAR_DOT
|
||||
|| cp == LIT_CHAR_ASTERISK || cp == LIT_CHAR_PLUS || cp == LIT_CHAR_QUESTION || cp == LIT_CHAR_LEFT_PAREN
|
||||
|| cp == LIT_CHAR_RIGHT_PAREN || cp == LIT_CHAR_LEFT_SQUARE || cp == LIT_CHAR_RIGHT_SQUARE
|
||||
|| cp == LIT_CHAR_LEFT_BRACE || cp == LIT_CHAR_RIGHT_BRACE || cp == LIT_CHAR_VLINE);
|
||||
} /* re_is_syntax_char */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@@ -589,17 +574,15 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
|
||||
re_ctx_p->input_curr_p += 4;
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE
|
||||
&& lit_is_code_point_utf16_high_surrogate (re_ctx_p->token.value)
|
||||
&& re_ctx_p->input_curr_p + 6 <= re_ctx_p->input_end_p
|
||||
&& re_ctx_p->input_curr_p[0] == '\\'
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE && lit_is_code_point_utf16_high_surrogate (re_ctx_p->token.value)
|
||||
&& re_ctx_p->input_curr_p + 6 <= re_ctx_p->input_end_p && re_ctx_p->input_curr_p[0] == '\\'
|
||||
&& re_ctx_p->input_curr_p[1] == 'u')
|
||||
{
|
||||
hex_value = lit_char_hex_lookup (re_ctx_p->input_curr_p + 2, re_ctx_p->input_end_p, 4);
|
||||
if (lit_is_code_point_utf16_low_surrogate (hex_value))
|
||||
{
|
||||
re_ctx_p->token.value = lit_convert_surrogate_pair_to_code_point ((ecma_char_t) re_ctx_p->token.value,
|
||||
(ecma_char_t) hex_value);
|
||||
re_ctx_p->token.value =
|
||||
lit_convert_surrogate_pair_to_code_point ((ecma_char_t) re_ctx_p->token.value, (ecma_char_t) hex_value);
|
||||
re_ctx_p->input_curr_p += 6;
|
||||
}
|
||||
}
|
||||
@@ -611,8 +594,7 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
|
||||
#if JERRY_ESNEXT
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE)
|
||||
{
|
||||
if (re_ctx_p->input_curr_p + 1 < re_ctx_p->input_end_p
|
||||
&& re_ctx_p->input_curr_p[0] == LIT_CHAR_LEFT_BRACE
|
||||
if (re_ctx_p->input_curr_p + 1 < re_ctx_p->input_end_p && re_ctx_p->input_curr_p[0] == LIT_CHAR_LEFT_BRACE
|
||||
&& lit_char_is_hex_digit (re_ctx_p->input_curr_p[1]))
|
||||
{
|
||||
lit_code_point_t cp = lit_char_hex_to_int (re_ctx_p->input_curr_p[1]);
|
||||
@@ -648,9 +630,7 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context
|
||||
{
|
||||
#if JERRY_ESNEXT
|
||||
/* Must be '/', or one of SyntaxCharacter */
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE
|
||||
&& ch != LIT_CHAR_SLASH
|
||||
&& !re_is_syntax_char (ch))
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE && ch != LIT_CHAR_SLASH && !re_is_syntax_char (ch))
|
||||
{
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid escape"));
|
||||
}
|
||||
@@ -863,8 +843,7 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
|
||||
re_ctx_p->token.value = ch;
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE
|
||||
&& lit_is_code_point_utf16_high_surrogate (ch)
|
||||
if (re_ctx_p->flags & RE_FLAG_UNICODE && lit_is_code_point_utf16_high_surrogate (ch)
|
||||
&& re_ctx_p->input_curr_p < re_ctx_p->input_end_p)
|
||||
{
|
||||
const ecma_char_t next = lit_cesu8_peek_next (re_ctx_p->input_curr_p);
|
||||
@@ -908,8 +887,8 @@ re_class_add_range (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context */
|
||||
*/
|
||||
static void
|
||||
re_class_add_char (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context */
|
||||
uint32_t class_offset, /**< character class bytecode offset*/
|
||||
lit_code_point_t cp) /**< code point */
|
||||
uint32_t class_offset, /**< character class bytecode offset*/
|
||||
lit_code_point_t cp) /**< code point */
|
||||
{
|
||||
if (re_ctx_p->flags & RE_FLAG_IGNORE_CASE)
|
||||
{
|
||||
@@ -935,7 +914,7 @@ re_class_add_char (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context */
|
||||
static ecma_value_t
|
||||
re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context */
|
||||
{
|
||||
static const uint8_t escape_flags[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20};
|
||||
static const uint8_t escape_flags[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20 };
|
||||
const uint32_t class_offset = re_bytecode_size (re_ctx_p);
|
||||
|
||||
uint8_t found_escape_flags = 0;
|
||||
@@ -1002,13 +981,12 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
|
||||
current = LIT_CHAR_MINUS;
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
else if ((re_ctx_p->flags & RE_FLAG_UNICODE) == 0
|
||||
&& *re_ctx_p->input_curr_p == LIT_CHAR_LOWERCASE_C
|
||||
else if ((re_ctx_p->flags & RE_FLAG_UNICODE) == 0 && *re_ctx_p->input_curr_p == LIT_CHAR_LOWERCASE_C
|
||||
&& re_ctx_p->input_curr_p + 1 < re_ctx_p->input_end_p
|
||||
&& (lit_char_is_decimal_digit (*(re_ctx_p->input_curr_p + 1))
|
||||
|| *(re_ctx_p->input_curr_p + 1) == LIT_CHAR_UNDERSCORE))
|
||||
{
|
||||
current = ((uint8_t) *(re_ctx_p->input_curr_p + 1) % 32);
|
||||
current = ((uint8_t) * (re_ctx_p->input_curr_p + 1) % 32);
|
||||
re_ctx_p->input_curr_p += 2;
|
||||
}
|
||||
else
|
||||
@@ -1081,8 +1059,7 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context *
|
||||
continue;
|
||||
}
|
||||
|
||||
if (re_ctx_p->input_curr_p < re_ctx_p->input_end_p
|
||||
&& *re_ctx_p->input_curr_p == LIT_CHAR_MINUS)
|
||||
if (re_ctx_p->input_curr_p < re_ctx_p->input_end_p && *re_ctx_p->input_curr_p == LIT_CHAR_MINUS)
|
||||
{
|
||||
re_ctx_p->input_curr_p++;
|
||||
start = current;
|
||||
@@ -1215,8 +1192,9 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
|
||||
case RE_TOK_ALTERNATIVE:
|
||||
{
|
||||
re_insert_value (re_ctx_p, alternative_offset, re_bytecode_size (re_ctx_p) - alternative_offset);
|
||||
re_insert_opcode (re_ctx_p, alternative_offset, first_alternative ? RE_OP_ALTERNATIVE_START
|
||||
: RE_OP_ALTERNATIVE_NEXT);
|
||||
re_insert_opcode (re_ctx_p,
|
||||
alternative_offset,
|
||||
first_alternative ? RE_OP_ALTERNATIVE_START : RE_OP_ALTERNATIVE_NEXT);
|
||||
|
||||
alternative_offset = re_bytecode_size (re_ctx_p);
|
||||
first_alternative = false;
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
#ifndef RE_PARSER_H
|
||||
#define RE_PARSER_H
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
|
||||
#include "re-compiler-context.h"
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
*
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#ifndef RE_TOKEN_H
|
||||
#define RE_TOKEN_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
@@ -33,21 +35,21 @@
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RE_TOK_EOF, /**< EOF */
|
||||
RE_TOK_BACKREFERENCE, /**< "\[0..9]" */
|
||||
RE_TOK_ALTERNATIVE, /**< "|" */
|
||||
RE_TOK_ASSERT_START, /**< "^" */
|
||||
RE_TOK_ASSERT_END, /**< "$" */
|
||||
RE_TOK_PERIOD, /**< "." */
|
||||
RE_TOK_START_CAPTURE_GROUP, /**< "(" */
|
||||
RE_TOK_START_NON_CAPTURE_GROUP, /**< "(?:" */
|
||||
RE_TOK_END_GROUP, /**< ")" */
|
||||
RE_TOK_ASSERT_LOOKAHEAD, /**< "(?=" */
|
||||
RE_TOK_ASSERT_WORD_BOUNDARY, /**< "\b" */
|
||||
RE_TOK_ASSERT_NOT_WORD_BOUNDARY, /**< "\B" */
|
||||
RE_TOK_CLASS_ESCAPE, /**< "\d \D \w \W \s \S" */
|
||||
RE_TOK_CHAR_CLASS, /**< "[ ]" */
|
||||
RE_TOK_CHAR, /**< any character */
|
||||
RE_TOK_EOF, /**< EOF */
|
||||
RE_TOK_BACKREFERENCE, /**< "\[0..9]" */
|
||||
RE_TOK_ALTERNATIVE, /**< "|" */
|
||||
RE_TOK_ASSERT_START, /**< "^" */
|
||||
RE_TOK_ASSERT_END, /**< "$" */
|
||||
RE_TOK_PERIOD, /**< "." */
|
||||
RE_TOK_START_CAPTURE_GROUP, /**< "(" */
|
||||
RE_TOK_START_NON_CAPTURE_GROUP, /**< "(?:" */
|
||||
RE_TOK_END_GROUP, /**< ")" */
|
||||
RE_TOK_ASSERT_LOOKAHEAD, /**< "(?=" */
|
||||
RE_TOK_ASSERT_WORD_BOUNDARY, /**< "\b" */
|
||||
RE_TOK_ASSERT_NOT_WORD_BOUNDARY, /**< "\B" */
|
||||
RE_TOK_CLASS_ESCAPE, /**< "\d \D \w \W \s \S" */
|
||||
RE_TOK_CHAR_CLASS, /**< "[ ]" */
|
||||
RE_TOK_CHAR, /**< any character */
|
||||
} re_token_type_t;
|
||||
|
||||
/**
|
||||
@@ -55,11 +57,11 @@ typedef enum
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t value; /**< value of the token */
|
||||
uint32_t qmin; /**< minimum number of token iterations */
|
||||
uint32_t qmax; /**< maximum number of token iterations */
|
||||
re_token_type_t type; /**< type of the token */
|
||||
bool greedy; /**< type of iteration */
|
||||
uint32_t value; /**< value of the token */
|
||||
uint32_t qmin; /**< minimum number of token iterations */
|
||||
uint32_t qmax; /**< maximum number of token iterations */
|
||||
re_token_type_t type; /**< type of the token */
|
||||
bool greedy; /**< type of iteration */
|
||||
} re_token_t;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user