Factor out parser note code into parser.notes vocabulary, and print a note if a using list contains duplicates

db4
Slava Pestov 2009-05-16 09:40:17 -05:00
parent 90560d3959
commit 35ccf0231e
5 changed files with 24 additions and 18 deletions

View 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 )

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -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 ;

View 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 )

View 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 ]