new files vocab, dissolved builtins vocab, moved tutorial programs to doc/tutorial/

cvs
Slava Pestov 2004-08-28 20:43:43 +00:00
parent 7a6d816ab0
commit b64d81b3d2
32 changed files with 269 additions and 105 deletions

View File

@ -16,8 +16,8 @@ inspection of source code, as well as stack effect checking.
build.xml - Ant buildfile for Java interpreter. build.xml - Ant buildfile for Java interpreter.
factor/ - source code for Factor interpreter written in Java. factor/ - source code for Factor interpreter written in Java.
org/objectweb/asm/ - helper library for Java interpreter. org/objectweb/asm/ - helper library for Java interpreter.
Factor.jar - compiled, stand-alone Java interpreter
library/platform/jvm - JVM-specific Factor code library/platform/jvm - JVM-specific Factor code
Factor.jar - compiled, stand-alone Java interpreter
C interpreter C interpreter
------------- -------------
@ -27,21 +27,27 @@ of achieving the highest possible flexibility/lines of code
ratio. It runs faster than the Java interpreter, and uses ratio. It runs faster than the Java interpreter, and uses
far less memory. far less memory.
Makefile - Makefile for building C interpreter.
native/ - source code for Factor interpreter written in C. native/ - source code for Factor interpreter written in C.
native/build.sh - build script for C interpreter.
native/f - compiled C interpreter - needs image to run
native/factor.image - cross-compiler output
library/platform/native - C interpreter-specific code library/platform/native - C interpreter-specific code
f - compiled C interpreter - needs image to run
boot.image.le - image for x86
boot.image.be - image for 32-bit SPARC and 32-bit PowerPC
Notes on the C interpreter Notes on the C interpreter
-------------------------- --------------------------
At the moment it assumes little endian byte order, 32-bit When you run the interpreter with a boot image, it loads a
words. This pretty much means x86. bunch of files and saves a 'factor.image'. Run the
interpreter again with this image.
Very soon I will add image input and output in both byte At the moment it assumes a 32-bit architecture. Your C
orders - this will allow Factor to run on powerpc and compiler's types must be as follows:
sparc.
short - signed 16 bits
long - signed 32 bits
long long - signed 64 bits
double -IEEE double precision 64-bit float
Moving to 64-bits would require a few changes in the image Moving to 64-bits would require a few changes in the image
cross-compiler, namely in the way it packs strings. cross-compiler, namely in the way it packs strings.

View File

@ -58,6 +58,7 @@ to_c_string allots too much
+ native: + native:
- eliminate usage of long long
- is the profiler using correct stack depth? - is the profiler using correct stack depth?
- read1 - read1
- sbuf-hashcode - sbuf-hashcode
@ -82,7 +83,6 @@ to_c_string allots too much
+ misc: + misc:
- alist -vs- assoc terminology - alist -vs- assoc terminology
- dissolve builtins vocabulary
- 'cascading' styles - 'cascading' styles
- jedit ==> jedit-word, jedit takes a file name - jedit ==> jedit-word, jedit takes a file name
- some way to run httpd from command line - some way to run httpd from command line

View File

@ -51,6 +51,7 @@
<include name="factor/**/*.txt"/> <include name="factor/**/*.txt"/>
<include name="*.xml"/> <include name="*.xml"/>
<include name="library/**/*.factor"/> <include name="library/**/*.factor"/>
<include name="library/**/*.txt"/>
<include name="org/**/*.class"/> <include name="org/**/*.class"/>
<include name="*.factor"/> <include name="*.factor"/>
<include name="doc/**/*.html"/> <include name="doc/**/*.html"/>

View File

@ -0,0 +1,39 @@
! Numbers game example
IN: numbers-game
USE: kernel
USE: math
USE: parser
USE: random
USE: stdio
USE: stack
: read-number ( -- n ) read parse-number ;
: guess-banner
"I'm thinking of a number between 0 and 100." print ;
: guess-prompt "Enter your guess: " write ;
: too-high "Too high" print ;
: too-low "Too low" print ;
: correct "Correct - you win!" print ;
: inexact-guess ( actual guess -- )
< [ too-high ] [ too-low ] ifte ;
: judge-guess ( actual guess -- ? )
2dup = [
correct f
] [
inexact-guess t
] ifte ;
: number-to-guess ( -- n ) 0 100 random-int ;
: numbers-game-loop ( actual -- )
dup guess-prompt read-number judge-guess [
numbers-game-loop
] [
drop
] ifte ;
: numbers-game number-to-guess numbers-game-loop ;

