modern: confusing algorithm, add comments

modern-harvey3
Doug Coleman 2019-10-17 00:42:22 -05:00
parent 155171b828
commit 2c6d958030
2 changed files with 3 additions and 1 deletions

View File

@ -445,6 +445,7 @@ DEFER: lex-factor-top*
dup section-open? [ read-acute ] when dup section-open? [ read-acute ] when
] } ] }
! Two cases: zero width slice if we found whitespace, otherwise token
{ char: \s [ read-token-or-whitespace-top ] } { char: \s [ read-token-or-whitespace-top ] }
{ char: \r [ read-token-or-whitespace-top ] } { char: \r [ read-token-or-whitespace-top ] }
{ char: \n [ read-token-or-whitespace-top ] } { char: \n [ read-token-or-whitespace-top ] }

View File

@ -97,7 +97,8 @@ ERROR: unexpected-eof string n expected ;
] when ; ] when ;
! Takes at least one character if not whitespace ! Whitespace is either found immediately, returning a zero-width slice
! OR we find it at the end of a token
:: slice-til-either ( string n tokens -- string n'/f slice/f ch/f ) :: slice-til-either ( string n tokens -- string n'/f slice/f ch/f )
n [ n [
string n [ tokens member? ] find-from' string n [ tokens member? ] find-from'