diff --git a/basis/byte-arrays/hex/authors.txt b/basis/byte-arrays/hex/authors.txt new file mode 100644 index 0000000000..f13c9c1e77 --- /dev/null +++ b/basis/byte-arrays/hex/authors.txt @@ -0,0 +1 @@ +Joe Groff diff --git a/basis/byte-arrays/hex/hex-docs.factor b/basis/byte-arrays/hex/hex-docs.factor new file mode 100644 index 0000000000..8c60dc2646 --- /dev/null +++ b/basis/byte-arrays/hex/hex-docs.factor @@ -0,0 +1,6 @@ +IN: byte-arrays.hex +USING: byte-arrays help.markup help.syntax ; + +HELP: HEX{ +{ $syntax "HEX{ 0123 45 67 89abcdef }" } +{ $description "Constructs a " { $link byte-array } " from data specified in hexadecimal format. Whitespace between the curly braces is ignored." } ; diff --git a/basis/byte-arrays/hex/hex.factor b/basis/byte-arrays/hex/hex.factor new file mode 100644 index 0000000000..054c35dcfa --- /dev/null +++ b/basis/byte-arrays/hex/hex.factor @@ -0,0 +1,11 @@ +! Copyright (C) 2009 Joe Groff. +! See http://factorcode.org/license.txt for BSD license. +USING: grouping lexer ascii parser sequences kernel math.parser ; +IN: byte-arrays.hex + +SYNTAX: HEX{ + "}" parse-tokens "" join + [ blank? not ] filter + 2 group [ hex> ] B{ } map-as + parsed ; + diff --git a/core/byte-arrays/byte-arrays-docs.factor b/core/byte-arrays/byte-arrays-docs.factor index 56832a56e5..f1d94a46f7 100644 --- a/core/byte-arrays/byte-arrays-docs.factor +++ b/core/byte-arrays/byte-arrays-docs.factor @@ -23,10 +23,6 @@ $nl ABOUT: "byte-arrays" -HELP: HEX{ -{ $syntax "HEX{ 0123 45 67 89abcdef }" } -{ $description "Constructs a " { $link byte-array } " from data specified in hexadecimal format. Whitespace between the curly braces is ignored." } ; - HELP: byte-array { $description "The class of byte arrays. See " { $link "syntax-byte-arrays" } " for syntax and " { $link "byte-arrays" } " for general information." } ; diff --git a/core/byte-arrays/byte-arrays.factor b/core/byte-arrays/byte-arrays.factor index b32060ec99..72989ac447 100644 --- a/core/byte-arrays/byte-arrays.factor +++ b/core/byte-arrays/byte-arrays.factor @@ -1,16 +1,9 @@ ! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien.accessors ascii grouping kernel -kernel.private lexer math math.parser parser sequences -sequences.private ; +USING: accessors kernel kernel.private alien.accessors sequences +sequences.private math ; IN: byte-arrays -SYNTAX: HEX{ - "}" parse-tokens "" join - [ blank? not ] filter - 2 group [ hex> ] B{ } map-as - parsed ; - M: byte-array clone (clone) ; M: byte-array length length>> ; M: byte-array nth-unsafe swap >fixnum alien-unsigned-1 ;