morse: fixed docs and morse code parsing
parent
ba4062e04b
commit
9c8c79236d
|
@ -1,6 +1,7 @@
|
||||||
! Copyright (C) 2007 Alex Chapman
|
! Copyright (C) 2007 Alex Chapman
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: help.markup help.syntax morse ;
|
USING: help.markup help.syntax ;
|
||||||
|
IN: morse
|
||||||
|
|
||||||
HELP: ch>morse
|
HELP: ch>morse
|
||||||
{ $values
|
{ $values
|
||||||
|
@ -11,3 +12,14 @@ HELP: morse>ch
|
||||||
{ $values
|
{ $values
|
||||||
{ "str" "A string of dots and dashes that represents a single character in morse code" } { "ch" "The translated character" } }
|
{ "str" "A string of dots and dashes that represents a single character in morse code" } { "ch" "The translated character" } }
|
||||||
{ $description "If the given string represents a morse code character, then return that character, otherwise return f" } ;
|
{ $description "If the given string represents a morse code character, then return that character, otherwise return f" } ;
|
||||||
|
|
||||||
|
HELP: >morse
|
||||||
|
{ $values
|
||||||
|
{ "str" "A string of ASCII characters which can be translated into morse code" } { "str" "A string in morse code" } }
|
||||||
|
{ $description "Translates ASCII text into morse code, represented by a series of dots, dashes, and slashes." }
|
||||||
|
{ $see-also morse> ch>morse } ;
|
||||||
|
|
||||||
|
HELP: morse>
|
||||||
|
{ $values { "str" "A string of morse code, in which the character '.' represents dots, '-' dashes, ' ' spaces between letters, and ' / ' spaces between words." } { "str" "The ASCII translation of the given string" } }
|
||||||
|
{ $description "Translates morse code into ASCII text" }
|
||||||
|
{ $see-also >morse morse>ch } ;
|
||||||
|
|
|
@ -88,7 +88,7 @@ PRIVATE>
|
||||||
: dot ( -- ch ) CHAR: . ;
|
: dot ( -- ch ) CHAR: . ;
|
||||||
: dash ( -- ch ) CHAR: - ;
|
: dash ( -- ch ) CHAR: - ;
|
||||||
: char-gap ( -- ch ) CHAR: \s ;
|
: char-gap ( -- ch ) CHAR: \s ;
|
||||||
: word-gap ( -- ch ) " / " ;
|
: word-gap ( -- ch ) CHAR: / ;
|
||||||
|
|
||||||
: =parser ( obj -- parser )
|
: =parser ( obj -- parser )
|
||||||
[ = ] curry satisfy ;
|
[ = ] curry satisfy ;
|
||||||
|
@ -103,7 +103,7 @@ LAZY: 'char-gap' ( -- parser )
|
||||||
char-gap =parser ;
|
char-gap =parser ;
|
||||||
|
|
||||||
LAZY: 'word-gap' ( -- parser )
|
LAZY: 'word-gap' ( -- parser )
|
||||||
word-gap token ;
|
word-gap =parser ;
|
||||||
|
|
||||||
LAZY: 'morse-char' ( -- parser )
|
LAZY: 'morse-char' ( -- parser )
|
||||||
'dot' 'dash' <|> <+> ;
|
'dot' 'dash' <|> <+> ;
|
||||||
|
|
Loading…
Reference in New Issue