-USING: accessors eval multiline tools.test ;
+USING: accessors eval multiline sequences tools.test ;
IN: multiline.tests
STRING: test-it
[ "whoa" ]
[ DELIMITED: factor blows my mind
whoafactor blows my mind ] unit-test
+
+<<
+SYNTAX: MULTILINE-LITERAL: parse-here suffix! ;
+>>
+
+[ { "bar" } ]
+[
+ CONSTANT: foo { MULTILINE-LITERAL:
+bar
+;
+} foo
+] unit-test
+
+
+! Make sure parse-here fails if extra crap appears on the first line
+[
+ "CONSTANT: foo { MULTILINE-LITERAL: asdfasfdasdfas
+bar
+;
+}" eval
+] must-fail
ERROR: bad-heredoc identifier ;
<PRIVATE
+
+: rest-of-line ( -- seq )
+ lexer get [ line-text>> ] [ column>> ] bi tail ;
+
: next-line-text ( -- str )
lexer get dup next-line line-text>> ;
[ drop lexer get next-line ]
[ % "\n" % (parse-here) ] if
] [ ";" unexpected-eof ] if* ;
+
PRIVATE>
+ERROR: text-found-before-eol string ;
+
: parse-here ( -- str )
- [ (parse-here) ] "" make but-last
- lexer get next-line ;
+ [
+ rest-of-line dup [ drop ] [ text-found-before-eol ] if-empty
+ (parse-here)
+ ] "" make but-last ;
SYNTAX: STRING:
CREATE-WORD
change-column drop
] "" make ;
-: rest-of-line ( -- seq )
- lexer get [ line-text>> ] [ column>> ] bi tail ;
-
:: advance-same-line ( text -- )
lexer get [ text length + ] change-column drop ;