Add support for multi-line ( comments
authorHelmut Eller <eller.helmut@gmail.com>
Mon, 2 Jan 2017 11:33:55 +0000 (12:33 +0100)
committerHelmut Eller <eller.helmut@gmail.com>
Mon, 2 Jan 2017 21:29:58 +0000 (22:29 +0100)
* fth/file.fth ((): Redefine.
(MULTI-LINE-COMMENT): New helper.

* fth/t_file.fth: Uncomment test for multi line comments.

fth/file.fth
fth/t_file.fth

index b71edc5..6b0db20 100644 (file)
@@ -61,6 +61,16 @@ create (LINE-TERMINATOR) \n c,
     0 2r> + c!        ( )
 ;
 
+: MULTI-LINE-COMMENT ( "comment<rparen>" -- )
+    BEGIN
+        >in @ ')' parse         ( >in c-addr len )
+        nip + >in @ =           ( delimiter-not-found? )
+    WHILE                       ( )
+        refill 0= IF EXIT THEN  ( )
+    REPEAT
+
+;
+
 }private
 
 \ This treats \n, \r\n, and \r as line terminator.  Reading is done
@@ -108,4 +118,13 @@ create (LINE-TERMINATOR) \n c,
     THEN
 ;
 
+: (  ( "comment<rparen>"  -- )
+    source-id
+    CASE
+        -1 OF postpone ( ENDOF
+        0  OF postpone ( ENDOF
+        multi-line-comment
+    ENDCASE
+; immediate
+
 privatize
index f024926..10f434f 100644 (file)
@@ -215,12 +215,12 @@ T{ FN2 R/W BIN OPEN-FILE SWAP DROP 0= -> FALSE }T
 T{ FN2 DELETE-FILE 0= -> FALSE }T
 
 \ ----------------------------------------------------------------------------
-TESTING multi-line ( comments
-\ 
-T{ ( 1 2 3
-4 5 6
-7 8 9 ) 11 22 33 -> 11 22 33 }T
-\ 
+TESTING multi-line ( comments
+
+T{ ( 1 2 3
+4 5 6
+7 8 9 ) 11 22 33 -> 11 22 33 }T
+
 \ ----------------------------------------------------------------------------
 TESTING SOURCE-ID (can only test it does not return 0 or -1)