fix for the previous fix xd

This commit is contained in:
jacekpoz 2024-11-09 16:01:47 +01:00
parent d68db68e6c
commit 20151339b2
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -2,6 +2,7 @@
#include <stdbool.h>
bool leave_docs = false;
bool in_docs = false;
%}
%x SINGLE_LINE
@ -19,32 +20,54 @@
<STRING>. { ECHO; }
<INITIAL>"///"|"//!" {
in_docs = true;
if (leave_docs) {
ECHO;
} else {
BEGIN(SINGLE_LINE);
}
BEGIN(SINGLE_LINE);
}
<INITIAL>"/**/" { putchar(' '); }
<INITIAL>"/**"|"/*!" {
in_docs = true;
if (leave_docs) {
ECHO;
} else {
BEGIN(MULTI_LINE);
}
BEGIN(MULTI_LINE);
}
<INITIAL>"//" { BEGIN(SINGLE_LINE); }
<INITIAL>. { ECHO; }
<SINGLE_LINE>"\\\n" { }
<SINGLE_LINE>\n { BEGIN(INITIAL); }
<SINGLE_LINE>. { }
<SINGLE_LINE>\n {
if (leave_docs && in_docs) {
ECHO;
in_docs = false;
}
BEGIN(INITIAL);
}
<SINGLE_LINE>. {
if (leave_docs && in_docs) {
ECHO;
}
}
<INITIAL>"/*" { BEGIN(MULTI_LINE); }
<MULTI_LINE>"*/" { putchar(' '); BEGIN(INITIAL); }
<MULTI_LINE>. { }
<MULTI_LINE>"*/" {
if (leave_docs && in_docs) {
ECHO;
in_docs = false;
} else {
putchar(' ');
}
BEGIN(INITIAL);
}
<MULTI_LINE>. {
if (leave_docs && in_docs) {
ECHO;
}
}
%%
// single line comment