modern: working on parser.
! not sure what these all do. \ foo \\ foo foo \ \abc{ \ abc{ } \\ abc{ } def{ }modern-harvey3
parent
4ef0a41d05
commit
5def4de6f3
|
@ -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 ;
|
||||
|
||||
|
|
|
@ -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 ;
|
||||
|
|
Loading…
Reference in New Issue