]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'emacs' of http://git.hacks-galore.org/jao/factor
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 20 Apr 2009 04:58:57 +0000 (23:58 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 20 Apr 2009 04:58:57 +0000 (23:58 -0500)
16 files changed:
basis/help/handbook/handbook.factor
basis/tools/deploy/shaker/shaker.factor
basis/tools/test/test-tests.factor
basis/tools/test/test.factor
core/syntax/syntax-docs.factor
extra/couchdb/tags.txt [new file with mode: 0644]
extra/jamshred/game/game.factor
extra/jamshred/gl/gl.factor
extra/jamshred/jamshred.factor
extra/jamshred/player/player.factor
extra/jamshred/tunnel/tunnel.factor
extra/morse/authors.txt
extra/morse/morse-docs.factor
extra/morse/morse-tests.factor
extra/morse/morse.factor
extra/synth/buffers/buffers.factor

index ebce042e06054a0d063e304a3e8fb7cdb23f5c1a..1aac99defe6ae873593d1147858e208496ac5146 100644 (file)
@@ -13,13 +13,13 @@ ARTICLE: "conventions" "Conventions"
 { $heading "Documentation conventions" }
 "Factor documentation consists of two distinct bodies of text. There is a hierarchy of articles, much like this one, and there is word documentation. Help articles reference word documentation, and vice versa, but not every documented word is referenced from some help article."
 $nl
-"Every article has links to parent articles at the top. These can be persued if the article is too specific."
+"Every article has links to parent articles at the top. Explore these if the article you are reading is too specific."
 $nl
 "Some generic words have " { $strong "Description" } " headings, and others have " { $strong "Contract" } " headings. A distinction is made between words which are not intended to be extended with user-defined methods, and those that are."
 { $heading "Vocabulary naming conventions" }
 "A vocabulary name ending in " { $snippet ".private" } " contains words which are either implementation detail, unsafe, or both. For example, the " { $snippet "sequence.private" } " vocabulary contains words which access sequence elements without bounds checking (" { $link "sequences-unsafe" } ")."
 $nl
-"You should should avoid using internal words from the Factor library unless absolutely necessary. Similarly, your own code can place words in internal vocabularies if you do not want other people to use them unless they have a good reason."
+"You should avoid using internal words from the Factor library unless absolutely necessary. Similarly, your own code can place words in internal vocabularies if you do not want other people to use them unless they have a good reason."
 { $heading "Word naming conventions" }
 "These conventions are not hard and fast, but are usually a good first step in understanding a word's behavior:"
 { $table
index 37eec5eae2a4ce02d967394c30c62f15e00b1596..ba0daf6056544076d90bb5005a20969e025da375 100755 (executable)
@@ -15,6 +15,7 @@ QUALIFIED: definitions
 QUALIFIED: init
 QUALIFIED: layouts
 QUALIFIED: source-files
+QUALIFIED: source-files.errors
 QUALIFIED: vocabs
 IN: tools.deploy.shaker
 
@@ -264,6 +265,7 @@ IN: tools.deploy.shaker
                 compiled-crossref
                 compiled-generic-crossref
                 compiler-impl
+                compiler.errors:compiler-errors
                 definition-observers
                 definitions:crossref
                 interactive-vocabs
@@ -275,6 +277,7 @@ IN: tools.deploy.shaker
                 lexer-factory
                 print-use-hook
                 root-cache
+                source-files.errors:error-types
                 vocabs:dictionary
                 vocabs:load-vocab-hook
                 word
index 473335645f5a25ee4b465b25939d1a8f40eb5d8d..03f7f006c9ce76edb147ee3f038bac006812da62 100644 (file)
@@ -1,4 +1,18 @@
 IN: tools.test.tests
-USING: tools.test ;
+USING: tools.test tools.test.private namespaces kernel sequences ;
 
 \ test-all must-infer
+
+: fake-unit-test ( quot -- )
+    [
+        "fake" file set
+        V{ } clone test-failures set
+        call
+        test-failures get
+    ] with-scope ; inline
+
+[ 1 ] [
+    [
+        [ "OOPS" ] must-fail
+    ] fake-unit-test length
+] unit-test
\ No newline at end of file
index b98f58b1430e5b09b35829780de6058a42584831..1ff47e3d7f38d6c78099d1c4525b658f90393a83 100644 (file)
@@ -48,17 +48,17 @@ SYMBOL: file
     f file get f failure ;
 
 :: (unit-test) ( output input -- error ? )
-    [ { } input with-datastack output assert-sequence= f f ] [ t ] recover ; inline
+    [ { } input with-datastack output assert-sequence= f f ] [ t ] recover ;
 
 : short-effect ( effect -- pair )
     [ in>> length ] [ out>> length ] bi 2array ;
 
 :: (must-infer-as) ( effect quot -- error ? )
-    [ quot infer short-effect effect assert= f f ] [ t ] recover ; inline
+    [ quot infer short-effect effect assert= f f ] [ t ] recover ;
 
 :: (must-infer) ( word/quot -- error ? )
     word/quot dup word? [ '[ _ execute ] ] when :> quot
-    [ quot infer drop f f ] [ t ] recover ; inline
+    [ quot infer drop f f ] [ t ] recover ;
 
 TUPLE: did-not-fail ;
 CONSTANT: did-not-fail T{ did-not-fail }
@@ -66,11 +66,11 @@ CONSTANT: did-not-fail T{ did-not-fail }
 M: did-not-fail summary drop "Did not fail" ;
 
 :: (must-fail-with) ( quot pred -- error ? )
-    [ quot call did-not-fail t ]
-    [ dup pred call [ drop f f ] [ t ] if ] recover ; inline
+    [ { } quot with-datastack drop did-not-fail t ]
+    [ dup pred call( error -- ? ) [ drop f f ] [ t ] if ] recover ;
 
 :: (must-fail) ( quot -- error ? )
-    [ quot call did-not-fail t ] [ drop f f ] recover ; inline
+    [ { } quot with-datastack drop did-not-fail t ] [ drop f f ] recover ;
 
 : experiment-title ( word -- string )
     "(" ?head drop ")" ?tail drop { { CHAR: - CHAR: \s } } substitute >title ;
index 33a0096ff9324a8f7564562d00b397bb5986ce68..f869cff50614f308caabd1e1010cdc84d8d9ca06 100644 (file)
@@ -526,10 +526,10 @@ HELP: ((
 { $notes "Useful for meta-programming with " { $link define-declared } "." }
 { $examples
     { $code
-        "SYMBOL: my-dynamic-word"
+        "<< SYMBOL: my-dynamic-word"
         "USING: math random words ;"
-        "3 { [ + ] [ - ] [ * ] [ / ] } random curry"
-        "(( x -- y )) define-declared"
+        "my-dynamic-word 3 { [ + ] [ - ] [ * ] [ / ] } random curry"
+        "(( x -- y )) define-declared >>"
     }
 } ;
 
@@ -789,4 +789,4 @@ HELP: execute(
 { $syntax "execute( stack -- effect )" }
 { $description "Calls the word on the top of the stack, asserting that it has the given stack effect. The word does not need to be known at compile time." } ;
 
-{ POSTPONE: call( POSTPONE: execute( } related-words
\ No newline at end of file
+{ POSTPONE: call( POSTPONE: execute( } related-words
diff --git a/extra/couchdb/tags.txt b/extra/couchdb/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
index 9cb5bc7c3aab29866a841242c9f4e7502306ada9..14bf18a9c1644085f46b93e6a7234873255b6448 100644 (file)
@@ -29,7 +29,7 @@ TUPLE: jamshred sounds tunnel players running quit ;
 : mouse-moved ( x-radians y-radians jamshred -- )
     jamshred-player -rot turn-player ;
 
-: units-per-full-roll ( -- n ) 50 ;
+CONSTANT: units-per-full-roll 50
 
 : jamshred-roll ( jamshred n -- )
     [ jamshred-player ] dip 2 pi * * units-per-full-roll / roll-player ;
index bae275e96a52fe3d0fa4a5e7e568529c35ed6fcc..a1d22c48dc548e715b3ba34e0427f6a74d84ff0e 100644 (file)
@@ -6,18 +6,17 @@ math.functions math.vectors opengl opengl.gl opengl.glu
 opengl.demo-support sequences specialized-arrays.float ;
 IN: jamshred.gl
 
-: min-vertices ( -- n ) 6 ; inline
-: max-vertices ( -- n ) 32 ; inline
+CONSTANT: min-vertices 6
+CONSTANT: max-vertices 32
 
-: n-vertices ( -- n ) 32 ; inline
+CONSTANT: n-vertices 32
 
 ! render enough of the tunnel that it looks continuous
-: n-segments-ahead ( -- n ) 60 ; inline
-: n-segments-behind ( -- n ) 40 ; inline
+CONSTANT: n-segments-ahead 60
+CONSTANT: n-segments-behind 40
 
-: wall-drawing-offset ( -- n )
-    #! so that we can't see through the wall, we draw it a bit further away
-    0.15 ;
+! so that we can't see through the wall, we draw it a bit further away
+CONSTANT: wall-drawing-offset 0.15
 
 : wall-drawing-radius ( segment -- r )
     radius>> wall-drawing-offset + ;
index 49624e29470bb07f780c2433953d4bbcb618c7e3..fd683e3bc4e74545e2c7cb87ea613cee2420a7f3 100644 (file)
@@ -8,8 +8,8 @@ TUPLE: jamshred-gadget < gadget { jamshred jamshred } last-hand-loc ;
 : <jamshred-gadget> ( jamshred -- gadget )
     jamshred-gadget new swap >>jamshred ;
 
-: default-width ( -- x ) 800 ;
-: default-height ( -- y ) 600 ;
+CONSTANT: default-width 800
+CONSTANT: default-height 600
 
 M: jamshred-gadget pref-dim*
     drop default-width default-height 2array ;
index d33b78f29c8ad1608a84c7e1cac58040d9ef45fc..5b92b3a43495190aec227e74c78bb4a16c44f515 100644 (file)
@@ -12,8 +12,8 @@ TUPLE: player < oint
     { speed float } ;
 
 ! speeds are in GL units / second
-: default-speed ( -- speed ) 1.0 ;
-: max-speed ( -- speed ) 30.0 ;
+CONSTANT: default-speed 1.0
+CONSTANT: max-speed 30.0
 
 : <player> ( name sounds -- player )
     [ float-array{ 0 0 5 } float-array{ 0 0 -1 } float-array{ 0 1 0 } float-array{ -1 0 0 } ] 2dip
index 4c4b3e6812f9bb2c558cb07208a7fed5591a2b99..6171c3053b9e2701abc750eadd9cb9a435f73302 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2007, 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays colors combinators kernel locals math math.constants math.matrices math.order math.ranges math.vectors math.quadratic random sequences specialized-arrays.float vectors jamshred.oint ;
+USING: accessors arrays colors combinators kernel literals locals math math.constants math.matrices math.order math.ranges math.vectors math.quadratic random sequences specialized-arrays.float vectors jamshred.oint ;
 IN: jamshred.tunnel
 
-: n-segments ( -- n ) 5000 ; inline
+CONSTANT: n-segments 5000
 
 TUPLE: segment < oint number color radius ;
 C: <segment> segment
@@ -14,8 +14,8 @@ C: <segment> segment
 : random-color ( -- color )
     { 100 100 100 } [ random 100 / >float ] map first3 1.0 <rgba> ;
 
-: tunnel-segment-distance ( -- n ) 0.4 ;
-: random-rotation-angle ( -- theta ) pi 20 / ;
+CONSTANT: tunnel-segment-distance 0.4
+CONSTANT: random-rotation-angle $[ pi 20 / ]
 
 : random-segment ( previous-segment -- segment )
     clone dup random-rotation-angle random-turn
@@ -27,7 +27,7 @@ C: <segment> segment
         [ dup peek random-segment over push ] dip 1- (random-segments)
     ] [ drop ] if ;
 
-: default-segment-radius ( -- r ) 1 ;
+CONSTANT: default-segment-radius 1
 
 : initial-segment ( -- segment )
     float-array{ 0 0 0 } float-array{ 0 0 -1 } float-array{ 0 1 0 } float-array{ -1 0 0 }
@@ -115,7 +115,7 @@ C: <segment> segment
 : wall-normal ( seg oint -- n )
     location>> vector-to-centre normalize ;
 
-: distant ( -- n ) 1000 ;
+CONSTANT: distant 1000
 
 : max-real ( a b -- c )
     #! sometimes collision-coefficient yields complex roots, so we ignore these (hack)
index e9c193bac72836f0710fc5440af248256e9fc736..409f0443a67557e80e3abf087400cb6393ec519c 100644 (file)
@@ -1 +1,2 @@
 Alex Chapman
+Diego Martinelli
index e35967d3e965e85f5703f8faa547991241e8686d..93350ad02d3da97bb49ad328bd43ca864e6dd8db 100644 (file)
@@ -6,12 +6,12 @@ IN: morse
 HELP: ch>morse
 { $values
     { "ch" "A character that has a morse code translation" } { "str" "A string consisting of zero or more dots and dashes" } }
-{ $description "If the given character has a morse code translation, then return that translation, otherwise return an empty string." } ;
+{ $description "If the given character has a morse code translation, then return that translation, otherwise return a ? character." } ;
 
 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" } ;
+{ $description "If the given string represents a morse code character, then return that character, otherwise return a space character." } ;
 
 HELP: >morse
 { $values
index 144448917f3e3d10ac432952c7d77cda49d81925..fd52df1c4d54987bf06ca7fe78e480c9554d04b6 100644 (file)
@@ -1,13 +1,43 @@
 ! Copyright (C) 2007 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays morse strings tools.test ;
+IN: morse.tests
 
-[ "" ] [ CHAR: \\ ch>morse ] unit-test
+[ CHAR: ? ] [ CHAR: \\ ch>morse ] unit-test
 [ "..." ] [ CHAR: s ch>morse ] unit-test
 [ CHAR: s ] [ "..." morse>ch ] unit-test
-[ f ] [ "..--..--.." morse>ch ] unit-test
+[ CHAR: \s ] [ "..--..--.." morse>ch ] unit-test
 [ "-- --- .-. ... . / -.-. --- -.. ." ] [ "morse code" >morse ] unit-test
 [ "morse code" ] [ "-- --- .-. ... . / -.-. --- -.. ." morse> ] unit-test
 [ "hello, world!" ] [ "Hello, World!" >morse morse> ] unit-test
+[ ".- -... -.-." ] [ "abc" >morse ] unit-test
+
+[ "abc" ] [ ".- -... -.-." morse> ] unit-test
+
+[ "morse code" ] [
+    [MORSE
+        -- --- .-. ... . /
+        -.-. --- -.. .
+    MORSE] >morse morse> ] unit-test
+
+[ "morse code 123" ] [
+    [MORSE
+        __ ___ ._. ... . / 
+        _._. ___ _.. . / 
+        .____ ..___ ...__
+    MORSE] ] unit-test
+
+[ [MORSE
+      -- --- .-. ... . /
+      -.-. --- -.. .
+  MORSE] ] [
+    "morse code" >morse morse> 
+] unit-test
+
+[ "factor rocks!" ] [
+    [MORSE
+      ..-. .- -.-. - --- .-. / 
+      .-. --- -.-. -.- ... -.-.--
+    MORSE] ] unit-test
 ! [ ] [ "sos" 0.075 play-as-morse* ] unit-test
 ! [ ] [ "Factor rocks!" play-as-morse ] unit-test
index 54abce93953808f9a3e0835987d6a5942238cf28..ef4b9d4b889520b12d93ea6a05950472f410ef02 100644 (file)
@@ -1,13 +1,20 @@
-! Copyright (C) 2007, 2008 Alex Chapman
+! Copyright (C) 2007, 2008, 2009 Alex Chapman, 2009 Diego Martinelli
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors ascii assocs combinators hashtables kernel lists math
-namespaces make openal parser-combinators promises sequences
-strings synth synth.buffers unicode.case ;
+USING: accessors ascii assocs biassocs combinators hashtables kernel lists literals math namespaces make multiline openal parser sequences splitting strings synth synth.buffers ;
 IN: morse
 
 <PRIVATE
-: morse-codes ( -- array )
-    {
+
+CONSTANT: dot-char CHAR: .
+CONSTANT: dash-char CHAR: -
+CONSTANT: char-gap-char CHAR: \s
+CONSTANT: word-gap-char CHAR: /
+CONSTANT: unknown-char CHAR: ?
+
+PRIVATE>
+
+CONSTANT: morse-code-table $[
+    H{
         { CHAR: a ".-"    }
         { CHAR: b "-..."  }
         { CHAR: c "-.-."  }
@@ -63,68 +70,47 @@ IN: morse
         { CHAR: $ "...-..-" }
         { CHAR: @ ".--.-." }
         { CHAR: \s "/" }
-    } ;
+    } >biassoc
+]
 
-: ch>morse-assoc ( -- assoc )
-    morse-codes >hashtable ;
-
-: morse>ch-assoc ( -- assoc )
-    morse-codes [ reverse ] map >hashtable ;
-
-PRIVATE>
-
-: ch>morse ( ch -- str )
-    ch>lower ch>morse-assoc at* swap "" ? ;
+: ch>morse ( ch -- morse )
+    ch>lower morse-code-table at [ unknown-char ] unless* ;
 
 : morse>ch ( str -- ch )
-    morse>ch-assoc at* swap f ? ;
-
-: >morse ( str -- str )
-    [
-        [ CHAR: \s , ] [ ch>morse % ] interleave
-    ] "" make ;
-
+    morse-code-table value-at [ char-gap-char ] unless* ;
+    
 <PRIVATE
+    
+: word>morse ( str -- morse )
+    [ ch>morse ] { } map-as " " join ;
 
-: dot-char ( -- ch ) CHAR: . ;
-: dash-char ( -- ch ) CHAR: - ;
-: char-gap-char ( -- ch ) CHAR: \s ;
-: word-gap-char ( -- ch ) CHAR: / ;
-
-: =parser ( obj -- parser )
-    [ = ] curry satisfy ;
-
-LAZY: 'dot' ( -- parser )
-    dot-char =parser ;
-
-LAZY: 'dash' ( -- parser )
-    dash-char =parser ;
+: sentence>morse ( str -- morse )
+    " " split [ word>morse ] map " / " join ;
+    
+: trim-blanks ( str -- newstr )
+    [ blank? ] trim ; inline
 
-LAZY: 'char-gap' ( -- parser )
-    char-gap-char =parser ;
+: morse>word ( morse -- str )
+    " " split [ morse>ch ] "" map-as ;
 
-LAZY: 'word-gap' ( -- parser )
-    word-gap-char =parser ;
+: morse>sentence ( morse -- sentence )
+    "/" split [ trim-blanks morse>word ] map " " join ;
 
-LAZY: 'morse-char' ( -- parser )
-    'dot' 'dash' <|> <+> ;
-
-LAZY: 'morse-word' ( -- parser )
-    'morse-char' 'char-gap' list-of ;
-
-LAZY: 'morse-words' ( -- parser )
-    'morse-word' 'word-gap' list-of ;
+: replace-underscores ( str -- str' )
+    [ dup CHAR: _ = [ drop CHAR: - ] when ] map ;
 
 PRIVATE>
-
-: morse> ( str -- str )
-    'morse-words' parse car parsed>> [
-        [ 
-            >string morse>ch
-        ] map >string
-    ] map [ [ CHAR: \s , ] [ % ] interleave ] "" make ;
-
+    
+: >morse ( str -- newstr )
+    trim-blanks sentence>morse ;
+    
+: morse> ( morse -- plain )
+    replace-underscores morse>sentence ;
+
+SYNTAX: [MORSE "MORSE]" parse-multiline-string morse> parsed ; 
+    
 <PRIVATE
+    
 SYMBOLS: source dot-buffer dash-buffer intra-char-gap-buffer letter-gap-buffer ;
 
 : queue ( symbol -- )
@@ -135,7 +121,7 @@ SYMBOLS: source dot-buffer dash-buffer intra-char-gap-buffer letter-gap-buffer ;
 : intra-char-gap ( -- ) intra-char-gap-buffer queue ;
 : letter-gap ( -- ) letter-gap-buffer queue ;
 
-: beep-freq ( -- n ) 880 ;
+CONSTANT: beep-freq 880
 
 : <morse-buffer> ( -- buffer )
     half-sample-freq <8bit-mono-buffer> ;
index 671ebead63fb72b4764bf6a3cb8a209f0e39bf88..4c0ef6460745c129d84c43533a2691eda1825e35 100644 (file)
@@ -57,11 +57,11 @@ M: 8bit-stereo-buffer buffer-data
 M: 16bit-stereo-buffer buffer-data
     interleaved-stereo-data 16bit-buffer-data ;
 
-: telephone-sample-freq ( -- n ) 8000 ;
-: half-sample-freq ( -- n ) 22050 ;
-: cd-sample-freq ( -- n ) 44100 ;
-: digital-sample-freq ( -- n ) 48000 ;
-: professional-sample-freq ( -- n ) 88200 ;
+CONSTANT: telephone-sample-freq 8000
+CONSTANT: half-sample-freq 22050
+CONSTANT: cd-sample-freq 44100
+CONSTANT: digital-sample-freq 48000
+CONSTANT: professional-sample-freq 88200
 
 : send-buffer ( buffer -- buffer )
     {