Multiline string literals
parent
77ead806e0
commit
fd63917d8b
|
@ -0,0 +1 @@
|
|||
Daniel Ehrenberg
|
|
@ -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:
|
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
Multiline string literals
|
Loading…
Reference in New Issue