re2正则表达式引擎学习(五)

改写为DFA匹配时的运行过程。

首先打印出来的是NFA的结构,然后将NFA的结构转化为DFA的结构,构建对应的DFA转移矩阵。然后根据转移矩阵进行匹配

运行时,正则表达式为ab*c|d,匹配的字符串为d


ab*c|d
9. alt -> 6 | 8
6. alt -> 1 | 5
8. byte [00-ff] -> 9
1. byte [61-61] -> 3
5. byte [64-64] -> 7
3. alt -> 2 | 4
7. match! 0
2. byte [62-62] -> 3
4. byte [63-63] -> 7




kind 0
9. alt -> 6 | 8
6. alt -> 1 | 5
8. byte [00-ff] -> 9
1. byte [61-61] -> 3
5. byte [64-64] -> 7
3. alt -> 2 | 4
7. match! 0
2. byte [62-62] -> 3
4. byte [63-63] -> 7


开始BuildAllStates2函数:
开始AnalyzeSearch函数:
开始AnalyzeSearchHelper函数:
WorkqToCachedState 9,6,1,5,8 [0x5] -> (00188900)9,6,1,5,8 flag=0 ID=0xcdcdcdcd
RunWorkqOnByte 开始:
9,6,1,5,8 on 0[0] -> 9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 9,6,1,5,8 [0] -cached-> (00188900)9,6,1,5,8 flag=0 ID=0xcdcdc
dcd
RunWorkqOnByte 开始:
9,6,1,5,8 on 97[0] -> 3,2,4,9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 3,2,4,9,6,1,5,8 [0x2000] -> (0016F708)3,2,4,9,6,1,5,8 flag=0
ID=0xcdcdcdcd
RunWorkqOnByte 开始:
9,6,1,5,8 on 98[0] -> 9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 9,6,1,5,8 [0x2000] -cached-> (00188900)9,6,1,5,8 flag=0 ID=0x
cdcdcdcd
RunWorkqOnByte 开始:
9,6,1,5,8 on 99[0] -> 9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 9,6,1,5,8 [0x2000] -cached-> (00188900)9,6,1,5,8 flag=0 ID=0x
cdcdcdcd
RunWorkqOnByte 开始:
9,6,1,5,8 on 100[0] -> 7,9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 7,9,6,1,5,8 [0x2000] -> (0016E8A0)7 flag=0 ID=0xcdcdcdcd
结束AnalyzeSearchHelper函数!
anchored=0 fwd=0 flags=0x5 state=(00188900)9,6,1,5,8 flag=0 ID=0xcdcdcdcd firstb
yte=-2
结束AnalyzeSearch函数!
RunWorkqOnByte 开始:
9,6,1,5,8 on 101[0] -> 9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 9,6,1,5,8 [0x2000] -cached-> (00188900)9,6,1,5,8 flag=0 ID=0x
cdcdcdcd
RunWorkqOnByte 开始:
9,6,1,5,8 on 256[0] ->  [0]
RunWorkqOnByte 结束!
WorkqToCachedState  [0] -> DeadState
RunWorkqOnByte 开始:
3,2,4,9,6,1,5,8 on 0[0] -> 9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 9,6,1,5,8 [0] -cached-> (00188900)9,6,1,5,8 flag=0 ID=0xcdcdc
dcd
RunWorkqOnByte 开始:
3,2,4,9,6,1,5,8 on 97[0] -> 3,2,4,9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 3,2,4,9,6,1,5,8 [0x2000] -cached-> (0016F708)3,2,4,9,6,1,5,8
flag=0 ID=0xcdcdcdcd
RunWorkqOnByte 开始:
3,2,4,9,6,1,5,8 on 98[0] -> 3,2,4,9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 3,2,4,9,6,1,5,8 [0x2000] -cached-> (0016F708)3,2,4,9,6,1,5,8
flag=0 ID=0xcdcdcdcd
RunWorkqOnByte 开始:
3,2,4,9,6,1,5,8 on 99[0] -> 7,9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 7,9,6,1,5,8 [0x2000] -cached-> (0016E8A0)7 flag=0 ID=0xcdcdcd
cd
RunWorkqOnByte 开始:
3,2,4,9,6,1,5,8 on 100[0] -> 7,9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 7,9,6,1,5,8 [0x2000] -cached-> (0016E8A0)7 flag=0 ID=0xcdcdcd
cd
RunWorkqOnByte 开始:
3,2,4,9,6,1,5,8 on 101[0] -> 9,6,1,5,8 [0]
RunWorkqOnByte 结束!
WorkqToCachedState 9,6,1,5,8 [0x2000] -cached-> (00188900)9,6,1,5,8 flag=0 ID=0x
cdcdcdcd
RunWorkqOnByte 开始:
3,2,4,9,6,1,5,8 on 256[0] ->  [0]
RunWorkqOnByte 结束!
WorkqToCachedState  [0] -> DeadState
RunWorkqOnByte 开始:
RunWorkqOnByte 结束!
WorkqToCachedState  [0x1000] -> (0016E840) flag=0x1000 ID=0xcdcdcdcd
RunWorkqOnByte 开始:
RunWorkqOnByte 结束!
WorkqToCachedState  [0x3000] -cached-> (0016E840) flag=0x1000 ID=0xcdcdcdcd
RunWorkqOnByte 开始:
RunWorkqOnByte 结束!
WorkqToCachedState  [0x3000] -cached-> (0016E840) flag=0x1000 ID=0xcdcdcdcd
RunWorkqOnByte 开始:
RunWorkqOnByte 结束!
WorkqToCachedState  [0x3000] -cached-> (0016E840) flag=0x1000 ID=0xcdcdcdcd
RunWorkqOnByte 开始:
RunWorkqOnByte 结束!
WorkqToCachedState  [0x3000] -cached-> (0016E840) flag=0x1000 ID=0xcdcdcdcd
RunWorkqOnByte 开始:
RunWorkqOnByte 结束!
WorkqToCachedState  [0x3000] -cached-> (0016E840) flag=0x1000 ID=0xcdcdcdcd
RunWorkqOnByte 开始:
RunWorkqOnByte 结束!
WorkqToCachedState  [0x1000] -cached-> (0016E840) flag=0x1000 ID=0xcdcdcdcd
RunWorkqOnByte 开始:
 on 0[0] ->  [0]
