parsed -> suffix!, add append!

db4
Doug Coleman 2009-10-28 13:38:27 -05:00
parent 37a87e85ab
commit 7ce4b746e5
52 changed files with 138 additions and 143 deletions

View File

@ -205,9 +205,6 @@ M: fortran-type (fortran-ret-type>c-type) (fortran-type>c-type) ;
M: real-type (fortran-ret-type>c-type) M: real-type (fortran-ret-type>c-type)
drop real-functions-return-double? [ "double" ] [ "float" ] if ; drop real-functions-return-double? [ "double" ] [ "float" ] if ;
: suffix! ( seq elt -- seq ) over push ; inline
: append! ( seq-a seq-b -- seq-a ) over push-all ; inline
GENERIC: (fortran-arg>c-args) ( type -- main-quot added-quot ) GENERIC: (fortran-arg>c-args) ( type -- main-quot added-quot )
: args?dims ( type quot -- main-quot added-quot ) : args?dims ( type quot -- main-quot added-quot )

View File

@ -7,11 +7,11 @@ effects assocs combinators lexer strings.parser alien.parser
fry vocabs.parser words.constant alien.libraries ; fry vocabs.parser words.constant alien.libraries ;
IN: alien.syntax IN: alien.syntax
SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ; SYNTAX: DLL" lexer get skip-blank parse-string dlopen suffix! ;
SYNTAX: ALIEN: 16 scan-base <alien> parsed ; SYNTAX: ALIEN: 16 scan-base <alien> suffix! ;
SYNTAX: BAD-ALIEN <bad-alien> parsed ; SYNTAX: BAD-ALIEN <bad-alien> suffix! ;
SYNTAX: LIBRARY: scan "c-library" set ; SYNTAX: LIBRARY: scan "c-library" set ;

View File

@ -7,4 +7,4 @@ SYNTAX: HEX{
"}" parse-tokens "" join "}" parse-tokens "" join
[ blank? not ] filter [ blank? not ] filter
2 group [ hex> ] B{ } map-as 2 group [ hex> ] B{ } map-as
parsed ; suffix! ;

View File

@ -365,10 +365,10 @@ SYNTAX: UNION-STRUCT:
parse-struct-definition define-union-struct-class ; parse-struct-definition define-union-struct-class ;
SYNTAX: S{ SYNTAX: S{
scan-word dup struct-slots parse-tuple-literal-slots parsed ; scan-word dup struct-slots parse-tuple-literal-slots suffix! ;
SYNTAX: S@ SYNTAX: S@
scan-word scan-object swap memory>struct parsed ; scan-word scan-object swap memory>struct suffix! ;
! functor support ! functor support
@ -389,7 +389,7 @@ SYNTAX: S@
PRIVATE> PRIVATE>
FUNCTOR-SYNTAX: STRUCT: FUNCTOR-SYNTAX: STRUCT:
scan-param parsed scan-param suffix!
[ 8 <vector> ] over push-all [ 8 <vector> ] over push-all
[ parse-struct-slots` ] [ ] while [ parse-struct-slots` ] [ ] while
[ >array define-struct-class ] over push-all ; [ >array define-struct-class ] over push-all ;

View File

@ -14,14 +14,14 @@ SYMBOL: sent-messages
: remember-send ( selector -- ) : remember-send ( selector -- )
sent-messages (remember-send) ; sent-messages (remember-send) ;
SYNTAX: -> scan dup remember-send parsed \ send parsed ; SYNTAX: -> scan dup remember-send suffix! \ send suffix! ;
SYMBOL: super-sent-messages SYMBOL: super-sent-messages
: remember-super-send ( selector -- ) : remember-super-send ( selector -- )
super-sent-messages (remember-send) ; super-sent-messages (remember-send) ;
SYNTAX: SUPER-> scan dup remember-super-send parsed \ super-send parsed ; SYNTAX: SUPER-> scan dup remember-super-send suffix! \ super-send suffix! ;
SYMBOL: frameworks SYMBOL: frameworks

View File

@ -30,4 +30,4 @@ ERROR: no-such-color name ;
: named-color ( name -- color ) : named-color ( name -- color )
dup colors at [ ] [ no-such-color ] ?if ; dup colors at [ ] [ no-such-color ] ?if ;
SYNTAX: COLOR: scan named-color parsed ; SYNTAX: COLOR: scan named-color suffix! ;

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008, 2009 Slava Pestov. ! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors namespaces kernel parser assocs ; USING: accessors namespaces kernel parser assocs sequences ;
IN: compiler.cfg.registers IN: compiler.cfg.registers
! Virtual registers, used by CFG and machine IRs, are just integers ! Virtual registers, used by CFG and machine IRs, are just integers
@ -42,5 +42,5 @@ C: <ds-loc> ds-loc
TUPLE: rs-loc < loc ; TUPLE: rs-loc < loc ;
C: <rs-loc> rs-loc C: <rs-loc> rs-loc
SYNTAX: D scan-word <ds-loc> parsed ; SYNTAX: D scan-word <ds-loc> suffix! ;
SYNTAX: R scan-word <rs-loc> parsed ; SYNTAX: R scan-word <rs-loc> suffix! ;

View File

@ -1,10 +1,10 @@
! Copyright (C) 2007, 2008 Slava Pestov. ! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: parser layouts system kernel ; USING: parser layouts system kernel sequences ;
IN: bootstrap.ppc IN: bootstrap.ppc
: c-area-size ( -- n ) 10 bootstrap-cells ; : c-area-size ( -- n ) 10 bootstrap-cells ;
: lr-save ( -- n ) bootstrap-cell ; : lr-save ( -- n ) bootstrap-cell ;
<< "vocab:cpu/ppc/bootstrap.factor" parse-file parsed >> << "vocab:cpu/ppc/bootstrap.factor" parse-file suffix! >>
call call

View File

@ -1,10 +1,10 @@
! Copyright (C) 2007, 2008 Slava Pestov. ! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: parser layouts system kernel ; USING: parser layouts system kernel sequences ;
IN: bootstrap.ppc IN: bootstrap.ppc
: c-area-size ( -- n ) 14 bootstrap-cells ; : c-area-size ( -- n ) 14 bootstrap-cells ;
: lr-save ( -- n ) 2 bootstrap-cells ; : lr-save ( -- n ) 2 bootstrap-cells ;
<< "vocab:cpu/ppc/bootstrap.factor" parse-file parsed >> << "vocab:cpu/ppc/bootstrap.factor" parse-file suffix! >>
call call

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: bootstrap.image.private kernel namespaces system USING: bootstrap.image.private kernel namespaces system
cpu.x86.assembler cpu.x86.assembler.operands layouts cpu.x86.assembler cpu.x86.assembler.operands layouts
vocabs parser compiler.constants ; vocabs parser compiler.constants sequences ;
IN: bootstrap.x86 IN: bootstrap.x86
4 \ cell set 4 \ cell set
@ -35,5 +35,5 @@ IN: bootstrap.x86
0 JMP rc-relative rt-primitive jit-rel 0 JMP rc-relative rt-primitive jit-rel
] jit-primitive jit-define ] jit-primitive jit-define
<< "vocab:cpu/x86/bootstrap.factor" parse-file parsed >> << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>
call call

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: bootstrap.image.private kernel namespaces system USING: bootstrap.image.private kernel namespaces system
layouts vocabs parser compiler.constants math layouts vocabs parser compiler.constants math
cpu.x86.assembler cpu.x86.assembler.operands ; cpu.x86.assembler cpu.x86.assembler.operands sequences ;
IN: bootstrap.x86 IN: bootstrap.x86
8 \ cell set 8 \ cell set
@ -35,5 +35,5 @@ IN: bootstrap.x86
temp1 JMP temp1 JMP
] jit-primitive jit-define ] jit-primitive jit-define
<< "vocab:cpu/x86/bootstrap.factor" parse-file parsed >> << "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>
call call

