modern: working on parser.

! not sure what these all do.
\ foo
\\ foo foo
\ \abc{
\ abc{ }
\\ abc{ } def{ }
modern-harvey3
Doug Coleman 2019-10-17 01:14:36 -05:00
parent 4ef0a41d05
commit 5def4de6f3
2 changed files with 13 additions and 10 deletions

View File

@ -15,9 +15,9 @@ M: ws nth-unsafe string>> nth-unsafe ;
M: ws length string>> length ;
! Weird experiment
! M: ws pprint*
M: ws pprint*
! drop ;
! string>> dup "\"" "\"" pprint-string ;
string>> dup "\"" "\"" pprint-string ;
TUPLE: lexed tokens ;

View File

@ -329,14 +329,21 @@ MACRO:: read-matched ( ch -- quot: ( string n tag -- string n' slice' ) )
dup { [ "!" sequence= ] [ "#!" sequence= ] } 1||
[ take-comment ] [ merge-slice-til-whitespace ] if ;
! \ foo ! push the word, don't call it
! \\ foo bar ! push two words
! \ ! error, expects another token
! \\ ! error, expects two tokens
! \ \abc{ ! push the abc{ word
! \ abc{ } ! push the ``abc{ }`` form for running later
: (read-backslash) ( string n slice -- string n' obj )
merge-slice-til-whitespace dup "\\" tail? [
! \ foo, M\ foo
dup [ char: \\ = ] count-tail
'[
_ [
slice-til-not-whitespace drop <ws>
[ slice-til-whitespace drop ] dip
slice-til-not-whitespace drop
[ <ws> ] [ "escaped string" unexpected-eof ] if*
[ lex-factor ] dip
swap 2array
] replicate
ensure-tokens
@ -419,9 +426,7 @@ DEFER: lex-factor-top*
} case ;
: lex-factor-nested ( n/f string -- n'/f string literal )
! skip-whitespace
"\"\\!:[{(]})<>\s\r\n" slice-til-either
lex-factor-nested* ; inline
"\"\\!:[{(]})<>\s\r\n" slice-til-either lex-factor-nested* ; inline
: lex-factor-top* ( n/f string slice/f ch/f -- n'/f string literal )
{
@ -447,9 +452,7 @@ DEFER: lex-factor-top*
} case ;
: lex-factor-top ( string/f n/f -- string/f n'/f literal )
! skip-whitespace
"\"\\!:[{(]})<>\s\r\n" slice-til-either
lex-factor-top* ; inline
"\"\\!:[{(]})<>\s\r\n" slice-til-either lex-factor-top* ; inline
: check-for-compound-syntax ( seq n/f obj -- seq n/f obj )
dup length 1 > [ compound-syntax-disallowed ] when ;