]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/multiline/multiline.factor
multiline: adding (( )) comments.
[factor.git] / basis / multiline / multiline.factor
index ce5abbeac5ce1b17ef9836c45fbf6407bcf07414..c6d5576347a7122ed29eab33f6b27b209e756b57 100644 (file)
@@ -1,11 +1,9 @@
 ! Copyright (C) 2007 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators kernel lexer locals make math
-namespaces parser quotations sequences words ;
+USING: accessors kernel lexer make math namespaces parser
+quotations sequences strings.parser.private words ;
 IN: multiline
 
-ERROR: bad-heredoc identifier ;
-
 <PRIVATE
 
 : rest-of-line ( lexer -- seq )
@@ -42,10 +40,10 @@ SYNTAX: STRING:
 :: (scan-multiline-string) ( i end lexer -- j )
     lexer line-text>> :> text
     lexer still-parsing? [
-        end text i subseq-start-from [| j |
+        i text end subseq-index-from [| j |
             i j text subseq % j end length +
         ] [
-            text i short tail % CHAR: \n ,
+            text i index-or-length tail % CHAR: \n ,
             lexer next-line
             0 end lexer (scan-multiline-string)
         ] if*
@@ -55,28 +53,12 @@ SYNTAX: STRING:
     [
         lexer
         [ skip-n-chars + end-text lexer (scan-multiline-string) ]
-        change-column drop
+        change-column check-space
     ] "" make ;
 
 : advance-same-line ( lexer text -- )
     length [ + ] curry change-column drop ;
 
-:: (parse-til-line-begins) ( begin-text lexer -- )
-    lexer still-parsing? [
-        lexer line-text>> begin-text sequence= [
-            lexer begin-text advance-same-line
-        ] [
-            lexer line-text>> % CHAR: \n ,
-            lexer next-line
-            begin-text lexer (parse-til-line-begins)
-        ] if
-    ] [
-        begin-text bad-heredoc
-    ] if ;
-
-: parse-til-line-begins ( begin-text lexer -- seq )
-    [ (parse-til-line-begins) ] "" make ;
-
 PRIVATE>
 
 : parse-multiline-string ( end-text -- str )
@@ -84,13 +66,7 @@ PRIVATE>
 
 SYNTAX: /* "*/" parse-multiline-string drop ;
 
-SYNTAX: HEREDOC:
-    lexer get {
-        [ skip-blank ]
-        [ rest-of-line ]
-        [ next-line ]
-        [ parse-til-line-begins ]
-    } cleave suffix! ;
+SYNTAX: (( "))" parse-multiline-string drop ;
 
 SYNTAX: [[ "]]" parse-multiline-string suffix! ;
 SYNTAX: [=[ "]=]" parse-multiline-string suffix! ;