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 11 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
通过调用
yylex()
。默认情况下,
lex
从stdin
读取,如果您希望它从其他流读取,请分配yyin
,例如By calling
yylex()
.By default
lex
reads fromstdin
, if you want it to read from other stream, assignyyin
, like值得注意的是,yylex 没有在任何地方声明,因此您需要声明它:
传统上,lex 或 flex 的整个输出似乎将通过 #include 合并到 C 程序中。
Flex 的最新版本包含一个创建头文件的选项,可以在命令行上通过
--header-file
选项,或者在脚本中。
头文件包含可以使用的内容,例如,要求 Flex 从内存而不是文件中读取。
It's worth noting that yylex is not declared anywhere so you need to declare it:
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
The header file contains stuff which can be used, for example, to ask Flex to read from memory rather than a file.