]> gitweb.factorcode.org Git - factor.git/commitdiff
Refactor the lexer/parser to expose friendlier words for scanning tokens. The preferr...
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 27 Sep 2011 20:20:07 +0000 (13:20 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 29 Sep 2011 18:28:28 +0000 (11:28 -0700)
CREATE -> scan-new
CREATE-CLASS -> scan-new-class
CREATE-WORD -> scan-new-word
CREATE-GENERIC -> scan-new-generic
scan -> (scan-token)
scan-token now throws on eof
(scan-word) returns word/number/f
scan-word now throws on eof
scan-word-name expects a non-number
Fixes #183.
Fixes #209.

68 files changed:
basis/alien/parser/parser.factor
basis/alien/syntax/syntax.factor
basis/bootstrap/image/syntax/syntax.factor
basis/classes/struct/struct.factor
basis/cocoa/cocoa.factor
basis/colors/constants/constants.factor
basis/colors/hex/hex.factor
basis/compiler/cfg/dataflow-analysis/dataflow-analysis.factor
basis/compiler/cfg/instructions/syntax/syntax.factor
basis/compiler/cfg/renaming/functor/functor.factor
basis/core-foundation/strings/strings.factor
basis/definitions/icons/icons.factor
basis/delegate/delegate.factor
basis/functors/backend/backend.factor
basis/functors/functors.factor
basis/gobject-introspection/gobject-introspection.factor
basis/html/templates/chloe/syntax/syntax.factor
basis/io/encodings/8-bit/8-bit.factor
basis/io/encodings/euc/euc.factor
basis/locals/locals.factor
basis/locals/parser/parser.factor
basis/logging/logging.factor
basis/math/vectors/simd/cords/cords.factor
basis/math/vectors/simd/simd.factor
basis/multiline/multiline.factor
basis/openssl/libssl/libssl.factor
basis/peg/ebnf/ebnf.factor
basis/roman/roman.factor
basis/tools/test/test.factor
basis/tr/tr.factor
basis/ui/pixel-formats/pixel-formats.factor
basis/ui/ui.factor
basis/unicode/categories/syntax/syntax.factor
basis/values/values.factor
basis/windows/com/syntax/syntax.factor
basis/xml/syntax/syntax.factor
basis/xmode/loader/syntax/syntax.factor
core/classes/parser/parser.factor
core/classes/tuple/parser/parser.factor
core/effects/parser/parser.factor
core/generic/parser/parser.factor
core/lexer/lexer-docs.factor
core/lexer/lexer.factor
core/parser/parser-docs.factor
core/parser/parser-tests.factor
core/parser/parser.factor
core/syntax/syntax.factor
extra/calendar/holidays/holidays.factor
extra/cpu/8080/emulator/emulator.factor
extra/cpu/arm/assembler/assembler.factor
extra/cuda/syntax/syntax.factor
extra/decimals/decimals.factor
extra/game/worlds/worlds.factor
extra/gpu/render/render.factor
extra/gpu/shaders/shaders.factor
extra/irc/messages/base/base.factor
extra/money/money.factor
extra/multi-methods/multi-methods.factor
extra/opencl/syntax/syntax.factor
extra/pair-methods/pair-methods.factor
extra/roles/roles.factor
extra/smalltalk/selectors/selectors.factor
extra/units/reduction/reduction.factor
extra/variables/variables.factor
extra/variants/variants.factor
extra/vocabs/git/git.factor
unmaintained/peg-lexer/peg-lexer.factor
unmaintained/ui/gadgets/layout/layout.factor

index 09fedc5e3cca13e8bcb6736b518722ab584f4eb4..a9cf10b9f90996b1ee0ab37f5e91c3cd3ae0db82 100755 (executable)
@@ -18,7 +18,7 @@ ERROR: bad-array-type ;
 
 : parse-array-type ( name -- c-type )
     "[" split unclip
-    [ [ "]" ?tail [ bad-array-type ] unless parse-word ] map ]
+    [ [ "]" ?tail [ bad-array-type ] unless parse-word/number ] map ]
     [ (parse-c-type) ]
     bi* prefix ;
 
@@ -70,7 +70,7 @@ ERROR: *-in-c-type-name name ;
     } cleave ;
 
 : CREATE-C-TYPE ( -- word )
-    scan (CREATE-C-TYPE) ;
+    (scan-token) (CREATE-C-TYPE) ;
 
 <PRIVATE
 GENERIC: return-type-name ( type -- name )
@@ -88,21 +88,21 @@ M: pointer return-type-name to>> return-type-name CHAR: * suffix ;
     [ [ 2array suffix! ] [ enum>number 1 + ] bi ] 2bi ;
 
 : parse-enum-name ( -- name )
-    scan (CREATE-C-TYPE) dup save-location ;
+    (scan-token) (CREATE-C-TYPE) dup save-location ;
 
 : parse-enum-base-type ( -- base-type token )
