开发者

Where's the syntax error in this (f)lex snippet?

I'm having a great time doing a lexer using flex. Problem is, my code editor doesn't color the syntax of the file, and it seems my rule has an error in it. Since I'm not too sure about how to use single quotes and double quotes inside intervals, I thought I'd share that snippet with you:

[^\\\'\n]+
{
    wchar_t* string;
    utf8_decode(yytext, &string);
    yyextra->append(string)开发者_JS百科;
    free(string);
}

Flex tells me there's an 'unrecognized rule' on the utf8_decode line. If I remove the whole rule, things look fine again.

Can anyone tell what I'm doing wrong here?


The action must begin on the same line as the pattern. So use

[^\\\'\n]+ {
    wchar_t* string;
    utf8_decode(yytext, &string);
    yyextra->append(string);
    free(string);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