modern: Clearer concatenative lexing check.

modern-harvey2
Doug Coleman 2017-12-03 22:23:28 -06:00
parent 527fa59fc6
commit 57872a8a17
1 changed files with 8 additions and 3 deletions

View File

@ -208,6 +208,8 @@ ERROR: unexpected-terminator n string slice ;
dup ?last { dup ?last {
{ [ dup ";" tail? ] [ drop unclip-last 3array ] } { [ dup ";" tail? ] [ drop unclip-last 3array ] }
{ [ dup "--" tail? ] [ drop unclip-last -rot 2array [ rewind-slice ] dip ] } { [ dup "--" tail? ] [ drop unclip-last -rot 2array [ rewind-slice ] dip ] }
{ [ dup "]" tail? ] [ drop unclip-last -rot 2array [ rewind-slice ] dip ] }
{ [ dup "}" tail? ] [ drop unclip-last -rot 2array [ rewind-slice ] dip ] }
{ [ dup ")" tail? ] [ drop unclip-last -rot 2array [ rewind-slice ] dip ] } { [ dup ")" tail? ] [ drop unclip-last -rot 2array [ rewind-slice ] dip ] }
{ [ dup section-close? ] [ drop unclip-last -rot 2array [ rewind-slice ] dip ] } { [ dup section-close? ] [ drop unclip-last -rot 2array [ rewind-slice ] dip ] }
{ [ dup upper-colon? ] [ drop unclip-last -rot 2array [ rewind-slice ] dip ] } { [ dup upper-colon? ] [ drop unclip-last -rot 2array [ rewind-slice ] dip ] }
@ -343,6 +345,11 @@ ERROR: compound-syntax-disallowed seq i obj ;
dup [ length 1 > ] find dup [ length 1 > ] find
[ compound-syntax-disallowed ] [ drop ] if* ; [ compound-syntax-disallowed ] [ drop ] if* ;
: check-next-compound ( n/f string -- n/f string ? )
[ ] [ peek-from ] [ previous-from ] 2tri
[ blank? ] bi@ or not ! no blanks between tokens
pick and ; ! and a valid index
: lex-factor ( n/f string/f -- n'/f string literal/f ) : lex-factor ( n/f string/f -- n'/f string literal/f )
[ [
! Compound syntax loop ! Compound syntax loop
@ -350,9 +357,7 @@ ERROR: compound-syntax-disallowed seq i obj ;
lex-factor-top lex-factor-top
f like [ , ] when* f like [ , ] when*
! concatenated syntax ( a )[ a 1 + ]( b ) ! concatenated syntax ( a )[ a 1 + ]( b )
[ ] check-next-compound
[ peek-from blank? ]
[ previous-from blank? or not ] 2tri pick and
] loop ] loop
] { } make ] { } make
! check-for-compound-syntax ! check-for-compound-syntax