retroforth/example/c-style-comments.retro
crc 96ae77edbb example updates
FossilOrigin-Name: 20149d1819aa93a0fd469c5ad05031d065bf168a2d47a5c94bd233c71f427a41
2020-02-11 19:30:14 +00:00

34 lines
605 B
Forth

# C Style Comments
This adds support for comments with embedded spaces. It is useful
for quickly commenting out portions of lines or larger chunks of
code during debugging.
Specifically, this provides for C style /* ... */ comments. It
works by patching `interpret` to make it ignore tokens until the
token is `*/`.
~~~
{{
:done? '*/ s:eq? ;
:revert &interpret unhook ;
---reveal---
:/* (-a) [ (a-) done? &revert if ] &interpret set-hook ; immediate
}}
~~~
# Test Case
```
:test /* hello world */
#1
/*
this is a test. drop stuff.
more lines
*/
#2 + /* display */ n:put nl ;
test
```