View File

@ -1,12 +1,13 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: bootstrap.image.private kernel namespaces system USING: bootstrap.image.private cpu.x86.assembler
cpu.x86.assembler cpu.x86.assembler.operands layouts vocabs parser ; cpu.x86.assembler.operands kernel layouts namespaces parser
sequences system vocabs ;
IN: bootstrap.x86 IN: bootstrap.x86
: stack-frame-size ( -- n ) 4 bootstrap-cells ; : stack-frame-size ( -- n ) 4 bootstrap-cells ;
: arg1 ( -- reg ) RDI ; : arg1 ( -- reg ) RDI ;
: arg2 ( -- reg ) RSI ; : arg2 ( -- reg ) RSI ;
<< "vocab:cpu/x86/64/bootstrap.factor" parse-file parsed >> << "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >>
call call

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: bootstrap.image.private kernel namespaces system USING: bootstrap.image.private kernel namespaces system
layouts vocabs parser cpu.x86.assembler layouts vocabs sequences cpu.x86.assembler
cpu.x86.assembler.operands ; cpu.x86.assembler.operands ;
IN: bootstrap.x86 IN: bootstrap.x86
@ -9,5 +9,5 @@ IN: bootstrap.x86
: arg1 ( -- reg ) RCX ; : arg1 ( -- reg ) RCX ;
: arg2 ( -- reg ) RDX ; : arg2 ( -- reg ) RDX ;
<< "vocab:cpu/x86/64/bootstrap.factor" parse-file parsed >> << "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >>
call call

View File

@ -1,9 +1,9 @@
! Copyright (C) 2007, 2009 Slava Pestov. ! Copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: bootstrap.image.private kernel kernel.private namespaces system USING: bootstrap.image.private compiler.constants
layouts compiler.units math math.private compiler.constants vocabs compiler.units cpu.x86.assembler cpu.x86.assembler.operands
slots.private words locals.backend make sequences combinators arrays kernel kernel.private layouts locals.backend make math
cpu.x86.assembler cpu.x86.assembler.operands ; math.private namespaces sequences slots.private vocabs ;
IN: bootstrap.x86 IN: bootstrap.x86
big-endian off big-endian off

View File

