1 ! Copyright (C) 2005, 2006 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
4 USING: arrays errors generic hashtables kernel math namespaces
5 sequences strings vectors words ;
16 TUPLE: check-vocab name ;
17 : check-vocab ( name -- vocab )
20 { { "Continue" f } } condition
23 : use+ ( vocab -- ) check-vocab [ use get push ] when* ;
25 : add-use ( seq -- ) [ use+ ] each ;
28 [ check-vocab ] map [ ] subset >vector use set ;
32 [ "Vocabulary name must be a string" throw ] unless
33 dup ensure-vocab dup in set use+ ;
35 : parsing? ( obj -- ? )
36 dup word? [ "parsing" word-prop ] [ drop f ] if ;
39 file get line-number get 2dup and
40 [ 2array ] [ 2drop f ] if ;
42 : save-location ( word -- )
43 dup set-word location "loc" set-word-prop ;
45 : create-in ( string -- word )
46 in get create dup save-location ;
48 : create-constructor ( class -- word )
49 dup word-name swap word-vocabulary constructor-word
52 TUPLE: parse-error file line col text ;
54 C: parse-error ( msg -- error )
55 file get over set-parse-error-file
56 line-number get over set-parse-error-line
57 column-number get over set-parse-error-col
58 line-text get over set-parse-error-text
59 [ set-delegate ] keep ;