RunWorkqOnByte 结束!
WorkqToCachedState  [0] -> DeadState
RunWorkqOnByte 开始:
 on 97[0] ->  [0]
RunWorkqOnByte 结束!
WorkqToCachedState  [0x2000] -> DeadState
RunWorkqOnByte 开始:
 on 98[0] ->  [0]
RunWorkqOnByte 结束!
WorkqToCachedState  [0x2000] -> DeadState
RunWorkqOnByte 开始:
 on 99[0] ->  [0]
RunWorkqOnByte 结束!
WorkqToCachedState  [0x2000] -> DeadState
RunWorkqOnByte 开始:
 on 100[0] ->  [0]
RunWorkqOnByte 结束!
WorkqToCachedState  [0x2000] -> DeadState
RunWorkqOnByte 开始:
 on 101[0] ->  [0]
RunWorkqOnByte 结束!
WorkqToCachedState  [0x2000] -> DeadState
RunWorkqOnByte 开始:
 on 256[0] ->  [0]
RunWorkqOnByte 结束!
WorkqToCachedState  [0] -> DeadState
(00188900)9,6,1,5,8 flag=0 ID=0x1
(0016F708)3,2,4,9,6,1,5,8 flag=0 ID=0x2
(0016E8A0)7 flag=0 ID=0x3
(0016E840) flag=0x1000 ID=0x4
q.size(): 4 prog_->bytemap_range()+1: 7
  1   2   1   1   3   1   0
  1   2   2   3   3   1   0
 -4  -4  -4  -4  -4  -4  -4
  0   0   0   0   0   0   0
BuildAllStates2函数结束!
1 on 100[4] -> 3
3 on 256 -> 3
匹配位置2:2
请按任意键继续. . .

你可能感兴趣的:(re2正则表达式引擎学习)