@ -42,85 +42,85 @@ M: fake-call-next-method (fake-quotations>)
M: object (fake-quotations>) , ; M: object (fake-quotations>) , ;
: parse-definition* ( accum -- accum ) : parse-definition* ( accum -- accum )
parse-definition >fake-quotations parsed parse-definition >fake-quotations suffix!
[ fake-quotations> first ] over push-all ; [ fake-quotations> first ] over push-all ;
: parse-declared* ( accum -- accum ) : parse-declared* ( accum -- accum )
complete-effect complete-effect
[ parse-definition* ] dip [ parse-definition* ] dip
parsed ; suffix! ;
FUNCTOR-SYNTAX: TUPLE: FUNCTOR-SYNTAX: TUPLE:
scan-param parsed scan-param suffix!
scan { scan {
{ ";" [ tuple parsed f parsed ] } { ";" [ tuple suffix! f suffix! ] }
{ "<" [ scan-param parsed [ parse-tuple-slots ] { } make parsed ] } { "<" [ scan-param suffix! [ parse-tuple-slots ] { } make suffix! ] }
[ [
[ tuple parsed ] dip [ tuple suffix! ] dip
[ parse-slot-name [ parse-tuple-slots ] when ] { } [ parse-slot-name [ parse-tuple-slots ] when ] { }
make parsed make suffix!
] ]
} case } case
\ define-tuple-class parsed ; \ define-tuple-class suffix! ;
FUNCTOR-SYNTAX: SINGLETON: FUNCTOR-SYNTAX: SINGLETON:
scan-param parsed scan-param suffix!
\ define-singleton-class parsed ; \ define-singleton-class suffix! ;
FUNCTOR-SYNTAX: MIXIN: FUNCTOR-SYNTAX: MIXIN:
scan-param parsed scan-param suffix!
\ define-mixin-class parsed ; \ define-mixin-class suffix! ;
FUNCTOR-SYNTAX: M: FUNCTOR-SYNTAX: M:
scan-param parsed scan-param suffix!
scan-param parsed scan-param suffix!
[ create-method-in dup method-body set ] over push-all [ create-method-in dup method-body set ] over push-all
parse-definition* parse-definition*
\ define* parsed ; \ define* suffix! ;
FUNCTOR-SYNTAX: C: FUNCTOR-SYNTAX: C:
scan-param parsed scan-param suffix!
scan-param parsed scan-param suffix!
complete-effect complete-effect
[ [ [ boa ] curry ] over push-all ] dip parsed [ [ [ boa ] curry ] over push-all ] dip suffix!
\ define-declared* parsed ; \ define-declared* suffix! ;
FUNCTOR-SYNTAX: : FUNCTOR-SYNTAX: :
scan-param parsed scan-param suffix!
parse-declared* parse-declared*
\ define-declared* parsed ; \ define-declared* suffix! ;
FUNCTOR-SYNTAX: SYMBOL: FUNCTOR-SYNTAX: SYMBOL:
scan-param parsed scan-param suffix!
\ define-symbol parsed ; \ define-symbol suffix! ;
FUNCTOR-SYNTAX: SYNTAX: FUNCTOR-SYNTAX: SYNTAX:
scan-param parsed scan-param suffix!
parse-definition* parse-definition*
\ define-syntax parsed ; \ define-syntax suffix! ;
FUNCTOR-SYNTAX: INSTANCE: FUNCTOR-SYNTAX: INSTANCE:
scan-param parsed scan-param suffix!
scan-param parsed scan-param suffix!
\ add-mixin-instance parsed ; \ add-mixin-instance suffix! ;
FUNCTOR-SYNTAX: GENERIC: FUNCTOR-SYNTAX: GENERIC:
scan-param parsed scan-param suffix!
complete-effect parsed complete-effect suffix!
\ define-simple-generic* parsed ; \ define-simple-generic* suffix! ;
FUNCTOR-SYNTAX: MACRO: FUNCTOR-SYNTAX: MACRO:
scan-param parsed scan-param suffix!
parse-declared* parse-declared*
\ define-macro parsed ; \ define-macro suffix! ;
FUNCTOR-SYNTAX: inline [ word make-inline ] over push-all ; FUNCTOR-SYNTAX: inline [ word make-inline ] over push-all ;
FUNCTOR-SYNTAX: call-next-method T{ fake-call-next-method } parsed ; FUNCTOR-SYNTAX: call-next-method T{ fake-call-next-method } suffix! ;
: (INTERPOLATE) ( accum quot -- accum ) : (INTERPOLATE) ( accum quot -- accum )
[ scan interpolate-locals ] dip [ scan interpolate-locals ] dip
'[ _ with-string-writer @ ] parsed ; '[ _ with-string-writer @ ] suffix! ;
PRIVATE> PRIVATE>

View File

@ -31,14 +31,14 @@ DEFER: <% delimiter
: found-<% ( accum lexer col -- accum ) : found-<% ( accum lexer col -- accum )
[ [
over line-text>> over line-text>>
[ column>> ] 2dip subseq parsed [ column>> ] 2dip subseq suffix!
\ write parsed \ write suffix!
] 2keep 2 + >>column drop ; ] 2keep 2 + >>column drop ;
: still-looking ( accum lexer -- accum ) : still-looking ( accum lexer -- accum )
[ [
[ line-text>> ] [ column>> ] bi tail [ line-text>> ] [ column>> ] bi tail
parsed \ print parsed suffix! \ print suffix!
] keep next-line ; ] keep next-line ;
: parse-%> ( accum lexer -- accum ) : parse-%> ( accum lexer -- accum )

