diff --git a/extra/modern/lexer/lexer.factor b/extra/modern/lexer/lexer.factor index 3d62b3f720..21199efeb0 100644 --- a/extra/modern/lexer/lexer.factor +++ b/extra/modern/lexer/lexer.factor @@ -1,8 +1,20 @@ ! Copyright (C) 2019 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: constructors ; +USING: accessors ascii constructors kernel prettyprint.custom +sequences ; IN: modern.lexer +ERROR: ws-expected string ; + +TUPLE: ws string ; +CONSTRUCTOR: ws ( string -- ws ) + dup string>> [ blank? not ] any? [ ws-expected ] when ; + +! Weird experiment +M: ws pprint* + drop ; + ! string>> dup "\"" "\"" pprint-string ; + TUPLE: lexed tokens ; TUPLE: bracket < lexed tag payload ; diff --git a/extra/modern/modern.factor b/extra/modern/modern.factor index 69328cb36e..fcc548ed71 100644 --- a/extra/modern/modern.factor +++ b/extra/modern/modern.factor @@ -134,7 +134,7 @@ MACRO:: read-matched ( ch -- quot: ( string n tag -- string n' slice' ) ) 2over ?nth-of char: \[ = [ [ 1 + ] dip 1 modify-to 2over ?nth-of read-double-matched-bracket ] [ - [ slice-til-eol drop ] dip swap 2array + [ slice-til-eol drop ] dip swap 2array ] if ; : terminator? ( slice -- ? ) @@ -152,7 +152,7 @@ MACRO:: read-matched ( ch -- quot: ( string n tag -- string n' slice' ) ) dup [ char: \: = ] count-tail '[ _ [ - slice-til-not-whitespace drop ! XXX: whitespace here + slice-til-not-whitespace drop ! XXX: whitespace here [ dup [ f unexpected-eof ] unless ] dip [ lex-factor ] dip swap 2array ] replicate @@ -335,7 +335,7 @@ MACRO:: read-matched ( ch -- quot: ( string n tag -- string n' slice' ) ) dup [ char: \\ = ] count-tail '[ _ [ - slice-til-not-whitespace drop + slice-til-not-whitespace drop [ slice-til-whitespace drop ] dip swap 2array ] replicate