REPL character substitution now working again.
[forth.jl.git] / src / lib_4_comments.4th
1 \ Parenthetic comments
2
3 : ( IMMEDIATE
4         1               \ allowed nested parens by keeping track of depth
5         BEGIN
6                 >IN @ #IB @ >= IF      \ End of TIB?
7                         QUERY-INPUT    \ Get next line
8                 THEN
9
10                 IB >IN @ + @ 1 >IN +!
11                 DUP [CHAR] ( = IF       \ open paren?
12                         DROP            \ drop the open paren
13                         1+              \ depth increases
14                 ELSE
15                         [CHAR] ) = IF   \ close paren?
16                                 1-      \ depth decreases
17                         THEN
18                 THEN
19         DUP 0= UNTIL            \ continue until we reach matching close paren, depth 0
20         DROP            \ drop the depth counter
21 ;
22