• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright JS Foundation and other contributors, http://js.foundation
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 #ifndef RE_TOKEN_H
17 #define RE_TOKEN_H
18 
19 #if ENABLED (JERRY_BUILTIN_REGEXP)
20 
21 /** \addtogroup parser Parser
22  * @{
23  *
24  * \addtogroup regexparser Regular expression
25  * @{
26  *
27  * \addtogroup regexparser_parser Parser
28  * @{
29  */
30 
31 /**
32  * RegExp token type definitions
33  */
34 typedef enum
35 {
36   RE_TOK_EOF,                        /**< EOF */
37   RE_TOK_BACKREFERENCE,              /**< "\[0..9]" */
38   RE_TOK_ALTERNATIVE,                /**< "|" */
39   RE_TOK_ASSERT_START,               /**< "^" */
40   RE_TOK_ASSERT_END,                 /**< "$" */
41   RE_TOK_PERIOD,                     /**< "." */
42   RE_TOK_START_CAPTURE_GROUP,        /**< "(" */
43   RE_TOK_START_NON_CAPTURE_GROUP,    /**< "(?:" */
44   RE_TOK_END_GROUP,                  /**< ")" */
45   RE_TOK_ASSERT_LOOKAHEAD,           /**< "(?=" */
46   RE_TOK_ASSERT_WORD_BOUNDARY,       /**< "\b" */
47   RE_TOK_ASSERT_NOT_WORD_BOUNDARY,   /**< "\B" */
48   RE_TOK_CLASS_ESCAPE,               /**< "\d \D \w \W \s \S" */
49   RE_TOK_CHAR_CLASS,                 /**< "[ ]" */
50   RE_TOK_CHAR,                       /**< any character */
51 } re_token_type_t;
52 
53 /**
54  * RegExp token
55  */
56 typedef struct
57 {
58   uint32_t value;         /**< value of the token */
59   uint32_t qmin;          /**< minimum number of token iterations */
60   uint32_t qmax;          /**< maximum number of token iterations */
61   re_token_type_t type;   /**< type of the token */
62   bool greedy;            /**< type of iteration */
63 } re_token_t;
64 
65 /**
66  * @}
67  * @}
68  * @}
69  */
70 
71 #endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
72 #endif /* !RE_TOKEN_H */
73