Compact Byte Code parser and executor for Jerry.
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com JerryScript-DCO-1.0-Signed-off-by: Tamas Gergely tgergely.u-szeged@partner.samsung.com JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs.u-szeged@partner.samsung.com JerryScript-DCO-1.0-Signed-off-by: István Kádár ikadar@inf.u-szeged.hu JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2015 University of Szeged.
|
||||
/* 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.
|
||||
@@ -19,49 +19,65 @@
|
||||
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN
|
||||
|
||||
#include "opcodes-dumper.h"
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
*
|
||||
* \addtogroup regexparser Regular expression
|
||||
* @{
|
||||
*
|
||||
* \addtogroup regexparser_bytecode Bytecode
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* RegExp token type definitions
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RE_TOK_EOF, /* EOF */
|
||||
RE_TOK_BACKREFERENCE, /* \[0..9] */
|
||||
RE_TOK_CHAR, /* any character */
|
||||
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_EOF, /* EOF */
|
||||
RE_TOK_BACKREFERENCE, /* \[0..9] */
|
||||
RE_TOK_CHAR, /* any character */
|
||||
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_START_POS_LOOKAHEAD, /* (?= */
|
||||
RE_TOK_ASSERT_START_NEG_LOOKAHEAD, /* (?! */
|
||||
RE_TOK_ASSERT_WORD_BOUNDARY, /* \b */
|
||||
RE_TOK_ASSERT_NOT_WORD_BOUNDARY, /* \B */
|
||||
RE_TOK_DIGIT, /* \d */
|
||||
RE_TOK_NOT_DIGIT, /* \D */
|
||||
RE_TOK_WHITE, /* \s */
|
||||
RE_TOK_NOT_WHITE, /* \S */
|
||||
RE_TOK_WORD_CHAR, /* \w */
|
||||
RE_TOK_NOT_WORD_CHAR, /* \W */
|
||||
RE_TOK_START_CHAR_CLASS, /* [ ] */
|
||||
RE_TOK_START_INV_CHAR_CLASS, /* [^ ] */
|
||||
RE_TOK_ASSERT_WORD_BOUNDARY, /* \b */
|
||||
RE_TOK_ASSERT_NOT_WORD_BOUNDARY, /* \B */
|
||||
RE_TOK_DIGIT, /* \d */
|
||||
RE_TOK_NOT_DIGIT, /* \D */
|
||||
RE_TOK_WHITE, /* \s */
|
||||
RE_TOK_NOT_WHITE, /* \S */
|
||||
RE_TOK_WORD_CHAR, /* \w */
|
||||
RE_TOK_NOT_WORD_CHAR, /* \W */
|
||||
RE_TOK_START_CHAR_CLASS, /* [ ] */
|
||||
RE_TOK_START_INV_CHAR_CLASS, /* [^ ] */
|
||||
} re_token_type_t;
|
||||
|
||||
/**
|
||||
* RegExp constant of infinite
|
||||
*/
|
||||
* @}
|
||||
*
|
||||
* \addtogroup regexparser_parser Parser
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* RegExp constant of infinite
|
||||
*/
|
||||
#define RE_ITERATOR_INFINITE ((uint32_t)-1)
|
||||
|
||||
/**
|
||||
* Maximum number of decimal escape digits
|
||||
*/
|
||||
* Maximum number of decimal escape digits
|
||||
*/
|
||||
#define RE_MAX_RE_DECESC_DIGITS 9
|
||||
|
||||
/**
|
||||
* Undefined character (out of the range of the codeunit)
|
||||
*/
|
||||
* Undefined character (out of the range of the codeunit)
|
||||
*/
|
||||
#define RE_CHAR_UNDEF 0xFFFFFFFF
|
||||
|
||||
/**
|
||||
@@ -69,11 +85,11 @@ typedef enum
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
re_token_type_t type; /**< type of the token */
|
||||
uint32_t value; /**< value of the token */
|
||||
uint32_t qmin; /**< minimum number of token iterations */
|
||||
uint32_t qmax; /**< maximum number of token iterations */
|
||||
bool greedy; /**< type of iteration */
|
||||
re_token_type_t type; /**< type of the token */
|
||||
uint32_t value; /**< value of the token */
|
||||
uint32_t qmin; /**< minimum number of token iterations */
|
||||
uint32_t qmax; /**< maximum number of token iterations */
|
||||
bool greedy; /**< type of iteration */
|
||||
} re_token_t;
|
||||
|
||||
/**
|
||||
@@ -82,10 +98,10 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
lit_utf8_byte_t *input_start_p; /**< start of input pattern */
|
||||
lit_utf8_byte_t *input_curr_p; /**< current position in input pattern */
|
||||
lit_utf8_byte_t *input_end_p; /**< end of input pattern */
|
||||
int num_of_groups; /**< number of groups */
|
||||
uint32_t num_of_classes; /**< number of character classes */
|
||||
lit_utf8_byte_t *input_curr_p; /**< current position in input pattern */
|
||||
lit_utf8_byte_t *input_end_p; /**< end of input pattern */
|
||||
int num_of_groups; /**< number of groups */
|
||||
uint32_t num_of_classes; /**< number of character classes */
|
||||
} re_parser_ctx_t;
|
||||
|
||||
typedef void (*re_char_class_callback) (void *re_ctx_p, uint32_t start, uint32_t end);
|
||||
@@ -96,5 +112,10 @@ re_parse_char_class (re_parser_ctx_t *, re_char_class_callback, void *, re_token
|
||||
ecma_completion_value_t
|
||||
re_parse_next_token (re_parser_ctx_t *, re_token_t *);
|
||||
|
||||
#endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
|
||||
#endif /* RE_PARSER_H */
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN */
|
||||
#endif /* !RE_PARSER_H */
|
||||
|
||||
Reference in New Issue
Block a user