| \G @code{input-var} variable -- @i{a-addr} is the address of a |
\G @code{input-var} variable -- @i{a-addr} is the address of a |
| \G cell containing the char offset from the start of the input |
\G cell containing the char offset from the start of the input |
| \G buffer to the start of the parse area. |
\G buffer to the start of the parse area. |
| |
cell input-var input-start-parse ( -- addr ) \ gforth |
| |
\G @code{input-var} variable -- @i{a-addr} is the address of a |
| |
\G cell containing a pointer to the start of the last parsed |
| |
\G string (but after skipped characters, if any); this is set |
| |
\G automatically by @code{parse}, @code{parse-name} and |
| |
\G @code{word}, but not if you set @code{>in} yourself. |
| cell input-var #tib ( -- addr ) \ core-ext number-t-i-b |
cell input-var #tib ( -- addr ) \ core-ext number-t-i-b |
| \G @code{input-var} variable -- @i{a-addr} is the address of a |
\G @code{input-var} variable -- @i{a-addr} is the address of a |
| \G cell containing the number of characters in the terminal input |
\G cell containing the number of characters in the terminal input |
| |
|
| Constant tib+ |
Constant tib+ |
| |
|
| |
\ helper words |
| |
|
| |
: input-start-line ( -- ) |
| |
>in off input-start-parse off ; |
| |
|
| |
: start-lexeme ( c-addr -- ) |
| |
\ record that the current lexeme starts at c-addr |
| |
source drop - input-start-parse ! ; |
| |
|
| \ terminal input implementation |
\ terminal input implementation |
| |
|
| :noname ( in 1 -- ) 1 <> -12 and throw >in ! ; |
:noname ( in 1 -- ) 1 <> -12 and throw >in ! ; |
| :noname ( -- flag ) [ has? file [IF] ] |
:noname ( -- flag ) [ has? file [IF] ] |
| stdin file-eof? IF false EXIT THEN [ [THEN] ] |
stdin file-eof? IF false EXIT THEN [ [THEN] ] |
| tib max#tib @ accept #tib ! |
tib max#tib @ accept #tib ! |
| >in off true 1 loadline +! ; \ refill |
input-start-line true 1 loadline +! ; \ refill |
| :noname ( -- addr u ) tib #tib @ ; \ source |
:noname ( -- addr u ) tib #tib @ ; \ source |
| |
|
| | Create terminal-input A, A, A, A, A, |
| Create terminal-input A, A, A, A, A, |
| 4 ; \ save-input |
4 ; \ save-input |
| :noname ( -- file ) loadfile @ ; \ source-id |
:noname ( -- file ) loadfile @ ; \ source-id |
| :noname ( -- flag ) |
:noname ( -- flag ) |
| #tib off #fill-bytes off >in off |
#tib off #fill-bytes off input-start-line |
| BEGIN |
BEGIN |
| tib max#tib @ #tib @ /string |
tib max#tib @ #tib @ /string |
| loadfile @ (read-line) throw #fill-bytes +! |
loadfile @ (read-line) throw #fill-bytes +! |
| : pop-file ( throw-code -- throw-code ) \ gforth |
: pop-file ( throw-code -- throw-code ) \ gforth |
| \G pop and free the current top input buffer |
\G pop and free the current top input buffer |
| dup IF |
dup IF |
| source >in @ sourceline# |
input-error-data >error |
| [ has? file [IF] ] sourcefilename [ [THEN] ] |
|
| >error |
|
| THEN |
THEN |
| current-input @ old-input @ current-input ! free throw ; |
current-input @ old-input @ current-input ! free throw ; |
| |
|