SyntaxProperties.java revision 953:221a84ef44c0
1/*
2 * Permission is hereby granted, free of charge, to any person obtaining a copy of
3 * this software and associated documentation files (the "Software"), to deal in
4 * the Software without restriction, including without limitation the rights to
5 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
6 * of the Software, and to permit persons to whom the Software is furnished to do
7 * so, subject to the following conditions:
8 *
9 * The above copyright notice and this permission notice shall be included in all
10 * copies or substantial portions of the Software.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 * SOFTWARE.
19 */
20package jdk.nashorn.internal.runtime.regexp.joni.constants;
21
22public interface SyntaxProperties {
23    /* syntax (operators); */
24    final int OP_VARIABLE_META_CHARACTERS    = (1<<0);
25    final int OP_DOT_ANYCHAR                 = (1<<1);   /* . */
26    final int OP_ASTERISK_ZERO_INF           = (1<<2);   /* * */
27    final int OP_ESC_ASTERISK_ZERO_INF       = (1<<3);
28    final int OP_PLUS_ONE_INF                = (1<<4);   /* + */
29    final int OP_ESC_PLUS_ONE_INF            = (1<<5);
30    final int OP_QMARK_ZERO_ONE              = (1<<6);   /* ? */
31    final int OP_ESC_QMARK_ZERO_ONE          = (1<<7);
32    final int OP_BRACE_INTERVAL              = (1<<8);   /* {lower,upper} */
33    final int OP_ESC_BRACE_INTERVAL          = (1<<9);   /* \{lower,upper\} */
34    final int OP_VBAR_ALT                    = (1<<10);   /* | */
35    final int OP_ESC_VBAR_ALT                = (1<<11);  /* \| */
36    final int OP_LPAREN_SUBEXP               = (1<<12);  /* (...);   */
37    final int OP_ESC_LPAREN_SUBEXP           = (1<<13);  /* \(...\); */
38    final int OP_ESC_AZ_BUF_ANCHOR           = (1<<14);  /* \A, \Z, \z */
39    final int OP_ESC_CAPITAL_G_BEGIN_ANCHOR  = (1<<15);  /* \G     */
40    final int OP_DECIMAL_BACKREF             = (1<<16);  /* \num   */
41    final int OP_BRACKET_CC                  = (1<<17);  /* [...]  */
42    final int OP_ESC_W_WORD                  = (1<<18);  /* \w, \W */
43    final int OP_ESC_LTGT_WORD_BEGIN_END     = (1<<19);  /* \<. \> */
44    final int OP_ESC_B_WORD_BOUND            = (1<<20);  /* \b, \B */
45    final int OP_ESC_S_WHITE_SPACE           = (1<<21);  /* \s, \S */
46    final int OP_ESC_D_DIGIT                 = (1<<22);  /* \d, \D */
47    final int OP_LINE_ANCHOR                 = (1<<23);  /* ^, $   */
48    final int OP_POSIX_BRACKET               = (1<<24);  /* [:xxxx:] */
49    final int OP_QMARK_NON_GREEDY            = (1<<25);  /* ??,*?,+?,{n,m}? */
50    final int OP_ESC_CONTROL_CHARS           = (1<<26);  /* \n,\r,\t,\a ... */
51    final int OP_ESC_C_CONTROL               = (1<<27);  /* \cx  */
52    final int OP_ESC_OCTAL3                  = (1<<28);  /* \OOO */
53    final int OP_ESC_X_HEX2                  = (1<<29);  /* \xHH */
54    final int OP_ESC_X_BRACE_HEX8            = (1<<30);  /* \x{7HHHHHHH} */
55
56    final int OP2_ESC_CAPITAL_Q_QUOTE        = (1<<0);  /* \Q...\E */
57    final int OP2_QMARK_GROUP_EFFECT         = (1<<1);  /* (?...); */
58    final int OP2_OPTION_PERL                = (1<<2);  /* (?imsx);,(?-imsx); */
59    final int OP2_OPTION_RUBY                = (1<<3);  /* (?imx);, (?-imx);  */
60    final int OP2_PLUS_POSSESSIVE_REPEAT     = (1<<4);  /* ?+,*+,++ */
61    final int OP2_PLUS_POSSESSIVE_INTERVAL   = (1<<5);  /* {n,m}+   */
62    final int OP2_CCLASS_SET_OP              = (1<<6);  /* [...&&..[..]..] */
63    final int OP2_QMARK_LT_NAMED_GROUP       = (1<<7);  /* (?<name>...); */
64    final int OP2_ESC_K_NAMED_BACKREF        = (1<<8);  /* \k<name> */
65    final int OP2_ESC_G_SUBEXP_CALL          = (1<<9);  /* \g<name>, \g<n> */
66    final int OP2_ATMARK_CAPTURE_HISTORY     = (1<<10); /* (?@..);,(?@<x>..); */
67    final int OP2_ESC_CAPITAL_C_BAR_CONTROL  = (1<<11); /* \C-x */
68    final int OP2_ESC_CAPITAL_M_BAR_META     = (1<<12); /* \M-x */
69    final int OP2_ESC_V_VTAB                 = (1<<13); /* \v as VTAB */
70    final int OP2_ESC_U_HEX4                 = (1<<14); /* \\uHHHH */
71    final int OP2_ESC_GNU_BUF_ANCHOR         = (1<<15); /* \`, \' */
72    final int OP2_ESC_P_BRACE_CHAR_PROPERTY  = (1<<16); /* \p{...}, \P{...} */
73    final int OP2_ESC_P_BRACE_CIRCUMFLEX_NOT = (1<<17); /* \p{^..}, \P{^..} */
74    /* final int OP2_CHAR_PROPERTY_PREFIX_IS = (1<<18); */
75    final int OP2_ESC_H_XDIGIT               = (1<<19); /* \h, \H */
76    final int OP2_INEFFECTIVE_ESCAPE         = (1<<20); /* \ */
77
78    /* syntax (behavior); */
79    final int CONTEXT_INDEP_ANCHORS           = (1<<31); /* not implemented */
80    final int CONTEXT_INDEP_REPEAT_OPS        = (1<<0);  /* ?, *, +, {n,m} */
81    final int CONTEXT_INVALID_REPEAT_OPS      = (1<<1);  /* error or ignore */
82    final int ALLOW_UNMATCHED_CLOSE_SUBEXP    = (1<<2);  /* ...);... */
83    final int ALLOW_INVALID_INTERVAL          = (1<<3);  /* {??? */
84    final int ALLOW_INTERVAL_LOW_ABBREV       = (1<<4);  /* {,n} => {0,n} */
85    final int STRICT_CHECK_BACKREF            = (1<<5);  /* /(\1);/,/\1();/ ..*/
86    final int DIFFERENT_LEN_ALT_LOOK_BEHIND   = (1<<6);  /* (?<=a|bc); */
87    final int CAPTURE_ONLY_NAMED_GROUP        = (1<<7);  /* see doc/RE */
88    final int ALLOW_MULTIPLEX_DEFINITION_NAME = (1<<8);  /* (?<x>);(?<x>); */
89    final int FIXED_INTERVAL_IS_GREEDY_ONLY   = (1<<9);  /* a{n}?=(?:a{n});? */
90
91    /* syntax (behavior); in char class [...] */
92    final int NOT_NEWLINE_IN_NEGATIVE_CC      = (1<<20); /* [^...] */
93    final int BACKSLASH_ESCAPE_IN_CC          = (1<<21); /* [..\w..] etc.. */
94    final int ALLOW_EMPTY_RANGE_IN_CC         = (1<<22);
95    final int ALLOW_DOUBLE_RANGE_OP_IN_CC     = (1<<23); /* [0-9-a]=[0-9\-a] */
96    /* syntax (behavior); warning */
97    final int WARN_CC_OP_NOT_ESCAPED          = (1<<24); /* [,-,] */
98    final int WARN_REDUNDANT_NESTED_REPEAT    = (1<<25); /* (?:a*);+ */
99
100    final int POSIX_COMMON_OP =
101                            OP_DOT_ANYCHAR | OP_POSIX_BRACKET |
102                            OP_DECIMAL_BACKREF |
103                            OP_BRACKET_CC | OP_ASTERISK_ZERO_INF |
104                            OP_LINE_ANCHOR |
105                            OP_ESC_CONTROL_CHARS;
106
107    final int GNU_REGEX_OP =
108                            OP_DOT_ANYCHAR | OP_BRACKET_CC |
109                            OP_POSIX_BRACKET | OP_DECIMAL_BACKREF |
110                            OP_BRACE_INTERVAL | OP_LPAREN_SUBEXP |
111                            OP_VBAR_ALT |
112                            OP_ASTERISK_ZERO_INF | OP_PLUS_ONE_INF |
113                            OP_QMARK_ZERO_ONE |
114                            OP_ESC_AZ_BUF_ANCHOR | OP_ESC_CAPITAL_G_BEGIN_ANCHOR |
115                            OP_ESC_W_WORD |
116                            OP_ESC_B_WORD_BOUND | OP_ESC_LTGT_WORD_BEGIN_END |
117                            OP_ESC_S_WHITE_SPACE | OP_ESC_D_DIGIT |
118                            OP_LINE_ANCHOR;
119
120    final int GNU_REGEX_BV =
121                            CONTEXT_INDEP_ANCHORS | CONTEXT_INDEP_REPEAT_OPS |
122                            CONTEXT_INVALID_REPEAT_OPS | ALLOW_INVALID_INTERVAL |
123                            BACKSLASH_ESCAPE_IN_CC | ALLOW_DOUBLE_RANGE_OP_IN_CC;
124}
125