View File

@ -31,7 +31,7 @@ M: iso2022 <encoder>
M: iso2022 <decoder> M: iso2022 <decoder>
make-iso-coder <decoder> ; make-iso-coder <decoder> ;
<< SYNTAX: ESC HEX: 16 parsed ; >> << SYNTAX: ESC HEX: 16 suffix! ; >>
CONSTANT: switch-ascii B{ ESC CHAR: ( CHAR: B } CONSTANT: switch-ascii B{ ESC CHAR: ( CHAR: B }
CONSTANT: switch-jis201 B{ ESC CHAR: ( CHAR: J } CONSTANT: switch-jis201 B{ ESC CHAR: ( CHAR: J }

View File

@ -7,7 +7,7 @@ IN: locals
SYNTAX: :> SYNTAX: :>
scan locals get [ :>-outside-lambda-error ] unless* scan locals get [ :>-outside-lambda-error ] unless*
[ make-local ] bind <def> parsed ; [ make-local ] bind <def> suffix! ;
SYNTAX: [| parse-lambda over push-all ; SYNTAX: [| parse-lambda over push-all ;

View File

@ -8,7 +8,7 @@ TUPLE: rect { loc initial: { 0 0 } } { dim initial: { 0 0 } } ;
: <rect> ( loc dim -- rect ) rect boa ; inline : <rect> ( loc dim -- rect ) rect boa ; inline
SYNTAX: RECT: scan-object scan-object <rect> parsed ; SYNTAX: RECT: scan-object scan-object <rect> suffix! ;
: <zero-rect> ( -- rect ) rect new ; inline : <zero-rect> ( -- rect ) rect new ; inline

View File

@ -81,10 +81,10 @@ SYNTAX: HEREDOC:
lexer get skip-blank lexer get skip-blank
rest-of-line rest-of-line
lexer get next-line lexer get next-line
parse-til-line-begins parsed ; parse-til-line-begins suffix! ;
SYNTAX: DELIMITED: SYNTAX: DELIMITED:
lexer get skip-blank lexer get skip-blank
rest-of-line rest-of-line
lexer get next-line lexer get next-line
0 (parse-multiline-string) parsed ; 0 (parse-multiline-string) suffix! ;

View File

@ -19,5 +19,5 @@ SYMBOL: G-world
<< \ gl-break t "break?" set-word-prop >> << \ gl-break t "break?" set-word-prop >>
SYNTAX: GB SYNTAX: GB
\ gl-break parsed ; \ gl-break suffix! ;

View File

@ -547,12 +547,12 @@ PRIVATE>
SYNTAX: <EBNF SYNTAX: <EBNF
"EBNF>" "EBNF>"
reset-tokenizer parse-multiline-string parse-ebnf main swap at reset-tokenizer parse-multiline-string parse-ebnf main swap at
parsed reset-tokenizer ; suffix! reset-tokenizer ;
SYNTAX: [EBNF SYNTAX: [EBNF
"EBNF]" "EBNF]"
reset-tokenizer parse-multiline-string ebnf>quot nip reset-tokenizer parse-multiline-string ebnf>quot nip
parsed \ call parsed reset-tokenizer ; suffix! \ call suffix! reset-tokenizer ;
SYNTAX: EBNF: SYNTAX: EBNF:
reset-tokenizer CREATE-WORD dup ";EBNF" parse-multiline-string reset-tokenizer CREATE-WORD dup ";EBNF" parse-multiline-string

View File

@ -1,8 +1,8 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: layouts kernel parser math ; USING: layouts kernel parser math sequences ;
IN: persistent.hashtables.config IN: persistent.hashtables.config
: radix-bits ( -- n ) << cell 4 = 4 5 ? parsed >> ; foldable : radix-bits ( -- n ) << cell 4 = 4 5 ? suffix! >> ; foldable
: radix-mask ( -- n ) radix-bits 2^ 1 - ; foldable : radix-mask ( -- n ) radix-bits 2^ 1 - ; foldable
: full-bitmap-mask ( -- n ) radix-bits 2^ 2^ 1 - ; inline : full-bitmap-mask ( -- n ) radix-bits 2^ 2^ 1 - ; inline

View File

@ -121,7 +121,7 @@ ARTICLE: "prettyprint-literal" "Literal prettyprinting protocol"
" scan-word \\ * assert=" " scan-word \\ * assert="
" scan-word" " scan-word"
" scan-word \\ ] assert=" " scan-word \\ ] assert="
" <rect> parsed ;" " <rect> suffix! ;"
} }
"An example literal might be:" "An example literal might be:"
{ $code "RECT[ 100 * 200 ]" } { $code "RECT[ 100 * 200 ]" }

View File

@ -200,7 +200,7 @@ PRIVATE>
: parsing-regexp ( accum end -- accum ) : parsing-regexp ( accum end -- accum )
lexer get [ take-until ] [ parse-noblank-token ] bi lexer get [ take-until ] [ parse-noblank-token ] bi
<optioned-regexp> compile-next-match parsed ; <optioned-regexp> compile-next-match suffix! ;
PRIVATE> PRIVATE>

View File

@ -69,4 +69,4 @@ ROMAN-OP: *
ROMAN-OP: /i ROMAN-OP: /i
ROMAN-OP: /mod ROMAN-OP: /mod
SYNTAX: ROMAN: scan roman> parsed ; SYNTAX: ROMAN: scan roman> suffix! ;

View File

@ -50,7 +50,7 @@ CONSTANT: objects
B{ 50 13 55 64 1 } B{ 50 13 55 64 1 }
?{ t f t f f t f } ?{ t f t f f t f }
double-array{ 1.0 3.0 4.0 1.0 2.35 0.33 } double-array{ 1.0 3.0 4.0 1.0 2.35 0.33 }
<< 1 [ 2 ] curry parsed >> << 1 [ 2 ] curry suffix! >>
{ { "a" "bc" } { "de" "fg" } } { { "a" "bc" } { "de" "fg" } }
H{ { "a" "bc" } { "de" "fg" } } H{ { "a" "bc" } { "de" "fg" } }
} }

View File

@ -20,7 +20,7 @@ MACRO: shuffle-effect ( effect -- )
] [ ] make ; ] [ ] make ;
SYNTAX: shuffle( SYNTAX: shuffle(
")" parse-effect parsed \ shuffle-effect parsed ; ")" parse-effect suffix! \ shuffle-effect suffix! ;
: 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline : 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline

View File

@ -105,7 +105,7 @@ M: A pprint-delims drop \ A{ \ } ;
M: A >pprint-sequence ; M: A >pprint-sequence ;
SYNTAX: A{ \ } [ >A ] parse-literal ; SYNTAX: A{ \ } [ >A ] parse-literal ;
SYNTAX: A@ scan-object scan-object <direct-A> parsed ; SYNTAX: A@ scan-object scan-object <direct-A> suffix! ;
INSTANCE: A specialized-array INSTANCE: A specialized-array

View File

@ -96,9 +96,9 @@ MACRO: <experiment> ( word -- )
] [ drop ] if ; inline ] [ drop ] if ; inline
: parse-test ( accum word -- accum ) : parse-test ( accum word -- accum )
literalize parsed literalize suffix!
lexer get line>> parsed lexer get line>> suffix!
\ experiment parsed ; inline \ experiment suffix! ; inline
<< <<

View File

@ -167,4 +167,4 @@ SYMBOL: +stopped+
! For convenience ! For convenience
IN: syntax IN: syntax
SYNTAX: B \ break parsed ; SYNTAX: B \ break suffix! ;

View File

@ -181,7 +181,7 @@ PRIVATE>
clone dup protocol>> '[ _ protocol-port or ] change-port ; clone dup protocol>> '[ _ protocol-port or ] change-port ;
! Literal syntax ! Literal syntax
SYNTAX: URL" lexer get skip-blank parse-string >url parsed ; SYNTAX: URL" lexer get skip-blank parse-string >url suffix! ;
USING: vocabs vocabs.loader ; USING: vocabs vocabs.loader ;

View File

@ -44,8 +44,8 @@ M: value-word definition drop f ;
def>> first (>>obj) ; def>> first (>>obj) ;
SYNTAX: to: SYNTAX: to:
scan-word literalize parsed scan-word literalize suffix!
\ set-value parsed ; \ set-value suffix! ;
: get-value ( word -- value ) : get-value ( word -- value )
def>> first obj>> ; def>> first obj>> ;

View File

@ -101,7 +101,7 @@ SYNTAX: COM-INTERFACE:
dup save-com-interface-definition dup save-com-interface-definition
define-words-for-com-interface ; define-words-for-com-interface ;
SYNTAX: GUID: scan string>guid parsed ; SYNTAX: GUID: scan string>guid suffix! ;
USING: vocabs vocabs.loader ; USING: vocabs vocabs.loader ;

View File

@ -156,16 +156,16 @@ MACRO: interpolate-xml ( xml -- quot )
: collect ( accum variables -- accum ? ) : collect ( accum variables -- accum ? )
{ {
{ [ dup empty? ] [ drop f ] } ! Just a literal { [ dup empty? ] [ drop f ] } ! Just a literal
{ [ dup [ ] all? ] [ >search-hash parsed t ] } ! locals { [ dup [ ] all? ] [ >search-hash suffix! t ] } ! locals
{ [ dup [ not ] all? ] [ length parsed \ nenum parsed t ] } ! fry { [ dup [ not ] all? ] [ length suffix! \ nenum suffix! t ] } ! fry
[ drop "XML interpolation contains both fry and locals" throw ] ! mixed [ drop "XML interpolation contains both fry and locals" throw ] ! mixed
} cond ; } cond ;
: parse-def ( accum delimiter quot -- accum ) : parse-def ( accum delimiter quot -- accum )
[ parse-multiline-string [ blank? ] trim ] dip call [ parse-multiline-string [ blank? ] trim ] dip call
[ extract-variables collect ] keep swap [ extract-variables collect ] keep swap
[ number<-> parsed ] dip [ number<-> suffix! ] dip
[ \ interpolate-xml parsed ] when ; inline [ \ interpolate-xml suffix! ] when ; inline
PRIVATE> PRIVATE>

View File

@ -66,7 +66,7 @@ $nl
$nl $nl
"Parsing words can read input, add word definitions to the dictionary, and do anything an ordinary word can." "Parsing words can read input, add word definitions to the dictionary, and do anything an ordinary word can."
$nl $nl
"Because of the stack restriction, parsing words cannot pass data to other words by leaving values on the stack; instead, use " { $link parsed } " to add the data to the parse tree so that it can be evaluated later." "Because of the stack restriction, parsing words cannot pass data to other words by leaving values on the stack; instead, use " { $link suffix! } " to add the data to the parse tree so that it can be evaluated later."
$nl $nl
"Parsing words cannot be called from the same source file where they are defined, because new definitions are only compiled at the end of the source file. An attempt to use a parsing word in its own source file raises an error:" "Parsing words cannot be called from the same source file where they are defined, because new definitions are only compiled at the end of the source file. An attempt to use a parsing word in its own source file raises an error:"
{ $subsections staging-violation } { $subsections staging-violation }
@ -172,11 +172,6 @@ $parsing-note ;
{ parse-tokens (parse-until) parse-until } related-words { parse-tokens (parse-until) parse-until } related-words
HELP: parsed
{ $values { "accum" vector } { "obj" object } }
{ $description "Convenience word for parsing words. It behaves exactly the same as " { $link push } ", except the accumulator remains on the stack." }
$parsing-note ;
HELP: (parse-lines) HELP: (parse-lines)
{ $values { "lexer" lexer } { "quot" "a new " { $link quotation } } } { $values { "lexer" lexer } { "quot" "a new " { $link quotation } } }
{ $description "Parses Factor source code using a custom lexer. The vocabulary search path is taken from the current scope." } { $description "Parses Factor source code using a custom lexer. The vocabulary search path is taken from the current scope." }

View File

@ -79,8 +79,6 @@ HOOK: parse-quotation quotation-parser ( -- quot )
M: f parse-quotation \ ] parse-until >quotation ; M: f parse-quotation \ ] parse-until >quotation ;
: parsed ( accum obj -- accum ) over push ;
: (parse-lines) ( lexer -- quot ) : (parse-lines) ( lexer -- quot )
[ f parse-until >quotation ] with-lexer ; [ f parse-until >quotation ] with-lexer ;
@ -88,7 +86,7 @@ M: f parse-quotation \ ] parse-until >quotation ;
lexer-factory get call( lines -- lexer ) (parse-lines) ; lexer-factory get call( lines -- lexer ) (parse-lines) ;
: parse-literal ( accum end quot -- accum ) : parse-literal ( accum end quot -- accum )
[ parse-until ] dip call parsed ; inline [ parse-until ] dip call suffix! ; inline
: parse-definition ( -- quot ) : parse-definition ( -- quot )
\ ; parse-until >quotation ; \ ; parse-until >quotation ;
@ -104,7 +102,7 @@ ERROR: bad-number ;
scan swap base> [ bad-number ] unless* ; scan swap base> [ bad-number ] unless* ;
: parse-base ( parsed base -- parsed ) : parse-base ( parsed base -- parsed )
scan-base parsed ; scan-base suffix! ;
SYMBOL: bootstrap-syntax SYMBOL: bootstrap-syntax

