【发布时间】:2021-06-20 13:05:30
【问题描述】:
我得到了这个规则的 lex 文件:
%option noyywrap
%{
%}
LNA [^<>]
LNANA [^<>!]
%%
(<!!) fprintf(yyout, "begin_comment\t\t\t%s\n", yytext);
(!!>) fprintf(yyout, "end_comment\t\t\t%s\n", yytext);
({LNANA}*|({LNA}{LNANA})*|{LNA}+{LNANA}{LNANA}{LNA}) fprintf(yyout,
"string\t\t\t%s\n", yytext);
. fprintf(yyout, "illegal char %s\n", yytext);
%%
我需要在“”和代码中的字符串什么都没有
例如
<!! This is a comment that need to be found !!>
simple string that need to be found also
如您所见,这不能按需要工作。 有什么帮助吗?
【问题讨论】:
-
实际上,我看不出您的尝试“没有按需要工作”,因为您只提供了对您想要的内容的非常模糊的描述。请提供您期望的精确输出,作为文本(不是图像)。在编辑问题时,请将图像(在手机上难以阅读)替换为粘贴到问题中的实际文本。对于加分,请说明您认为您的每条规则的作用。
标签: c flex-lexer lex text-parsing