retroforth/example/c-style-comments.retro

32 lines
561 B
Text
Raw Normal View History

Support for comments with embedded spaces; this is useful for quickly
commenting out portions of lines or larger chunks of code during
debugging.
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
```