问题描述
我是 Lex/Flex 的新手,在获得所需的输出时遇到了一些麻烦。
Lex 文件如下所示:
%{
#include<stdio.h>
#include <string.h>
char buf[1024];
%}
TOK_NUM [0-9]+
%%
{TOK_NUM} strcat(buf,yytext); strcat(buf,"\n");
%%
int yywrap()
{
}
int main(){
FILE *in;
in = fopen("BASIC.lgc","r");
yyin = in;
yylex();
fclose(in);
printf("%s\n",buf);
}
我希望输入:“This is a test for nums 12 test”产生输出:“12”,但我得到:“This is a test for nums test12”。我在这里错过了什么,谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)