From 980840d360540c0e13f1d4dc570efecc514593be Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 19 Oct 2019 13:54:04 -0500 Subject: [PATCH] modern: Turned-off syntax. A token like ``#: foo ;`` will remove ``foo`` from the parse tree. You can turn off single tokens: ``{ 1 #2 3 }`` -> ``{ 1 3 } ``#{ 1 2 3 }`` -> empty "#" string>literals >strings -- turn off a whole section --- extra/modern/modern.factor | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extra/modern/modern.factor b/extra/modern/modern.factor index f3020f0049..4186c939f8 100644 --- a/extra/modern/modern.factor +++ b/extra/modern/modern.factor @@ -327,6 +327,9 @@ MACRO:: read-matched ( ch -- quot: ( string n tag -- string n' slice' ) ) : read-acute ( string n slice -- string n' acute ) [ matching-section-delimiter 1array lex-until ] keep swap unclip-last 3array ; +: read-turnoff ( string n slice -- string n' obj ) + [ lex-factor ] dip swap 2array ; + ! Words like append! and suffix! are allowed for now. : read-exclamation ( string n slice -- string n' obj ) dup { [ "!" sequence= ] [ "#!" sequence= ] } 1|| @@ -376,6 +379,7 @@ DEFER: lex-factor-top* : lex-factor-fallthrough ( string n/f slice/f ch/f -- string n'/f literal ) { + { char: # [ read-turnoff ] } ! char: \# { char: \\ [ read-backslash ] } { char: \[ [ read-bracket ] } { char: \{ [ read-brace ] } @@ -428,7 +432,7 @@ DEFER: lex-factor-top* } case ; : lex-factor-nested ( n/f string -- n'/f string literal ) - "\"\\!:[{(]})<>\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 ) { @@ -454,7 +458,7 @@ DEFER: lex-factor-top* } case ; : lex-factor-top ( string/f n/f -- string/f n'/f literal ) - "\"\\!:[{(]})<>\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 ;