]> gitweb.factorcode.org Git - factor.git/commitdiff
CHAR: notation for literal chars, native parser work
authorSlava Pestov <slava@factorcode.org>
Thu, 22 Jul 2004 23:48:50 +0000 (23:48 +0000)
committerSlava Pestov <slava@factorcode.org>
Thu, 22 Jul 2004 23:48:50 +0000 (23:48 +0000)
112 files changed:
TODO.FACTOR.txt
build.sh [new file with mode: 0644]
factor/.FactorInterpreter.java.marks
factor/FactorInterpreter.java
factor/parser/CharLiteral.java
library/ansi.factor
library/assoc.factor
library/combinators.factor
library/cons.factor
library/continuations.factor
library/debugger.factor
library/errors.factor
library/format.factor
library/hashtables.factor
library/httpd/default-responders.factor
library/httpd/file-responder.factor
library/httpd/html.factor
library/httpd/http-common.factor
library/httpd/httpd.factor
library/httpd/inspect-responder.factor
library/httpd/quit-responder.factor
library/httpd/responder.factor
library/httpd/test-responder.factor
library/httpd/url-encoding.factor
library/httpd/wiki-responder.factor
library/init.factor
library/inspect-vocabularies.factor
library/inspector.factor
library/interpreter.factor
library/list-namespaces.factor
library/lists.factor
library/logging.factor
library/logic.factor
library/math/arc-trig-hyp.factor
library/math/arithmetic.factor
library/math/list-math.factor
library/math/math-combinators.factor
library/math/math.factor
library/math/namespace-math.factor
library/math/pow.factor
library/math/quadratic.factor
library/math/trig-hyp.factor
library/namespaces.factor
library/platform/jvm/arithmetic.factor
library/platform/jvm/boot-mini.factor
library/platform/jvm/boot-sumo.factor
library/platform/jvm/boot.factor
library/platform/jvm/combinators.factor
library/platform/jvm/compiler.factor
library/platform/jvm/cons.factor
library/platform/jvm/debugger.factor
library/platform/jvm/errors.factor
library/platform/jvm/init.factor
library/platform/jvm/kernel.factor
library/platform/jvm/listener.factor
library/platform/jvm/math-types.factor
library/platform/jvm/namespaces.factor
library/platform/jvm/parser.factor
library/platform/jvm/prettyprint.factor
library/platform/jvm/random.factor
library/platform/jvm/real-math.factor
library/platform/jvm/regexp.factor
library/platform/jvm/sbuf.factor
library/platform/jvm/stack.factor
library/platform/jvm/stack2.factor
library/platform/jvm/stream.factor
library/platform/jvm/strings.factor
library/platform/jvm/threads.factor
library/platform/jvm/unparser.factor
library/platform/jvm/vectors.factor
library/platform/jvm/vocabularies.factor
library/platform/jvm/words.factor
library/platform/native/.image.factor.marks
library/platform/native/.kernel.factor.marks
library/platform/native/boot.factor
library/platform/native/cross-compiler.factor
library/platform/native/errors.factor
library/platform/native/image.factor
library/platform/native/init.factor
library/platform/native/io-internals.factor
library/platform/native/kernel.factor
library/platform/native/namespaces.factor
library/platform/native/parse-numbers.factor [new file with mode: 0644]
library/platform/native/parse-stream.factor
library/platform/native/parse-syntax.factor [new file with mode: 0644]
library/platform/native/parser.factor
library/platform/native/prettyprint.factor
library/platform/native/stack.factor
library/platform/native/stream.factor
library/platform/native/unparser.factor
library/platform/native/vectors.factor
library/platform/native/vocabularies.factor
library/platform/native/words.factor
library/prettyprint.factor
library/random.factor
library/sbuf.factor
library/stdio.factor
library/stream.factor
library/strings.factor
library/styles.factor
library/telnetd.factor
library/vector-combinators.factor
library/vectors.factor
library/vocabularies.factor
library/vocabulary-style.factor
library/words.factor
native/build.sh [deleted file]
native/error.c
native/fixnum.c
native/fixnum.h
native/primitives.c
native/primitives.h

index c6b9e1e1885e9e62f4200a691252f953372627e3..4ce20f9048c991f1734819e8a1cfb2c3312d64e4 100644 (file)
@@ -1,6 +1,7 @@
 + native:\r
 \r
-- parsing: #\, |\r
+- top level catch should be a continuation\r
+- parsing: #\\r
 - {...} vectors\r
 - parsing should be parsing\r
 - telnetd: listening on a socket\r
diff --git a/build.sh b/build.sh
new file mode 100644 (file)
index 0000000..17fd95f
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,8 @@
+rm *.o
+
+export CC=gcc34
+export CFLAGS="-pedantic -Wall -Winline -O4 -Os -march=pentium4 -fomit-frame-pointer -falign-functions=8"
+
+$CC $CFLAGS -o f native/*.c
+
+strip f
index d7496649acf64c6e9cf1371046f9eae0fd6dc691..c699161e890a9cd0946ca962108a656461f5a021 100644 (file)
Binary files a/factor/.FactorInterpreter.java.marks and b/factor/.FactorInterpreter.java.marks differ
index 2941bccc4c8e5c4329eb3b6351a5e20dca6dfcec..66afc6ff22f6ee79d5c64bec43081e87ddc66c3d 100644 (file)
@@ -153,23 +153,39 @@ public class FactorInterpreter implements FactorObject, Runnable
                in = "builtins";
                use = new Cons(in,null);
 
-               // parsing words
+               /* comments */
                FactorWord lineComment = define("builtins","!");
                lineComment.parsing = new LineComment(lineComment,false);
                FactorWord stackComment = define("builtins","(");
                stackComment.parsing = new StackComment(stackComment);
+               FactorWord docComment = define("builtins","#!");
+               docComment.parsing = new LineComment(docComment,true);
+
+               /* strings */
                FactorWord str = define("builtins","\"");
                str.parsing = new StringLiteral(str,true);
