/*Regular Definitions*/
delim[\t\n]
WS{delim}+
letter[A-Za-z]
digit[0-9]
id{letter}({letter|digit})*
number{digit}+(\.{digit}+?(E[+-]?{digit}+)?
%%
{WS}{/*do nothing*/}
if{printf("\nIF found");return 0;}
then{printf("\nTHEN found");return 0;}
else{printf("\nELSE found");return 0;}
{id}{printf("\nID found");return 0;}
{number}{printf("\nNUMBER found");return 0;}
"<"{printf("\nLess than symbol found.");return 0;}
"<="{printf("\nLess than or Equals to symbol found.");return 0;}
"="{printf("\nEquals to symbol found.");return 0;}
"<>"{printf("\nNot equals to symbol found.");return 0;}
">"{printf("\nGreater than symbol found.");return 0;}
">="{printf("\nGreater than or equal to symbol found.");return 0;}
%%
虽然使用Flex编译此错误与Flex工具
G:\>flex Lex.l
我收到以下错误:
"Lex.l", line 14: unrecognized rule
"Lex.l", line 14: unrecognized rule
"Lex.l", line 14: unrecognized rule
"Lex.l", line 14: unrecognized rule
"Lex.l", line 14: unrecognized rule
"Lex.l", line 27: EOF encountered inside an action
谁能帮助我呢?
谢谢。
我编辑了问题补充编译代码标签之间的误差。它更容易阅读。 – Birei 2012-02-15 15:27:38