mirror of
https://github.com/nineties/planckforth
synced 2024-12-26 21:58:42 +01:00
Wrote read-commandline-args
This commit is contained in:
parent
6e30c23cce
commit
dd1ad8d1f7
1 changed files with 38 additions and 0 deletions
38
bootstrap.fs
38
bootstrap.fs
|
@ -1805,3 +1805,41 @@ v argc ! argv !
|
|||
1 arg
|
||||
shift-args
|
||||
;
|
||||
|
||||
( === Environment-Dependent Code === )
|
||||
|
||||
\ Parse '--gen' option.
|
||||
\ $ ./planck < bootstrap --gen i386-linux ...
|
||||
|
||||
: strn= ( c-addr1 c-addr2 u -- f )
|
||||
begin dup 0> while
|
||||
1- >r
|
||||
over c@ over c@
|
||||
<> if r> drop drop drop false exit then
|
||||
1+ swap 1+ swap r>
|
||||
repeat drop drop drop
|
||||
true
|
||||
;
|
||||
|
||||
variable codegen-target
|
||||
|
||||
\ Parse command-line arguments.
|
||||
: read-commandline-args ( -- )
|
||||
begin argc @ 1 > while
|
||||
1 arg dup c@ '-' <> if drop exit then
|
||||
dup s" --gen" 5 strn= if
|
||||
dup 5 + c@ '=' = if
|
||||
6 + codegen-target !
|
||||
shift-args
|
||||
else
|
||||
shift-args
|
||||
next-arg codegen-target !
|
||||
then
|
||||
else
|
||||
." Unknown option: " type cr
|
||||
drop ABORTED-ERROR throw
|
||||
then
|
||||
repeat
|
||||
;
|
||||
|
||||
read-commandline-args
|
||||
|
|
Loading…
Reference in a new issue