Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
重複の可能性: flex/lexでcスタイルのコメントを取得する際の問題
flexを使用して字句解析プログラムを作成しています。次のようなコメントを回避するにはどうすればよいですか。
/* COMMENTS */
少し複雑です。これが私が見つけた解決策です:
<INITIAL>{ "/*" BEGIN(IN_COMMENT); } <IN_COMMENT>{ "*/" BEGIN(INITIAL); [^*\n]+ // eat comment in chunks "*" // eat the lone star \n yylineno++; } { return COMMENT; }
「明白な」解決策、次のようなもの:
"/*".*"*/" { return COMMENT; }
似合いすぎます。