improved native run-resource
parent
5b24e99fc9
commit
87331addba
|
@ -1,7 +1,6 @@
|
|||
- input style after clicking link
|
||||
- fedit broken with listener
|
||||
- maple-like: press enter at old commands to evaluate there
|
||||
- fix up native file/line info
|
||||
- standalone listener input style
|
||||
- add a socket timeout
|
||||
- drop test in http server
|
||||
|
@ -45,6 +44,7 @@
|
|||
|
||||
+ native:
|
||||
|
||||
- accept multi-line input in listener
|
||||
- gc call in the middle of some ops might affect callstack
|
||||
- multitasking
|
||||
- better error reporting
|
||||
|
|
|
@ -68,10 +68,10 @@ USE: words
|
|||
|
||||
: jedit ( word -- )
|
||||
intern dup [
|
||||
word-line/file 2dup and [
|
||||
word-line/file dup [
|
||||
jedit-line/file
|
||||
] [
|
||||
"Unknown source" print
|
||||
3drop "Unknown source" print
|
||||
] ifte
|
||||
] [
|
||||
"Not defined" print
|
||||
|
|
|
@ -66,32 +66,49 @@ USE: strings
|
|||
"file-in" get "in" set
|
||||
"file-use" get "use" set ;
|
||||
|
||||
: parse-stream ( name stream -- code )
|
||||
: (parse-stream) ( name stream -- quot )
|
||||
#! Uses the current namespace for temporary variables.
|
||||
>r "file" set f r>
|
||||
[ (parse) ] read-lines nreverse
|
||||
"file" off
|
||||
"line-number" off ;
|
||||
|
||||
: parse-file ( file -- code )
|
||||
dup <filecr> parse-stream ;
|
||||
: parse-stream ( name stream -- quot )
|
||||
[
|
||||
10 "base" set
|
||||
file-vocabs
|
||||
(parse-stream)
|
||||
] with-scope ;
|
||||
|
||||
: (run-file) ( file -- )
|
||||
#! Run a file. The file is read with the same IN:/USE: as
|
||||
#! the current interactive interpreter.
|
||||
parse-file call ;
|
||||
: parse-file ( file -- quot )
|
||||
dup <filecr> parse-stream ;
|
||||
|
||||
: run-file ( file -- )
|
||||
#! Run a file. The file is read with the default IN:/USE:
|
||||
#! for files.
|
||||
[
|
||||
10 "base" set
|
||||
file-vocabs
|
||||
parse-file
|
||||
] with-scope call ;
|
||||
parse-file call ;
|
||||
|
||||
: (parse-file) ( file -- quot )
|
||||
dup <filecr> (parse-stream) ;
|
||||
|
||||
: (run-file) ( file -- )
|
||||
#! Run a file. The file is read with the same IN:/USE: as
|
||||
#! the current interactive interpreter.
|
||||
(parse-file) call ;
|
||||
|
||||
: resource-path ( -- path )
|
||||
"resource-path" get [ "." ] unless* ;
|
||||
|
||||
: parse-resource ( path -- quot )
|
||||
#! Resources are loaded from the resource-path variable, or
|
||||
#! the current directory if it is not set. Words defined in
|
||||
#! resources have a definition source path starting with
|
||||
#! resource:. This allows words that operate on source
|
||||
#! files, like "jedit", to use a different resource path
|
||||
#! at run time than was used at parse time.
|
||||
"resource:" over cat2
|
||||
swap resource-path swap cat2 <filecr>
|
||||
parse-stream ;
|
||||
|
||||
: run-resource ( file -- )
|
||||
resource-path swap cat2 run-file ;
|
||||
parse-resource call ;
|
||||
|
|
Loading…
Reference in New Issue