View File

@ -0,0 +1,74 @@
! Contractor timesheet example
IN: timesheet
USE: combinators
USE: errors
USE: format
USE: kernel
USE: lists
USE: math
USE: parser
USE: stack
USE: stdio
USE: strings
USE: unparser
USE: vectors
! Adding a new entry to the time sheet.
: measure-duration ( -- duration )
millis
read drop
millis swap - 1000 /i 60 /i ;
: add-entry-prompt ( -- duration description )
"Start work on the task now. Press ENTER when done." print
measure-duration
"Please enter a description:" print
read ;
: add-entry ( timesheet -- )
add-entry-prompt cons swap vector-push ;
! Printing the timesheet.
: hh ( duration -- str ) 60 /i ;
: mm ( duration -- str ) 60 mod unparse 2 digits ;
: hh:mm ( millis -- str ) <% dup hh % ":" % mm % %> ;
: print-entry ( duration description -- )
dup write
60 swap pad-string write
hh:mm print ;
: print-timesheet ( timesheet -- )
"TIMESHEET:" print
[ uncons print-entry ] vector-each ;
! Displaying a menu
: print-menu ( menu -- )
terpri [ cdr car print ] each terpri
"Enter a letter between ( ) to execute that action." print ;
: menu-prompt ( menu -- )
read swap assoc dup [
cdr call
] [
"Invalid input: " swap unparse cat2 throw
] ifte ;
: menu ( menu -- )
dup print-menu menu-prompt ;
! Main menu
: main-menu ( timesheet -- )
[
[ "e" "(E)xit" drop ]
[ "a" "(A)dd entry" dup add-entry main-menu ]
[ "p" "(P)rint timesheet" dup print-timesheet main-menu ]
] menu ;
: timesheet-app ( -- )
10 <vector> main-menu ;

View File