-    scan dup "<" =
-    [ drop scan-object scan ]
+    (scan-token) dup "<" =
+    [ drop scan-object (scan-token) ]
     [ [ int ] dip ] if ;
 
 : parse-enum-member ( members name value -- members value' )
     over "{" =
-    [ 2drop scan create-class-in scan-object next-enum-member "}" expect ]
+    [ 2drop (scan-token) create-class-in scan-object next-enum-member "}" expect ]
     [ [ create-class-in ] dip next-enum-member ] if ;
 
 : parse-enum-members ( members counter token -- members )
     dup ";" = not
-    [ swap parse-enum-member scan parse-enum-members ] [ 2drop ] if ;
+    [ swap parse-enum-member (scan-token) parse-enum-members ] [ 2drop ] if ;
 
 PRIVATE>
 
@@ -112,14 +112,14 @@ PRIVATE>
     [ V{ } clone 0 ] dip parse-enum-members ;
 
 : scan-function-name ( -- return function )
-    scan-c-type scan parse-pointers ;
+    scan-c-type (scan-token) parse-pointers ;
 
 :: (scan-c-args) ( end-marker types names -- )
-    scan :> type-str
+    (scan-token) :> type-str
     type-str end-marker = [
         type-str { "(" ")" } member? [
             type-str parse-c-type :> type
-            scan "," ?tail drop :> name
+            (scan-token) "," ?tail drop :> name
             type name parse-pointers :> ( type' name' )
             type' types push name' names push
         ] unless
index fe5a6dcadc5de992e8d3d58b44e59f496d61aacf..3630933899ca184f531a66827610854f96c23a47 100755 (executable)
@@ -13,7 +13,7 @@ SYNTAX: ALIEN: 16 scan-base <alien> suffix! ;
 
 SYNTAX: BAD-ALIEN <bad-alien> suffix! ;
 
-SYNTAX: LIBRARY: scan current-library set ;
+SYNTAX: LIBRARY: scan-token current-library set ;
 
 SYNTAX: FUNCTION:
     (FUNCTION:) make-function define-inline ;
@@ -35,9 +35,9 @@ SYNTAX: C-TYPE:
     void CREATE-C-TYPE typedef ;
 
 SYNTAX: &:
-    scan current-library get '[ _ _ address-of ] append! ;
+    scan-token current-library get '[ _ _ address-of ] append! ;
 
-SYNTAX: C-GLOBAL: scan-c-type CREATE-WORD define-global ;
+SYNTAX: C-GLOBAL: scan-c-type scan-new-word define-global ;
 
 SYNTAX: pointer:
     scan-c-type <pointer> suffix! ;
index 7025cd61e14bbaf491b768ab88bb95395760d5a8..e8dff6143096b42efbbc39a198e9e2956354d137 100644 (file)
@@ -8,7 +8,7 @@ SYMBOL: special-objects
 SYNTAX: RESET H{ } clone special-objects set-global ;
 
 SYNTAX: SPECIAL-OBJECT:
-    CREATE-WORD scan-word
+    scan-new-word scan-word
     [ swap special-objects get set-at ]
     [ drop define-symbol ]
-    2bi ;
\ No newline at end of file
+    2bi ;
index 1770444d8d14db846942fe5c584b7245f8b46312..0f22ba6cc5a057d11c7f655f78f9a037260617ba 100644 (file)
@@ -354,7 +354,7 @@ PRIVATE>
 
 <PRIVATE
 : parse-struct-slot ( -- slot )
-    scan scan-c-type \ } parse-until <struct-slot-spec> ;
+    (scan-token) scan-c-type \ } parse-until <struct-slot-spec> ;
 
 : parse-struct-slots ( slots -- slots' more? )
     scan-token {
@@ -364,7 +364,7 @@ PRIVATE>
     } case ;
 
 : parse-struct-definition ( -- class slots )
-    CREATE-CLASS 8 <vector> [ parse-struct-slots ] [ ] while >array
+    scan-new-class 8 <vector> [ parse-struct-slots ] [ ] while >array
     dup [ name>> ] map check-duplicate-slots ;
 PRIVATE>
 
@@ -387,14 +387,14 @@ SYNTAX: S@
 
 <PRIVATE
 : scan-c-type` ( -- c-type/param )
-    scan dup "{" = [ drop \ } parse-until >array ] [ search ] if ;
+    (scan-token) dup "{" = [ drop \ } parse-until >array ] [ search ] if ;
 
 : parse-struct-slot` ( accum -- accum )
     scan-string-param scan-c-type` \ } parse-until
     [ <struct-slot-spec> suffix! ] 3curry append! ;
 
 : parse-struct-slots` ( accum -- accum more? )
-    scan {
+    (scan-token) {
         { ";" [ f ] }
         { "{" [ parse-struct-slot` t ] }
         [ invalid-struct-slot ]
index 53f22addcb2aa9ada3c9b5812b1c8fb43731ecaf..558c4f5f26a6f5fc47223c9cf83ac4acb73175fe 100644 (file)
@@ -14,14 +14,14 @@ SYMBOL: sent-messages
 : remember-send ( selector -- )
     sent-messages (remember-send) ;
 
-SYNTAX: -> scan dup remember-send suffix! \ send suffix! ;
+SYNTAX: -> scan-token dup remember-send suffix! \ send suffix! ;
 
 SYMBOL: super-sent-messages
 
 : remember-super-send ( selector -- )
     super-sent-messages (remember-send) ;
 
-SYNTAX: SUPER-> scan dup remember-super-send suffix! \ super-send suffix! ;
+SYNTAX: SUPER-> scan-token dup remember-super-send suffix! \ super-send suffix! ;
 
 SYMBOL: frameworks
 
@@ -29,9 +29,9 @@ frameworks [ V{ } clone ] initialize
 
 [ frameworks get [ load-framework ] each ] "cocoa" add-startup-hook
 
-SYNTAX: FRAMEWORK: scan [ load-framework ] [ frameworks get push ] bi ;
+SYNTAX: FRAMEWORK: scan-token [ load-framework ] [ frameworks get push ] bi ;
 
-SYNTAX: IMPORT: scan [ ] import-objc-class ;
+SYNTAX: IMPORT: scan-token [ ] import-objc-class ;
 
 "Importing Cocoa classes..." print
 
index c17d1069b27533263a456e06c4d69c47d27781df..6f1b3cb951fc796a1a7d565f59fd9dc402f46527 100644 (file)
@@ -30,4 +30,4 @@ ERROR: no-such-color name ;
 : named-color ( name -- color )
     dup colors at [ ] [ no-such-color ] ?if ;
 
-SYNTAX: COLOR: scan named-color suffix! ;
+SYNTAX: COLOR: scan-token named-color suffix! ;
index a4b1aef7e5d4e6dbf7e8a917577a23ba026d15f5..c9f13b7236fe6e7c465d80e6b6f1952317a8660f 100644 (file)
@@ -13,4 +13,4 @@ IN: colors.hex
     [ red>> ] [ green>> ] [ blue>> ] tri
     [ 255 * >integer ] tri@ "%02X%02X%02X" sprintf ;
 
-SYNTAX: HEXCOLOR: scan hex>rgba suffix! ;
+SYNTAX: HEXCOLOR: scan-token hex>rgba suffix! ;
index 553b84383334cbd60bca6567c2caf8895d03a503..b5e9535d97a68d2c273de1eee02c05bd5c7e1049 100644 (file)
@@ -133,7 +133,7 @@ INSTANCE: name-analysis backward-analysis
 PRIVATE>
 
 SYNTAX: FORWARD-ANALYSIS:
-    scan [ define-analysis ] [ define-forward-analysis ] bi ;
+    scan-token [ define-analysis ] [ define-forward-analysis ] bi ;
 
 SYNTAX: BACKWARD-ANALYSIS:
-    scan [ define-analysis ] [ define-backward-analysis ] bi ;
+    scan-token [ define-analysis ] [ define-backward-analysis ] bi ;
index 16a3ff41586250eff531c6b08e09d5d93230f812..46517671b962edd20296c21642b5a9d1528d390c 100644 (file)
@@ -86,13 +86,13 @@ TUPLE: insn-slot-spec type name rep ;
     } 3cleave ;
 
 SYNTAX: INSN:
-    CREATE-CLASS insn-word ";" parse-tokens define-insn ;
+    scan-new-class insn-word ";" parse-tokens define-insn ;
 
 SYNTAX: VREG-INSN:
-    CREATE-CLASS vreg-insn-word ";" parse-tokens define-insn ;
+    scan-new-class vreg-insn-word ";" parse-tokens define-insn ;
 
 SYNTAX: FLUSHABLE-INSN:
-    CREATE-CLASS flushable-insn-word ";" parse-tokens define-insn ;
+    scan-new-class flushable-insn-word ";" parse-tokens define-insn ;
 
 SYNTAX: FOLDABLE-INSN:
-    CREATE-CLASS foldable-insn-word ";" parse-tokens define-insn ;
+    scan-new-class foldable-insn-word ";" parse-tokens define-insn ;
index 1b7f6d5f0cc7397aa19164b1017f6aa363d05076..0e1cf5311de56aba6a2714da60f3cce907ff7bdc 100644 (file)
@@ -74,4 +74,4 @@ insn-classes get [ insn-temp-slots empty? not ] filter [
 
 ;FUNCTOR
 
-SYNTAX: RENAMING: scan scan-object scan-object scan-object define-renaming ;
\ No newline at end of file
+SYNTAX: RENAMING: scan-token scan-object scan-object scan-object define-renaming ;
index 11d28024f875d2eabfebe0120b32adc9c0ee7ac1..25cd16485b77001347212a510a15c418478223af 100644 (file)
@@ -97,6 +97,6 @@ FUNCTION: CFStringRef CFCopyTypeIDDescription ( CFTypeID type_id ) ;
     CFGetTypeID [ CFCopyTypeIDDescription &CFRelease CF>string ] with-destructors ;
 
 SYNTAX: CFSTRING: 
-    CREATE scan-object 
+    scan-new-word scan-object 
     [ drop ] [ '[ _ [ _ <CFString> ] initialize-alien ] ] 2bi
     (( -- alien )) define-declared ;
index 90b8d3363c718c903caec227bdb56f10eb6f233f..1e5a0037be2ed99f99a5246e45f4f40f09d81040 100644 (file)
@@ -24,7 +24,7 @@ icons [ H{ } clone ] initialize
         define
     ] 2bi ;
 
-SYNTAX: ICON: scan-word scan define-icon ;
+SYNTAX: ICON: scan-word scan-token define-icon ;
 
 >>
 
index f37a5624443e5848ac37e885986f1e68eed61893..7958f51bc30d335c441bf9e2526bd372511396e8 100644 (file)
@@ -166,7 +166,7 @@ PRIVATE>
     ] 2bi ;
 
 SYNTAX: PROTOCOL:
-    CREATE-WORD parse-definition define-protocol ;
+    scan-new-word parse-definition define-protocol ;
 
 PREDICATE: protocol < word protocol-words ; ! Subclass of symbol?
 
@@ -181,6 +181,6 @@ M: protocol definer drop \ PROTOCOL: \ ; ;
 M: protocol group-words protocol-words ;
 
 SYNTAX: SLOT-PROTOCOL:
-    CREATE-WORD ";"
+    scan-new-word ";"
     [ [ reader-word ] [ writer-word ] bi 2array ]
     map-tokens concat define-protocol ;
index 9ade1d50f894c15b2932009a69bb1e72ed117cf4..0bdbb03ab10fa8f5b57b3e99e0901f2a546e1468 100644 (file)
@@ -23,7 +23,7 @@ SYNTAX: FUNCTOR-SYNTAX:
     scan-token >string-param ;
 
 : scan-c-type-param ( -- c-type/param )
-    scan dup "{" = [ drop \ } parse-until >array ] [ >string-param ] if ;
+    (scan-token) dup "{" = [ drop \ } parse-until >array ] [ >string-param ] if ;
 
 : define* ( word def -- ) over set-word define ;
 
index 1895c6e0f4b218b0c698f9e7a7ed47a830ad2549..64a387092613780dd8a54121983fbb65f9d7b046 100644 (file)
@@ -52,7 +52,7 @@ M: object (fake-quotations>) , ;
 
 FUNCTOR-SYNTAX: TUPLE:
     scan-param suffix!
-    scan {
+    (scan-token) {
         { ";" [ tuple suffix! f suffix! ] }
         { "<" [ scan-param suffix! [ parse-tuple-slots ] { } make suffix! ] }
         [
@@ -122,7 +122,7 @@ FUNCTOR-SYNTAX: inline [ word make-inline ] append! ;
 FUNCTOR-SYNTAX: call-next-method T{ fake-call-next-method } suffix! ;
 
 : (INTERPOLATE) ( accum quot -- accum )
-    [ scan interpolate-locals ] dip
+    [ (scan-token) interpolate-locals ] dip
     '[ _ with-string-writer @ ] suffix! ;
 
 PRIVATE>
@@ -175,7 +175,7 @@ DEFER: ;FUNCTOR delimiter
     pop-functor-words ;
 
 : (FUNCTOR:) ( -- word def effect )
-    CREATE-WORD [ parse-functor-body ] parse-locals-definition ;
+    scan-new-word [ parse-functor-body ] parse-locals-definition ;
 
 PRIVATE>
 
index 4973545333110c28c7b7624173d76be1fb52f0e3..09cd62f2d3eb146eabde77636ed97e03d9654750 100755 (executable)
@@ -54,7 +54,7 @@ M: gir-not-found summary
 
 PRIVATE>
 
-SYNTAX: GIR: scan define-gir-vocab ;
+SYNTAX: GIR: scan-token define-gir-vocab ;
 
 SYNTAX: IMPLEMENT-STRUCTS:
     ";" parse-tokens
index f7da0fe27742ea3aa029f235a0a5d4ce8f99c4ae..264559e2d8c04b296e56adef7e80b3a1dc08a1f6 100644 (file)
@@ -14,7 +14,7 @@ tags [ H{ } clone ] initialize
 : define-chloe-tag ( name quot -- ) swap tags get set-at ;
 
 SYNTAX: CHLOE:
-    scan parse-definition define-chloe-tag ;
+    scan-token parse-definition define-chloe-tag ;
 
 CONSTANT: chloe-ns "http://factorcode.org/chloe/1.0"
 
index db269c319d5a524f87e35db203dc4144186d72f3..17cb5270733f7c89205ddff7227cb32a32fd18a9 100644 (file)
@@ -54,4 +54,4 @@ M: 8-bit-encoding <decoder>
 
 PRIVATE>
 
-SYNTAX: 8-BIT: scan scan scan load-encoding ;
+SYNTAX: 8-BIT: scan-token scan-token scan-token load-encoding ;
index bf882fcfd02ac4def4eaa47bff8cb91677bcd6d4..a61046a5c7c53ffaed97b3e45b6d535f69610355 100644 (file)
@@ -65,4 +65,4 @@ PRIVATE>
 
 SYNTAX: EUC:
     ! EUC: euc-kr "vocab:io/encodings/korean/cp949.txt"
-    CREATE-CLASS scan-object define-euc ;
+    scan-new-class scan-object define-euc ;
index 5fd12e2fb3fe611fb6383e9bc8e07b63a6917f27..c7b05e0120f362cd0deb588f0768a8afc603fea1 100644 (file)
@@ -6,7 +6,7 @@ locals.errors ;
 IN: locals
 
 SYNTAX: :>
-    scan locals get [ :>-outside-lambda-error ] unless*
+    scan-token locals get [ :>-outside-lambda-error ] unless*
     parse-def suffix! ;
 
 SYNTAX: [| parse-lambda append! ;
index 5248d50ced963adcacddfb7d4d9b62b6edcfc5b7..09f75a0fa0b88bce175cdf8a7dddafba0d24ab48 100644 (file)
@@ -76,12 +76,12 @@ M: lambda-parser parse-quotation ( -- quotation )
     [ drop nip ] 3tri ; inline
 
 : (::) ( -- word def effect )
-    CREATE-WORD
+    scan-new-word
     [ parse-definition ]
     parse-locals-definition ;
 
 : (M::) ( -- word def )
-    CREATE-METHOD
+    scan-new-method
     [
         [ parse-definition ] 
         parse-locals-definition drop
index 7542c269bdff9be2b5779b093645cdccabe71ef7..0521951574ccc0833ef5b52522edd84f3c6066c5 100644 (file)
@@ -138,7 +138,7 @@ PRIVATE>
 \r
 SYNTAX: LOG:\r
     #! Syntax: name level\r
-    CREATE-WORD dup scan-word\r
+    scan-new-word dup scan-word\r
     '[ 1array stack>message _ _ log-message ]\r
     (( message -- )) define-declared ;\r
 \r
index cc3aa023e72119f2eeab49b3505c1662872ae613..37f1d6db5170bca0e4b7d4d077a4113b0ec5520e 100644 (file)
@@ -79,7 +79,7 @@ SYNTAX: A{ \ } [ >A ] parse-literal ;
     [ create-in (define-simd-128-cord) ] 2bi ;
 
 SYNTAX: SIMD-128-CORD:
-    scan-word scan define-simd-128-cord ;
+    scan-word scan-token define-simd-128-cord ;
 
 PRIVATE>
 >>
index 1c2f61c7c620f7ccda91ae1d7da3de429d82ec53..dcd200ee0841d671459821f3e7290aeda01b9195 100644 (file)
@@ -309,7 +309,7 @@ c:<c-type>
 ;FUNCTOR
 
 SYNTAX: SIMD-128:
-    scan define-simd-128 ;
+    scan-token define-simd-128 ;
 
 PRIVATE>
 
index 1b62513abf500206abfcadfa02b00497bcac0a27..51efecc9cd9e9498c19869175749ff8b6a0858a0 100644 (file)
@@ -32,7 +32,7 @@ ERROR: text-found-before-eol string ;
     ] "" make but-last ;
 
 SYNTAX: STRING:
-    CREATE-WORD
+    scan-new-word
     parse-here 1quotation
     (( -- string )) define-inline ;
 
index 148f12e017fe018e398d3208066c82debbcb02c2..1f4fe9b869c00493cb1786334b158e8886a9937d 100644 (file)
@@ -280,7 +280,7 @@ H{ } clone verify-messages set-global
 : verify-message ( n -- word ) verify-messages get-global at ;
 
 SYNTAX: X509_V_:
-    scan "X509_V_" prepend create-in
+    scan-token "X509_V_" prepend create-in
     scan-word
     [ 1quotation (( -- value )) define-inline ]
     [ verify-messages get set-at ]
index eac9c21fd68c2992a75a6f0a36481b7071ee5506..d808b9aaa0fd376782cd546f3674d9dac4c2de2a 100644 (file)
@@ -49,7 +49,7 @@ M: no-tokenizer summary
     drop "Tokenizer not found" ;\r
 \r
 SYNTAX: TOKENIZER: \r
-  scan dup search [ nip ] [ no-tokenizer ] if*\r
+  scan-word-name dup search [ nip ] [ no-tokenizer ] if*\r
   execute( -- tokenizer ) \ tokenizer set-global ;\r
 \r
 TUPLE: ebnf-non-terminal symbol ;\r
@@ -570,7 +570,7 @@ SYNTAX: [EBNF
   suffix! \ call suffix! reset-tokenizer ;\r
 \r
 SYNTAX: EBNF: \r
-  reset-tokenizer CREATE-WORD dup ";EBNF" parse-multiline-string  \r
+  reset-tokenizer scan-new-word dup ";EBNF" parse-multiline-string  \r
   ebnf>quot swapd\r
   (( input -- ast )) define-declared "ebnf-parser" set-word-prop \r
   reset-tokenizer ;\r
index 588166829ad7142128a217f04b8a66b0bf9a7cd9..be7c70431dae838603b99b8a24edc4f526f38af7 100644 (file)
@@ -69,4 +69,4 @@ ROMAN-OP: * ( x y -- z )
 ROMAN-OP: /i ( x y -- z )
 ROMAN-OP: /mod ( x y -- z w )
 
-SYNTAX: ROMAN: scan roman> suffix! ;
+SYNTAX: ROMAN: scan-token roman> suffix! ;
index b789fa853785de6455618564f7b41885e73b2950..79399123afa79dffec4c4634fa94df1fcdd653a7 100644 (file)
@@ -104,7 +104,7 @@ MACRO: <experiment> ( word -- )
 <<
 
 SYNTAX: TEST:
-    scan
+    scan-token
     [ create-in ]
     [ "(" ")" surround search '[ _ parse-test ] ] bi
     define-syntax ;
index 690103edf5eeb2a0ca8ee22e1c62d805188182ed..c7a21c3cb201c38a4f384cf1a36fd8d45ed1415f 100644 (file)
@@ -41,7 +41,7 @@ M: bad-tr summary
 PRIVATE>
 
 SYNTAX: TR:
-    scan parse-definition
+    scan-token parse-definition
     unclip-last [ unclip-last ] dip compute-tr
     [ check-tr ]
     [ [ create-tr ] dip define-tr ]
index c0a645629b5be24a275101c231e4dc072708e4bb..e0cd9ede62d4701010463eb25ae6bda22127924d 100644 (file)
@@ -87,7 +87,7 @@ M: pixel-format-attribute >PFA
 ;FUNCTOR
 
 SYNTAX: PIXEL-FORMAT-ATTRIBUTE-TABLE:
-    scan scan-object scan-object define-pixel-format-attribute-table ;
+    scan-token scan-object scan-object define-pixel-format-attribute-table ;
 
 PRIVATE>
 
index 9837938c0a68c6cd0e0027be861bbd4fa9fab4be..7a7868149d6c5a77497df4f778e6c8ab06c41bb8 100644 (file)
@@ -226,7 +226,7 @@ HOOK: system-alert ui-backend ( caption text -- )
     ] [ 2drop current-vocab main<< ] 3bi ;
 
 SYNTAX: MAIN-WINDOW:
-    CREATE
+    scan-new-word
     world-attributes parse-main-window-attributes
     parse-definition
     define-main-window ;
index 849f361fcd34852dc1235aa89f9a864dfc0363ed..4c763bd2bc147c8d0ae9b19d07443823f7d8861e 100644 (file)
@@ -23,7 +23,7 @@ SYMBOLS: Cn Lu Ll Lt Lm Lo Mn Mc Me Nd Nl No Pc Pd Ps Pe Pi Pf Po Sm Sc Sk So Zs
     [category] [ not ] compose integer-predicate-class ;
 
 : parse-category ( -- word tokens quot )
-    CREATE-CLASS \ ; parse-until { | } split1
+    scan-new-class \ ; parse-until { | } split1
     [ [ name>> categories-map at ] map ]
     [ [ [ ] like ] [ [ drop f ] ] if* ] bi* ;
 
index 8154c7db59d1e1ca214b04496103bc726c3265b7..0189742ad476b2b99e3d21e365ac8d59f665011b 100644 (file)
@@ -31,7 +31,7 @@ PREDICATE: value-word < word
     } 1&& ;
 
 SYNTAX: VALUE:
-    CREATE-WORD
+    scan-new-word
     dup t "no-def-strip" set-word-prop
     T{ value-holder } clone [ obj>> ] curry
     (( -- value )) define-declared ;
index 27105992ecaa9aa66f8f6e575ad949aba8951857..83c9b38790e317452e04f610f02b1016f6305628 100755 (executable)
@@ -43,8 +43,8 @@ ERROR: no-com-interface interface ;
     <com-function-definition> ;
 
 :: (parse-com-functions) ( functions -- )
-    scan dup ";" = [ drop ] [
-        parse-c-type scan parse-pointers
+    (scan-token) dup ";" = [ drop ] [
+        parse-c-type (scan-token) parse-pointers
         (parse-com-function) functions push
         functions (parse-com-functions)
     ] if ;
@@ -86,13 +86,13 @@ SYNTAX: COM-INTERFACE:
     CREATE-C-TYPE
     void* over typedef
     scan-object find-com-interface-definition
-    scan string>guid
+    scan-token string>guid
     parse-com-functions
     <com-interface-definition>
     dup save-com-interface-definition
     define-words-for-com-interface ;
 
-SYNTAX: GUID: scan string>guid suffix! ;
+SYNTAX: GUID: scan-token string>guid suffix! ;
 
 USE: vocabs.loader
 
index 6455d7ba0bd79dad758ab68b5b75fe5ce92a60d9..0b880e259c663297d8aa2e845a1eb27d97f43261 100644 (file)
@@ -28,16 +28,16 @@ M: no-tag summary
 PRIVATE>
 
 SYNTAX: TAGS:
-    CREATE-WORD complete-effect
+    scan-new-word complete-effect
     [ drop H{ } clone "xtable" set-word-prop ]
     [ define-tags ]
     2bi ;
 
 SYNTAX: TAG:
-    scan scan-word parse-definition define-tag ;
+    scan-token scan-word parse-definition define-tag ;
 
 SYNTAX: XML-NS:
-    CREATE-WORD scan '[ f swap _ <name> ] (( string -- name )) define-memoized ;
+    scan-new-word scan-token '[ f swap _ <name> ] (( string -- name )) define-memoized ;
 
 <PRIVATE
 
index 5f093b0ccb0de0d7b866bd7df647418bb64d55ce..170348e10001463859f31d4873d77ba0bc8a6f35 100644 (file)
@@ -11,7 +11,7 @@ IN: xmode.loader.syntax
     new swap init-from-tag swap add-rule ; inline
 
 SYNTAX: RULE:
-    scan scan-word scan-word [
+    scan-token scan-word scan-word [
         [ parse-definition call( -- ) ] { } make
         swap [ (parse-rule-tag) ] 2curry
     ] dip swap define-tag ;
index 41ce32105da525f70528dc4923e3c4bb4e3faaf6..f7b3801390c860a63347b05696c89cf2f30626f7 100644 (file)
@@ -12,5 +12,5 @@ IN: classes.parser
     dup save-class-location
     dup create-predicate-word save-location ;
 
-: CREATE-CLASS ( -- word )
-    scan create-class-in ;
+: scan-new-class ( -- word )
+    scan-word-name create-class-in ;
index 631ab92743835f684a164249bf42d0b040bf6e38..3059f2683fd0539a68d64815e45254f5beb66039 100644 (file)
@@ -31,7 +31,7 @@ ERROR: duplicate-slot-names names ;
 ERROR: invalid-slot-name name ;
 
 : parse-long-slot-name ( -- spec )
-    [ scan , \ } parse-until % ] { } make ;
+    [ (scan-token) , \ } parse-until % ] { } make ;
 
 : parse-slot-name-delim ( end-delim string/f -- ? )
     ! Check for mistakes of this form:
@@ -55,8 +55,8 @@ ERROR: invalid-slot-name name ;
     ";" parse-tuple-slots-delim ;
 
 : parse-tuple-definition ( -- class superclass slots )
-    CREATE-CLASS
-    scan {
+    scan-new-class
+    scan-token {
         { ";" [ tuple f ] }
         { "<" [ scan-word [ parse-tuple-slots ] { } make ] }
         [ tuple swap [ parse-slot-name [ parse-tuple-slots ] when ] { } make ]
@@ -72,7 +72,7 @@ ERROR: bad-slot-name class slot ;
     2dup swap slot-named* nip [ 2nip ] [ nip bad-slot-name ] if ;
 
 : parse-slot-value ( class slots -- )
-    scan check-slot-name scan-object 2array , scan-token {
+    (scan-token) check-slot-name scan-object 2array , scan-token {
         { "}" [ ] }
         [ bad-literal-tuple ]
     } case ;
index 07ecc0d88b266cf56938c52c9b922544c2749c93..bbc49c97b12c5f0f8a64a64e936a0238699cec69 100644 (file)
@@ -34,7 +34,7 @@ SYMBOL: effect-var
 PRIVATE>
 
 : parse-effect-token ( first? var end -- var more? )
-    scan {
+    (scan-token) {
         { [ end-token? ] [ drop nip f ] }
         { [ effect-opener? ] [ bad-effect ] }
         { [ effect-closer? ] [ stack-effect-omits-dashes ] }
@@ -58,6 +58,6 @@ PRIVATE>
     [ ")" parse-effect ] dip 2array append! ;
 
 : (:) ( -- word def effect )
-    CREATE-WORD
+    scan-new-word
     complete-effect
     parse-definition swap ;
index 11fb2b5b42fa7ca87f6bb54d5888b828be1f899b..652fafc2e344715804fef05a79cdb5bb5f1dd36e 100644 (file)
@@ -5,10 +5,10 @@ IN: generic.parser
 
 ERROR: not-in-a-method-error ;
 
-: CREATE-GENERIC ( -- word ) CREATE dup reset-word ;
+: scan-new-generic ( -- word ) scan-new dup reset-word ;
 
 : (GENERIC:) ( quot -- )
-    [ CREATE-GENERIC ] dip call complete-effect define-generic ; inline
+    [ scan-new-generic ] dip call complete-effect define-generic ; inline
 
 : create-method-in ( class generic -- method )
     create-method dup set-word dup save-location ;
@@ -16,7 +16,7 @@ ERROR: not-in-a-method-error ;
 : define-inline-method ( class generic quot -- )
     [ create-method-in ] dip [ define ] [ drop make-inline ] 2bi ;
 
-: CREATE-METHOD ( -- method )
+: scan-new-method ( -- method )
     scan-word bootstrap-word scan-word create-method-in ;
 
 SYMBOL: current-method
@@ -25,5 +25,5 @@ SYMBOL: current-method
     over current-method set call current-method off ; inline
 
 : (M:) ( -- method def )
-    CREATE-METHOD [ parse-definition ] with-method-definition ;
+    scan-new-method [ parse-definition ] with-method-definition ;
 
index 0fbf3b3563f53cf717431f23b1f314c9f93f444a..c5ce3a39ad04342eef8f6b8dca0cb9494c87dbe8 100644 (file)
@@ -57,14 +57,14 @@ HELP: parse-token
 { $values { "lexer" lexer } { "str/f" { $maybe string } } }
 { $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace." } ;
 
-HELP: scan
+HELP: (scan-token)
 { $values { "str/f" { $maybe string } } }
 { $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace. This word outputs " { $link f } " on end of input. To throw an error on end of input, use " { $link scan-token } " instead." }
 $parsing-note ;
 
 HELP: scan-token
 { $values { "str" string } }
-{ $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace. This word throws " { $link unexpected-eof } " on end of input. To output " { $link f } " on end of input, use " { $link scan } " instead." }
+{ $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace. This word throws " { $link unexpected-eof } " on end of input. To output " { $link f } " on end of input, use " { $link (scan-token) } " instead." }
 $parsing-note ;
 
 HELP: still-parsing?
@@ -102,7 +102,7 @@ HELP: unexpected-eof
 
 HELP: with-lexer
 { $values { "lexer" lexer } { "quot" quotation } { "newquot" quotation } }
-{ $description "Calls the quotation with the " { $link lexer } " variable set to the given lexer. The quotation can make use of words such as " { $link scan } ". Any errors thrown by the quotation are wrapped in " { $link lexer-error } " instances." } ;
+{ $description "Calls the quotation with the " { $link lexer } " variable set to the given lexer. The quotation can make use of words such as " { $link scan-token } ". Any errors thrown by the quotation are wrapped in " { $link lexer-error } " instances." } ;
 
 HELP: lexer-factory
 { $var-description "A variable holding a quotation with stack effect " { $snippet "( lines -- lexer )" } ". This quotation is called by the parser to create " { $link lexer } " instances. This variable can be rebound to a quotation which outputs a custom tuple delegating to " { $link lexer } " to customize syntax." } ;
index 8f373640d37b03bcaba3ba2d3f8d5f97a33ed53b..8caaf78403426a11d031f9efd89cf9dbd75e423a 100644 (file)
@@ -84,13 +84,13 @@ M: lexer skip-word ( lexer -- )
         [ (parse-token) ] [ dup next-line parse-token ] if
     ] [ drop f ] if ;
 
-: scan ( -- str/f ) lexer get parse-token ;
+: (scan-token) ( -- str/f ) lexer get parse-token ;
 
 PREDICATE: unexpected-eof < unexpected got>> not ;
 
 : unexpected-eof ( word -- * ) f unexpected ;
 
-: scan-token ( -- str ) scan [ "token" unexpected-eof ] unless* ;
+: scan-token ( -- str ) (scan-token) [ "token" unexpected-eof ] unless* ;
 
 : expect ( token -- )
     scan-token 2dup = [ 2drop ] [ unexpected ] if ;
index 716dcf49141820d7037a8d500147b463ea98eb05..2766f5aac9c348c2a30397347c5679e9348f82c2 100644 (file)
@@ -9,12 +9,13 @@ ARTICLE: "reading-ahead" "Reading ahead"
 "Parsing words can consume input:"
 { $subsections
     scan-token
+    scan-word
     scan-object
 }
 "Lower-level words:"
 { $subsections
-    scan
-    scan-word
+    (scan-token)
+    (scan-word)
 }
 "For example, the " { $link POSTPONE: HEX: } " word uses this feature to read hexadecimal literals:"
 { $see POSTPONE: HEX: }
@@ -39,14 +40,14 @@ $nl
 ARTICLE: "defining-words" "Defining words"
 "Defining words add definitions to the dictionary without modifying the parse tree. The simplest example is the " { $link POSTPONE: SYMBOL: } " word."
 { $see POSTPONE: SYMBOL: }
-"The key factor in the definition of " { $link POSTPONE: SYMBOL: } " is " { $link CREATE } ", which reads a token from the input and creates a word with that name. This word is then passed to " { $link define-symbol } "."
+"The key factor in the definition of " { $link POSTPONE: SYMBOL: } " is " { $link scan-new } ", which reads a token from the input and creates a word with that name. This word is then passed to " { $link define-symbol } "."
 { $subsections
-    CREATE
-    CREATE-WORD
+    scan-new
+    scan-new-word
 }
 "Colon definitions are defined in a more elaborate way:"
 { $subsections POSTPONE: : }
-"The " { $link POSTPONE: : } " word first calls " { $link CREATE } ", and then reads input until reaching " { $link POSTPONE: ; } " using a utility word:"
+"The " { $link POSTPONE: : } " word first calls " { $link scan-new } ", and then reads input until reaching " { $link POSTPONE: ; } " using a utility word:"
 { $subsections parse-definition }
 "The " { $link POSTPONE: ; } " word is just a delimiter; an unpaired occurrence throws a parse error:"
 { $see POSTPONE: ; }
@@ -129,7 +130,7 @@ HELP: create-in
 { $description "Creates a word in the current vocabulary. Until re-defined, the word throws an error when invoked." }
 $parsing-note ;
 
-HELP: CREATE
+HELP: scan-new
 { $values { "word" word } }
 { $description "Reads the next token from the line currently being parsed, and creates a word with that name in the current vocabulary." }
 { $errors "Throws an error if the end of the line is reached." }
@@ -144,13 +145,19 @@ HELP: no-word
 { $description "Throws a " { $link no-word-error } "." } ;
 
 HELP: parse-word
-{ $values { "string" string } { "word/number" "a word or number" } }
+{ $values { "string" string } { "word" "a number" } }
 { $description "If " { $snippet "string" } " is a valid number literal, it is converted to a number, otherwise the current vocabulary search path is searched for a word named by the string." }
 { $errors "Throws an error if the token does not name a word, and does not parse as a number." }
 { $notes "This word is used to implement " { $link scan-word } "." } ;
 
+HELP: parse-word/number
+{ $values { "string" string } { "word/number" "a word or number" } }
+{ $description "If " { $snippet "string" } " is a valid number literal, it is converted to a number, otherwise the current vocabulary search path is searched for a word named by the string." }
+{ $errors "Throws an error if the token does not name a word, and does not parse as a number." }
+{ $notes "This word is used to implement " { $link (scan-word) } "." } ;
+
 HELP: scan-word
-{ $values { "word/number/f" "a word, number or " { $link f } } }
+{ $values { "word/number" "a word or a number" } }
 { $description "Reads the next token from parser input. If the token is a valid number literal, it is converted to a number, otherwise the vocabulary search path is searched for a word named by the token. Outputs " { $link f } " if the end of the input has been reached." }
 { $errors "Throws an error if the token does not name a word, and does not parse as a number." }
 $parsing-note ;
index 842e5c607f5d4589f9fc5192b8f023d9488b58d9..e96d7600d5838f23d08babacf62e01724a9f31e9 100644 (file)
@@ -624,3 +624,13 @@ EXCLUDE: qualified.tests.bar => x ;
     [ ] [ "vocabs.loader.test.l" unuse-vocab ] unit-test
     [ f ] [ "vocabs.loader.test.l" manifest get search-vocab-names>> key? ] unit-test    
 ] with-file-vocabs
+
+! Test cases for #183
+[ "SINGLETON: 33" <string-reader> "class identifier test" parse-stream ]
+[ error>> lexer-error? ] must-fail-with
+
+[ ": 44 ( -- ) ;" <string-reader> "word identifier test" parse-stream ]
+[ error>> lexer-error? ] must-fail-with
+
+[ "GENERIC: 33 ( -- )" <string-reader> "generic identifier test" parse-stream ]
+[ error>> lexer-error? ] must-fail-with
index 4f2d9b563442fcef9bc06e5e3a6d06a1ace7fcaf..65b90338b021a49a1bc2f8d3c58515b0242aa358 100644 (file)
@@ -20,10 +20,6 @@ M: parsing-word stack-effect drop (( parsed -- parsed )) ;
 : create-in ( str -- word )
     current-vocab create dup set-word dup save-location ;
 
-: CREATE ( -- word ) scan create-in ;
-
-: CREATE-WORD ( -- word ) CREATE dup reset-generic ;
-
 SYMBOL: auto-use?
 
 : no-word-restarted ( restart-value -- word )
@@ -48,13 +44,31 @@ SYMBOL: auto-use?
     [ drop <no-word-error> throw-restarts no-word-restarted ]
     if ;
 
-: parse-word ( string -- word/number )
+: parse-word ( string -- word )
+    dup search [ ] [ no-word ] ?if ;
+
+: parse-word/number ( string -- word/number )
     dup search [ ] [
         dup string>number [ ] [ no-word ] ?if
     ] ?if ;
 
-: scan-word ( -- word/number/f )
-    scan dup [ parse-word ] when ;
+: (scan-word) ( -- word/number/f )
+    (scan-token) dup [ parse-word/number ] when ;
+
+: scan-word ( -- word/number )
+    (scan-word) [ \ word unexpected-eof ] unless* ;
+
+: scan-word-name ( -- string )
+    scan-token
+    dup string>number [
+        "Word names cannot be numbers" throw
+    ] when ;
+
+: scan-new ( -- word )
+    scan-word-name create-in ;
+
+: scan-new-word ( -- word )
+    scan-new dup reset-generic ;
 
 ERROR: staging-violation word ;
 
@@ -68,14 +82,13 @@ ERROR: staging-violation word ;
     (execute-parsing) ;
 
 : scan-object ( -- object )
-    scan-word {
-        { [ dup not ] [ unexpected-eof ] }
-        { [ dup parsing-word? ] [ V{ } clone swap execute-parsing first ] }
-        [ ]
-    } cond  ;
+    scan-word
+    dup parsing-word? [
+        V{ } clone swap execute-parsing first
+    ] when ;
 
 : parse-step ( accum end -- accum ? )
-    scan-word {
+    (scan-word) {
         { [ 2dup eq? ] [ 2drop f ] }
         { [ dup not ] [ drop unexpected-eof t ] }
         { [ dup delimiter? ] [ unexpected t ] }
@@ -110,7 +123,7 @@ M: f parse-quotation \ ] parse-until >quotation ;
 ERROR: bad-number ;
 
 : scan-base ( base -- n )
-    scan swap base> [ bad-number ] unless* ;
+    scan-token swap base> [ bad-number ] unless* ;
 
 : parse-base ( parsed base -- parsed )
     scan-base suffix! ;
index 864c67d172cbc568a281a46699e049250a5e421a..a3b398be5432d4cd1eb9f34ca29bfbd125654ef8 100644 (file)
@@ -117,11 +117,11 @@ IN: bootstrap.syntax
     "deprecated" [ word make-deprecated ] define-core-syntax
 
     "SYNTAX:" [
-        CREATE-WORD parse-definition define-syntax
+        scan-new-word parse-definition define-syntax
     ] define-core-syntax
 
     "SYMBOL:" [
-        CREATE-WORD define-symbol
+        scan-new-word define-symbol
     ] define-core-syntax
 
     "SYMBOLS:" [
@@ -138,11 +138,11 @@ IN: bootstrap.syntax
     ] define-core-syntax
     
     "ALIAS:" [
-        CREATE-WORD scan-word define-alias
+        scan-new-word scan-word define-alias
     ] define-core-syntax
 
     "CONSTANT:" [
-        CREATE-WORD scan-object define-constant
+        scan-new-word scan-object define-constant
     ] define-core-syntax
 
     ":" [
@@ -170,15 +170,15 @@ IN: bootstrap.syntax
     ] define-core-syntax
 
     "UNION:" [
-        CREATE-CLASS parse-definition define-union-class
+        scan-new-class parse-definition define-union-class
     ] define-core-syntax
 
     "INTERSECTION:" [
-        CREATE-CLASS parse-definition define-intersection-class
+        scan-new-class parse-definition define-intersection-class
     ] define-core-syntax
 
     "MIXIN:" [
-        CREATE-CLASS define-mixin-class
+        scan-new-class define-mixin-class
     ] define-core-syntax
 
     "INSTANCE:" [
@@ -189,14 +189,14 @@ IN: bootstrap.syntax
     ] define-core-syntax
 
     "PREDICATE:" [
-        CREATE-CLASS
+        scan-new-class
         "<" expect
         scan-word
         parse-definition define-predicate-class
     ] define-core-syntax
 
     "SINGLETON:" [
-        CREATE-CLASS define-singleton-class
+        scan-new-class define-singleton-class
     ] define-core-syntax
 
     "TUPLE:" [
@@ -212,7 +212,7 @@ IN: bootstrap.syntax
     ] define-core-syntax
 
     "C:" [
-        CREATE-WORD scan-word define-boa-word
+        scan-new-word scan-word define-boa-word
     ] define-core-syntax
 
     "ERROR:" [
index 7a87a1df45a26d7c7c25d25f65288b12cc1692f9..cfae6028bbaafe642e6bd61a6b360b000c1e30cc 100644 (file)
@@ -8,7 +8,7 @@ SINGLETONS: all world commonwealth-of-nations ;
 
 <<
 SYNTAX: HOLIDAY:
-    CREATE-WORD
+    scan-new-word
     dup "holiday" word-prop [
         dup H{ } clone "holiday" set-word-prop
     ] unless
index 015d98157f67363ccebb48635796b63ecc3a48ca..914f7a17a90e5f72e0a8555dc2f766fc00725813 100644 (file)
@@ -1397,10 +1397,10 @@ SYNTAX: INSTRUCTION:  ";" parse-tokens parse-instructions ;
 
 SYNTAX: cycles 
   #! Set the number of cycles for the last instruction that was defined. 
-  scan string>number last-opcode global at instruction-cycles set-nth ; 
+  scan-token string>number last-opcode global at instruction-cycles set-nth ; 
 
 SYNTAX: opcode ( -- )
   #! Set the opcode number for the last instruction that was defined.
-  last-instruction global at 1quotation scan 16 base>
+  last-instruction global at 1quotation scan-token 16 base>
   dup last-opcode global set-at set-instruction ; 
 
index 38e385020f70a99c6eef83909e6ce74a97902e03..1ef5692b6544401067a07fcdd7f0eee280b1c113 100644 (file)
@@ -12,7 +12,7 @@ SYMBOL: registers
 V{ } registers set-global
 
 SYNTAX: REGISTER:
-    CREATE-WORD
+    scan-new-word
     [ define-symbol ]
     [ registers get length "register" set-word-prop ]
     [ registers get push ]
index 09b7786cf96fec22ddcd2466fc0d5a70c2a47948..e3173995e2c3625d5f2c5fa76cc029da4c2dbfd1 100644 (file)
@@ -5,14 +5,14 @@ fry kernel lexer namespaces parser ;
 IN: cuda.syntax
 
 SYNTAX: CUDA-LIBRARY:
-    scan scan-word scan
+    scan-token scan-word scan-token
     '[ _ _ add-cuda-library ]
     [ current-cuda-library set-global ] bi ;
 
 SYNTAX: CUDA-FUNCTION:
-    scan [ create-in current-cuda-library get ] keep
+    scan-token [ create-in current-cuda-library get ] keep
     ";" scan-c-args drop define-cuda-function ;
 
 SYNTAX: CUDA-GLOBAL:
-    scan [ create-in current-cuda-library get ] keep
+    scan-token [ create-in current-cuda-library get ] keep
     define-cuda-global ;
index d5c62fee5e3d0d4fa4f87ff2f78b2aa18a1d11af..3cd51abc98e8787a89863c30e0dc224c0b2f4056 100644 (file)
@@ -18,7 +18,7 @@ TUPLE: decimal { mantissa read-only } { exponent read-only } ;
     [ [ CHAR: 0 = ] trim-tail [ "" ] when-empty ] bi*
     [ append string>number ] [ nip length neg ] 2bi <decimal> ; 
 
-: parse-decimal ( -- decimal ) scan string>decimal ;
+: parse-decimal ( -- decimal ) scan-token string>decimal ;
 
 SYNTAX: D: parse-decimal suffix! ;
 
index 8ce720f983a21dbf08ba2c23fd6008e8f8a88077..d48aa94f65997ed5dc8f14459ca57e56170980c0 100644 (file)
@@ -82,7 +82,7 @@ M: game-world apply-world-attributes
     [ name>> "-attributes" append create-in ] dip define-constant ;
 
 SYNTAX: GAME:
-    CREATE
+    scan-new-word
     game-attributes parse-main-window-attributes
     2dup define-attributes-word
     parse-definition
index ed75f218de3ec66207eb522f9d375347f48a88f1..72880a39f4959919f8aec0f64caa82a448a0f32f 100755 (executable)
@@ -507,7 +507,7 @@ DEFER: [bind-uniform-tuple]
     ] 3bi ;
 
 : parse-uniform-tuple-definition ( -- class superclass uniforms )
-    CREATE-CLASS scan {
+    scan-new-class scan-token {
         { ";" [ uniform-tuple f ] }
         { "<" [ scan-word parse-definition [ first3 uniform boa ] map ] }
         { "{" [
index b032004d40d66ea9dadfbbb94fb2b9999deca43f..8302547b3966c218a8d72fe7383c7e39d3ad3386 100755 (executable)
@@ -356,7 +356,7 @@ PRIVATE>
     [ "vertex-format-attributes" set-word-prop ] 2bi ;
 
 SYNTAX: VERTEX-FORMAT:
-    CREATE-CLASS parse-definition
+    scan-new-class parse-definition
     [ first4 vertex-attribute boa ] map
     define-vertex-format ;
 
@@ -365,7 +365,7 @@ SYNTAX: VERTEX-FORMAT:
     define-struct-class ;
 
 SYNTAX: VERTEX-STRUCT:
-    CREATE-CLASS scan-word define-vertex-struct ;
+    scan-new-class scan-word define-vertex-struct ;
 
 TUPLE: vertex-array-object < gpu-object
     { program-instance program-instance read-only }
@@ -589,7 +589,7 @@ TYPED: <program-instance> ( program: program -- instance: program-instance )
 PRIVATE>
 
 SYNTAX: GLSL-SHADER:
-    CREATE dup
+    scan-new dup
     dup old-instances [
         scan-word
         f
@@ -601,7 +601,7 @@ SYNTAX: GLSL-SHADER:
     define-constant ;
 
 SYNTAX: GLSL-SHADER-FILE:
-    CREATE dup
+    scan-new dup
     dup old-instances [
         scan-word execute( -- kind )
         scan-object in-word's-path
@@ -613,7 +613,7 @@ SYNTAX: GLSL-SHADER-FILE:
     define-constant ;
 
 SYNTAX: GLSL-PROGRAM:
-    CREATE dup
+    scan-new dup
     dup old-instances [
         f
         lexer get line>>
index f0f9ca02cefb931474707be81f8c6e2548afb2f5..7a9f849dea606521ac221e6a764e8b132c6fdc96 100644 (file)
@@ -110,7 +110,7 @@ PRIVATE>
 #! IRC: type "COMMAND" slot1 ...;
 #! IRC: type "COMMAND" slot1 ... : trailing-slot;
 SYNTAX: IRC: ( name string parameters -- )
-    CREATE-CLASS
+    scan-new-class
     [ scan-object register-irc-message-type ] keep
     ";" parse-tokens
     [ define-irc-class ] [ define-irc-parameter-slots ] 2bi ;
index 6cafeff2895f3a90d558bce921ac62bf67846607..a3ac4ebb136715a01cdfedc0f4650b16462fe1eb 100644 (file)
@@ -30,4 +30,4 @@ ERROR: not-an-integer x ;
     ] keep length
     10^ / + swap [ neg ] when ;
 
-SYNTAX: DECIMAL: scan parse-decimal suffix! ;
+SYNTAX: DECIMAL: scan-token parse-decimal suffix! ;
index ebe60e00f63567afe405032e7d875ddc431353f8..d46c30a17cd75dd2f9b47fc881710e527ecd70f6 100644 (file)
@@ -224,7 +224,7 @@ M: no-method error.
     ] if ;
 
 ! Syntax
-SYNTAX: GENERIC: CREATE-WORD complete-effect define-generic ;
+SYNTAX: GENERIC: scan-new-word complete-effect define-generic ;
 
 : parse-method ( -- quot classes generic )
     parse-definition [ 2 tail ] [ second ] [ first ] tri ;
@@ -232,10 +232,10 @@ SYNTAX: GENERIC: CREATE-WORD complete-effect define-generic ;
 : create-method-in ( specializer generic -- method )
     create-method dup save-location f set-word ;
 
-: CREATE-METHOD ( -- method )
+: scan-new-method ( -- method )
     scan-word scan-object swap create-method-in ;
 
-: (METHOD:) ( -- method def ) CREATE-METHOD parse-definition ;
+: (METHOD:) ( -- method def ) scan-new-method parse-definition ;
 
 SYNTAX: METHOD: (METHOD:) define ;
 
index e9dbabd7fcc296cffb8cc1a48f43f2a82ccf5f36..bd9589d9564307152ce8097d98d172f85dd6e365 100644 (file)
@@ -5,4 +5,4 @@ sequences ;
 IN: opencl.syntax
 
 SYNTAX: SINGLETONS-UNION:
-    CREATE-CLASS ";" parse-tokens [ create-class-in [ define-singleton-class ] keep ] map define-union-class ;
+    scan-new-class ";" parse-tokens [ create-class-in [ define-singleton-class ] keep ] map define-union-class ;
index 131f9f5465107c2b597850589203143e1bed36cd..28a1182cf259eaf4172ea512fd59cebacb3b284a 100644 (file)
@@ -37,7 +37,7 @@ ERROR: no-pair-method a b generic ;
     [ drop make-pair-generic ] 2tri ;
 
 : (PAIR-GENERIC:) ( -- )
-    CREATE-GENERIC complete-effect define-pair-generic ;
+    scan-new-generic complete-effect define-pair-generic ;
 
 SYNTAX: PAIR-GENERIC: (PAIR-GENERIC:) ;
 
index d54b4339a703a523641ab2ac8fc8531ada525b55..3a58be9830aa51686eb54e0e6867e394aab73233 100644 (file)
@@ -12,7 +12,7 @@ PREDICATE: role < mixin-class
     "role-slots" word-prop >boolean ;
 
 : parse-role-definition ( -- class superroles slots )
-    CREATE-CLASS scan {
+    scan-new-class scan-token {
         { ";" [ { } { } ] }
         { "<" [ scan-word 1array [ parse-tuple-slots ] { } make ] }
         { "<{" [ \ } parse-until >array [ parse-tuple-slots ] { } make ] }
index 609498634574e2eb834adca3f4f186f524d7e50c..8485430018efd4c0445010fdcdb4a47245592717 100644 (file)
@@ -25,4 +25,4 @@ SYMBOLS: unary binary keyword ;
     [ selector>effect ]
     bi define-simple-generic ;
 
-SYNTAX: SELECTOR: scan selector>generic drop ;
\ No newline at end of file
+SYNTAX: SELECTOR: scan-token selector>generic drop ;
index 52279771f9cd6c36c5ebb450f26ceb69d562ebab..6f67f163faab6d4e9227faa76f552bc68ac32d8b 100644 (file)
@@ -55,4 +55,4 @@ ERROR: bad-storage-string string reason ;
 : n>money ( n -- string )
     3 10 { "" "K" "M" "B" "T" } reduce-magnitude ;
 
-SYNTAX: STORAGE: scan storage>n suffix! ;
+SYNTAX: STORAGE: scan-token storage>n suffix! ;
index e4632d04eaac90a59633729d1b6b2b2d6361d002..1ce77f66a6304a1ef3e5057642a1805f46e6a131 100644 (file)
@@ -35,7 +35,7 @@ SYNTAX: set:
     dup [ [variable-getter] ] [ [variable-setter] ] bi (define-variable) ;
 
 SYNTAX: VAR:
-    CREATE-WORD define-variable ;    
+    scan-new-word define-variable ;    
 
 M: variable definer drop \ VAR: f ;
 M: variable definition drop f ;
@@ -59,7 +59,7 @@ PREDICATE: typed-variable < variable
     } 2cleave (define-variable) ;
 
 SYNTAX: TYPED-VAR:
-    CREATE-WORD scan-object define-typed-variable ;    
+    scan-new-word scan-object define-typed-variable ;    
 
 M: typed-variable definer drop \ TYPED-VAR: f ;
 M: typed-variable definition "variable-type" word-prop 1quotation ;
@@ -78,7 +78,7 @@ PREDICATE: global-variable < variable
     global-box new [ [global-getter] ] [ [global-setter] ] bi (define-variable) ;
 
 SYNTAX: GLOBAL:
-    CREATE-WORD define-global ;
+    scan-new-word define-global ;
 
 M: global-variable definer drop \ GLOBAL: f ;
 
@@ -92,7 +92,7 @@ INTERSECTION: typed-global-variable
     [ [ [global-setter] ] dip [typed-setter] ] 2bi (define-variable) ;
 
 SYNTAX: TYPED-GLOBAL:
-    CREATE-WORD scan-object define-typed-global ;
+    scan-new-word scan-object define-typed-global ;
 
 M: typed-global-variable definer drop \ TYPED-GLOBAL: f ;
 
index df948b18635ba6cce3d9d1b162314f1b5ab733ec..55ee0390e0d8ad2d5f086deba43fcd182544eb0a 100644 (file)
@@ -38,17 +38,17 @@ M: variant-class initial-value*
     ":" ?tail [ parse-variant-tuple-member ] [ create-class-in ] if ;
 
 : parse-variant-members ( -- members )
-    [ scan dup ";" = not ]
+    [ scan-token dup ";" = not ]
     [ parse-variant-member ] produce nip ;
 
 SYNTAX: VARIANT:
-    CREATE-CLASS
+    scan-new-class
     parse-variant-members
     define-variant-class-members ;
 
 SYNTAX: VARIANT-MEMBER:
     scan-word
-    scan parse-variant-member
+    scan-token parse-variant-member
     define-variant-class-member ;
 
 MACRO: unboa ( class -- )
index eb945b57c7da1a09ab8f97def461b7b6b98d2b77..6411623b8eeefaec98200557aba6e0b00c8a1701 100644 (file)
@@ -25,4 +25,4 @@ ERROR: git-revision-not-found path ;
     [ [ input-stream get swap parse-stream call( -- ) ] with-git-object-stream ]
     [ git-revision-not-found ] if* ;
 
-SYNTAX: USE-REV: scan scan use-vocab-rev ;
+SYNTAX: USE-REV: scan-token scan-token use-vocab-rev ;
index dcde55c91ada82f2a6c696b928ebb2d58549a219..56dda70bddb35fc9d24dc1e362c240f6fb8f64e9 100644 (file)
@@ -52,7 +52,7 @@ M: lex-hash at*
     define-syntax word make-inline ;
     
 SYNTAX: ON-BNF:
-    CREATE-WORD reset-tokenizer ";ON-BNF" parse-multiline-string parse-ebnf
+    scan-new-word reset-tokenizer ";ON-BNF" parse-multiline-string parse-ebnf
     main swap at create-bnf ;
 
 ! Tokenizer like standard factor lexer
index c287b9a0598ed33f4525c0b509ca30ca8ec8be59..fb498103b5ba9632e488b9876cd17196845c2f63 100644 (file)
@@ -54,7 +54,7 @@ M: model -> dup , ;
 : <book*> ( quot -- book ) f make-layout f make-book ; inline
 
 ERROR: not-in-template word ;
-SYNTAX: $ CREATE-WORD dup
+SYNTAX: $ scan-new-word dup
     [ [ dup templates get at [ nip , ] [ not-in-template ] if* ] curry (( -- )) define-declared "$" expect ]
     [ [ <placeholder> [ swap templates get set-at ] keep , ] curry ] bi append! ;