gpt4 book ai didi

gcc - yywrap() 在 flex 中的含义

转载 作者:行者123 更新时间:2023-12-03 13:52:13 25 4
gpt4 key购买 nike

这个指令在 flex (lex) 中是什么意思:
#define yywrap() 1
而这 [\t]+$
我在下面的代码中找到它:

( %%
[ \t]+ putchar('_');
[ \t]+%
%%

输入“ Hello World ”

输出“hello_world”

)

最佳答案

根据 The Lex & Yacc Page :

When the scanner receives an end-of-file indication from YY_INPUT, it then checks the yywrap() function. If yywrap() returns false (zero), then it is assumed that the function has gone ahead and set up yyin to point to another input file, and scanning continues. If it returns true (non-zero), then the scanner terminates, returning 0 to its caller. Note that in either case, the start condition remains unchanged; it does not revert to INITIAL.


#define用于简化程序的构建(因此不需要 -ll 链接选项)。

进一步阅读:
  • What are lex and yacc?
  • Routines to reprocess input
  • 6. How do Lex and YACC work internally (Lex 和 YACC 入门/HOWTO)
  • 关于gcc - yywrap() 在 flex 中的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34479903/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com