morse: fixed docs and morse code parsing

db4
Alex Chapman 2008-01-26 01:13:25 +11:00
parent ba4062e04b
commit 9c8c79236d
2 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,7 @@
! Copyright (C) 2007 Alex Chapman
! 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
{ $values
@ -11,3 +12,14 @@ HELP: morse>ch
{ $values
{ "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" } ;
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 } ;

View File

@ -88,7 +88,7 @@ PRIVATE>
: dot ( -- ch ) CHAR: . ;
: dash ( -- ch ) CHAR: - ;
: char-gap ( -- ch ) CHAR: \s ;
: word-gap ( -- ch ) " / " ;
: word-gap ( -- ch ) CHAR: / ;
: =parser ( obj -- parser )
[ = ] curry satisfy ;
@ -103,7 +103,7 @@ LAZY: 'char-gap' ( -- parser )
char-gap =parser ;
LAZY: 'word-gap' ( -- parser )
word-gap token ;
word-gap =parser ;
LAZY: 'morse-char' ( -- parser )
'dot' 'dash' <|> <+> ;