开发者

How to call a flex parser in c [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. 开发者_StackOverflow社区

Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist

Closed 9 years ago.

Improve this question

How to call a flex parser in c ?


By calling yylex().

By default lex reads from stdin, if you want it to read from other stream, assign yyin, like

yyin = fopen("myfile", "r");


It's worth noting that yylex is not declared anywhere so you need to declare it:

int yylex ();

Traditionally it seems that the entire output of lex or flex would be incorporated in the C program via #include.

Recent versions of Flex include an option to create a header file, either on the command line via the

--header-file

option, or in the script

%option header-file

The header file contains stuff which can be used, for example, to ask Flex to read from memory rather than a file.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