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 locals ;
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
30 :: (parse-multiline-string) ( i end -- j )
31 lexer get line-text>> :> text
34 [| j | i j text subseq % j end length + ] [
35 text i tail % CHAR: \n ,
37 0 end (parse-multiline-string)
39 ] [ end unexpected-eof ] if ;
43 : parse-multiline-string ( end-text -- str )
46 [ 1+ swap (parse-multiline-string) ]
51 "\">" parse-multiline-string parsed ; parsing
53 : /* "*/" parse-multiline-string drop ; parsing