+               FactorWord ch = define("builtins","CHAR:");
+               ch.parsing = new CharLiteral(ch);
+               FactorWord raw = define("builtins","#\"");
+               raw.parsing = new StringLiteral(raw,false);
+
+               /* constants */
                FactorWord t = define("builtins","t");
                t.parsing = new T(t);
                FactorWord f = define("builtins","f");
                f.parsing = new F(f);
+               FactorWord complex = define("builtins","#{");
+               complex.parsing = new ComplexLiteral(complex,"}");
+
+               /* lists */
                FactorWord bra = define("builtins","[");
                bra.parsing = new Bra(bra);
                FactorWord ket = define("builtins","]");
                ket.parsing = new Ket(bra,ket);
                FactorWord bar = define("builtins","|");
                bar.parsing = new Bar(bar);
+
+               /* word defs */
                FactorWord def = define("builtins",":");
                def.parsing = new Def(def);
                def.getNamespace().setVariable("doc-comments",Boolean.TRUE);
@@ -178,20 +194,17 @@ public class FactorInterpreter implements FactorObject, Runnable
                FactorWord shuffle = define("builtins","~<<");
                shuffle.parsing = new Shuffle(shuffle,">>~");
 
-               FactorWord noParsing = define("builtins","POSTPONE:");
-               noParsing.parsing = new NoParsing(noParsing);
+               /* reading numbers with another base */
+               FactorWord bin = define("builtins","BIN:");
+               bin.parsing = new Base(bin,2);
+               FactorWord oct = define("builtins","OCT:");
+               oct.parsing = new Base(oct,8);
+               FactorWord hex = define("builtins","HEX:");
+               hex.parsing = new Base(hex,16);
 
-               // #X
+               /* specials */
                FactorWord dispatch = define("builtins","#");
                dispatch.parsing = new Dispatch(dispatch);
-               FactorWord ch = define("builtins","#\\");
-               ch.parsing = new CharLiteral(ch);
-               FactorWord raw = define("builtins","#\"");
-               raw.parsing = new StringLiteral(raw,false);
-               FactorWord complex = define("builtins","#{");
-               complex.parsing = new ComplexLiteral(complex,"}");
-               FactorWord docComment = define("builtins","#!");
-               docComment.parsing = new LineComment(docComment,true);
                FactorWord unreadable = define("builtins","#<");
                unreadable.parsing = new Unreadable(unreadable);
 
@@ -201,7 +214,9 @@ public class FactorInterpreter implements FactorObject, Runnable
                FactorWord passthru = define("builtins","#:");
                passthru.parsing = new PassThrough(passthru);
 
-               // vocabulary parsing words
+               /* vocabulary parsing words */
+               FactorWord noParsing = define("builtins","POSTPONE:");
+               noParsing.parsing = new NoParsing(noParsing);
                FactorWord defer = define("builtins","DEFER:");
                defer.parsing = new Defer(defer);
                FactorWord in = define("builtins","IN:");
@@ -213,14 +228,6 @@ public class FactorInterpreter implements FactorObject, Runnable
                interpreterGet.def = new InterpreterGet(interpreterGet);
                interpreterGet.inline = true;
 
-               // reading numbers with another base
-               FactorWord bin = define("builtins","BIN:");
-               bin.parsing = new Base(bin,2);
-               FactorWord oct = define("builtins","OCT:");
-               oct.parsing = new Base(oct,8);
-               FactorWord hex = define("builtins","HEX:");
-               hex.parsing = new Base(hex,16);
-
                // primitives used by 'expand' and 'map'
                FactorWord restack = define("builtins","restack");
                restack.def = new Restack(restack);
index 53aa0ff35f3248e6a79fc425fcdf852faf2ceba2..42b987b74b7e4c7bcc5b61ff6cbdb1f1fbcc2a93 100644 (file)
@@ -47,8 +47,9 @@ public class CharLiteral extends FactorParsingDefinition
        public void eval(FactorInterpreter interp, FactorReader reader)
                throws IOException, FactorParseException
        {
-               reader.append(new Character(
-                       reader.getScanner()
-                       .readNonEOFEscaped()));
+               String word = (String)reader.nextNonEOF(false,false);
+               if(word.length() != 1)
+                       reader.error("Bad character literal: " + word);
+               reader.append(new Character(word.charAt(0)));
        }
 }
index fac785efc6d4767d7a48301003aa1d2525da94b4..e0408c264552107eaffb544afd25f8176268160b 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
@@ -35,7 +35,8 @@ USE: stack
 USE: streams
 USE: strings
 
-!!! Some words for outputting ANSI colors.
+! Some words for outputting ANSI colors.
+
 : black   0 ; inline
 : red     1 ; inline
 : green   2 ; inline
index b61e5a6911f9ba4c77c06b0865b27db3cc95e8d0..0b5e5ab0e16eacc4cc9b46e4d7f37b42d85fc7a5 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 5fad275265540b93989a21749052d2a2bac18321..6219463ccc53524f2e9757e0b1277bf95c4e0d92 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index c6fef017fccb16eefb2ed42847628a82494dcfaf..2d06641276f8239d22c60640f99fd909f91f69ea 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 8fac305ffc47fa04f0ef6732207e46649e5460b4..40a68b9a9fe7dac938dcc195f0d059e963669924 100644 (file)
@@ -1,8 +1,8 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
-! Copyright (C) 2003 Slava Pestov.
+! Copyright (C) 2003, 2004 Slava Pestov.
 ! 
 ! Redistribution and use in source and binary forms, with or without
 ! modification, are permitted provided that the following conditions are met:
index 7691e4b5d2f1c7ca90c49da544e3a1f3974956c0..ef8f788a6556dbbb4004be4ce3fe6a78a78ae55a 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 0fb9b813b7a417a13c6e5ebbdb5e80c4f882891c..bb4f09b2427c4aed8da8cf13d729e86438fb0eb1 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 100441996a02ce25831461164e920130a802422e..41b2c669975831851291e29edcc0119f848a3032 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index e2d964c4bbc578b3b019431d1848ada38a4216e9..e28c6b2c7b8d9bae723ea8b330defac1bbf0982f 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
@@ -33,9 +33,9 @@ USE: lists
 USE: stack
 USE: vectors
 