@ -35,7 +35,11 @@ import java.io.*;
public class FactorInterpreter implements FactorObject, Runnable public class FactorInterpreter implements FactorObject, Runnable
{ {
public static final String VERSION = "0.64"; public static final String VERSION = "0.65";
public static final Cons DEFAULT_USE = new Cons("builtins",
new Cons("syntax",new Cons("scratchpad",null)));
public static final String DEFAULT_IN = "scratchpad";
// command line arguments are stored here. // command line arguments are stored here.
public Cons args; public Cons args;
@ -63,18 +67,12 @@ public class FactorInterpreter implements FactorObject, Runnable
/** /**
* Vocabulary search path for interactive parser. * Vocabulary search path for interactive parser.
*/ */
public Cons use; public Cons use = DEFAULT_USE;
/** /**
* Vocabulary to define new words in. * Vocabulary to define new words in.
*/ */
public String in; public String in = DEFAULT_IN;
/**
* Kernel vocabulary. Re-created on each startup, contains
* primitives and parsing words.
*/
public FactorNamespace builtins;
/** /**
* Most recently defined word. * Most recently defined word.
@ -110,7 +108,6 @@ public class FactorInterpreter implements FactorObject, Runnable
this.vocabularies = interp.vocabularies; this.vocabularies = interp.vocabularies;
this.use = interp.use; this.use = interp.use;
this.in = interp.in; this.in = interp.in;
this.builtins = interp.builtins;
this.last = interp.last; this.last = interp.last;
this.global = interp.global; this.global = interp.global;
this.startupDone = true; this.startupDone = true;
@ -148,73 +145,71 @@ public class FactorInterpreter implements FactorObject, Runnable
//{{{ initBuiltinDictionary() method //{{{ initBuiltinDictionary() method
private void initBuiltinDictionary() throws Exception private void initBuiltinDictionary() throws Exception
{ {
builtins = new FactorNamespace(); vocabularies.setVariable("builtins",new FactorNamespace());
vocabularies.setVariable("builtins",builtins); vocabularies.setVariable("combinators",new FactorNamespace());
vocabularies.setVariable("syntax",new FactorNamespace());
in = "builtins";
use = new Cons(in,null);
/* comments */ /* comments */
FactorWord lineComment = define("builtins","!"); FactorWord lineComment = define("syntax","!");
lineComment.parsing = new LineComment(lineComment,false); lineComment.parsing = new LineComment(lineComment,false);
FactorWord stackComment = define("builtins","("); FactorWord stackComment = define("syntax","(");
stackComment.parsing = new StackComment(stackComment); stackComment.parsing = new StackComment(stackComment);
FactorWord docComment = define("builtins","#!"); FactorWord docComment = define("syntax","#!");
docComment.parsing = new LineComment(docComment,true); docComment.parsing = new LineComment(docComment,true);
/* strings */ /* strings */
FactorWord str = define("builtins","\""); FactorWord str = define("syntax","\"");
str.parsing = new StringLiteral(str,true); str.parsing = new StringLiteral(str,true);
FactorWord ch = define("builtins","CHAR:"); FactorWord ch = define("syntax","CHAR:");
ch.parsing = new CharLiteral(ch); ch.parsing = new CharLiteral(ch);
/* constants */ /* constants */
FactorWord t = define("builtins","t"); FactorWord t = define("syntax","t");
t.parsing = new T(t); t.parsing = new T(t);
FactorWord f = define("builtins","f"); FactorWord f = define("syntax","f");
f.parsing = new F(f); f.parsing = new F(f);
FactorWord complex = define("builtins","#{"); FactorWord complex = define("syntax","#{");
complex.parsing = new ComplexLiteral(complex,"}"); complex.parsing = new ComplexLiteral(complex,"}");
/* lists */ /* lists */
FactorWord bra = define("builtins","["); FactorWord bra = define("syntax","[");
bra.parsing = new Bra(bra); bra.parsing = new Bra(bra);
FactorWord ket = define("builtins","]"); FactorWord ket = define("syntax","]");
ket.parsing = new Ket(bra,ket); ket.parsing = new Ket(bra,ket);
FactorWord bar = define("builtins","|"); FactorWord bar = define("syntax","|");
bar.parsing = new Bar(bar); bar.parsing = new Bar(bar);
/* vectors */ /* vectors */
FactorWord beginVector = define("builtins","{"); FactorWord beginVector = define("syntax","{");
beginVector.parsing = new BeginVector(beginVector); beginVector.parsing = new BeginVector(beginVector);
FactorWord endVector = define("builtins","}"); FactorWord endVector = define("syntax","}");
endVector.parsing = new EndVector(beginVector,endVector); endVector.parsing = new EndVector(beginVector,endVector);
/* word defs */ /* word defs */
FactorWord def = define("builtins",":"); FactorWord def = define("syntax",":");
def.parsing = new Def(def); def.parsing = new Def(def);
def.getNamespace().setVariable("doc-comments",Boolean.TRUE); def.getNamespace().setVariable("doc-comments",Boolean.TRUE);
FactorWord ine = define("builtins",";"); FactorWord ine = define("syntax",";");
ine.parsing = new Ine(def,ine); ine.parsing = new Ine(def,ine);
FactorWord shuffle = define("builtins","~<<"); FactorWord shuffle = define("syntax","~<<");
shuffle.parsing = new Shuffle(shuffle,">>~"); shuffle.parsing = new Shuffle(shuffle,">>~");
/* reading numbers with another base */ /* reading numbers with another base */
FactorWord bin = define("builtins","BIN:"); FactorWord bin = define("syntax","BIN:");
bin.parsing = new Base(bin,2); bin.parsing = new Base(bin,2);
FactorWord oct = define("builtins","OCT:"); FactorWord oct = define("syntax","OCT:");
oct.parsing = new Base(oct,8); oct.parsing = new Base(oct,8);
FactorWord hex = define("builtins","HEX:"); FactorWord hex = define("syntax","HEX:");
hex.parsing = new Base(hex,16); hex.parsing = new Base(hex,16);
/* vocabulary parsing words */ /* vocabulary parsing words */
FactorWord noParsing = define("builtins","POSTPONE:"); FactorWord noParsing = define("syntax","POSTPONE:");
noParsing.parsing = new NoParsing(noParsing); noParsing.parsing = new NoParsing(noParsing);
FactorWord defer = define("builtins","DEFER:"); FactorWord defer = define("syntax","DEFER:");
defer.parsing = new Defer(defer); defer.parsing = new Defer(defer);
FactorWord in = define("builtins","IN:"); FactorWord in = define("syntax","IN:");
in.parsing = new In(in); in.parsing = new In(in);
FactorWord use = define("builtins","USE:"); FactorWord use = define("syntax","USE:");
use.parsing = new Use(use); use.parsing = new Use(use);
FactorWord interpreterGet = define("builtins","interpreter"); FactorWord interpreterGet = define("builtins","interpreter");
@ -258,12 +253,12 @@ public class FactorInterpreter implements FactorObject, Runnable
define.def = new Define(define); define.def = new Define(define);
// combinators // combinators
FactorWord execute = define("builtins","execute"); FactorWord execute = define("words","execute");
execute.def = new Execute(execute); execute.def = new Execute(execute);
FactorWord call = define("builtins","call"); FactorWord call = define("combinators","call");
call.def = new Call(call); call.def = new Call(call);
call.inline = true; call.inline = true;
FactorWord ifte = define("builtins","ifte"); FactorWord ifte = define("combinators","ifte");
ifte.def = new Ifte(ifte); ifte.def = new Ifte(ifte);
ifte.inline = true; ifte.inline = true;
} //}}} } //}}}
@ -289,7 +284,6 @@ public class FactorInterpreter implements FactorObject, Runnable
"args", "args",
"dump", "dump",
"interactive", "interactive",
"builtins",
"in", "in",
"last", "last",
"use" "use"

View File

@ -38,10 +38,6 @@ import java.util.*;
*/ */
public class FactorReader public class FactorReader
{ {
public static final Cons DEFAULT_USE = new Cons("builtins",
new Cons("scratchpad",null));
public static final String DEFAULT_IN = "scratchpad";
private FactorInterpreter interp; private FactorInterpreter interp;
private FactorScanner scanner; private FactorScanner scanner;
private Cons states; private Cons states;
@ -265,8 +261,8 @@ public class FactorReader
pushState(toplevel,null); pushState(toplevel,null);
this.alwaysDocComments = alwaysDocComments; this.alwaysDocComments = alwaysDocComments;
this.interactive = interactive; this.interactive = interactive;
this.in = DEFAULT_IN; this.in = FactorInterpreter.DEFAULT_IN;
this.use = DEFAULT_USE; this.use = FactorInterpreter.DEFAULT_USE;
} //}}} } //}}}
//{{{ getScanner() method //{{{ getScanner() method

View File

@ -26,6 +26,7 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: cross-compiler IN: cross-compiler
USE: combinators
USE: kernel USE: kernel
USE: lists USE: lists
USE: math USE: math

63
library/files.factor Normal file
View File

@ -0,0 +1,63 @@
! :folding=indent:collapseFolds=1:
! $Id$
!
! Copyright (C) 2004 Slava Pestov.
!
! Redistribution and use in source and binary forms, with or without
! modification, are permitted provided that the following conditions are met:
!
! 1. Redistributions of source code must retain the above copyright notice,
! this list of conditions and the following disclaimer.
!
! 2. Redistributions in binary form must reproduce the above copyright notice,
! this list of conditions and the following disclaimer in the documentation
! and/or other materials provided with the distribution.
!
! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: files
USE: combinators
USE: lists
USE: namespaces
USE: stack
USE: strings
: set-mime-types ( assoc -- )
"mime-types" global set* ;
: mime-types ( -- assoc )
"mime-types" global get* ;
: file-extension ( filename -- extension )
"." split cdr dup [ last ] when ;
: mime-type ( filename -- mime-type )
file-extension mime-types assoc [ "text/plain" ] unless* ;
[
[ "html" | "text/html" ]
[ "txt" | "text/plain" ]
[ "gif" | "image/gif" ]
[ "png" | "image/png" ]
[ "jpg" | "image/jpeg" ]
[ "jpeg" | "image/jpeg" ]
[ "jar" | "application/octet-stream" ]
[ "zip" | "application/octet-stream" ]
[ "tgz" | "application/octet-stream" ]
[ "tar.gz" | "application/octet-stream" ]
[ "gz" | "application/octet-stream" ]
[ "factor" | "application/x-factor" ]
] set-mime-types

View File

@ -30,6 +30,7 @@ USE: combinators
USE: html USE: html
USE: kernel USE: kernel
USE: lists USE: lists
USE: files
USE: namespaces USE: namespaces
USE: parser USE: parser
USE: regexp USE: regexp
@ -41,27 +42,6 @@ USE: strings
USE: httpd USE: httpd
USE: httpd-responder USE: httpd-responder
!!! Support words.
: mime-types ( -- alist )
[
[ "html" | "text/html" ]
[ "txt" | "text/plain" ]
[ "gif" | "image/gif" ]
[ "png" | "image/png" ]
[ "jpg" | "image/jpeg" ]
[ "jpeg" | "image/jpeg" ]
[ "jar" | "application/octet-stream" ]
[ "zip" | "application/octet-stream" ]
[ "tgz" | "application/octet-stream" ]
[ "tar.gz" | "application/octet-stream" ]
[ "gz" | "application/octet-stream" ]
] ;
: mime-type ( filename -- mime-type )
file-extension mime-types assoc [ "text/plain" ] unless* ;
!!! Serving files. !!! Serving files.
: file-header ( filename -- header ) : file-header ( filename -- header )
"200 Document follows" swap mime-type response ; "200 Document follows" swap mime-type response ;
@ -72,7 +52,7 @@ USE: httpd-responder
!!! Serving directories. !!! Serving directories.
: file>html ( filename -- ... ) : file>html ( filename -- ... )
"<li><a href=\"" swap "<li><a href=\"" swap
!dup directory? [ "/" cat2 ] when ! dup directory? [ "/" cat2 ] when
chars>entities chars>entities
"\">" over "</a></li>" ; "\">" over "</a></li>" ;

View File

@ -26,6 +26,7 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: quit-responder IN: quit-responder
USE: combinators
USE: namespaces USE: namespaces
USE: stdio USE: stdio
USE: stack USE: stack

View File

@ -87,26 +87,10 @@ USE: words
#! Parse command line arguments. #! Parse command line arguments.
parse-switches run-files ; parse-switches run-files ;
: (word-of-the-day) ( -- word )
vocabs random-element words dup [
random-element
] [
drop (word-of-the-day) ( empty vocab )
] ifte ;
: word-of-the-day ( -- )
#! Something to entertain the poor hacker.
(word-of-the-day) dup defined? [
"WORD OF THE DAY: " print see
] [
drop word-of-the-day
] ifte ;
: init-interpreter ( -- ) : init-interpreter ( -- )
init-history init-history
print-banner print-banner
word-of-the-day
room. room.
interpreter-loop ; interpreter-loop ;

View File

@ -25,7 +25,10 @@
! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: logic USE: kernel USE: stack IN: logic
USE: combinators
USE: kernel
USE: stack
: ? ( cond t f -- t/f ) : ? ( cond t f -- t/f )
#! Push t if cond is true, otherwise push f. #! Push t if cond is true, otherwise push f.

View File

@ -73,6 +73,7 @@ USE: parser
"/library/styles.factor" run-resource ! styles "/library/styles.factor" run-resource ! styles
"/library/platform/jvm/threads.factor" run-resource ! threads "/library/platform/jvm/threads.factor" run-resource ! threads
"/library/logging.factor" run-resource ! logging "/library/logging.factor" run-resource ! logging
"/library/files.factor" run-resource ! files
!!! Math library. !!! Math library.
"/library/platform/jvm/real-math.factor" run-resource ! real-math "/library/platform/jvm/real-math.factor" run-resource ! real-math

View File

@ -28,6 +28,8 @@
!!! Minimum amount of words needed to be able to read other !!! Minimum amount of words needed to be able to read other
!!! resources. !!! resources.
USE: combinators
IN: stack IN: stack
~<< dup A -- A A >>~ ~<< dup A -- A A >>~

View File

@ -26,6 +26,7 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: cross-compiler IN: cross-compiler
USE: combinators
USE: kernel USE: kernel
USE: lists USE: lists
USE: math USE: math

View File

@ -83,4 +83,4 @@ USE: words
t "startup-done" set t "startup-done" set
"interactive" get [ init-interpreter ] when ; "interactive" get [ init-interpreter 1 exit* ] when ;

View File

@ -26,6 +26,7 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: parser IN: parser
USE: combinators
USE: errors USE: errors
USE: namespaces USE: namespaces
USE: stack USE: stack

View File

@ -26,6 +26,7 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: stack IN: stack
USE: combinators
USE: kernel USE: kernel
USE: vectors USE: vectors

View File

@ -212,9 +212,6 @@ USE: strings
[ "java.io.File" ] "java.io.File" "renameTo" [ "java.io.File" ] "java.io.File" "renameTo"
jinvoke ; jinvoke ;
: file-extension ( filename -- extension )
".*\\.(.*)" group1 ;
: <sreader> ( string -- reader ) : <sreader> ( string -- reader )
[ "java.lang.String" ] "java.io.StringReader" jnew ; [ "java.lang.String" ] "java.io.StringReader" jnew ;

View File

@ -26,6 +26,7 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: strings IN: strings
USE: combinators
USE: kernel USE: kernel
USE: logic USE: logic
USE: stack USE: stack

View File

@ -1,4 +1,5 @@
IN: test IN: test
USE: combinators
USE: compiler USE: compiler
USE: namespaces USE: namespaces
USE: stdio USE: stdio

View File

@ -98,6 +98,7 @@ USE: stdio
"/library/random.factor" "/library/random.factor"
"/library/stdio-binary.factor" "/library/stdio-binary.factor"
"/library/platform/native/prettyprint.factor" "/library/platform/native/prettyprint.factor"
"/library/files.factor"
"/library/interpreter.factor" "/library/interpreter.factor"
"/library/inspector.factor" "/library/inspector.factor"
"/library/inspect-vocabularies.factor" "/library/inspect-vocabularies.factor"

View File

@ -39,6 +39,7 @@ USE: stdio
USE: strings USE: strings
USE: unparser USE: unparser
USE: vectors USE: vectors
USE: words
: expired-port-error ( obj -- ) : expired-port-error ( obj -- )
"Expired port: " write . ; "Expired port: " write . ;

View File

@ -27,7 +27,7 @@
! Parsing words. 'builtins' is a stupid vocabulary name now ! Parsing words. 'builtins' is a stupid vocabulary name now
! that it does not contain Java words anymore! ! that it does not contain Java words anymore!
IN: builtins IN: syntax
USE: combinators USE: combinators
USE: cross-compiler USE: cross-compiler

View File

@ -26,6 +26,7 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: profiler IN: profiler
USE: combinators
USE: kernel USE: kernel
USE: lists USE: lists
USE: math USE: math

View File

@ -26,6 +26,7 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: random IN: random
USE: combinators
USE: kernel USE: kernel
USE: math USE: math
USE: stack USE: stack

View File

@ -26,6 +26,7 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: words IN: words
USE: combinators
USE: lists USE: lists
USE: namespaces USE: namespaces
USE: stack USE: stack

View File

@ -26,6 +26,7 @@
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: stdio IN: stdio
USE: combinators
USE: errors USE: errors
USE: kernel USE: kernel
USE: namespaces USE: namespaces

View File

@ -0,0 +1,9 @@
IN: scratchpad
USE: files
USE: test
[ "txt" ] [ "foo.txt" file-extension ] unit-test
[ f ] [ "foobar" file-extension ] unit-test
[ "txt" ] [ "foo.bar.txt" file-extension ] unit-test
[ "text/plain" ] [ "foo.bar.txt" mime-type ] unit-test
[ "text/html" ] [ "index.html" mime-type ] unit-test

View File

@ -73,6 +73,7 @@ USE: unparser
"hashtables" "hashtables"
"strings" "strings"
"namespaces/namespaces" "namespaces/namespaces"
"files"
"format" "format"
"parser" "parser"
"parse-number" "parse-number"

View File

@ -66,10 +66,10 @@ USE: strings
: init-search-path ( -- ) : init-search-path ( -- )
! For files ! For files
"user" "file-in" set "scratchpad" "file-in" set
[ "user" "builtins" ] "file-use" set [ "builtins" "syntax" "scratchpad" ] "file-use" set
! For interactive ! For interactive
"user" "in" set "scratchpad" "in" set
[ [
"user" "user"
"arithmetic" "arithmetic"
@ -95,6 +95,7 @@ USE: strings
"streams" "streams"
"stdio" "stdio"
"strings" "strings"
"syntax"
"test" "test"
"threads" "threads"
"trace" "trace"