modern: Allow comound literals
parent
d3497b9f6b
commit
d8d7c0cd3c
|
@ -51,7 +51,7 @@ ERROR: lex-expected-but-got-eof n string expected ;
|
||||||
: lex-until ( n string tag-sequence -- n' string payload )
|
: lex-until ( n string tag-sequence -- n' string payload )
|
||||||
3dup '[
|
3dup '[
|
||||||
[
|
[
|
||||||
lex-factor dup [ , ] when* [
|
lex-factor dup f like [ , ] when* [
|
||||||
dup [
|
dup [
|
||||||
! } gets a chance, but then also full seq { } after recursion...
|
! } gets a chance, but then also full seq { } after recursion...
|
||||||
[ _ ] dip '[ _ sequence= ] any? not
|
[ _ ] dip '[ _ sequence= ] any? not
|
||||||
|
@ -67,7 +67,7 @@ ERROR: lex-expected-but-got-eof n string expected ;
|
||||||
: lex-colon-until ( n string tag-sequence -- n' string payload )
|
: lex-colon-until ( n string tag-sequence -- n' string payload )
|
||||||
'[
|
'[
|
||||||
[
|
[
|
||||||
lex-factor dup [ , ] when* [
|
lex-factor dup f like [ , ] when* [
|
||||||
dup [
|
dup [
|
||||||
! } gets a chance, but then also full seq { } after recursion...
|
! } gets a chance, but then also full seq { } after recursion...
|
||||||
[ _ ] dip '[ _ sequence= ] any? not
|
[ _ ] dip '[ _ sequence= ] any? not
|
||||||
|
@ -218,10 +218,9 @@ ERROR: no-backslash-payload n string slice ;
|
||||||
] when ;
|
] when ;
|
||||||
|
|
||||||
! If the slice is 0 width, we stopped on whitespace.
|
! If the slice is 0 width, we stopped on whitespace.
|
||||||
! Advance the index and read again!
|
! Advance the index and read again somewhere else!
|
||||||
: read-token-or-whitespace ( n string slice -- n' string slice )
|
: read-token-or-whitespace ( n string slice -- n' string slice/f )
|
||||||
dup length 0 =
|
dup length 0 = [ [ 1 + ] 2dip ] when ;
|
||||||
[ drop [ 1 + ] dip lex-factor ] when ;
|
|
||||||
|
|
||||||
ERROR: mismatched-terminator n string slice ;
|
ERROR: mismatched-terminator n string slice ;
|
||||||
: read-terminator ( n string slice -- n' string slice ) ;
|
: read-terminator ( n string slice -- n' string slice ) ;
|
||||||
|
@ -267,9 +266,9 @@ ERROR: mismatched-terminator n string slice ;
|
||||||
{ char: \[ [ read-bracket ] }
|
{ char: \[ [ read-bracket ] }
|
||||||
{ char: \{ [ read-brace ] }
|
{ char: \{ [ read-brace ] }
|
||||||
{ char: \( [ read-paren ] }
|
{ char: \( [ read-paren ] }
|
||||||
{ char: \] [ ] }
|
{ char: \] [ ] }
|
||||||
{ char: \} [ ] }
|
{ char: \} [ ] }
|
||||||
{ char: \) [ ] }
|
{ char: \) [ ] }
|
||||||
{ char: \s [ read-token-or-whitespace ] }
|
{ char: \s [ read-token-or-whitespace ] }
|
||||||
{ char: \r [ read-token-or-whitespace ] }
|
{ char: \r [ read-token-or-whitespace ] }
|
||||||
{ char: \n [ read-token-or-whitespace ] }
|
{ char: \n [ read-token-or-whitespace ] }
|
||||||
|
@ -301,7 +300,7 @@ ERROR: mismatched-terminator n string slice ;
|
||||||
] if ; inline
|
] if ; inline
|
||||||
|
|
||||||
: string>literals ( string -- sequence )
|
: string>literals ( string -- sequence )
|
||||||
[ 0 ] dip [ lex-factor ] loop>array 2nip ;
|
[ 0 ] dip [ [ lex-factor f like ] loop>array f like ] loop>array 2nip ;
|
||||||
|
|
||||||
: vocab>literals ( vocab -- sequence )
|
: vocab>literals ( vocab -- sequence )
|
||||||
".private" ?tail drop
|
".private" ?tail drop
|
||||||
|
|
Loading…
Reference in New Issue