开发者

Can I get lex to put out a yylex() function with a different name?

开发者 https://www.devze.com 2023-02-25 03:29 出处:网络
I want to have two lexers in one project, and I don\'t want to run into problems with hav开发者_C百科ing multiple yylex functions in the build. Can I make lex output with a different prefix? You can u

I want to have two lexers in one project, and I don't want to run into problems with hav开发者_C百科ing multiple yylex functions in the build. Can I make lex output with a different prefix?


You can use the -Pprefix parameter for flex in your makefile. Using flex -Pfoo you would effectively prefix all yy generated functions. Have a look at the manual page for further details.


flex lets you do that. Just define the YY_DECL macro. Dunno about actual Unix(tm) lex(1) though.


You could build a C++ lexer. This means all the state information is held in an object.

Then it is just a matter of using the correct object!

0

精彩评论

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

关注公众号