-!!! Note that the length of a hashtable vector must not change
-!!! for the lifetime of the hashtable, otherwise problems will
-!!! occur. Do not use vector words with hashtables.
+! Note that the length of a hashtable vector must not change
+! for the lifetime of the hashtable, otherwise problems will
+! occur. Do not use vector words with hashtables.
 
 : hashtable? ( obj -- ? )
     dup vector? [ [ assoc? ] vector-all? ] [ drop f ] ifte ;
index e5f47398eaf42b5ddba8175ea82f0db2aa65ca0a..0e42a876b5b2fc8eefef48278059fe7ee32324ce 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 7bfbda4da750793c399df19708ca25eeb3070074..f0cbc39ba451a3f1c9d34418058e506b2029a7a5 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 622b7abed8d9ea932abe215e4d015d5f4713c983..36518d680d1ac137d299a9d6119ea17e9ae2dc7b 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
@@ -40,11 +40,11 @@ USE: url-encoding
 
 : html-entities ( -- alist )
     [
-        [ #\< | "&lt;"   ]
-        [ #\> | "&gt;"   ]
-        [ #\& | "&amp;"  ]
-        [ #\' | "&apos;" ]
-        [ #\" | "&quot;" ]
+        [ CHAR: < | "&lt;"   ]
+        [ CHAR: > | "&gt;"   ]
+        [ CHAR: & | "&amp;"  ]
+        [ CHAR: ' | "&apos;" ]
+        [ CHAR: " | "&quot;" ]
     ] ;
 
 : chars>entities ( str -- str )
index 33dd523ea73fd32f58dec6e7e7458be87534a620..b9b2000f777622bca8006b198f5d61da56ac403c 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 4c06743cb1645080408df3b7fb289ffd9548cbe0..6d451f4a1113d29a53cb9576fecf7ee1480c809e 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 73fafcb059a24cb17ae7a6a9e14628e51303b93d..47dd4e4dfb395ed8ba99342f8b28f80d2d5b9235 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index afa885f95dc712bf737ea23d0d437c00447e1ee0..cb77914d981c638d0a77f2890113d0ddee1d2a9a 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 7a5050dcdcfa8581617c328a0d575bda6e558f9b..4346f7c2035ea70069472f410c0e449e928a7821 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 38920023a9237c531c459ff9e8c07db72b743c8f..879e25170179b45df697482288a0e6011c88b253 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 8b65bb45dac880383d09f1b6686c2693d74d5061..1a4528331ab5ef777b7a8a2e3757dd8cf333f4a2 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 9f758eb55549473773855b81d82a58ae596c6dae..4aa31379c45556d0ea012cde41cf4f4757ad55db 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 34f020b83ec06f33194d05769ce7fcf858b227cb..643e49bde5117e138a7d91928a59086e7621be21 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
@@ -39,8 +39,8 @@ USE: stdio
 USE: streams
 USE: strings
 
-!!! This file is run as the last stage of boot.factor; it relies
-!!! on all other words already being defined.
+! This file is run as the last stage of boot.factor; it relies
+! on all other words already being defined.
 
 : init-search-path ( -- )
     #! Sets up the default vocabularies.
index 7c33d922ddccca329ca26c8dbad38652e6e3241b..2046f1410d125431288ee7f3a7f7f582cff94a72 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index a11eaeb0af72280422e4929d74806d7e1bdda9e8..ba6f1bdb299a719b3318e2ce1b2bfd21677aa31e 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index ca6dd33977b03a82205ada3746134e14689be3da..030ea3ba430b36fa27698f7119e3d65512dd24d7 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 63b30ed73bf4b0651c942d486950216d72ce241e..febd2c120d82786d8c0d2d989ba3aa1ec42391a0 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 7bb819efc8db73870c30566a6f64a507c5f22a20..fa37fd315f46c8c048570b8e94788853210e7657 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 3785505086bca432edfd3bb7df17e079d91185ba..08707e91f9ef56563aff70b4bd937675a5f1ae9e 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 0ff690ec8591185a7438d288affd2779d20aa885..fc6da86f11ac5317b29870253f82a5c565b92166 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index f7b06377aa52ae461817afe8f4bc8d09a3c4fc76..8a57f71fe7706816512a0a4b8710a3b149e71a65 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index b7bfe6c97c86c8196473ada0848258b3f86152fd..66c1b357679b8458105ed06eafe6d587295a43c7 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index ba32fd750383e1ea4e47f78fac025adcaf3a8a9a..beee2697c707f3d4b8c4f1694f4fdc025a4d01d9 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 6aba07bc20cf843c810ab1008a1c591acfc9a683..2a3fa66abf28d1bdaa2df39ea6c95583ef0a51f2 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 40fb4758725b168980eefb8cd8371a7578a27eae..38f3aaeac47bac41e6b47f2d138187d887220596 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index f23e7cc2910d941f2fc533deaa7baf311a87ab39..ceaaecdda4258955442d16f5aeab4fe8e9e8aaad 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 0f73783d9db2412a26e220be27f75faa8003dc0b..267387791cab95882e50ca4b42dacbd9640689e9 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 8e0f392bd9b9f6b00bac5fdb158fe95968a7c9e3..f7587bb7ffd4647984227262ea2abff41274c83e 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 5af291641ca289cf5102e60fc9a0535ba7a88bbe..b8f6ff089e88a68f32bdc100fb3641ae2e1e0d91 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 11b92fa847116756f37a672c3561cbc8b8702106..7b3add7e3abcf17b077266f2d8175007825357d4 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
@@ -34,24 +34,24 @@ USE: stack
 USE: strings
 USE: vectors
 
-!!! Other languages have classes, objects, variables, etc.
-!!! Factor has similar concepts.
-!!!
-!!!   5 "x" set
-!!!   "x" get 2 + .
-!!! 7
-!!!   7 "x" set
-!!!   "x" get 2 + .
-!!! 9
-!!!
-!!! get ( name -- value ) and set ( value name -- ) search in
-!!! the namespaces on the namespace stack, in top-down order.
-!!!
-!!! At the bottom of the namespace stack, is the global
-!!! namespace; it is always present.
-!!!
-!!! bind ( namespace quot -- ) executes a quotation with a
-!!! namespace pushed on the namespace stack.
+! Other languages have classes, objects, variables, etc.
+! Factor has similar concepts.
+!
+!   5 "x" set
+!   "x" get 2 + .
+! 7
+!   7 "x" set
+!   "x" get 2 + .
+! 9
+!
+! get ( name -- value ) and set ( value name -- ) search in
+! the namespaces on the namespace stack, in top-down order.
+!
+! At the bottom of the namespace stack, is the global
+! namespace; it is always present.
+!
+! bind ( namespace quot -- ) executes a quotation with a
+! namespace pushed on the namespace stack.
 
 : namestack ( -- stack )
     #! Push a copy of the namespace stack; same naming
index fd1befa874308bc61f48b46fd852d38c10c58597..01247fede4396d94e34c29a2f15862b6a514b255 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index c8736fe99e60c01ced347d9776dcdfbc5995cb48..20c5126d32ebce036b14a2ab8d4141d1d8e8a5d9 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 5368ff5d50e07a881bfc1eb3baaa9581dfb29458..bd2554e42c471eb2a10f4069c35f856acb419da3 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 3d82ede77ddc8073ec18ffc6547d1ff5fc725da3..6986480274663462516e9ba3409a1026619c54a8 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 156420166e97e6909fe6fdc76b4915ca3a80b3f3..a54c9bf3e9ee2de5a5be99d6becba7fafe5480d6 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 5f07d7138345335861159c1e32fa6637df2836e8..e0e3bbf7d024a7ecbd68d3d3b94c3e3ce30cf716 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 5ffd5a164433de56949a3a68d8d58cac1971cc63..20f9d18e92a943453fe26d058494ef187860f3b8 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 2ef8ec5fff4e5f84b01ebedd1709b8103d83489a..9b5f8091fe66dc293cbe87ee36d42d97f6bf98a5 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index afb702cc5c132e0e0b3353cf05e96dbce600f852..9d9adc689c7289572ee1f101bf6cf9aeed362b19 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index bc762ddcf390d3356ee3002e89259569d8ec99cb..bf12631b4bcce1fd5db532606ca1c4d406426814 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 6573e2778f63b9f9766a541c76d6f90bfdfb0340..74054ccdd73b5da6ecf6b2ac4f4ae9f2ed8e8d90 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index e771e11d70eee9070f47b3aeb8917d5f2c6e6953..cbd9d3c0148a7a47c81e09a16d2f654e7cac3fc5 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 68a29053550383f0e4ace9bda20c1479a59f9906..c70a41eed518d2133e8966d22b833977259c3df9 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 267a7c90fee5305e056ef03fd7e4954bf23c45f4..f393931264a5acdc0ff117883ba2aac301c8bb33 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 13460f9b7dd70915f2640fb1a8e5e5f8bc5b59b9..a87cc71d27a034a32feecbc47edcac011ca95d2f 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 313b8a8ed09f9a92c9cf55760e9a9675037d7e7e..d97d469794270afd112d15a68f9a45fb34f94b64 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 8a13de40ee7f2b0f14db53b097750c608035dbd2..c5feab711eec474ab30497cc50fb514d288b03ef 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index bf07fbd86c26a8c01b8f39437b82726afd708750..88c23c124da7ca6f44427e1c3c1667e6d07bbe6a 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 5d56cb5c29eb692f01a4f46c43af899c7492be6d..85297ffd3861c84cfae06a6ed71a74a5a7f7d5c4 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 7a9891582854c1d78edf90a94e74beb737bde40f..a511ac927431d615909d0be75453c303a76fdf40 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index b20a5e767132264e0cadeb5a7b7da637c2c06958..114d1544dee9b86d26439ed71e6369122c981bbe 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index cbbcdda2f2af4ce09b6515c85cdbb1851f9b5f32..9c8b81b42773d13ff224487e4f6f0b6721740b0a 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index b89d429726f85eb29a4a6ad54f7e3fcafe929af8..a076c601c9158063232c57937ad305ae338444be 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 6d8dfb41ec1a4fce0ea0359759f4e5862d699ddc..b93d9a72704bc880fdb37f2265229a6c8fd44281 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index d08f2ca459a5004dea26c004061c02c06ab6b33b..dc4001c3ad238ca53f4d89404cf3292da4484b1b 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 9df7be59f4eff53a22225266ff9c17d53dcf2943..ef20353593ab0e7605dc40b84ff7b39c80703a3f 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index ad62ebce32501d51ce6a5496ec6315848ca83287..b154c85bd61c5dc916851dbef2b66c7bcef040ad 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index f6a5252ea9b589ed8a35babc1d869e8d76a7971c..f226d9eaa12cc5f7d24b8da8249dfe294113015c 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index f672734d3dd1caedd0f749f42805ba3f480902f5..cb884bd04fbdf9a6daa599cf302503419b4e6879 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index fac84b4fde01a16752076cd91dda49d7568d8503..3338d6b2629396a907f6371ab5a628dd7a054627 100644 (file)
Binary files a/library/platform/native/.image.factor.marks and b/library/platform/native/.image.factor.marks differ
index 55b01478eec2d9b6ab9daee743dad3ed017135d7..d622ba2c62241ec93d9db4a1e92a12f615371d14 100644 (file)
@@ -1 +1 @@
-!a;2200;2200
+!a;2201;2201
index 75619d5ebda272267b422204454c69a61a9961d8..93dd4f80a34a13091300bb39eff7ec81a27afd40 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=none:collapseFolds=1:
+! :folding=none:collapseFolds=1:
 
 ! $Id$
 !
@@ -79,8 +79,11 @@ primitives,
     "/library/platform/native/io-internals.factor"
     "/library/platform/native/stream.factor"
     "/library/platform/native/kernel.factor"
+    "/library/platform/native/image.factor"
     "/library/platform/native/namespaces.factor"
+    "/library/platform/native/parse-numbers.factor"
     "/library/platform/native/parser.factor"
+    "/library/platform/native/parse-syntax.factor"
     "/library/platform/native/parse-stream.factor"
     "/library/platform/native/prettyprint.factor"
     "/library/platform/native/stack.factor"
@@ -100,7 +103,7 @@ primitives,
     max 2list length reverse nth list? 2rlist
     all? clone-list clone-list-iter subset subset-iter
     subset-add car= cdr= cons= cons-hashcode
-    tree-contains? =-or-contains? last* last
+    tree-contains? =-or-contains? last* last inject
 ] [ worddef worddef, ] each
 
 version,
index f9d1e8295b90ff620203b19ac05c88198dfff0ac..c43193aa1be96097d9d023cc62a505dba7d38598 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=none:collapseFolds=1:
+! :folding=none:collapseFolds=1:
 
 ! $Id$
 !
@@ -107,7 +107,11 @@ IN: cross-compiler
         mod
         /mod
         bitand
+        bitor
         bitxor
+        bitnot
+        shift>
+        shift<
         <
         <=
         >
@@ -176,4 +180,4 @@ IN: cross-compiler
 
     ! Uncomment this on sparc and powerpc.
     ! "big-endian" on
-    "native/factor.image" write-image ;
+    "factor.image" write-image ;
index c2486caa941ffe5934d2efad86a52839439e5f9f..541155bf22c13fe3bff7270f1a8c5b007bdc4876 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 99a6640ce214f6e92895ced4961cb225146f7f30..e78cd706d4e2ca75ea5d76a31450a498d0cc3481 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=none:collapseFolds=1:
+! :folding=none:collapseFolds=1:
 
 ! $Id$
 !
index 6e15553fe493d06cc6d7b7c01d197ad18b851520..8f21e7a21bc0cc759ddd1cd76b52985a147d45cd 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index a2629fa08f3e733cb87c7db94b341efc5bb28343..f9c779c7a925a2a810bda07651f712f815b96902 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=none:collapseFolds=1:
+! :folding=none:collapseFolds=1:
 
 ! $Id$
 !
index 50dc6b4a7f054ee22c1e1595f0335533de939548..1d8973add6100dd2da8ad91c839c01277fd00dd8 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=none:collapseFolds=1:
+! :folding=none:collapseFolds=1:
 
 ! $Id$
 !
@@ -95,9 +95,11 @@ USE: words
 : inline ;
 : interpret-only ;
 
-!!! HACK
+! HACKS
 
 IN: strings
+: char? drop f ;
+: >char ;
 : >upper ;
 : >lower ;
 IN: lists
index 2e28e1a964a1b4a1846eaad286f753fa66698db5..b66bf9eb3818d7c560f9609f6722a073de407dfa 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
diff --git a/library/platform/native/parse-numbers.factor b/library/platform/native/parse-numbers.factor
new file mode 100644 (file)
index 0000000..906559c
--- /dev/null
@@ -0,0 +1,81 @@
+! :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: parser
+USE: arithmetic
+USE: combinators
+USE: errors
+USE: kernel
+USE: lists
+USE: logic
+USE: namespaces
+USE: stack
+USE: strings
+USE: words
+USE: vocabularies
+USE: unparser
+
+! Number parsing
+
+: letter? CHAR: a CHAR: z between? ;
+: LETTER? CHAR: A CHAR: Z between? ;
+: digit? CHAR: 0 CHAR: 9 between? ;
+
+: not-a-number "Not a number" throw ;
+
+: digit> ( ch -- n )
+    [
+        [ digit? ] [ CHAR: 0 - ]
+        [ letter? ] [ CHAR: a - 10 + ]
+        [ LETTER? ] [ CHAR: A - 10 + ]
+        [ drop t ] [ not-a-number ]
+    ] cond ;
+
+: >digit ( n -- ch )
+    dup 10 < [ CHAR: 0 + ] [ 10 - CHAR: a + ] ifte ;
+
+: digit ( num digit -- num )
+    "base" get swap 2dup > [
+        >r * r> +
+    ] [
+        not-a-number
+    ] ifte ;
+
+: (str>fixnum) ( str -- num )
+    0 swap [ digit> digit ] str-each ;
+
+: str>fixnum ( str -- num )
+    #! Parse a string representation of an integer.
+    dup str-length 0 = [
+        drop not-a-number
+    ] [
+        dup "-" str-head? dup [
+            nip str>fixnum neg
+        ] [
+            drop (str>fixnum)
+        ] ifte
+    ] ifte ;
index c8d19a3247d38a163fe1a21b46ee077da744f1e4..ff85b981feed0bc16dc482f5cc4dcfa9c447eda1 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
diff --git a/library/platform/native/parse-syntax.factor b/library/platform/native/parse-syntax.factor
new file mode 100644 (file)
index 0000000..b30ea49
--- /dev/null
@@ -0,0 +1,125 @@
+! :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: parser
+USE: arithmetic
+USE: combinators
+USE: errors
+USE: kernel
+USE: lists
+USE: logic
+USE: namespaces
+USE: stack
+USE: strings
+USE: words
+USE: vocabularies
+USE: unparser
+
+! Parsing words. 'builtins' is a stupid vocabulary name now
+! that it does not contain Java words anymore!
+
+IN: builtins
+
+! Constants
+: t t parsed ; parsing
+: f f parsed ; parsing
+
+! Lists
+: [ f ; parsing
+: ] nreverse parsed ; parsing
+
+: | ( syntax: | cdr ] )
+    #! See the word 'parsed'. We push a special sentinel, and
+    #! 'parsed' acts accordingly.
+    "|" ; parsing
+
+! Colon defs
+: :
+    #! Begin a word definition. Word name follows.
+    scan "in" get create f ; parsing
+
+: ;
+    #! End a word definition.
+    nreverse define ; parsing
+
+! Vocabularies
+: DEFER: scan "in" get create drop ; parsing
+: USE: scan "use" cons@ ; parsing
+: IN: scan dup "use" cons@ "in" set ; parsing
+
+! \x
+: escape ( ch -- esc )
+    [
+        [ CHAR: e | CHAR: \e ]
+        [ CHAR: n | CHAR: \n ]
+        [ CHAR: r | CHAR: \r ]
+        [ CHAR: t | CHAR: \t ]
+        [ CHAR: s | CHAR: \s ]
+        [ CHAR: \s | CHAR: \s ]
+        [ CHAR: 0 | CHAR: \0 ]
+        [ CHAR: \\ | CHAR: \\ ]
+        [ CHAR: \" | CHAR: \" ]
+    ] assoc ;
+
+! String literal
+
+: parse-escape ( -- )
+    next-ch escape dup [ drop "Bad escape" throw ] unless ;
+
+: parse-ch ( ch -- ch )
+    dup CHAR: \\ = [ drop parse-escape ] when ;
+
+: parse-string ( -- )
+    next-ch dup CHAR: " = [
+        drop
+    ] [
+        parse-ch % parse-string
+    ] ifte ;
+
+: "
+    #! Note the ugly hack to carry the new value of 'pos' from
+    #! the <% %> scope up to the original scope.
+    <% parse-string "pos" get %> swap "pos" set parsed ; parsing
+
+! Char literal
+: CHAR: ( -- ) skip-blank next-ch parse-ch parsed ; parsing
+
+! Comments
+: ( ")" until drop ; parsing
+: ! until-eol drop ; parsing
+: #! until-eol drop ; parsing
+    
+! Reading numbers in other bases
+
+: BASE: ( base -- )
+    #! Read a number in a specific base.
+    "base" get >r "base" set scan number, r> "base" set ;
+
+: HEX: 16 BASE: ; parsing
+: DEC: 10 BASE: ; parsing
+: OCT: 8 BASE: ; parsing
+: BIN: 2 BASE: ; parsing
index fde4ce15267301da1e8b79fe1d7160a317612ced..f60617d38db15b9610780824e5cd1051e6c633ef 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
@@ -39,47 +39,6 @@ USE: words
 USE: vocabularies
 USE: unparser
 
-! Number parsing
-
-: letter? #\a #\z between? ;
-: LETTER? #\A #\Z between? ;
-: digit? #\0 #\9 between? ;
-
-: not-a-number "Not a number" throw ;
-
-: digit> ( ch -- n )
-    [
-        [ digit? ] [ #\0 - ]
-        [ letter? ] [ #\a - 10 + ]
-        [ LETTER? ] [ #\A - 10 + ]
-        [ drop t ] [ not-a-number ]
-    ] cond ;
-
-: >digit ( n -- ch )
-    dup 10 < [ #\0 + ] [ 10 - #\a + ] ifte ;
-
-: digit ( num digit -- num )
-    "base" get swap 2dup >= [
-        >r * r> +
-    ] [
-        not-a-number
-    ] ifte ;
-
-: (str>fixnum) ( str -- num )
-    0 swap [ digit> digit ] str-each ;
-
-: str>fixnum ( str -- num )
-    #! Parse a string representation of an integer.
-    dup str-length 0 = [
-        drop not-a-number
-    ] [
-        dup "-" str-head? dup [
-            nip str>fixnum neg
-        ] [
-            drop (str>fixnum)
-        ] ifte
-    ] ifte ;
-
 ! The parser uses a number of variables:
 ! line - the line being parsed
 ! pos  - position in the line
@@ -118,7 +77,7 @@ USE: unparser
     #! "hello world"
     #!
     #! Will call the parsing word ".
-    ch "\"!" str-contains? ;
+    ch "\"" str-contains? ;
 
 : (scan) ( -- start end )
     skip-blank "pos" get
@@ -165,7 +124,7 @@ USE: unparser
 : eval ( "X" -- X )
     parse call ;
 
-!!! Used by parsing words
+! Used by parsing words
 : ch-search ( ch -- index )
     "pos" get "line" get rot index-of* ;
 
@@ -175,87 +134,8 @@ USE: unparser
 : until ( ch -- str )
     ch-search (until) ;
 
-: until-eol ( ch -- str )
+: until-eol ( -- str )
     "line" get str-length (until) ;
 
 : next-ch ( -- ch )
     end? [ "Unexpected EOF" throw ] [ ch advance ] ifte ;
-
-!!! Parsing words. 'builtins' is a stupid vocabulary name now
-!!! that it does not contain Java words anymore!
-
-IN: builtins
-
-! Constants
-: t t parsed ; parsing
-: f f parsed ; parsing
-
-! Lists
-: [ f ; parsing
-: ] nreverse parsed ; parsing
-
-: | ( syntax: | cdr ] )
-    #! See the word 'parsed'. We push a special sentinel, and
-    #! 'parsed' acts accordingly.
-    "|" ; parsing
-
-! Colon defs
-: :
-    #! Begin a word definition. Word name follows.
-    scan "in" get create f ; parsing
-
-: ;
-    #! End a word definition.
-    nreverse define ; parsing
-
-! Vocabularies
-: DEFER: scan "in" get create drop ; parsing
-: USE: scan "use" cons@ ; parsing
-: IN: scan dup "use" cons@ "in" set ; parsing
-
-! \x
-: escape ( ch -- esc )
-    [
-        [ #\e | #\\e ]
-        [ #\n | #\\n ]
-        [ #\r | #\\r ]
-        [ #\t | #\\t ]
-        [ #\s | #\\s ]
-        [ #\\s | #\\s ]
-        [ #\0 | #\\0 ]
-        [ #\\\ | #\\\ ]
-        [ #\\" | #\\" ]
-    ] assoc ;
-
-! String literal
-
-: parse-escape ( -- )
-    next-ch escape dup [ % ] [ drop "Bad escape" throw ] ifte ;
-
-: parse-string ( -- )
-    next-ch dup #\" = [
-        drop
-    ] [
-        dup #\\\ = [ drop parse-escape ] [ % ] ifte parse-string
-    ] ifte ;
-
-: "
-    #! Note the ugly hack to carry the new value of 'pos' from
-    #! the <% %> scope up to the original scope.
-    <% parse-string "pos" get %> swap "pos" set parsed ; parsing
-
-! Comments
-: ( ")" until drop ; parsing
-: ! until-eol drop ; parsing
-: #! until-eol drop ; parsing
-    
-! Reading numbers in other bases
-
-: BASE: ( base -- )
-    #! Read a number in a specific base.
-    "base" get >r "base" set scan number, r> "base" set ;
-
-: HEX: 16 BASE: ; parsing
-: DEC: 10 BASE: ; parsing
-: OCT: 8 BASE: ; parsing
-: BIN: 2 BASE: ; parsing
index 55032fd286f70aaddd00482efc2e62bc3a0cb571..4f4789139ecf711cc3b88e8da9d93f394b70a593 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 3970c135c21546e2a079293c1a67029beedd6a65..b936bae6289ed5e1acb3c0c5e396c3204080984f 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index c94bd2c8d11d33a7a84f8c51e5381d37045ce23a..364ccc1744a608bd303d64e96ebf792f396ad731 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
@@ -53,5 +53,11 @@ USE: namespaces
 : <file-stream> ( path mode -- stream )
     open-file dup <native-stream> ;
 
+: <filebr> ( path -- stream )
+    "r" <file-stream> ;
+
+: <filebw> ( path -- stream )
+    "w" <file-stream> ;
+
 : init-stdio ( -- )
     stdin stdout <native-stream> "stdio" set ;
index d3ea7ca55d1fbd520dc67b605532f3e4fe76082d..09338e6444e0ce62a2cdd62ec9c168e472657b5c 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
@@ -54,7 +54,7 @@ USE: vocabularies
 
 : unparse-str ( str -- str )
     #! Not done
-    <% #\" % % #\" % %> ;
+    <% CHAR: " % % CHAR: " % %> ;
 
 : unparse-word ( word -- str )
     word-name dup "#<unnamed>" ? ;
index f786f62eb20fa073a4007752128315aae4aebd3d..06ce9c7f3d5610f7420113fcf9f2e2dd5be2a7e6 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index d81c2f8e064cdc2f602cdb8a98cb1ffb51d66a86..62996702282d719a55a2f0fb62ac95823e104175 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 0b03e176f516a6a9b74be686dde49e79301bf4c9..74f374eb3c805e7089b511c9d2cbbcd291be7d47 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 749a4bda1be329129582b42aee53eb48385e1427..dc8c89d32cf005557bcbcab34eaf5cb61ed7e015 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 25f6009bd6c9bfade31d683d340569235cce3a5e..f75de33a1aea9d4a52af33dc282d77339665a01c 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 1afebc70781e5ad3928a7efdb23cb77cafbf781c..6f3ca6e417f1954e1d224c23108e8b82f66ad2a5 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=0:
+! :folding=indent:collapseFolds=0:
 
 ! $Id$
 !
index 2c489c822b6ca3ed2cc710586a6d3a4c35047b3d..cb565cd21e6cdce10a287c4cc10341d76041e7b6 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 55456934bc17164238e890d0bd18746297e53c91..10e88176822c18487eeeec6f70bd88d3ccdbbc4c 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index abc3091da6c4ed2afbc11938a6697eb24e5d5922..8a7b8ccfcfe624840e16315bd65350205d9867e0 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index d016a3eb2e372ad5567ac8af40f240f464ca4715..13e147575d79d0d28dd69fec4b882e7b120e89d5 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
@@ -31,12 +31,12 @@ USE: kernel
 USE: namespaces
 USE: stack
 
-!!! A style is a namespace whose variable names and values hold
-!!! significance to the 'fwrite-attr' word when applied to a
-!!! stream that supports attributed string output.
-!!!
-!!! The default style enumerates the canonical names and values
-!!! to determine a style.
+! A style is a namespace whose variable names and values hold
+! significance to the 'fwrite-attr' word when applied to a
+! stream that supports attributed string output.
+!
+! The default style enumerates the canonical names and values
+! to determine a style.
 
 : default-style ( -- style )
     #! Push the default style object.
index 13c8f8b0c5757de2ef371c46360b54ffd32bfeca..e0ba8a78c26b69c6c47670bfa397546f1d1c7b5c 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 582fcb0d57bc325408d35e8452648d55b74948e9..68e79c2446a980e7a90e000068e2f42d04a3d41b 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index f63eb8907bffb7ebe6d7c0445275236ee8fe70fe..ba4d48db99b0642c2d1082bd34d26c86b86d6a15 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 880869981170bba3c3c7732b37c78ce9dbd4d8f8..28d07718c00e860642f6aca65b98d205f515d357 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 8113f529675284e817171bb556308b4ee5135213..fe4bb40547360a2c465c1b6e339b440304385687 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
index 8a563f762a49b233c931dee23a2577f03622a896..cd7226b272ee6507a9874e46d270ed2ced2cec9e 100644 (file)
@@ -1,4 +1,4 @@
-!:folding=indent:collapseFolds=1:
+! :folding=indent:collapseFolds=1:
 
 ! $Id$
 !
diff --git a/native/build.sh b/native/build.sh
deleted file mode 100644 (file)
index 642d504..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-rm *.o
-
-export CC=gcc34
-export CFLAGS="-pedantic -Wall -Winline -O4 -Os -march=pentium4 -fomit-frame-pointer -falign-functions=8"
-
-$CC $CFLAGS -o f *.c
-
-strip f
-
-#export CC=gcc
-#export CFLAGS="-g"
-
-#$CC $CFLAGS -o f-debug *.c
index 4776d27812aec202d2160fe37c29be7028a562a6..c3ac2999bfc5041c75a7eb63123b56f8b6e9a1c9 100644 (file)
@@ -42,7 +42,6 @@ void general_error(CELL error, CELL tagged)
 
 void type_error(CELL type, CELL tagged)
 {
-       printf("throwing %d %d\n",type,tagged);
        CONS* c = cons(tag_fixnum(type),tag_cons(cons(tagged,F)));
        general_error(ERROR_TYPE,tag_cons(c));
 }
index 137f8875602d7b877b24ef0a23662eabc6bae218..c11a64cf6621c8c19ee3fb6f32d5e68b52b5939d 100644 (file)
@@ -58,12 +58,36 @@ void primitive_and(void)
        env.dt = x & y;
 }
 
+void primitive_or(void)
+{
+       BINARY_OP(x,y);
+       env.dt = x | y;
+}
+
 void primitive_xor(void)
 {
        BINARY_OP(x,y);
        env.dt = x ^ y;
 }
 
+void primitive_not(void)
+{
+       type_check(FIXNUM_TYPE,env.dt);
+       env.dt = RETAG(~env.dt,FIXNUM_TYPE);
+}
+
+void primitive_shiftleft(void)
+{
+       BINARY_OP(x,y);
+       env.dt = UNTAG(x >> (y >> TAG_BITS));
+}
+
+void primitive_shiftright(void)
+{
+       BINARY_OP(x,y);
+       env.dt = x << (y >> TAG_BITS);
+}
+
 void primitive_less(void)
 {
        BINARY_OP(x,y);
index f68556cd81491b7efaae5d0006b0057fa503a68d..be26f5dd843b10510608f0b02e422d83b884bc34 100644 (file)
@@ -19,7 +19,11 @@ void primitive_divide(void);
 void primitive_mod(void);
 void primitive_divmod(void);
 void primitive_and(void);
+void primitive_or(void);
 void primitive_xor(void);
+void primitive_not(void);
+void primitive_shiftleft(void);
+void primitive_shiftright(void);
 void primitive_less(void);
 void primitive_lesseq(void);
 void primitive_greater(void);
index 401480f9d587ab4475c371dc3250579acb16b94d..fc5aa4ea8e1c4f865468b4104af59412d37a7dd3 100644 (file)
@@ -42,44 +42,48 @@ XT primitives[] = {
        primitive_mod,                          /* 38 */
        primitive_divmod,                       /* 39 */
        primitive_and,                          /* 40 */
-       primitive_xor,                          /* 41 */
-       primitive_less,                         /* 42 */
-       primitive_lesseq,                       /* 43 */
-       primitive_greater,                      /* 44 */
-       primitive_greatereq,                    /* 45 */
-       primitive_wordp,                        /* 46 */
-       primitive_word,                         /* 47 */
-       primitive_word_primitive,               /* 48 */
-       primitive_set_word_primitive,           /* 49 */
-       primitive_word_parameter,               /* 50 */
-       primitive_set_word_parameter,           /* 51 */
-       primitive_word_plist,                   /* 52 */
-       primitive_set_word_plist,               /* 53 */
-       primitive_drop,                         /* 54 */
-       primitive_dup,                          /* 55 */
-       primitive_swap,                         /* 56 */
-       primitive_over,                         /* 57 */
-       primitive_pick,                         /* 58 */
-       primitive_nip,                          /* 59 */
-       primitive_tuck,                         /* 60 */
-       primitive_rot,                          /* 61 */
-       primitive_to_r,                         /* 62 */
-       primitive_from_r,                       /* 63 */
-       primitive_eq,                           /* 64 */
-       primitive_getenv,                       /* 65 */
-       primitive_setenv,                       /* 66 */
-       primitive_open_file,                    /* 67 */
-       primitive_read_line_8,                  /* 68 */
-       primitive_write_8,                      /* 69 */
-       primitive_close,                        /* 70 */
-       primitive_gc,                           /* 71 */
-       primitive_save_image,                   /* 72 */
-       primitive_datastack,                    /* 73 */
-       primitive_callstack,                    /* 74 */
-       primitive_set_datastack,                /* 75 */
-       primitive_set_callstack,                /* 76 */
-       primitive_handlep,                      /* 77 */
-       primitive_exit                          /* 78 */
+       primitive_or,                           /* 41 */
+       primitive_xor,                          /* 42 */
+       primitive_not,                          /* 43 */
+       primitive_shiftleft,                    /* 44 */
+       primitive_shiftright,                   /* 45 */
+       primitive_less,                         /* 46 */
+       primitive_lesseq,                       /* 47 */
+       primitive_greater,                      /* 48 */
+       primitive_greatereq,                    /* 49 */
+       primitive_wordp,                        /* 50 */
+       primitive_word,                         /* 51 */
+       primitive_word_primitive,               /* 52 */
+       primitive_set_word_primitive,           /* 53 */
+       primitive_word_parameter,               /* 54 */
+       primitive_set_word_parameter,           /* 55 */
+       primitive_word_plist,                   /* 56 */
+       primitive_set_word_plist,               /* 57 */
+       primitive_drop,                         /* 58 */
+       primitive_dup,                          /* 59 */
+       primitive_swap,                         /* 60 */
+       primitive_over,                         /* 61 */
+       primitive_pick,                         /* 62 */
+       primitive_nip,                          /* 63 */
+       primitive_tuck,                         /* 64 */
+       primitive_rot,                          /* 65 */
+       primitive_to_r,                         /* 66 */
+       primitive_from_r,                       /* 67 */
+       primitive_eq,                           /* 68 */
+       primitive_getenv,                       /* 69 */
+       primitive_setenv,                       /* 70 */
+       primitive_open_file,                    /* 71 */
+       primitive_read_line_8,                  /* 72 */
+       primitive_write_8,                      /* 73 */
+       primitive_close,                        /* 74 */
+       primitive_gc,                           /* 75 */
+       primitive_save_image,                   /* 76 */
+       primitive_datastack,                    /* 77 */
+       primitive_callstack,                    /* 78 */
+       primitive_set_datastack,                /* 79 */
+       primitive_set_callstack,                /* 80 */
+       primitive_handlep,                      /* 81 */
+       primitive_exit                          /* 82 */
 };
 
 CELL primitive_to_xt(CELL primitive)
index e7a48cf6b5e1c6dc48e9312fd62c61f73e10869d..070f5faea3919262006fcd8cd0eb4e52a7453ad7 100644 (file)
@@ -1,5 +1,5 @@
 extern XT primitives[];
-#define PRIMITIVE_COUNT 79
+#define PRIMITIVE_COUNT 83
 
 CELL primitive_to_xt(CELL primitive);