View File

@ -650,6 +650,10 @@ PRIVATE>
[ 0 swap copy ] keep [ 0 swap copy ] keep
] new-like ; ] new-like ;
: suffix! ( seq elt -- seq ) over push ;
: append! ( seq1 seq2 -- seq1 ) over push-all ;
: last ( seq -- elt ) [ length 1 - ] [ nth ] bi ; : last ( seq -- elt ) [ length 1 - ] [ nth ] bi ;
: set-last ( elt seq -- ) [ length 1 - ] keep set-nth ; : set-last ( elt seq -- ) [ length 1 - ] keep set-nth ;

View File

@ -73,9 +73,9 @@ IN: bootstrap.syntax
"OCT:" [ 8 parse-base ] define-core-syntax "OCT:" [ 8 parse-base ] define-core-syntax
"BIN:" [ 2 parse-base ] define-core-syntax "BIN:" [ 2 parse-base ] define-core-syntax
"NAN:" [ 16 scan-base <fp-nan> parsed ] define-core-syntax "NAN:" [ 16 scan-base <fp-nan> suffix! ] define-core-syntax
"f" [ f parsed ] define-core-syntax "f" [ f suffix! ] define-core-syntax
"t" "syntax" lookup define-singleton-class "t" "syntax" lookup define-singleton-class
"CHAR:" [ "CHAR:" [
@ -83,31 +83,31 @@ IN: bootstrap.syntax
{ [ dup length 1 = ] [ first ] } { [ dup length 1 = ] [ first ] }
{ [ "\\" ?head ] [ next-escape >string "" assert= ] } { [ "\\" ?head ] [ next-escape >string "" assert= ] }
[ name>char-hook get call( name -- char ) ] [ name>char-hook get call( name -- char ) ]
} cond parsed } cond suffix!
] define-core-syntax ] define-core-syntax
"\"" [ parse-multiline-string parsed ] define-core-syntax "\"" [ parse-multiline-string suffix! ] define-core-syntax
"SBUF\"" [ "SBUF\"" [
lexer get skip-blank parse-string >sbuf parsed lexer get skip-blank parse-string >sbuf suffix!
] define-core-syntax ] define-core-syntax
"P\"" [ "P\"" [
lexer get skip-blank parse-string <pathname> parsed lexer get skip-blank parse-string <pathname> suffix!
] define-core-syntax ] define-core-syntax
"[" [ parse-quotation parsed ] define-core-syntax "[" [ parse-quotation suffix! ] define-core-syntax
"{" [ \ } [ >array ] parse-literal ] define-core-syntax "{" [ \ } [ >array ] parse-literal ] define-core-syntax
"V{" [ \ } [ >vector ] parse-literal ] define-core-syntax "V{" [ \ } [ >vector ] parse-literal ] define-core-syntax
"B{" [ \ } [ >byte-array ] parse-literal ] define-core-syntax "B{" [ \ } [ >byte-array ] parse-literal ] define-core-syntax
"BV{" [ \ } [ >byte-vector ] parse-literal ] define-core-syntax "BV{" [ \ } [ >byte-vector ] parse-literal ] define-core-syntax
"H{" [ \ } [ >hashtable ] parse-literal ] define-core-syntax "H{" [ \ } [ >hashtable ] parse-literal ] define-core-syntax
"T{" [ parse-tuple-literal parsed ] define-core-syntax "T{" [ parse-tuple-literal suffix! ] define-core-syntax
"W{" [ \ } [ first <wrapper> ] parse-literal ] define-core-syntax "W{" [ \ } [ first <wrapper> ] parse-literal ] define-core-syntax
"POSTPONE:" [ scan-word parsed ] define-core-syntax "POSTPONE:" [ scan-word suffix! ] define-core-syntax
"\\" [ scan-word <wrapper> parsed ] define-core-syntax "\\" [ scan-word <wrapper> suffix! ] define-core-syntax
"M\\" [ scan-word scan-word method <wrapper> parsed ] define-core-syntax "M\\" [ scan-word scan-word method <wrapper> suffix! ] define-core-syntax
"inline" [ word make-inline ] define-core-syntax "inline" [ word make-inline ] define-core-syntax
"recursive" [ word make-recursive ] define-core-syntax "recursive" [ word make-recursive ] define-core-syntax
"foldable" [ word make-foldable ] define-core-syntax "foldable" [ word make-foldable ] define-core-syntax
@ -227,7 +227,7 @@ IN: bootstrap.syntax
] define-core-syntax ] define-core-syntax
"((" [ "((" [
"))" parse-effect parsed "))" parse-effect suffix!
] define-core-syntax ] define-core-syntax
"MAIN:" [ scan-word current-vocab (>>main) ] define-core-syntax "MAIN:" [ scan-word current-vocab (>>main) ] define-core-syntax
@ -240,8 +240,8 @@ IN: bootstrap.syntax
"call-next-method" [ "call-next-method" [
current-method get [ current-method get [
literalize parsed literalize suffix!
\ (call-next-method) parsed \ (call-next-method) suffix!
] [ ] [
not-in-a-method-error not-in-a-method-error
] if* ] if*

View File

@ -118,14 +118,14 @@ MACRO: data-map! ( ins outs -- )
: parse-data-map-effect ( accum -- accum ) : parse-data-map-effect ( accum -- accum )
")" parse-effect ")" parse-effect
[ in>> [ (parse-c-type) ] map parsed ] [ in>> [ (parse-c-type) ] map suffix! ]
[ out>> [ (parse-c-type) ] map parsed ] bi ; [ out>> [ (parse-c-type) ] map suffix! ] bi ;
PRIVATE> PRIVATE>
SYNTAX: data-map( SYNTAX: data-map(
parse-data-map-effect \ data-map parsed ; parse-data-map-effect \ data-map suffix! ;
SYNTAX: data-map!( SYNTAX: data-map!(
parse-data-map-effect \ data-map! parsed ; parse-data-map-effect \ data-map! suffix! ;

View File

@ -7,7 +7,7 @@ IN: annotations
<< <<
: (parse-annotation) ( accum -- accum ) : (parse-annotation) ( accum -- accum )
lexer get [ line-text>> parsed ] [ next-line ] bi ; lexer get [ line-text>> suffix! ] [ next-line ] bi ;
: (non-annotation-usage) ( word -- usages ) : (non-annotation-usage) ( word -- usages )
smart-usage smart-usage
@ -24,7 +24,7 @@ NAMEs. DEFINES ${NAME}s.
WHERE WHERE
: (NAME) ( str -- ) drop ; inline : (NAME) ( str -- ) drop ; inline
SYNTAX: !NAME (parse-annotation) \ (NAME) parsed ; SYNTAX: !NAME (parse-annotation) \ (NAME) suffix! ;
: NAMEs ( -- usages ) : NAMEs ( -- usages )
\ (NAME) (non-annotation-usage) ; \ (NAME) (non-annotation-usage) ;

View File

@ -10,6 +10,6 @@ SYNTAX: get-psql-info <postgresql-db> get-info 5 firstn
[ >>username ] [ >>username ]
[ [ f ] [ ] if-empty >>password ] [ [ f ] [ ] if-empty >>password ]
[ >>database ] [ >>database ]
} spread parsed ; } spread suffix! ;
SYNTAX: get-sqlite-info get-info first <sqlite-db> parsed ; SYNTAX: get-sqlite-info get-info first <sqlite-db> suffix! ;

View File

@ -20,7 +20,7 @@ TUPLE: decimal { mantissa read-only } { exponent read-only } ;
: parse-decimal ( -- decimal ) scan string>decimal ; : parse-decimal ( -- decimal ) scan string>decimal ;
SYNTAX: D: parse-decimal parsed ; SYNTAX: D: parse-decimal suffix! ;
: decimal>ratio ( decimal -- ratio ) >decimal< 10^ * ; : decimal>ratio ( decimal -- ratio ) >decimal< 10^ * ;
: decimal>float ( decimal -- ratio ) decimal>ratio >float ; : decimal>float ( decimal -- ratio ) decimal>ratio >float ;

View File

@ -82,7 +82,7 @@ M: ast-function infix-codegen
PRIVATE> PRIVATE>
SYNTAX: [infix SYNTAX: [infix
"infix]" [infix-parse parsed \ call parsed ; "infix]" [infix-parse suffix! \ call suffix! ;
<PRIVATE <PRIVATE

View File

@ -242,4 +242,4 @@ Program = Type
;EBNF ;EBNF
SYNTAX: TYPE: ";" parse-multiline-string parse-type parsed ; SYNTAX: TYPE: ";" parse-multiline-string parse-type suffix! ;

View File

@ -30,4 +30,4 @@ ERROR: not-an-integer x ;
] keep length ] keep length
10^ / + swap [ neg ] when ; 10^ / + swap [ neg ] when ;
SYNTAX: DECIMAL: scan parse-decimal parsed ; SYNTAX: DECIMAL: scan parse-decimal suffix! ;

View File

@ -109,7 +109,7 @@ PRIVATE>
: morse> ( morse -- plain ) : morse> ( morse -- plain )
replace-underscores morse>sentence ; replace-underscores morse>sentence ;
SYNTAX: [MORSE "MORSE]" parse-multiline-string morse> parsed ; SYNTAX: [MORSE "MORSE]" parse-multiline-string morse> suffix! ;
<PRIVATE <PRIVATE

View File

@ -2,5 +2,5 @@
USING: arrays kernel parser sequences ; USING: arrays kernel parser sequences ;
IN: pair-rocket IN: pair-rocket
SYNTAX: => dup pop scan-object 2array parsed ; SYNTAX: => dup pop scan-object 2array suffix! ;

View File

@ -26,5 +26,5 @@ SYNTAX: STORED-TUPLE: parse-tuple-definition [ drop persistent ] dip [ remove-ty
: remove-tuples ( tuple -- ) [ delete-tuples ] w/db ; : remove-tuples ( tuple -- ) [ delete-tuples ] w/db ;
TUPLE: pattern value ; C: <pattern> pattern TUPLE: pattern value ; C: <pattern> pattern
SYNTAX: %" parse-string <pattern> parsed ; SYNTAX: %" parse-string <pattern> suffix! ;
M: pattern where value>> over column-name>> 0% " LIKE " 0% bind# ; M: pattern where value>> over column-name>> 0% " LIKE " 0% bind# ;

View File

@ -1,5 +1,5 @@
! (c)2009 Joe Groff bsd license ! (c)2009 Joe Groff bsd license
USING: lexer parser ; USING: lexer sequences parser ;
IN: qw IN: qw
SYNTAX: qw{ "}" parse-tokens parsed ; SYNTAX: qw{ "}" parse-tokens suffix! ;

View File

@ -99,7 +99,7 @@ TUPLE: slides < book ;
] with map ; ] with map ;
SYNTAX: STRIP-TEASE: SYNTAX: STRIP-TEASE:
parse-definition strip-tease [ parsed ] each ; parse-definition strip-tease [ suffix! ] each ;
\ slides H{ \ slides H{
{ T{ button-down } [ request-focus ] } { T{ button-down } [ request-focus ] }

View File

@ -66,4 +66,4 @@ SYNTAX: ADVISE: ! word adname location => word adname quot loc
scan-word scan scan-word parse-definition swap [ spin ] dip advise ; scan-word scan scan-word parse-definition swap [ spin ] dip advise ;
SYNTAX: UNADVISE: SYNTAX: UNADVISE:
scan-word parsed \ unadvise parsed ; scan-word suffix! \ unadvise suffix! ;