koka-lang / koka

Koka language compiler and interpreter
http://koka-lang.org
Other
3.31k stars 167 forks source link

nested comments #594

Open backtracking opened 3 weeks ago

backtracking commented 3 weeks ago

Nested comments are accepted in Koka source code, but then are copied verbatim in C source code, resulting in errors after the first closing */. For instance, this Koka source code

/* a /* b */ fun main () 1 */
fun main() 42

results in the following syntax error:

test.h: In function ‘main’:
test.h:30:26: error: expected declaration specifiers before numeric constant
   30 | /* a /* b */ fun main () 1 */
      |                          ^

I'm using Koka version 3.1.2.

daanx commented 3 weeks ago

ah, darn. Will fix it soon :-)

backtracking commented 3 weeks ago

An easy fix would be to prefix the comments from Koka source with // in the C code. (Or to remove them, of course, as this is in generated C code after all.)

daanx commented 2 weeks ago

Should be fixed now using your technique.