-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.js
66 lines (52 loc) · 5.05 KB
/
temp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
let RegeRex = require("./source"), group = new RegeRex.RegexGroup("regex");
group.add("regex:\\a(:flag:(i\\|)?+)(:nameStr:(:name)):(:parsed:(:parsed))*\\z");
group.add("name:(:nameStr:[[-AZ][-az]][[-AZ][-az][-09]_]*+)");
group.add("character:(:char:[^\\^\\$\\|\\\\\\*\\+\\?\\{\\}\\[\\]\\(\\)])");
group.add("charNoColon:(:char:[^:\\^\\$\\|\\\\\\*\\+\\?\\{\\}\\[\\]\\(\\)])");
group.add("charNoLessThan:(:char:[^<\\^\\$\\|\\\\\\*\\+\\?\\{\\}\\[\\]\\(\\)])");
group.add("charNoGreaterThan:(:char:[^>\\^\\$\\|\\\\\\*\\+\\?\\{\\}\\[\\]\\(\\)])");
group.add("charNoColonGreaterThan:(:char:[^:>\\^\\$\\|\\\\\\*\\+\\?\\{\\}\\[\\]\\(\\)])");
group.add("specialChar:(:char:[\\^\\$\\|\\\\\\*\\+\\?\\{\\}\\[\\]\\(\\)])");
group.add("reference:(:nameStr:(:name))(\\[(:dimensions:\\d+)\\])*");
group.add("parsed:[(:parsed:(:characterClass))(:parsed:(:alternation))(:parsed:(:negatedAlternation))(:parsed:(:assertion))(:parsed:(:backreference))(:parsed:(:boundary))(:parsed:(:captrGroup))(:parsed:(:escapeSequence))(:parsed:(:group))(:parsed:(:lookaround))(:parsed:(:subroutine))(:parsed:[(:character)])](:quantifier:(:quantifier))?");
group.add("parsedNoColon:[(:parsed:(:characterClass))(:parsed:(:alternation))(:parsed:(:negatedAlternation))(:parsed:(:assertion))(:parsed:(:backreference))(:parsed:(:boundary))(:parsed:(:captrGroup))(:parsed:(:escapeSequence))(:parsed:(:group))(:parsed:(:lookaround))(:parsed:(:subroutine))(:parsed:[(:charNoColon)(\\\\:)])](:quantifier:(:quantifier))?");
group.add("parsedNoLessThan:[(:parsed:(:characterClass))(:parsed:(:alternation))(:parsed:(:negatedAlternation))(:parsed:(:assertion))(:parsed:(:backreference))(:parsed:(:boundary))(:parsed:(:captrGroup))(:parsed:(:escapeSequence))(:parsed:(:group))(:parsed:(:lookaround))(:parsed:(:subroutine))(:parsed:[(:charNoLessThan)(\\\\<)])](:quantifier:(:quantifier))?");
group.add("parsedNoGreaterThan:[(:parsed:(:characterClass))(:parsed:(:alternation))(:parsed:(:negatedAlternation))(:parsed:(:assertion))(:parsed:(:backreference))(:parsed:(:boundary))(:parsed:(:captrGroup))(:parsed:(:escapeSequence))(:parsed:(:group))(:parsed:(:lookaround))(:parsed:(:subroutine))(:parsed:[(:charNoGreaterThan)(\\\\>)])](:quantifier:(:quantifier))?");
group.add("parsedNoColonGreaterThan:[(:parsed:(:characterClass))(:parsed:(:alternation))(:parsed:(:negatedAlternation))(:parsed:(:assertion))(:parsed:(:backreference))(:parsed:(:boundary))(:parsed:(:captrGroup))(:parsed:(:escapeSequence))(:parsed:(:group))(:parsed:(:lookaround))(:parsed:(:subroutine))(:parsed:[(:charNoColonGreaterThan)(\\\\:)(\\\\>)])])(:quantifier:(:quantifier))?");
group.add("alternation:\\[(:contents:(:parsed))*\\]"); // LATER lookahead to see if this is not a characterClass
group.add("negatedAlternation:\\[^[(:contents:(:character))(:contents:(:characterClass))(:contents:(:negatedAlternation))]*\\]");
group.add("assertion:\\(\\|(:reference:(:reference))([=](:condition:(:parsedNoGreaterThan))+)?>(:then:(:parsedNoColon))*:(:thenNot:(:parsed))*\\)");
group.add("backreference:\\(=(:reference:(:reference))\\)");
group.add("boundary:(:boundary:[\\^\\$\\|(\\\\a)(\\\\z)(\\\\`)(\\\\')])");
group.add("captrGroup:\\((:hidden:[:.])(:nameStr:(:name))(:shallow:[:.])[(:subroutine:(:subroutine))(:contents:(:parsed))*]\\)");
group.add("characterClass:\\[(:negated:^)?-[(:first:(:escapeChar))(:first:(:character))][(:second:(:escapeChar))(:second:(:character))]\\]");
group.add("escapeSequence:[(:escapeSequence:(:escapeChar))(:escapeSequence:(:escapeRegexPart))]");
group.add("escapeChar:\\\\(:escapeChar:[nrt(u\\{(:hex:[\d[-af]]{4,5})\\})(:specialChar)])");
group.add("escapeRegexPart:\\\\(:escapeRegexPart:[dwslDWSLNRT])");
group.add("group:\\((:contents:(:parsed))*\\)");
group.add("lookaround:\\(\\?[((:then:(:parsedNoColon)):(:thenNot:(:parsedNoLessThan))(:conditionLookahead:(:parsed)))((:conditionLookbehind:(:parsedNoGreaterThan))(:then:(:parsedNoColon))(:thenNot:(:parsed)))]\\)");
group.add("subroutine:\\((:nameStr:(:name))\\)");
group.add("quantifier:(:boundaries:[\\?\\*\\+(\\{(:min:\d+)((:comma:,)(:max:\d+)?)?\\})])(:type:[\\?\\+]?)");
group.match('Tag:<(:tagName:\\w+)(:attributes:(:Attr))*>(:children:(:Tag))*</>')
let RegeRex = require("./source"), group = new RegeRex.RegexGroup("a");
group.add('a:\\aabc\\z')
group.match('abc')
let RegeRex = require("./index"), group = new RegeRex.RegexGroup("a");
group.add('a:a(:a:(:a:f)+b+)+')
group.match('affbfbbfffbbb')
let RegeRex = require("./index"), group = new RegeRex.RegexGroup("a");
group.add('a:a(f+b+)+')
group.match('affbfbbfffbbb')
let RegeRex = require("./index"), group = new RegeRex.RegexGroup("a");
group.add('a:a\\n*\n[sd]f+\\s\\w')
group.match('a\n\nsff J')
let RegeRex = require("./index"), group = new RegeRex.RegexGroup("a");
group.add('a:\\w')
group.match('f')
let RegeRex = require("./index"), group = new RegeRex.RegexGroup("Tag");
group.add('Tag:<(:tagName:\\w+)(:attributes:(:Attr))*>(:children:(:Tag))*</>')
group.add('Attr:\\s+(:attrName:\\w+)=(:value:\\w+)')
group.match('<html><head></><body id=bodyId></></>')
let RegeRex = require("./index"), group = new RegeRex.RegexGroup("a");
group.add('a:a(:a:(:a))?b')
group.match('aaaabbbb')