Multiline string literals

release
Daniel Ehrenberg 2007-12-11 01:39:32 -05:00
parent 77ead806e0
commit fd63917d8b
4 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1 @@
Daniel Ehrenberg

View File

@ -0,0 +1,8 @@
USING: help.markup help.syntax multiline ;
HELP: STRING:
{ $syntax "STRING: name\nfoo\n;" }
{ $description "Forms a multiline string literal, or 'here document' stored in the word called name. A semicolon is used to signify the end, and that semicolon must be on a line by itself, not preceeded or followed by any whitespace. The string will have newlines in between lines and at the end." } ;
IN: multiline
ABOUT: POSTPONE: STRING:

View File

@ -0,0 +1,19 @@
! Copyright (C) 2007 Daniel Ehrenberg
! See http://factorcode.org/license.txt for BSD license.
USING: namespaces parser kernel sequences words quotations ;
IN: multiline
: next-line-text ( -- str )
lexer get dup next-line line-text ;
: (parse-here) ( -- )
next-line-text dup ";" =
[ drop lexer get next-line ] [ % "\n" % (parse-here) ] if ;
: parse-here ( -- str )
[ (parse-here) ] "" make
lexer get next-line ;
: STRING:
CREATE dup reset-generic
parse-here 1quotation define-compound ; parsing

View File

@ -0,0 +1 @@
Multiline string literals