]> gitweb.factorcode.org Git - factor.git/blob - basis/xmode/modes/regex.xml
xmode.modes: updating with recent xmode files
[factor.git] / basis / xmode / modes / regex.xml
1 <?xml version="1.0"?>
2
3 <!DOCTYPE MODE SYSTEM 'xmode.dtd'>
4
5 <!-- Regular Expression mode, by Kevin Hunter -->
6
7 <!-- Currently implemented artifacts:
8 ***** Classes
9 [...] - user-defined character classes
10 \d - Numerical characters (eq. [0-9])
11 \D - Non-numerical characters (eq. [^0-9])
12 \w - Alphanumeric characters and underscore (eq. [A-Za-z0-9_])
13 \W - Opposite of \w (eq. [^A-Za-z0-9_])
14 \s - Whitespace characters (ex. space, tab, formfeed, newline)
15 \S - Non-whitespace characters
16 \b - Word-break character
17 .  - Any character, generally not including a newline (\n)
18
19 ***** Operators
20 ^ - Match at beginning of string
21 $ - Match at end of string
22 ? - optionally match previous item token
23 * - Match previous token 0 or more times.
24 + - Match previous token 1 or more times.
25 | - Logical OR, allowing the previous token or next token to match
26 {m} - Match previous token exactly m times.
27 {m,} - Match previous token at least m times
28 {m,n} - Match previous token between m and n times, inclusive.
29
30 ***** Functions
31 [^...] - negate user-defined character classes
32 (...) - Backreference - effectively save the matched part for later use
33 (?:...) - Group - Don't save, just mark the section of the pattern as a group
34 (?=...) - zero-width positive lookahead assertion
35 (?!...) - zero-width negative lookahead assertion
36 (?<=...) - zero-width positive lookbehind assertion
37 (?<!...) - zero-width negative lookbehind assertion
38
39 -->
40 <MODE>
41         <RULES IGNORE_CASE='FALSE' HIGHLIGHT_DIGITS='TRUE' SET='FORCED_NUMBER'>
42                 <SEQ TYPE='OPERATOR'>,</SEQ>
43         </RULES>
44
45         <RULES IGNORE_CASE='FALSE' HIGHLIGHT_DIGITS='TRUE'>
46                 <SEQ TYPE='NULL'>\\</SEQ>
47                 <SEQ TYPE='NULL'>\(</SEQ>
48                 <SEQ TYPE='NULL'>\)</SEQ>
49                 <SEQ TYPE='NULL'>\[</SEQ>
50                 <SEQ TYPE='NULL'>\]</SEQ>
51                 <SEQ TYPE='NULL'>\{</SEQ>
52                 <SEQ TYPE='NULL'>\}</SEQ>
53                 <SEQ TYPE='NULL'>\^</SEQ>
54                 <SEQ TYPE='NULL'>\$</SEQ>
55                 <SEQ TYPE='NULL'>\?</SEQ>
56                 <SEQ TYPE='NULL'>\+</SEQ>
57                 <SEQ TYPE='NULL'>\*</SEQ>
58                 <SEQ TYPE='NULL'>\.</SEQ>
59                 <SEQ TYPE='NULL'>\|</SEQ>
60
61                 <SEQ TYPE='OPERATOR'>^</SEQ>
62                 <SEQ TYPE='OPERATOR'>$</SEQ>
63                 <SEQ TYPE='OPERATOR'>?</SEQ>
64                 <SEQ TYPE='OPERATOR'>*</SEQ>
65                 <SEQ TYPE='OPERATOR'>+</SEQ>
66                 <SEQ TYPE='OPERATOR'>|</SEQ>
67
68                 <SEQ TYPE='KEYWORD1'>\b</SEQ>
69
70                 <SEQ TYPE='DIGIT'>\d</SEQ>
71                 <SEQ TYPE='LITERAL2'>\D</SEQ>
72
73                 <SEQ TYPE='KEYWORD3'>\w</SEQ>
74                 <SEQ TYPE='KEYWORD3'>.</SEQ>
75                 <SEQ TYPE='LITERAL3'>\W</SEQ>
76
77                 <SEQ TYPE='KEYWORD4'>\s</SEQ>
78                 <SEQ TYPE='LITERAL4'>\S</SEQ>
79
80                 <SPAN TYPE='FUNCTION' DELEGATE='MAIN'>
81                         <BEGIN>[^</BEGIN> <!-- user-defined negative character class -->
82                         <END>]</END>
83                 </SPAN>
84
85                 <SPAN TYPE='FUNCTION' DELEGATE='MAIN'>
86                         <BEGIN>(?=</BEGIN> <!-- zero-width positive lookahead assertion -->
87                         <END>)</END>
88                 </SPAN>
89                 <SPAN TYPE='FUNCTION' DELEGATE='MAIN'>
90                         <BEGIN>(?!</BEGIN> <!-- zero-width negative lookahead assertion -->
91                         <END>)</END>
92                 </SPAN>
93                 <SPAN TYPE='FUNCTION' DELEGATE='MAIN'>
94                         <BEGIN><![CDATA[(?<=]]></BEGIN> <!-- zero-width positive lookbehind assertion -->
95                         <END>)</END>
96                 </SPAN>
97                 <SPAN TYPE='FUNCTION' DELEGATE='MAIN'>
98                         <BEGIN><![CDATA[(?<!]]></BEGIN> <!-- zero-width negative lookbehind assertion -->
99                         <END>)</END>
100                 </SPAN>
101                 <SPAN TYPE='FUNCTION' DELEGATE='MAIN'>
102                         <BEGIN>(?:</BEGIN> <!-- unsaved group -->
103                         <END>)</END>
104                 </SPAN>
105
106                 <SPAN TYPE='OPERATOR' DELEGATE='FORCED_NUMBER'>
107                         <BEGIN>{</BEGIN>
108                         <END>}</END>
109                 </SPAN>
110                 <SPAN TYPE='OPERATOR' DELEGATE='MAIN'>
111                         <BEGIN>[</BEGIN> <!-- user-defined character class -->
112                         <END>]</END>
113                 </SPAN>
114                 <SPAN TYPE='FUNCTION' DELEGATE='MAIN'>
115                         <BEGIN>(</BEGIN> <!-- saved group (backreference) -->
116                         <END>)</END>
117                 </SPAN>
118         </RULES>
119
120 </MODE>
121