retroforth/example/c-style-comments.retro
crc 40c6b897ab example: adding c style comments
FossilOrigin-Name: 256a802203164209e63c63b3cbc42096766477147e221e63d887ad6ee7d5c31e
2020-01-27 14:34:58 +00:00

31 lines
561 B
Text

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
```