2007-12-11 01:39:32 -05:00
|
|
|
! Copyright (C) 2007 Daniel Ehrenberg
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2007-12-11 17:23:56 -05:00
|
|
|
USING: namespaces parser kernel sequences words quotations math ;
|
2007-12-11 01:39:32 -05:00
|
|
|
IN: multiline
|
|
|
|
|
|
|
|
: next-line-text ( -- str )
|
2008-02-05 23:36:10 -05:00
|
|
|
lexer get dup next-line lexer-line-text ;
|
2007-12-11 01:39:32 -05:00
|
|
|
|
|
|
|
: (parse-here) ( -- )
|
|
|
|
next-line-text dup ";" =
|
|
|
|
[ drop lexer get next-line ] [ % "\n" % (parse-here) ] if ;
|
|
|
|
|
|
|
|
: parse-here ( -- str )
|
2007-12-11 01:54:16 -05:00
|
|
|
[ (parse-here) ] "" make 1 head*
|
2007-12-11 01:39:32 -05:00
|
|
|
lexer get next-line ;
|
|
|
|
|
|
|
|
: STRING:
|
|
|
|
CREATE dup reset-generic
|
2008-01-16 09:12:14 -05:00
|
|
|
parse-here 1quotation define ; parsing
|
2007-12-11 17:23:56 -05:00
|
|
|
|
2007-12-12 00:33:36 -05:00
|
|
|
: (parse-multiline-string) ( start-index end-text -- end-index )
|
2008-02-05 23:36:10 -05:00
|
|
|
lexer get lexer-line-text 2dup start
|
2007-12-11 17:23:56 -05:00
|
|
|
[ rot dupd >r >r swap subseq % r> r> length + ] [
|
|
|
|
rot tail % "\n" % 0
|
2007-12-12 00:33:36 -05:00
|
|
|
lexer get next-line swap (parse-multiline-string)
|
2007-12-11 17:23:56 -05:00
|
|
|
] if* ;
|
|
|
|
|
2007-12-12 00:33:36 -05:00
|
|
|
: parse-multiline-string ( end-text -- str )
|
2007-12-11 17:23:56 -05:00
|
|
|
[
|
2007-12-12 00:33:36 -05:00
|
|
|
lexer get lexer-column swap (parse-multiline-string)
|
2007-12-11 17:23:56 -05:00
|
|
|
lexer get set-lexer-column
|
|
|
|
] "" make 1 tail 1 head* ;
|
|
|
|
|
|
|
|
: <"
|
2007-12-12 00:33:36 -05:00
|
|
|
"\">" parse-multiline-string parsed ; parsing
|