]> gitweb.factorcode.org Git - factor.git/blob - basis/byte-arrays/hex/hex.factor
5474f1b7458dd995656dea76df4e568080826a4f
[factor.git] / basis / byte-arrays / hex / hex.factor
1 ! Copyright (C) 2009,2011 Maxim Savchenko, Slava Pestov, Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: ascii grouping kernel math.parser sequences
4 strings.parser lexer math ;
5 IN: byte-arrays.hex
6
7 ERROR: odd-length-hex-string string ;
8
9 SYNTAX: HEX{
10     "}" parse-tokens concat
11     [ blank? not ] filter
12     dup length even? [ odd-length-hex-string ] unless
13     2 <groups> [ hex> ] B{ } map-as
14     suffix! ;