]> gitweb.factorcode.org Git - factor.git/commitdiff
Factor out parser note code into parser.notes vocabulary, and print a note if a using...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 16 May 2009 14:40:17 +0000 (09:40 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 16 May 2009 14:40:17 +0000 (09:40 -0500)
core/classes/tuple/parser/parser.factor
core/parser/notes/authors.txt [new file with mode: 0644]
core/parser/notes/notes.factor [new file with mode: 0644]
core/parser/parser.factor
core/vocabs/parser/parser.factor

index 85a6249dd3090dab000b4a641d1d55e19fe3dd68..efb77e32746b2cc1791fd338da086a10de80a1ef 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel sets namespaces make sequences parser
 lexer combinators words classes.parser classes.tuple arrays
-slots math assocs ;
+slots math assocs parser.notes ;
 IN: classes.tuple.parser
 
 : slot-names ( slots -- seq )
diff --git a/core/parser/notes/authors.txt b/core/parser/notes/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/core/parser/notes/notes.factor b/core/parser/notes/notes.factor
new file mode 100644 (file)
index 0000000..3f702d3
--- /dev/null
@@ -0,0 +1,18 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: namespaces kernel source-files lexer accessors io math.parser ;
+IN: parser.notes
+
+SYMBOL: parser-notes
+
+t parser-notes set-global
+
+: parser-notes? ( -- ? )
+    parser-notes get "quiet" get not and ;
+
+: note. ( str -- )
+    parser-notes? [
+        file get [ path>> write ":" write ] when* 
+        lexer get [ line>> number>string write ": " write ] when*
+        "Note:" print dup print
+    ] when drop ;
\ No newline at end of file
index eb8d77959e05fafa59801b5171447c64972feca0..8d52dcaa2cb50269031cf1ec3fbc4c85f7406f7e 100644 (file)
@@ -5,7 +5,7 @@ sequences strings vectors words words.symbol quotations io
 combinators sorting splitting math.parser effects continuations
 io.files vocabs io.encodings.utf8 source-files classes
 hashtables compiler.units accessors sets lexer vocabs.parser
-effects.parser slots ;
+effects.parser slots parser.notes ;
 IN: parser
 
 : location ( -- loc )
@@ -15,20 +15,6 @@ IN: parser
 : save-location ( definition -- )
     location remember-definition ;
 
-SYMBOL: parser-notes
-
-t parser-notes set-global
-
-: parser-notes? ( -- ? )
-    parser-notes get "quiet" get not and ;
-
-: note. ( str -- )
-    parser-notes? [
-        file get [ path>> write ":" write ] when* 
-        lexer get [ line>> number>string write ": " write ] when*
-        "Note:" print dup print
-    ] when drop ;
-
 M: parsing-word stack-effect drop (( parsed -- parsed )) ;
 
 : create-in ( str -- word )
index ba4fb265c3d3e2fb00be758902785e976af92a64..45084ae8ffb20da295ab49013ad68b25fde439fd 100644 (file)
@@ -3,7 +3,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs hashtables kernel namespaces sequences
 sets strings vocabs sorting accessors arrays compiler.units
-combinators vectors splitting continuations math ;
+combinators vectors splitting continuations math
+parser.notes ;
 IN: vocabs.parser
 
 ERROR: no-word-error name ;
@@ -105,7 +106,7 @@ TUPLE: no-current-vocab ;
 
 : use-vocab ( vocab -- )
     dup using-vocab?
-    [ drop ] [
+    [ vocab-name "Already using ``" "'' vocabulary" surround note. ] [
         manifest get
         [ [ vocab-name ] dip search-vocab-names>> conjoin ]
         [ [ load-vocab ] dip search-vocabs>> push ]