我現在想做的是一個能夠scan C-file的scanner, 下面的code是我的lex file, 如果我不加rule的話flex & gcc都可以很順利的過關, 但是如果我一加入rule在flex的時候就會出現下列的錯誤訊息
"scanc.lex:14: unrecognized rule"
請問是我的definition哪裡寫錯了嗎?
- 代碼: 選擇全部
KEYWORD ("int" | "char" | "float" | "double" | "struct" | "auto" | "extern" | "register" | "static" | "goto" | "return" | "sizeof" | "break" | "continue" | "if" | "else" | "for" | "do" | "while" | "switch" | "case" | "default" | "entry")
ALPHABAT [_a-zA-Z]
OCT_DIGIT [0-7]
DEC_DIGIT ({OCT_DIGIT} | [8-9])
HEX_DIGIT ({DEC_DIGIT} | [a-fA-F])
SIGN [-+]
INT_CONST {SIGN}?{DEC_DIGIT}+
OCT_CONST {SIGN}?0{OCT_DIGIT}+
HEX_CONST {SIGN}?0x{HEX_DIGIT}+
CHAR_CONST {SIGN}?'{ALPHABAT}'
IDENTIFIER ({ALPHABAT}({ALPHABAT}+ | {DEC_DIGIT}+))
%%
{KEYWORD} printf("KEYWORD\n");
%