Unable to compile output of lex

前端 未结 2 1490
执念已碎
执念已碎 2020-12-17 01:48

When I attempt to compile the output of this trivial lex program:

# lex.l
integer   printf(\"found keyword INT\");

using:

$         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-17 02:07

    As Eli's answer implies, that's not a trivial lex program. It's a trivial lex file, and thus a portion of a program, but it (like any lex file) needs to be combined with some C code to make a complete program. In particular, you still need a main function (which you write in C or C++ or something, in a separate file), and you will also need to write a yywrap function that provides the interface between the lex code and the rest of your C code.

提交回复
热议问题