diff --git a/l2/3.lex b/l2/3.lex index 5a6d260..192279d 100644 --- a/l2/3.lex +++ b/l2/3.lex @@ -6,8 +6,18 @@ %x SINGLE_LINE %x MULTI_LINE +%x STRING +%x INCLUDE %% +"#include <" { ECHO; BEGIN(INCLUDE); } +">" { ECHO; BEGIN(INITIAL); } + +\" { ECHO; BEGIN(STRING); } +\\\" { ECHO; } +\" { ECHO; BEGIN(INITIAL); } +. { ECHO; } + "///"|"//!" { if (leave_docs) { ECHO; @@ -16,6 +26,8 @@ } } +"/**/" { putchar(' '); } + "/**"|"/*!" { if (leave_docs) { ECHO; @@ -26,11 +38,12 @@ "//" { BEGIN(SINGLE_LINE); } . { ECHO; } +"\\\n" { } \n { BEGIN(INITIAL); } . { } "/*" { BEGIN(MULTI_LINE); } -"*/" { BEGIN(INITIAL); } +"*/" { putchar(' '); BEGIN(INITIAL); } . { } %%