diff --git a/extra/modern/modern-tests.factor b/extra/modern/modern-tests.factor index e5cbb176da..30f7aa90ce 100644 --- a/extra/modern/modern-tests.factor +++ b/extra/modern/modern-tests.factor @@ -3,6 +3,7 @@ USING: modern modern.slices tools.test ; IN: modern.tests +! Comment { { { "!" "" } } } [ "!" string>literals >strings ] unit-test @@ -18,3 +19,21 @@ IN: modern.tests { { { "!" "lol" } } } [ "!lol" string>literals >strings ] unit-test + +! Colon +{ + { ":asdf:" } +} [ ":asdf:" string>literals >strings ] unit-test + +{ + { { "one:" "1" } } +} [ "one: 1" string>literals >strings ] unit-test + +{ + { "1" ":>" "one" } +} [ "1 :> one" string>literals >strings ] unit-test + +! Acute +{ + { { "" } } +} [ "" string>literals >strings ] unit-test diff --git a/extra/modern/modern.factor b/extra/modern/modern.factor index f6fd7bfc6d..190c6ebcea 100644 --- a/extra/modern/modern.factor +++ b/extra/modern/modern.factor @@ -186,18 +186,12 @@ ERROR: unexpected-terminator n string slice ; ERROR: colon-word-must-be-all-uppercase-or-lowercase n string word ; : read-colon ( n string slice -- n' string colon ) - dup length 1 = [ - dup prev-char-from-slice { CHAR: \s CHAR: \r CHAR: \n f } member? [ - read-til-semicolon - ] [ - read-lowercase-colon - ] if - ] [ - { - { [ dup strict-upper? ] [ strict-upper on read-til-semicolon strict-upper off ] } - [ read-lowercase-colon ] - } cond - ] if ; + + { + { [ dup strict-upper? ] [ strict-upper on read-til-semicolon strict-upper off ] } + { [ dup ":" tail? ] [ dup ":" head? [ read-lowercase-colon ] unless ] } ! :foo: vs foo: + [ ] + } cond ; : read-acute ( n string slice -- n' string acute ) [ matching-section-delimiter 1array lex-until ] keep swap unclip-last 3array ; @@ -234,6 +228,7 @@ ERROR: mismatched-terminator n string slice ; { CHAR: \\ [ read-backslash ] } { CHAR: \! [ read-exclamation ] } { CHAR: \: [ + merge-slice-til-whitespace dup strict-upper? strict-upper get and [ length swap [ - ] dip f strict-upper off