From: Phil Burk Date: Wed, 4 Jan 2017 02:50:40 +0000 (-0800) Subject: Merge pull request #32 from ellerh/multi-line-comment X-Git-Url: https://git.subgeniuskitty.com/pforth/.git/commitdiff_plain/3f863e2896ed0418e1ad202e233b5a036f989ee2?hp=f9a1c9cea42bd3c290b8823e1ece25a3bc878462 Merge pull request #32 from ellerh/multi-line-comment Add support for multi-line ( comments --- diff --git a/fth/file.fth b/fth/file.fth index b71edc5..8fe0810 100644 --- a/fth/file.fth +++ b/fth/file.fth @@ -61,6 +61,15 @@ create (LINE-TERMINATOR) \n c, 0 2r> + c! ( ) ; +: MULTI-LINE-COMMENT ( "comment" -- ) + 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 +117,14 @@ create (LINE-TERMINATOR) \n c, THEN ; +: ( ( "comment" -- ) + source-id + CASE + -1 OF postpone ( ENDOF + 0 OF postpone ( ENDOF + \ for input from files + multi-line-comment + ENDCASE +; immediate + privatize diff --git a/fth/t_file.fth b/fth/t_file.fth index f024926..10f434f 100644 --- a/fth/t_file.fth +++ b/fth/t_file.fth @@ -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)