aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--generator.go4
-rw-r--r--generator_test.go6
-rw-r--r--go.mod5
-rw-r--r--go.sum2
5 files changed, 15 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3ea99d6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+coverage*
diff --git a/generator.go b/generator.go
index 4a56ce5..27ff770 100644
--- a/generator.go
+++ b/generator.go
@@ -143,18 +143,20 @@ func (g Generator) getClass(c string) (string, error) {
case ":digit:":
out = numeric
case ":print:":
+ fallthrough
+ case ":graph:":
c, err := g.getClass(":cntrl:")
if err != nil {
return "", err
}
out = g.filter(g.getRange(*g.minRune, *g.maxRune), c)
+
case ":upper:":
out = upper
case ":blank:":
out = " \t"
case ":word:":
out = lower + upper + numeric + "_"
- case ":graph:":
case ":punct:":
out = punct
case ":xdigit:":
diff --git a/generator_test.go b/generator_test.go
index 4cb6a9e..45c4ea0 100644
--- a/generator_test.go
+++ b/generator_test.go
@@ -14,8 +14,8 @@ func TestGenerator(t *testing.T) {
{"[]", ""},
{"[-]", "-"},
{"[]abc]", "]abc"},
- // Characterw
- //{"[\\]", "\\"},
+ // Character
+ {"[\u0e010-2]", "ก012"},
// Not
{"[^:cntrl::punct:]", " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},
{"[^-:cntrl::digit:]", " !\"#$%&'()*+,./:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"},
@@ -26,11 +26,13 @@ func TestGenerator(t *testing.T) {
{"[:digit:]", "0123456789"},
{"[:space:]", " \t\n\r\f\v"},
{"[:blank:]", " \t"},
+ {"[:word:]", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"},
{"[:cntrl:]", "\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\u007f"},
{"[:lower:]", "abcdefghijklmnopqrstuvwxyz"},
{"[:upper:]", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
{"[:digit::upper:]", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
{"[:print:]", " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"},
+ {"[:graph:]", " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"},
{"[:punct:]", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]"},
{"[:xdigit:]", "abcdefABCDEF0123456789"},
{"[:digit::punct::upper:]", "0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..5ceea4c
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,5 @@
+module src.userspace.com.au/brechars
+
+go 1.12
+
+require src.userspace.com.au/felix/lexer v1.0.0
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..63e8e6e
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,2 @@
+src.userspace.com.au/felix/lexer v1.0.0 h1:lg5uHLQtgSzt1qjDv4k0JDohGPvMviz+o+KQ3XZX5Ec=
+src.userspace.com.au/felix/lexer v1.0.0/go.mod h1:c/DEb5Wz8CWTqWjiU3jQWL612oUHuU46rZ39KrtHkOw=