计算lex中的do-while循环

时间:2018-12-05 12:03:33

标签: compiler-construction flex-lexer lex

我试图计算do-while循环发生的总数

%{
    int count=0,count2=0;
    %}
letter [a-zA-Z]
num[0-9]
%%

do^while count++;
while count2++;

\n {; }
    . {;}
%%
int main()
{
    yyin = fopen("pract.c","r");
    yylex();
    printf("There were %d do-while loop and %d while loop\n",
    count,count2);
    return 0;
}
int yywrap(){
}

我无法正确计数。请帮助。

0 个答案:

没有答案