%x comment %% int line_num = 1; "/*" BEGIN(comment); <comment>[^*\n]; <comment>"*"+[^*/\n]*;/*Perhaps you could wonder if it contains the kind "***" or more "*".The myths is that it match one "*" every time*/ <comment>\n ++line_num; <comment>"*/"{printf("%d lines\n",line_num); BEGIN(INITIAL);} %%