parsed -> suffix!, add append!
parent
37a87e85ab
commit
7ce4b746e5
|
@ -205,9 +205,6 @@ M: fortran-type (fortran-ret-type>c-type) (fortran-type>c-type) ;
|
|||
M: real-type (fortran-ret-type>c-type)
|
||||
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 )
|
||||
|
||||
: args?dims ( type quot -- main-quot added-quot )
|
||||
|
|
|
@ -7,11 +7,11 @@ effects assocs combinators lexer strings.parser alien.parser
|
|||
fry vocabs.parser words.constant alien.libraries ;
|
||||
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 ;
|
||||
|
||||
|
|
|
@ -7,4 +7,4 @@ SYNTAX: HEX{
|
|||
"}" parse-tokens "" join
|
||||
[ blank? not ] filter
|
||||
2 group [ hex> ] B{ } map-as
|
||||
parsed ;
|
||||
suffix! ;
|
||||
|
|
|
@ -365,10 +365,10 @@ SYNTAX: UNION-STRUCT:
|
|||
parse-struct-definition define-union-struct-class ;
|
||||
|
||||
SYNTAX: S{
|
||||
scan-word dup struct-slots parse-tuple-literal-slots parsed ;
|
||||
scan-word dup struct-slots parse-tuple-literal-slots suffix! ;
|
||||
|
||||
SYNTAX: S@
|
||||
scan-word scan-object swap memory>struct parsed ;
|
||||
scan-word scan-object swap memory>struct suffix! ;
|
||||
|
||||
! functor support
|
||||
|
||||
|
@ -389,7 +389,7 @@ SYNTAX: S@
|
|||
PRIVATE>
|
||||
|
||||
FUNCTOR-SYNTAX: STRUCT:
|
||||
scan-param parsed
|
||||
scan-param suffix!
|
||||
[ 8 <vector> ] over push-all
|
||||
[ parse-struct-slots` ] [ ] while
|
||||
[ >array define-struct-class ] over push-all ;
|
||||
|
|
|
@ -14,14 +14,14 @@ SYMBOL: sent-messages
|
|||
: remember-send ( selector -- )
|
||||
sent-messages (remember-send) ;
|
||||
|
||||
SYNTAX: -> scan dup remember-send parsed \ send parsed ;
|
||||
SYNTAX: -> scan 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 parsed \ super-send parsed ;
|
||||
SYNTAX: SUPER-> scan dup remember-super-send suffix! \ super-send suffix! ;
|
||||
|
||||
SYMBOL: frameworks
|
||||
|
||||
|
|
|
@ -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 parsed ;
|
||||
SYNTAX: COLOR: scan named-color suffix! ;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
! Copyright (C) 2008, 2009 Slava Pestov.
|
||||
! 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
|
||||
|
||||
! Virtual registers, used by CFG and machine IRs, are just integers
|
||||
|
@ -42,5 +42,5 @@ C: <ds-loc> ds-loc
|
|||
TUPLE: rs-loc < loc ;
|
||||
C: <rs-loc> rs-loc
|
||||
|
||||
SYNTAX: D scan-word <ds-loc> parsed ;
|
||||
SYNTAX: R scan-word <rs-loc> parsed ;
|
||||
SYNTAX: D scan-word <ds-loc> suffix! ;
|
||||
SYNTAX: R scan-word <rs-loc> suffix! ;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
! Copyright (C) 2007, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: parser layouts system kernel ;
|
||||
USING: parser layouts system kernel sequences ;
|
||||
IN: bootstrap.ppc
|
||||
|
||||
: c-area-size ( -- n ) 10 bootstrap-cells ;
|
||||
: lr-save ( -- n ) bootstrap-cell ;
|
||||
|
||||
<< "vocab:cpu/ppc/bootstrap.factor" parse-file parsed >>
|
||||
<< "vocab:cpu/ppc/bootstrap.factor" parse-file suffix! >>
|
||||
call
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
! Copyright (C) 2007, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: parser layouts system kernel ;
|
||||
USING: parser layouts system kernel sequences ;
|
||||
IN: bootstrap.ppc
|
||||
|
||||
: c-area-size ( -- n ) 14 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
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: bootstrap.image.private kernel namespaces system
|
||||
cpu.x86.assembler cpu.x86.assembler.operands layouts
|
||||
vocabs parser compiler.constants ;
|
||||
vocabs parser compiler.constants sequences ;
|
||||
IN: bootstrap.x86
|
||||
|
||||
4 \ cell set
|
||||
|
@ -35,5 +35,5 @@ IN: bootstrap.x86
|
|||
0 JMP rc-relative rt-primitive jit-rel
|
||||
] jit-primitive jit-define
|
||||
|
||||
<< "vocab:cpu/x86/bootstrap.factor" parse-file parsed >>
|
||||
<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>
|
||||
call
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: bootstrap.image.private kernel namespaces system
|
||||
layouts vocabs parser compiler.constants math
|
||||
cpu.x86.assembler cpu.x86.assembler.operands ;
|
||||
cpu.x86.assembler cpu.x86.assembler.operands sequences ;
|
||||
IN: bootstrap.x86
|
||||
|
||||
8 \ cell set
|
||||
|
@ -35,5 +35,5 @@ IN: bootstrap.x86
|
|||
temp1 JMP
|
||||
] jit-primitive jit-define
|
||||
|
||||
<< "vocab:cpu/x86/bootstrap.factor" parse-file parsed >>
|
||||
<< "vocab:cpu/x86/bootstrap.factor" parse-file suffix! >>
|
||||
call
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: bootstrap.image.private kernel namespaces system
|
||||
cpu.x86.assembler cpu.x86.assembler.operands layouts vocabs parser ;
|
||||
USING: bootstrap.image.private cpu.x86.assembler
|
||||
cpu.x86.assembler.operands kernel layouts namespaces parser
|
||||
sequences system vocabs ;
|
||||
IN: bootstrap.x86
|
||||
|
||||
: stack-frame-size ( -- n ) 4 bootstrap-cells ;
|
||||
: arg1 ( -- reg ) RDI ;
|
||||
: arg2 ( -- reg ) RSI ;
|
||||
|
||||
<< "vocab:cpu/x86/64/bootstrap.factor" parse-file parsed >>
|
||||
<< "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >>
|
||||
call
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: bootstrap.image.private kernel namespaces system
|
||||
layouts vocabs parser cpu.x86.assembler
|
||||
layouts vocabs sequences cpu.x86.assembler
|
||||
cpu.x86.assembler.operands ;
|
||||
IN: bootstrap.x86
|
||||
|
||||
|
@ -9,5 +9,5 @@ IN: bootstrap.x86
|
|||
: arg1 ( -- reg ) RCX ;
|
||||
: arg2 ( -- reg ) RDX ;
|
||||
|
||||
<< "vocab:cpu/x86/64/bootstrap.factor" parse-file parsed >>
|
||||
<< "vocab:cpu/x86/64/bootstrap.factor" parse-file suffix! >>
|
||||
call
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
! Copyright (C) 2007, 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: bootstrap.image.private kernel kernel.private namespaces system
|
||||
layouts compiler.units math math.private compiler.constants vocabs
|
||||
slots.private words locals.backend make sequences combinators arrays
|
||||
cpu.x86.assembler cpu.x86.assembler.operands ;
|
||||
USING: bootstrap.image.private compiler.constants
|
||||
compiler.units cpu.x86.assembler cpu.x86.assembler.operands
|
||||
kernel kernel.private layouts locals.backend make math
|
||||
math.private namespaces sequences slots.private vocabs ;
|
||||
IN: bootstrap.x86
|
||||
|
||||
big-endian off
|
||||
|
|
|
@ -42,85 +42,85 @@ M: fake-call-next-method (fake-quotations>)
|
|||
M: object (fake-quotations>) , ;
|
||||
|
||||
: parse-definition* ( accum -- accum )
|
||||
parse-definition >fake-quotations parsed
|
||||
parse-definition >fake-quotations suffix!
|
||||
[ fake-quotations> first ] over push-all ;
|
||||
|
||||
: parse-declared* ( accum -- accum )
|
||||
complete-effect
|
||||
[ parse-definition* ] dip
|
||||
parsed ;
|
||||
suffix! ;
|
||||
|
||||
FUNCTOR-SYNTAX: TUPLE:
|
||||
scan-param parsed
|
||||
scan-param suffix!
|
||||
scan {
|
||||
{ ";" [ tuple parsed f parsed ] }
|
||||
{ "<" [ scan-param parsed [ parse-tuple-slots ] { } make parsed ] }
|
||||
{ ";" [ tuple suffix! f suffix! ] }
|
||||
{ "<" [ scan-param suffix! [ parse-tuple-slots ] { } make suffix! ] }
|
||||
[
|
||||
[ tuple parsed ] dip
|
||||
[ tuple suffix! ] dip
|
||||
[ parse-slot-name [ parse-tuple-slots ] when ] { }
|
||||
make parsed
|
||||
make suffix!
|
||||
]
|
||||
} case
|
||||
\ define-tuple-class parsed ;
|
||||
\ define-tuple-class suffix! ;
|
||||
|
||||
FUNCTOR-SYNTAX: SINGLETON:
|
||||
scan-param parsed
|
||||
\ define-singleton-class parsed ;
|
||||
scan-param suffix!
|
||||
\ define-singleton-class suffix! ;
|
||||
|
||||
FUNCTOR-SYNTAX: MIXIN:
|
||||
scan-param parsed
|
||||
\ define-mixin-class parsed ;
|
||||
scan-param suffix!
|
||||
\ define-mixin-class suffix! ;
|
||||
|
||||
FUNCTOR-SYNTAX: M:
|
||||
scan-param parsed
|
||||
scan-param parsed
|
||||
scan-param suffix!
|
||||
scan-param suffix!
|
||||
[ create-method-in dup method-body set ] over push-all
|
||||
parse-definition*
|
||||
\ define* parsed ;
|
||||
\ define* suffix! ;
|
||||
|
||||
FUNCTOR-SYNTAX: C:
|
||||
scan-param parsed
|
||||
scan-param parsed
|
||||
scan-param suffix!
|
||||
scan-param suffix!
|
||||
complete-effect
|
||||
[ [ [ boa ] curry ] over push-all ] dip parsed
|
||||
\ define-declared* parsed ;
|
||||
[ [ [ boa ] curry ] over push-all ] dip suffix!
|
||||
\ define-declared* suffix! ;
|
||||
|
||||
FUNCTOR-SYNTAX: :
|
||||
scan-param parsed
|
||||
scan-param suffix!
|
||||
parse-declared*
|
||||
\ define-declared* parsed ;
|
||||
\ define-declared* suffix! ;
|
||||
|
||||
FUNCTOR-SYNTAX: SYMBOL:
|
||||
scan-param parsed
|
||||
\ define-symbol parsed ;
|
||||
scan-param suffix!
|
||||
\ define-symbol suffix! ;
|
||||
|
||||
FUNCTOR-SYNTAX: SYNTAX:
|
||||
scan-param parsed
|
||||
scan-param suffix!
|
||||
parse-definition*
|
||||
\ define-syntax parsed ;
|
||||
\ define-syntax suffix! ;
|
||||
|
||||
FUNCTOR-SYNTAX: INSTANCE:
|
||||
scan-param parsed
|
||||
scan-param parsed
|
||||
\ add-mixin-instance parsed ;
|
||||
scan-param suffix!
|
||||
scan-param suffix!
|
||||
\ add-mixin-instance suffix! ;
|
||||
|
||||
FUNCTOR-SYNTAX: GENERIC:
|
||||
scan-param parsed
|
||||
complete-effect parsed
|
||||
\ define-simple-generic* parsed ;
|
||||
scan-param suffix!
|
||||
complete-effect suffix!
|
||||
\ define-simple-generic* suffix! ;
|
||||
|
||||
FUNCTOR-SYNTAX: MACRO:
|
||||
scan-param parsed
|
||||
scan-param suffix!
|
||||
parse-declared*
|
||||
\ define-macro parsed ;
|
||||
\ define-macro suffix! ;
|
||||
|
||||
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 )
|
||||
[ scan interpolate-locals ] dip
|
||||
'[ _ with-string-writer @ ] parsed ;
|
||||
'[ _ with-string-writer @ ] suffix! ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
|
|
|
@ -31,14 +31,14 @@ DEFER: <% delimiter
|
|||
: found-<% ( accum lexer col -- accum )
|
||||
[
|
||||
over line-text>>
|
||||
[ column>> ] 2dip subseq parsed
|
||||
\ write parsed
|
||||
[ column>> ] 2dip subseq suffix!
|
||||
\ write suffix!
|
||||
] 2keep 2 + >>column drop ;
|
||||
|
||||
: still-looking ( accum lexer -- accum )
|
||||
[
|
||||
[ line-text>> ] [ column>> ] bi tail
|
||||
parsed \ print parsed
|
||||
suffix! \ print suffix!
|
||||
] keep next-line ;
|
||||
|
||||
: parse-%> ( accum lexer -- accum )
|
||||
|
|
|
@ -31,7 +31,7 @@ M: iso2022 <encoder>
|
|||
M: iso2022 <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-jis201 B{ ESC CHAR: ( CHAR: J }
|
||||
|
|
|
@ -7,7 +7,7 @@ IN: locals
|
|||
|
||||
SYNTAX: :>
|
||||
scan locals get [ :>-outside-lambda-error ] unless*
|
||||
[ make-local ] bind <def> parsed ;
|
||||
[ make-local ] bind <def> suffix! ;
|
||||
|
||||
SYNTAX: [| parse-lambda over push-all ;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ TUPLE: rect { loc initial: { 0 0 } } { dim initial: { 0 0 } } ;
|
|||
|
||||
: <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
|
||||
|
||||
|
@ -64,4 +64,4 @@ M: rect contains-point?
|
|||
|
||||
USING: vocabs vocabs.loader ;
|
||||
|
||||
"prettyprint" vocab [ "math.rectangles.prettyprint" require ] when
|
||||
"prettyprint" vocab [ "math.rectangles.prettyprint" require ] when
|
||||
|
|
|
@ -81,10 +81,10 @@ SYNTAX: HEREDOC:
|
|||
lexer get skip-blank
|
||||
rest-of-line
|
||||
lexer get next-line
|
||||
parse-til-line-begins parsed ;
|
||||
parse-til-line-begins suffix! ;
|
||||
|
||||
SYNTAX: DELIMITED:
|
||||
lexer get skip-blank
|
||||
rest-of-line
|
||||
lexer get next-line
|
||||
0 (parse-multiline-string) parsed ;
|
||||
0 (parse-multiline-string) suffix! ;
|
||||
|
|
|
@ -19,5 +19,5 @@ SYMBOL: G-world
|
|||
<< \ gl-break t "break?" set-word-prop >>
|
||||
|
||||
SYNTAX: GB
|
||||
\ gl-break parsed ;
|
||||
\ gl-break suffix! ;
|
||||
|
||||
|
|
|
@ -547,12 +547,12 @@ PRIVATE>
|
|||
SYNTAX: <EBNF
|
||||
"EBNF>"
|
||||
reset-tokenizer parse-multiline-string parse-ebnf main swap at
|
||||
parsed reset-tokenizer ;
|
||||
suffix! reset-tokenizer ;
|
||||
|
||||
SYNTAX: [EBNF
|
||||
"EBNF]"
|
||||
reset-tokenizer parse-multiline-string ebnf>quot nip
|
||||
parsed \ call parsed reset-tokenizer ;
|
||||
suffix! \ call suffix! reset-tokenizer ;
|
||||
|
||||
SYNTAX: EBNF:
|
||||
reset-tokenizer CREATE-WORD dup ";EBNF" parse-multiline-string
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: layouts kernel parser math ;
|
||||
USING: layouts kernel parser math sequences ;
|
||||
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
|
||||
: full-bitmap-mask ( -- n ) radix-bits 2^ 2^ 1 - ; inline
|
||||
|
|
|
@ -121,7 +121,7 @@ ARTICLE: "prettyprint-literal" "Literal prettyprinting protocol"
|
|||
" scan-word \\ * assert="
|
||||
" scan-word"
|
||||
" scan-word \\ ] assert="
|
||||
" <rect> parsed ;"
|
||||
" <rect> suffix! ;"
|
||||
}
|
||||
"An example literal might be:"
|
||||
{ $code "RECT[ 100 * 200 ]" }
|
||||
|
|
|
@ -200,7 +200,7 @@ PRIVATE>
|
|||
|
||||
: parsing-regexp ( accum end -- accum )
|
||||
lexer get [ take-until ] [ parse-noblank-token ] bi
|
||||
<optioned-regexp> compile-next-match parsed ;
|
||||
<optioned-regexp> compile-next-match suffix! ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
|
|
|
@ -69,4 +69,4 @@ ROMAN-OP: *
|
|||
ROMAN-OP: /i
|
||||
ROMAN-OP: /mod
|
||||
|
||||
SYNTAX: ROMAN: scan roman> parsed ;
|
||||
SYNTAX: ROMAN: scan roman> suffix! ;
|
||||
|
|
|
@ -50,7 +50,7 @@ CONSTANT: objects
|
|||
B{ 50 13 55 64 1 }
|
||||
?{ t f t f f t f }
|
||||
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" } }
|
||||
H{ { "a" "bc" } { "de" "fg" } }
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ MACRO: shuffle-effect ( effect -- )
|
|||
] [ ] make ;
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ M: A pprint-delims drop \ A{ \ } ;
|
|||
M: A >pprint-sequence ;
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -96,9 +96,9 @@ MACRO: <experiment> ( word -- )
|
|||
] [ drop ] if ; inline
|
||||
|
||||
: parse-test ( accum word -- accum )
|
||||
literalize parsed
|
||||
lexer get line>> parsed
|
||||
\ experiment parsed ; inline
|
||||
literalize suffix!
|
||||
lexer get line>> suffix!
|
||||
\ experiment suffix! ; inline
|
||||
|
||||
<<
|
||||
|
||||
|
|
|
@ -167,4 +167,4 @@ SYMBOL: +stopped+
|
|||
! For convenience
|
||||
IN: syntax
|
||||
|
||||
SYNTAX: B \ break parsed ;
|
||||
SYNTAX: B \ break suffix! ;
|
||||
|
|
|
@ -181,7 +181,7 @@ PRIVATE>
|
|||
clone dup protocol>> '[ _ protocol-port or ] change-port ;
|
||||
|
||||
! 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 ;
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ M: value-word definition drop f ;
|
|||
def>> first (>>obj) ;
|
||||
|
||||
SYNTAX: to:
|
||||
scan-word literalize parsed
|
||||
\ set-value parsed ;
|
||||
scan-word literalize suffix!
|
||||
\ set-value suffix! ;
|
||||
|
||||
: get-value ( word -- value )
|
||||
def>> first obj>> ;
|
||||
|
|
|
@ -101,7 +101,7 @@ SYNTAX: COM-INTERFACE:
|
|||
dup save-com-interface-definition
|
||||
define-words-for-com-interface ;
|
||||
|
||||
SYNTAX: GUID: scan string>guid parsed ;
|
||||
SYNTAX: GUID: scan string>guid suffix! ;
|
||||
|
||||
USING: vocabs vocabs.loader ;
|
||||
|
||||
|
|
|
@ -156,16 +156,16 @@ MACRO: interpolate-xml ( xml -- quot )
|
|||
: collect ( accum variables -- accum ? )
|
||||
{
|
||||
{ [ dup empty? ] [ drop f ] } ! Just a literal
|
||||
{ [ dup [ ] all? ] [ >search-hash parsed t ] } ! locals
|
||||
{ [ dup [ not ] all? ] [ length parsed \ nenum parsed t ] } ! fry
|
||||
{ [ dup [ ] all? ] [ >search-hash suffix! t ] } ! locals
|
||||
{ [ dup [ not ] all? ] [ length suffix! \ nenum suffix! t ] } ! fry
|
||||
[ drop "XML interpolation contains both fry and locals" throw ] ! mixed
|
||||
} cond ;
|
||||
|
||||
: parse-def ( accum delimiter quot -- accum )
|
||||
[ parse-multiline-string [ blank? ] trim ] dip call
|
||||
[ extract-variables collect ] keep swap
|
||||
[ number<-> parsed ] dip
|
||||
[ \ interpolate-xml parsed ] when ; inline
|
||||
[ number<-> suffix! ] dip
|
||||
[ \ interpolate-xml suffix! ] when ; inline
|
||||
|
||||
PRIVATE>
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ $nl
|
|||
$nl
|
||||
"Parsing words can read input, add word definitions to the dictionary, and do anything an ordinary word can."
|
||||
$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
|
||||
"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 }
|
||||
|
@ -172,11 +172,6 @@ $parsing-note ;
|
|||
|
||||
{ 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)
|
||||
{ $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." }
|
||||
|
|
|
@ -79,8 +79,6 @@ HOOK: parse-quotation quotation-parser ( -- quot )
|
|||
|
||||
M: f parse-quotation \ ] parse-until >quotation ;
|
||||
|
||||
: parsed ( accum obj -- accum ) over push ;
|
||||
|
||||
: (parse-lines) ( lexer -- quot )
|
||||
[ 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) ;
|
||||
|
||||
: parse-literal ( accum end quot -- accum )
|
||||
[ parse-until ] dip call parsed ; inline
|
||||
[ parse-until ] dip call suffix! ; inline
|
||||
|
||||
: parse-definition ( -- quot )
|
||||
\ ; parse-until >quotation ;
|
||||
|
@ -104,7 +102,7 @@ ERROR: bad-number ;
|
|||
scan swap base> [ bad-number ] unless* ;
|
||||
|
||||
: parse-base ( parsed base -- parsed )
|
||||
scan-base parsed ;
|
||||
scan-base suffix! ;
|
||||
|
||||
SYMBOL: bootstrap-syntax
|
||||
|
||||
|
|
|
@ -650,6 +650,10 @@ PRIVATE>
|
|||
[ 0 swap copy ] keep
|
||||
] new-like ;
|
||||
|
||||
: suffix! ( seq elt -- seq ) over push ;
|
||||
|
||||
: append! ( seq1 seq2 -- seq1 ) over push-all ;
|
||||
|
||||
: last ( seq -- elt ) [ length 1 - ] [ nth ] bi ;
|
||||
|
||||
: set-last ( elt seq -- ) [ length 1 - ] keep set-nth ;
|
||||
|
|
|
@ -73,9 +73,9 @@ IN: bootstrap.syntax
|
|||
"OCT:" [ 8 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
|
||||
|
||||
"CHAR:" [
|
||||
|
@ -83,31 +83,31 @@ IN: bootstrap.syntax
|
|||
{ [ dup length 1 = ] [ first ] }
|
||||
{ [ "\\" ?head ] [ next-escape >string "" assert= ] }
|
||||
[ name>char-hook get call( name -- char ) ]
|
||||
} cond parsed
|
||||
} cond suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"\"" [ parse-multiline-string parsed ] define-core-syntax
|
||||
"\"" [ parse-multiline-string suffix! ] define-core-syntax
|
||||
|
||||
"SBUF\"" [
|
||||
lexer get skip-blank parse-string >sbuf parsed
|
||||
lexer get skip-blank parse-string >sbuf suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"P\"" [
|
||||
lexer get skip-blank parse-string <pathname> parsed
|
||||
lexer get skip-blank parse-string <pathname> suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"[" [ parse-quotation parsed ] define-core-syntax
|
||||
"[" [ parse-quotation suffix! ] define-core-syntax
|
||||
"{" [ \ } [ >array ] parse-literal ] define-core-syntax
|
||||
"V{" [ \ } [ >vector ] parse-literal ] define-core-syntax
|
||||
"B{" [ \ } [ >byte-array ] parse-literal ] define-core-syntax
|
||||
"BV{" [ \ } [ >byte-vector ] 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
|
||||
|
||||
"POSTPONE:" [ scan-word parsed ] define-core-syntax
|
||||
"\\" [ scan-word <wrapper> parsed ] define-core-syntax
|
||||
"M\\" [ scan-word scan-word method <wrapper> parsed ] define-core-syntax
|
||||
"POSTPONE:" [ scan-word suffix! ] define-core-syntax
|
||||
"\\" [ scan-word <wrapper> suffix! ] define-core-syntax
|
||||
"M\\" [ scan-word scan-word method <wrapper> suffix! ] define-core-syntax
|
||||
"inline" [ word make-inline ] define-core-syntax
|
||||
"recursive" [ word make-recursive ] define-core-syntax
|
||||
"foldable" [ word make-foldable ] define-core-syntax
|
||||
|
@ -227,7 +227,7 @@ IN: bootstrap.syntax
|
|||
] define-core-syntax
|
||||
|
||||
"((" [
|
||||
"))" parse-effect parsed
|
||||
"))" parse-effect suffix!
|
||||
] define-core-syntax
|
||||
|
||||
"MAIN:" [ scan-word current-vocab (>>main) ] define-core-syntax
|
||||
|
@ -240,8 +240,8 @@ IN: bootstrap.syntax
|
|||
|
||||
"call-next-method" [
|
||||
current-method get [
|
||||
literalize parsed
|
||||
\ (call-next-method) parsed
|
||||
literalize suffix!
|
||||
\ (call-next-method) suffix!
|
||||
] [
|
||||
not-in-a-method-error
|
||||
] if*
|
||||
|
|
|
@ -118,14 +118,14 @@ MACRO: data-map! ( ins outs -- )
|
|||
|
||||
: parse-data-map-effect ( accum -- accum )
|
||||
")" parse-effect
|
||||
[ in>> [ (parse-c-type) ] map parsed ]
|
||||
[ out>> [ (parse-c-type) ] map parsed ] bi ;
|
||||
[ in>> [ (parse-c-type) ] map suffix! ]
|
||||
[ out>> [ (parse-c-type) ] map suffix! ] bi ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
SYNTAX: data-map(
|
||||
parse-data-map-effect \ data-map parsed ;
|
||||
parse-data-map-effect \ data-map suffix! ;
|
||||
|
||||
SYNTAX: data-map!(
|
||||
parse-data-map-effect \ data-map! parsed ;
|
||||
parse-data-map-effect \ data-map! suffix! ;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ IN: annotations
|
|||
<<
|
||||
|
||||
: (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 )
|
||||
smart-usage
|
||||
|
@ -24,7 +24,7 @@ NAMEs. DEFINES ${NAME}s.
|
|||
WHERE
|
||||
|
||||
: (NAME) ( str -- ) drop ; inline
|
||||
SYNTAX: !NAME (parse-annotation) \ (NAME) parsed ;
|
||||
SYNTAX: !NAME (parse-annotation) \ (NAME) suffix! ;
|
||||
|
||||
: NAMEs ( -- usages )
|
||||
\ (NAME) (non-annotation-usage) ;
|
||||
|
|
|
@ -10,6 +10,6 @@ SYNTAX: get-psql-info <postgresql-db> get-info 5 firstn
|
|||
[ >>username ]
|
||||
[ [ f ] [ ] if-empty >>password ]
|
||||
[ >>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! ;
|
||||
|
|
|
@ -20,7 +20,7 @@ TUPLE: decimal { mantissa read-only } { exponent read-only } ;
|
|||
|
||||
: parse-decimal ( -- decimal ) scan string>decimal ;
|
||||
|
||||
SYNTAX: D: parse-decimal parsed ;
|
||||
SYNTAX: D: parse-decimal suffix! ;
|
||||
|
||||
: decimal>ratio ( decimal -- ratio ) >decimal< 10^ * ;
|
||||
: decimal>float ( decimal -- ratio ) decimal>ratio >float ;
|
||||
|
|
|
@ -82,7 +82,7 @@ M: ast-function infix-codegen
|
|||
PRIVATE>
|
||||
|
||||
SYNTAX: [infix
|
||||
"infix]" [infix-parse parsed \ call parsed ;
|
||||
"infix]" [infix-parse suffix! \ call suffix! ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
|
|
@ -242,4 +242,4 @@ Program = Type
|
|||
|
||||
;EBNF
|
||||
|
||||
SYNTAX: TYPE: ";" parse-multiline-string parse-type parsed ;
|
||||
SYNTAX: TYPE: ";" parse-multiline-string parse-type suffix! ;
|
||||
|
|
|
@ -30,4 +30,4 @@ ERROR: not-an-integer x ;
|
|||
] keep length
|
||||
10^ / + swap [ neg ] when ;
|
||||
|
||||
SYNTAX: DECIMAL: scan parse-decimal parsed ;
|
||||
SYNTAX: DECIMAL: scan parse-decimal suffix! ;
|
||||
|
|
|
@ -109,7 +109,7 @@ PRIVATE>
|
|||
: morse> ( morse -- plain )
|
||||
replace-underscores morse>sentence ;
|
||||
|
||||
SYNTAX: [MORSE "MORSE]" parse-multiline-string morse> parsed ;
|
||||
SYNTAX: [MORSE "MORSE]" parse-multiline-string morse> suffix! ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
USING: arrays kernel parser sequences ;
|
||||
IN: pair-rocket
|
||||
|
||||
SYNTAX: => dup pop scan-object 2array parsed ;
|
||||
SYNTAX: => dup pop scan-object 2array suffix! ;
|
||||
|
||||
|
|
|
@ -26,5 +26,5 @@ SYNTAX: STORED-TUPLE: parse-tuple-definition [ drop persistent ] dip [ remove-ty
|
|||
: remove-tuples ( tuple -- ) [ delete-tuples ] w/db ;
|
||||
|
||||
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# ;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
! (c)2009 Joe Groff bsd license
|
||||
USING: lexer parser ;
|
||||
USING: lexer sequences parser ;
|
||||
IN: qw
|
||||
|
||||
SYNTAX: qw{ "}" parse-tokens parsed ;
|
||||
SYNTAX: qw{ "}" parse-tokens suffix! ;
|
||||
|
|
|
@ -99,7 +99,7 @@ TUPLE: slides < book ;
|
|||
] with map ;
|
||||
|
||||
SYNTAX: STRIP-TEASE:
|
||||
parse-definition strip-tease [ parsed ] each ;
|
||||
parse-definition strip-tease [ suffix! ] each ;
|
||||
|
||||
\ slides H{
|
||||
{ T{ button-down } [ request-focus ] }
|
||||
|
|
|
@ -66,4 +66,4 @@ SYNTAX: ADVISE: ! word adname location => word adname quot loc
|
|||
scan-word scan scan-word parse-definition swap [ spin ] dip advise ;
|
||||
|
||||
SYNTAX: UNADVISE:
|
||||
scan-word parsed \ unadvise parsed ;
|
||||
scan-word suffix! \ unadvise suffix! ;
|
||||
|
|
Loading…
Reference in New Issue