2010-12-07 9 views
0
1 %{ 
2  #include<stdio.h> 
3  #include<ctype.h> 
4 %} 
5 %option noyywrap 
6 %% 
7 [a-z] { putchar(yytext[0]); } 
8 
9 "/*" 
10  { 
11    char ch; 
12    while((ch = input()) != '*') 
13      putchar(toupper(ch)); 
14    while((ch = input()) == '*'); 
15    if((ch = input()) == '/') 
16      return 0; 
17  } 



%% 

int main() 
{ 
yylex(); 
return 0; 
} 
~ 

私はこの "lex comment.lex"をコンパイルしようとしていますが、12,14,15行目でルールエラーが認識されていません......誰でも教えてくれますか?答え.........lexを使用しているときに認識できないルールエラー

答えて

1

flex info page参照:

ルールの形式は次のとおりです。

pattern action 

Flexはactionless新しいルールがライン9、10に開始されていることを考えて、11等々。上の中括弧を10行目から一列に引いて、以下のようにします。

... 
"/*" { 
    char ch; 
... 
関連する問題