1 ! Copyright (C) 2007 Daniel Ehrenberg
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: namespaces make parser lexer kernel sequences words
4 quotations math accessors ;
8 : next-line-text ( -- str )
9 lexer get dup next-line line-text>> ;
14 [ drop lexer get next-line ]
15 [ % "\n" % (parse-here) ] if
16 ] [ ";" unexpected-eof ] if* ;
19 : parse-here ( -- str )
20 [ (parse-here) ] "" make but-last
26 (( -- string )) define-inline ; parsing
29 : (parse-multiline-string) ( start-index end-text -- end-index )
30 lexer get line-text>> [
32 [ rot dupd [ swap subseq % ] 2dip length + ] [
34 lexer get next-line swap (parse-multiline-string)
36 ] [ nip unexpected-eof ] if* ;
39 : parse-multiline-string ( end-text -- str )
41 lexer get [ swap (parse-multiline-string) ] change-column drop
45 "\">" parse-multiline-string parsed ; parsing
47 : /* "*/" parse-multiline-string drop ; parsing