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
33 end text i start* [| j |
34 i j text subseq % j end length +
36 text i short tail % CHAR: \n ,
38 0 end (parse-multiline-string)
40 ] [ end unexpected-eof ] if ;
44 : parse-multiline-string ( end-text -- str )
47 [ 1+ swap (parse-multiline-string) ]
52 "\">" parse-multiline-string parsed ; parsing
55 "'>" parse-multiline-string parsed ; parsing
58 "'}" parse-multiline-string parsed ; parsing
61 "\"}" parse-multiline-string parsed ; parsing
63 : /* "*/" parse-multiline-string drop ; parsing