From 20151339b293adec7f0ac91332c03b972c308ef7 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Sat, 9 Nov 2024 16:01:47 +0100 Subject: [PATCH] fix for the previous fix xd --- l2/3.lex | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/l2/3.lex b/l2/3.lex index 192279d..b6ed871 100644 --- a/l2/3.lex +++ b/l2/3.lex @@ -2,6 +2,7 @@ #include bool leave_docs = false; + bool in_docs = false; %} %x SINGLE_LINE @@ -19,32 +20,54 @@ . { ECHO; } "///"|"//!" { + in_docs = true; if (leave_docs) { ECHO; - } else { - BEGIN(SINGLE_LINE); } + BEGIN(SINGLE_LINE); } "/**/" { putchar(' '); } "/**"|"/*!" { + in_docs = true; if (leave_docs) { ECHO; - } else { - BEGIN(MULTI_LINE); } + BEGIN(MULTI_LINE); } "//" { BEGIN(SINGLE_LINE); } . { ECHO; } "\\\n" { } -\n { BEGIN(INITIAL); } -. { } +\n { + if (leave_docs && in_docs) { + ECHO; + in_docs = false; + } + BEGIN(INITIAL); +} +. { + if (leave_docs && in_docs) { + ECHO; + } +} "/*" { BEGIN(MULTI_LINE); } -"*/" { putchar(' '); BEGIN(INITIAL); } -. { } +"*/" { + if (leave_docs && in_docs) { + ECHO; + in_docs = false; + } else { + putchar(' '); + } + BEGIN(INITIAL); +} +. { + if (leave_docs && in_docs) { + ECHO; + } +} %% // single line comment