@@ -5,23 +5,24 @@ defmodule Dmp.DebugUtils do
5
5
6
6
use Bitwise , only_operators: true
7
7
8
- @ smallint_len 14
9
-
10
8
@ doc """
11
- Formats the `alphabet` bitarray into a list of lines, showing binary values.
9
+ Formats an alphabet bitarray into a list of lines, showing binary values.
10
+
11
+ * `s` - The alphabet as returned by `Dmp.Match.alphabet/1`.
12
+ * `pattern` - The pattern that is associated with the alphabet.
12
13
13
14
## Examples
14
15
15
- iex> DebugUtils.debug_alphabet("aba", %{?a => 5, ?b => 2})
16
+ iex> DebugUtils.debug_alphabet(%{?a => 5, ?b => 2}, "aba" )
16
17
[
17
18
"alphabet: a b a",
18
19
" a 5: 1 0 1",
19
20
" b 2: 0 1 0"
20
21
]
21
22
22
23
"""
23
- @ spec debug_alphabet ( String . t ( ) , Dmp.Match . alpha ( ) ) :: [ String . t ( ) ]
24
- def debug_alphabet ( pattern , s ) do
24
+ @ spec debug_alphabet ( Dmp.Match . alpha ( ) , String . t ( ) ) :: [ String . t ( ) ]
25
+ def debug_alphabet ( s , pattern ) do
25
26
pattern_length = String . length ( pattern )
26
27
int_len = value_size ( pattern_length )
27
28
@@ -52,13 +53,18 @@ defmodule Dmp.DebugUtils do
52
53
@ doc """
53
54
Formats the `rd` bitarray into a list of lines, showing binary values.
54
55
55
- * `d` - Error level for the bitarray.
56
- * `start` - Lowest index that has been calculated.
57
- * `best_loc` - Index in the text where the best match has been found.
56
+ * `rd` - The bitarrary.
57
+ * `text` - The text associated with `rd`.
58
+ * `pattern` - The pattern associated with `rd`.
59
+ * `d` - The error level.
60
+ * `start` - The lowest index that has been calculated. Lines below this
61
+ index will be marked with an asterisk.
62
+ * `best_loc` - The index in the text where the best match has been found.
63
+ The line at this index will be marked with an "@"-sign.
58
64
59
65
## Examples
60
66
61
- iex> DebugUtils.debug_rd("abc", "add", 0, %{1 => 5, 2 => 7, -1 => 3}, 1, 2)
67
+ iex> DebugUtils.debug_rd(%{1 => 5, 2 => 7, -1 => 3}, "abc", "add", 0 , 1, 2)
62
68
[
63
69
" rd_j^0: a d d",
64
70
" 0* _ 0: 0 0 0",
@@ -70,14 +76,14 @@ defmodule Dmp.DebugUtils do
70
76
71
77
"""
72
78
@ spec debug_rd (
79
+ Dmp.Match . bitap_array ( ) ,
73
80
String . t ( ) ,
74
81
String . t ( ) ,
75
82
non_neg_integer ( ) ,
76
- Dmp.Match . bitap_array ( ) ,
77
83
non_neg_integer ( ) ,
78
84
integer ( )
79
85
) :: [ String . t ( ) ]
80
- def debug_rd ( text , pattern , d , rd , start \\ 0 , best_loc \\ - 1 ) do
86
+ def debug_rd ( rd , text , pattern , d , start \\ 0 , best_loc \\ - 1 ) do
81
87
pattern_length = String . length ( pattern )
82
88
int_len = value_size ( pattern_length )
83
89
rd_size = max ( String . length ( text ) + 2 , Map . fetch! ( rd , - 1 ) )
0 commit comments