rre: add -i for interactive mode
FossilOrigin-Name: 1298ee794c8f9a90d099b39b2ef4c59f128de0ba73a7ae11f37abadc4ae24241
This commit is contained in:
parent
63abbb66b1
commit
1e3de483b7
4 changed files with 34 additions and 3 deletions
File diff suppressed because one or more lines are too long
|
@ -821,7 +821,13 @@ int main(int argc, char **argv) {
|
||||||
sys_argc = argc;
|
sys_argc = argc;
|
||||||
sys_argv = argv;
|
sys_argv = argv;
|
||||||
|
|
||||||
include_file(argv[1]);
|
if (argc > 1) {
|
||||||
|
if (strcmp(argv[1], "-i") == 0) {
|
||||||
|
execute(d_xt_for("listen", Dictionary));
|
||||||
|
} else {
|
||||||
|
include_file(argv[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sp >= 1)
|
if (sp >= 1)
|
||||||
dump_stack();
|
dump_stack();
|
||||||
|
|
|
@ -299,3 +299,26 @@ once for each line in a file. This makes some things trivial. E.g., a simple
|
||||||
file:W file:open !FID [ @FID file:write ] s:for-each @FID file:close ;
|
file:W file:open !FID [ @FID file:write ] s:for-each @FID file:close ;
|
||||||
}}
|
}}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
# Interactive Listener
|
||||||
|
|
||||||
|
~~~
|
||||||
|
:bye
|
||||||
|
'stty_-cbreak unix:system #0 unix:exit ;
|
||||||
|
|
||||||
|
{{
|
||||||
|
:version (-) @Version #100 /mod putn $. putc putn ;
|
||||||
|
:banner (-) 'RETRO_12_(rx- puts version $) putc nl
|
||||||
|
EOM putn '_MAX,_TIB_@_1025,_Heap_@_ puts here putn nl ;
|
||||||
|
:eol? (c-f) [ ASCII:CR eq? ] [ ASCII:LF eq? ] [ ASCII:SPACE eq? ] tri or or ;
|
||||||
|
:valid? (s-sf) dup s:length n:-zero? ;
|
||||||
|
:ok (-) compiling? [ nl 'Ok_ puts ] -if ;
|
||||||
|
:gets (-s) [ #1025 buffer:set
|
||||||
|
[ getc dup buffer:add eol? ] until
|
||||||
|
buffer:start s:chop ] buffer:preserve ;
|
||||||
|
---reveal---
|
||||||
|
:listen (-)
|
||||||
|
'stty_cbreak unix:system
|
||||||
|
banner ok repeat gets valid? [ interpret ok ] [ drop ] choose again ;
|
||||||
|
}}
|
||||||
|
~~~
|
||||||
|
|
|
@ -344,3 +344,5 @@ xor mn-o - - Perform a bitwise XOR operation. class:primitive {n/a} {n/a} glob
|
||||||
{{ - - - Begin a lexically scoped area. class:word {n/a} {n/a} global all
|
{{ - - - Begin a lexically scoped area. class:word {n/a} {n/a} global all
|
||||||
}as f- - - End an assembly section class:macro {n/a} {n/a} global all
|
}as f- - - End an assembly section class:macro {n/a} {n/a} global all
|
||||||
}} - - - End a lexically scoped area. class:word {n/a} {n/a} global all
|
}} - - - End a lexically scoped area. class:word {n/a} {n/a} global all
|
||||||
|
bye - - - Exit RETRO. class:word {n/a} {n/a} global rre
|
||||||
|
listen - - - Run interactive "listener" (a REPL). class:word {n/a} {n/a} global rre
|
||||||
|
|
Can't render this file because it contains an unexpected character in line 348 and column 30.
|
Loading…
Reference in a new issue